ifw-daq  2.1.0-pre1
IFW Data Acquisition modules
testConversion.cpp
Go to the documentation of this file.
1 /**
2  * @file
3  * @ingroup daq_ocm_daqifsupport
4  * @copyright 2022 ESO - European Southern Observatory
5  *
6  * @brief daqif:: conversion helper test
7  */
8 #include <gtest/gtest.h>
9 
10 #include <daq/conversion.hpp>
11 #include <daq/state.hpp>
12 
13 using namespace ::testing;
14 
15 TEST(Conversion, MakeOcmIfSubState) {
16  using daqif::FullState;
17  using daqif::operator==;
18  EXPECT_EQ(daq::MakeState(daq::State::NotStarted),
19  FullState({daqif::StateAcquiring, daqif::NotStarted}));
20  EXPECT_EQ(daq::MakeState(daq::State::Acquiring),
21  FullState({daqif::StateAcquiring, daqif::Acquiring}));
22  EXPECT_EQ(daq::MakeState(daq::State::Stopping),
23  FullState({daqif::StateAcquiring, daqif::Stopping}));
24  EXPECT_EQ(daq::MakeState(daq::State::Stopped),
25  FullState({daqif::StateAcquiring, daqif::Stopped}));
26  EXPECT_EQ(daq::MakeState(daq::State::AbortingAcquiring),
27  FullState({daqif::StateAcquiring, daqif::Aborting}));
28 
29  EXPECT_EQ(daq::MakeState(daq::State::NotScheduled),
30  FullState({daqif::StateMerging, daqif::NotScheduled}));
31  EXPECT_EQ(daq::MakeState(daq::State::Scheduled),
32  FullState({daqif::StateMerging, daqif::Scheduled}));
34  FullState({daqif::StateMerging, daqif::Transferring}));
36  FullState({daqif::StateMerging, daqif::Merging}));
37  EXPECT_EQ(daq::MakeState(daq::State::Releasing),
38  FullState({daqif::StateMerging, daqif::Releasing}));
39  EXPECT_EQ(daq::MakeState(daq::State::AbortingMerging),
40  FullState({daqif::StateMerging, daqif::Aborting}));
41 
43  FullState({daqif::StateCompleted, daqif::Completed}));
44  EXPECT_EQ(daq::MakeState(daq::State::Aborted),
45  FullState({daqif::StateCompleted, daqif::Aborted}));
46 }
47 
48 TEST(Conversion, MakeDaqState) {
49  EXPECT_EQ(daq::MakeState({daqif::StateAcquiring, daqif::NotStarted}), daq::State::NotStarted);
50  EXPECT_EQ(daq::MakeState({daqif::StateAcquiring, daqif::Acquiring}), daq::State::Acquiring);
51  EXPECT_EQ(daq::MakeState({daqif::StateAcquiring, daqif::Stopping}), daq::State::Stopping);
52  EXPECT_EQ(daq::MakeState({daqif::StateAcquiring, daqif::Stopped}), daq::State::Stopped);
53  EXPECT_EQ(daq::MakeState({daqif::StateAcquiring, daqif::Aborting}),
54  daq::State::AbortingAcquiring);
55 
56  EXPECT_EQ(daq::MakeState({daqif::StateMerging, daqif::NotScheduled}), daq::State::NotScheduled);
57  EXPECT_EQ(daq::MakeState({daqif::StateMerging, daqif::Scheduled}), daq::State::Scheduled);
58  EXPECT_EQ(daq::MakeState({daqif::StateMerging, daqif::Transferring}), daq::State::Transferring);
59  EXPECT_EQ(daq::MakeState({daqif::StateMerging, daqif::Merging}), daq::State::Merging);
60  EXPECT_EQ(daq::MakeState({daqif::StateMerging, daqif::Releasing}), daq::State::Releasing);
61  EXPECT_EQ(daq::MakeState({daqif::StateMerging, daqif::Aborting}), daq::State::AbortingMerging);
62 
63  EXPECT_EQ(daq::MakeState({daqif::StateCompleted, daqif::Completed}), daq::State::Completed);
64  EXPECT_EQ(daq::MakeState({daqif::StateCompleted, daqif::Aborted}), daq::State::Aborted);
65 
66  EXPECT_THROW(daq::MakeState({daqif::StateAcquiring, static_cast<daqif::DaqSubState>(-123)}),
67  std::invalid_argument);
68 }
daqif::FullState
Describes the full state and substate.
Definition: state.hpp:17
daq::State::Transferring
@ Transferring
Input files are being transferred.
conversion.hpp
Contains support functions for daqif.
daq::State::Merging
@ Merging
DAQ is being merged.
TEST
TEST(Conversion, MakeOcmIfSubState)
Definition: testConversion.cpp:15
state.hpp
Declares daq::State and related functions.
daq::MakeState
daqif::FullState MakeState(State state) noexcept
Converts daq::State to DaqSubstate.
Definition: conversion.cpp:63
daq::State::DAQ states handled by OCM.
DAQ states handled by OCM.
Initial state of data acquisition.