API
 
Loading...
Searching...
No Matches
telem_stdcam_generated_tests.cpp
Go to the documentation of this file.
1#include <assert.h>
2#include "../../../../tests/catch2/catch.hpp"
3#include "../generated/logCodes.hpp"
4#include "../types/telem_stdcam.hpp"
5#include "../types/generated/telem_stdcam_generated.h"
6#include "../types/flatbuffer_log.hpp"
7
8/*
9 * GENERATED TEST FILE for types/telem_stdcam.hpp
10 * generated by generateTemplateCatch2Tests.py
11 */
12
13const std::string telemStdcamMode_0 = "ard66k10xh"; // dummy mode
14const float telemStdcamXcen_0 = 0.961052; // dummy xcen
15const float telemStdcamYcen_0 = 0.011071; // dummy ycen
16const int telemStdcamWidth_0 = -1200764394; // dummy width
17const int telemStdcamHeight_0 = -2017878520; // dummy height
18const int telemStdcamXbin_0 = 1522852607; // dummy xbin
19const int telemStdcamYbin_0 = -869132048; // dummy ybin
20const float telemStdcamExptime_0 = 0.106793; // dummy exptime
21const float telemStdcamFps_0 = 0.198585; // dummy fps
22const float telemStdcamEmGain_0 = 0.649703; // dummy emGain
23const float telemStdcamAdcSpeed_0 = 0.751007; // dummy adcSpeed
24const float telemStdcamTemp_0 = 0.725439; // dummy temp
25const float telemStdcamSetpt_0 = 0.828431; // dummy setpt
26const uint8_t telemStdcamStatus_0 = 1; // dummy status
27const uint8_t telemStdcamOntarget_0 = 1; // dummy ontarget
28const std::string telemStdcamStatusStr_0 = "gxcf06mx3y"; // dummy statusStr
29const std::string telemStdcamShutterStatusSr_0 = "s5q0z75c56"; // dummy shutterStatusSr
30const int8_t telemStdcamShutterState_0 = 97; // dummy shutterState
31const uint8_t telemStdcamSynchro_0 = 126; // dummy synchro
32const float telemStdcamVshift_0 = 0.427453; // dummy vshift
33const uint8_t telemStdcamCropMode_0 = 88; // dummy cropMode
34const std::string telemStdcamReadout_speed_0 = "ghesiij5ia"; // dummy readout_speed
35
36
37/** Class to encapsulate telem_stdcam flatbuffer data using
38 ** => types/telem_stdcam.hpp
39 ** => types/generated/telem_stdcam_generated.h
40 **/
42{
43public:
44 // Saved input parameter value; unused
45 std::string m_saveTsMode;
60 std::string m_saveTsStatusStr;
67
68 // Parameters retrieved from flatbuffer
69 std::string m_mode;
70 float m_xcen;
71 float m_ycen;
74 int m_xbin;
75 int m_ybin;
76 float m_exptime;
77 float m_fps;
78 float m_emGain;
80 float m_temp;
81 float m_setpt;
82 uint8_t m_status;
83 uint8_t m_ontarget;
84 std::string m_statusStr;
85 std::string m_shutterStatusSr;
87 uint8_t m_synchro;
88 float m_vshift;
89 uint8_t m_cropMode;
90 std::string m_readout_speed;
91
92 // Flatbuffers verifier success/failure
93 bool m_verify{false};
94
95 // flatbuffer data length; used in ::verify
96 int L;
97
98 // Constructor
99 CTelemStdcam_0(std::string mode_, float xcen_, float ycen_, int width_, int height_, int xbin_, int ybin_, float exptime_, float fps_, float emGain_, float adcSpeed_, float temp_, float setpt_, uint8_t status_, uint8_t ontarget_, std::string statusStr_, std::string shutterStatusSr_, int8_t shutterState_, uint8_t synchro_, float vshift_, uint8_t cropMode_, std::string readout_speed_) {
100 // Save input parameters
101 m_saveTsMode = mode_;
102 m_saveTsXcen = xcen_;
103 m_saveTsYcen = ycen_;
104 m_saveTsWidth = width_;
105 m_saveTsHeight = height_;
106 m_saveTsXbin = xbin_;
107 m_saveTsYbin = ybin_;
108 m_saveTsExptime = exptime_;
109 m_saveTsFps = fps_;
110 m_saveTsEmGain = emGain_;
111 m_saveTsAdcSpeed = adcSpeed_;
112 m_saveTsTemp = temp_;
113 m_saveTsSetpt = setpt_;
114 m_saveTsStatus = status_;
115 m_saveTsOntarget = ontarget_;
116 m_saveTsStatusStr = statusStr_;
117 m_saveTsShutterStatusSr = shutterStatusSr_;
118 m_saveTsShutterState = shutterState_;
119 m_saveTsSynchro = synchro_;
120 m_saveTsVshift = vshift_;
121 m_saveTsCropMode = cropMode_;
122 m_saveTsReadout_speed = readout_speed_;
123
124 // Create the flatbuffer messageT using the input parameters
125 auto ts = MagAOX::logger::telem_stdcam::messageT(mode_, xcen_, ycen_, width_, height_, xbin_, ybin_, exptime_, fps_, emGain_, adcSpeed_, temp_, setpt_, status_, ontarget_, statusStr_, shutterStatusSr_, shutterState_, synchro_, vshift_, cropMode_, readout_speed_);
126
127 // Retrieve flatbuffer pointer (if not an empty_log type) and length
128 void* buffPtr = ts.builder.GetBufferPointer();
130
131 // Retrieve the flatbuffer parameters for Catch2 comparison below
132 m_mode = std::string(MagAOX::logger::GetTelem_stdcam_fb(buffPtr)->mode()->c_str());
133 m_xcen = MagAOX::logger::GetTelem_stdcam_fb(buffPtr)->roi()->xcen();
134 m_ycen = MagAOX::logger::GetTelem_stdcam_fb(buffPtr)->roi()->ycen();
135 m_width = MagAOX::logger::GetTelem_stdcam_fb(buffPtr)->roi()->w();
136 m_height = MagAOX::logger::GetTelem_stdcam_fb(buffPtr)->roi()->h();
137 m_xbin = MagAOX::logger::GetTelem_stdcam_fb(buffPtr)->roi()->xbin();
138 m_ybin = MagAOX::logger::GetTelem_stdcam_fb(buffPtr)->roi()->ybin();
139 m_exptime = MagAOX::logger::GetTelem_stdcam_fb(buffPtr)->exptime();
141 m_emGain = MagAOX::logger::GetTelem_stdcam_fb(buffPtr)->emGain();
142 m_adcSpeed = MagAOX::logger::GetTelem_stdcam_fb(buffPtr)->adcSpeed();
143 m_temp = MagAOX::logger::GetTelem_stdcam_fb(buffPtr)->tempCtrl()->temp();
144 m_setpt = MagAOX::logger::GetTelem_stdcam_fb(buffPtr)->tempCtrl()->setpt();
145 m_status = MagAOX::logger::GetTelem_stdcam_fb(buffPtr)->tempCtrl()->status();
146 m_ontarget = MagAOX::logger::GetTelem_stdcam_fb(buffPtr)->tempCtrl()->ontarget();
147 m_statusStr = std::string(MagAOX::logger::GetTelem_stdcam_fb(buffPtr)->tempCtrl()->statusStr()->c_str());
148 m_shutterStatusSr = std::string(MagAOX::logger::GetTelem_stdcam_fb(buffPtr)->shutter()->statusStr()->c_str());
149 m_shutterState = MagAOX::logger::GetTelem_stdcam_fb(buffPtr)->shutter()->state();
150 m_synchro = MagAOX::logger::GetTelem_stdcam_fb(buffPtr)->synchro();
151 m_vshift = MagAOX::logger::GetTelem_stdcam_fb(buffPtr)->vshift();
152 m_cropMode = MagAOX::logger::GetTelem_stdcam_fb(buffPtr)->cropMode();
153 m_readout_speed = std::string(MagAOX::logger::GetTelem_stdcam_fb(buffPtr)->readout_speed()->c_str());
154
155 // Run the telem_stdcam verifier
156 m_verify = verify(ts);
157 }
158
159 // Run the flatbuffer Verifier for this log type
160 // - requires bufferPtrT (shared_ptr<char*>) to full log entry
161 // comprising log header plus flatbuffer log message
163
164 // Timestamp, prioriy (use nominal value here)
165 flatlogs::timespecX tsx{0,0};
167
168 // Create full log: log header(*); log message (+)
169 // * Log level (priority)
170 // * Event code (implicit in <MagAOX::logger::type>)
171 // * Timestamp
172 // * Message size (variable length; 1, 2, or 8 bytes)
173 // + Message (variable length)
174
175 // N.G. allocates space and writes pointer value to logBuffer
176 flatlogs::bufferPtrT logBuffer;
177 flatlogs::logHeader::createLog<MagAOX::logger::telem_stdcam>(logBuffer
178 , tsx, msg
179 , prio);
180 // Run full log through flatbuffer Verifier
181 return MagAOX::logger::telem_stdcam::verify(logBuffer,L);
182 }
183};
184
185SCENARIO( "Create telem_stdcam 0", "[a log item]")
186{
187 GIVEN("a telem_stdcam log code")
188 {
189 WHEN("random values for fields")
190 {
191 // Create flatbuffer
193 // Compare flatbuffer parameters
194 REQUIRE(ts.m_mode == telemStdcamMode_0);
195 REQUIRE(ts.m_xcen == telemStdcamXcen_0);
196 REQUIRE(ts.m_ycen == telemStdcamYcen_0);
197 REQUIRE(ts.m_width == telemStdcamWidth_0);
198 REQUIRE(ts.m_height == telemStdcamHeight_0);
199 REQUIRE(ts.m_xbin == telemStdcamXbin_0);
200 REQUIRE(ts.m_ybin == telemStdcamYbin_0);
201 REQUIRE(ts.m_exptime == telemStdcamExptime_0);
202 REQUIRE(ts.m_fps == telemStdcamFps_0);
203 REQUIRE(ts.m_emGain == telemStdcamEmGain_0);
204 REQUIRE(ts.m_adcSpeed == telemStdcamAdcSpeed_0);
205 REQUIRE(ts.m_temp == telemStdcamTemp_0);
206 REQUIRE(ts.m_setpt == telemStdcamSetpt_0);
207 REQUIRE(ts.m_status == telemStdcamStatus_0);
208 REQUIRE(ts.m_ontarget == telemStdcamOntarget_0);
209 REQUIRE(ts.m_statusStr == telemStdcamStatusStr_0);
212 REQUIRE(ts.m_synchro == telemStdcamSynchro_0);
213 REQUIRE(ts.m_vshift == telemStdcamVshift_0);
214 REQUIRE(ts.m_cropMode == telemStdcamCropMode_0);
216 REQUIRE(ts.m_verify);
217 }
218 }
219}
220
221
CTelemStdcam_0(std::string mode_, float xcen_, float ycen_, int width_, int height_, int xbin_, int ybin_, float exptime_, float fps_, float emGain_, float adcSpeed_, float temp_, float setpt_, uint8_t status_, uint8_t ontarget_, std::string statusStr_, std::string shutterStatusSr_, int8_t shutterState_, uint8_t synchro_, float vshift_, uint8_t cropMode_, std::string readout_speed_)
bool verify(const typename MagAOX::logger::telem_stdcam::messageT &msg)
int8_t logPrioT
The type of the log priority code.
Definition logDefs.hpp:21
std::shared_ptr< char > bufferPtrT
The log entry buffer smart pointer.
Definition logHeader.hpp:58
const MagAOX::logger::Telem_stdcam_fb * GetTelem_stdcam_fb(const void *buf)
static constexpr logPrioT LOG_DEFAULT
Used to denote "use the default level for this log type".
static flatlogs::msgLenT length(const fbMessage &msg)
Get the length of the message.
The type of the input message.
static bool verify(flatlogs::bufferPtrT &logBuff, flatlogs::msgLenT len)
A fixed-width timespec structure.
Definition timespecX.hpp:35
SCENARIO("Create telem_stdcam 0", "[a log item]")
const float telemStdcamTemp_0
const float telemStdcamExptime_0
const std::string telemStdcamReadout_speed_0
const float telemStdcamAdcSpeed_0
const float telemStdcamEmGain_0
const uint8_t telemStdcamStatus_0
const int telemStdcamXbin_0
const uint8_t telemStdcamCropMode_0
const std::string telemStdcamShutterStatusSr_0
const int telemStdcamHeight_0
const float telemStdcamSetpt_0
const float telemStdcamYcen_0
const uint8_t telemStdcamOntarget_0
const int8_t telemStdcamShutterState_0
const int telemStdcamWidth_0
const int telemStdcamYbin_0
const std::string telemStdcamStatusStr_0
const std::string telemStdcamMode_0
const float telemStdcamXcen_0
const uint8_t telemStdcamSynchro_0
const float telemStdcamFps_0
const float telemStdcamVshift_0