ifw-daq  3.0.1
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 #include <daq/status.hpp>
13 
14 using namespace ::testing;
15 
16 TEST(Conversion, MakeOcmIfSubState) {
17  using daqif::FullState;
18  using daqif::operator==;
20  FullState({daqif::StateAcquiring, daqif::NotStarted}));
22  FullState({daqif::StateAcquiring, daqif::Acquiring}));
24  FullState({daqif::StateAcquiring, daqif::Stopping}));
26  FullState({daqif::StateAcquiring, daqif::Stopped}));
28  FullState({daqif::StateAcquiring, daqif::Aborting}));
29 
31  FullState({daqif::StateMerging, daqif::NotScheduled}));
33  FullState({daqif::StateMerging, daqif::Scheduled}));
35  FullState({daqif::StateMerging, daqif::Collecting}));
37  FullState({daqif::StateMerging, daqif::Merging}));
39  FullState({daqif::StateMerging, daqif::Releasing}));
41  FullState({daqif::StateMerging, daqif::Aborting}));
42 
44  FullState({daqif::StateCompleted, daqif::Completed}));
46  FullState({daqif::StateCompleted, daqif::Aborted}));
47 }
48 
49 TEST(Conversion, MakeDaqState) {
50  EXPECT_EQ(daq::MakeState({daqif::StateAcquiring, daqif::NotStarted}), daq::State::NotStarted);
51  EXPECT_EQ(daq::MakeState({daqif::StateAcquiring, daqif::Acquiring}), daq::State::Acquiring);
52  EXPECT_EQ(daq::MakeState({daqif::StateAcquiring, daqif::Stopping}), daq::State::Stopping);
53  EXPECT_EQ(daq::MakeState({daqif::StateAcquiring, daqif::Stopped}), daq::State::Stopped);
54  EXPECT_EQ(daq::MakeState({daqif::StateAcquiring, daqif::Aborting}),
56 
57  EXPECT_EQ(daq::MakeState({daqif::StateMerging, daqif::NotScheduled}), daq::State::NotScheduled);
58  EXPECT_EQ(daq::MakeState({daqif::StateMerging, daqif::Scheduled}), daq::State::Scheduled);
59  EXPECT_EQ(daq::MakeState({daqif::StateMerging, daqif::Collecting}), daq::State::Collecting);
60  EXPECT_EQ(daq::MakeState({daqif::StateMerging, daqif::Merging}), daq::State::Merging);
61  EXPECT_EQ(daq::MakeState({daqif::StateMerging, daqif::Releasing}), daq::State::Releasing);
62  EXPECT_EQ(daq::MakeState({daqif::StateMerging, daqif::Aborting}), daq::State::AbortingMerging);
63 
64  EXPECT_EQ(daq::MakeState({daqif::StateCompleted, daqif::Completed}), daq::State::Completed);
65  EXPECT_EQ(daq::MakeState({daqif::StateCompleted, daqif::Aborted}), daq::State::Aborted);
66 }
67 
68 TEST(Conversion, TimestampResolutionIsAtLeastMicrosecond) {
69  using Seconds = std::chrono::duration<double, std::ratio<1>>;
70  auto now_tp1 = daq::Status::Clock::now();
71  double now_d1 = std::chrono::time_point_cast<Seconds>(now_tp1).time_since_epoch().count();
72 
73  auto now_tp2 = now_tp1 + std::chrono::microseconds(1);
74  double now_d2 = std::chrono::time_point_cast<Seconds>(now_tp2).time_since_epoch().count();
75 
76  EXPECT_GT(now_d2, now_d1);
77  EXPECT_GT(now_tp2, now_tp1);
78 }
Contains support functions for daqif.
Declares daq::State and related functions.
daqif::FullState MakeState(State state) noexcept
Converts daq::State to DaqSubstate.
Definition: conversion.cpp:63
@ Completed
Completed DAQ.
@ NotScheduled
Before daq is acknowledged by dpm it remains in NotScheduled.
@ Scheduled
daq is acknowledged by dpm and is scheduled for merging (i.e.
@ Releasing
Releasing Data Product to receivers.
@ Collecting
Input files are being collected.
@ Aborted
Data acquisition has been aborted by user.
@ Merging
DAQ is being merged.
@ Stopping
Transitional state between Acquiring and Stopped.
@ AbortingMerging
Transitional state for aborting during merging.
@ Acquiring
All data sources have reported data acquisition is in progress.
@ Stopped
All data sources have reported they have stopped acquiring data.
@ AbortingAcquiring
Transitional state for aborting during acquisition.
@ NotStarted
Initial state of data acquisition.
Describes the full state and substate.
Definition: state.hpp:17
Contains declaration for Status and ObservableStatus.
TEST(Conversion, MakeOcmIfSubState)
EXPECT_EQ(meta.rr_uri, "zpb.rr://meta")