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 = "n0kl4uw40c"; // dummy mode
14const float telemStdcamXcen_0 = 0.35477; // dummy xcen
15const float telemStdcamYcen_0 = 0.524991; // dummy ycen
16const int telemStdcamWidth_0 = 1504395285; // dummy width
17const int telemStdcamHeight_0 = -1302212251; // dummy height
18const int telemStdcamXbin_0 = 40165639; // dummy xbin
19const int telemStdcamYbin_0 = 1520245768; // dummy ybin
20const float telemStdcamExptime_0 = 0.560484; // dummy exptime
21const float telemStdcamFps_0 = 0.367946; // dummy fps
22const float telemStdcamEmGain_0 = 0.773053; // dummy emGain
23const float telemStdcamAdcSpeed_0 = 0.273487; // dummy adcSpeed
24const float telemStdcamTemp_0 = 0.35382; // dummy temp
25const float telemStdcamSetpt_0 = 0.238657; // dummy setpt
26const uint8_t telemStdcamStatus_0 = 1; // dummy status
27const uint8_t telemStdcamOntarget_0 = 1; // dummy ontarget
28const std::string telemStdcamStatusStr_0 = "x2bamlt0jl"; // dummy statusStr
29const std::string telemStdcamShutterStatusSr_0 = "jzqrjgkv8v"; // dummy shutterStatusSr
30const int8_t telemStdcamShutterState_0 = 68; // dummy shutterState
31const uint8_t telemStdcamSynchro_0 = 162; // dummy synchro
32const float telemStdcamVshift_0 = 0.452963; // dummy vshift
33const uint8_t telemStdcamCropMode_0 = 18; // dummy cropMode
34
35
36/** Class to encapsulate telem_stdcam flatbuffer data using
37 ** => types/telem_stdcam.hpp
38 ** => types/generated/telem_stdcam_generated.h
39 **/
41{
42public:
43 // Saved input parameter value; unused
44 std::string m_saveTsMode;
59 std::string m_saveTsStatusStr;
65
66 // Parameters retrieved from flatbuffer
67 std::string m_mode;
68 float m_xcen;
69 float m_ycen;
72 int m_xbin;
73 int m_ybin;
74 float m_exptime;
75 float m_fps;
76 float m_emGain;
78 float m_temp;
79 float m_setpt;
80 uint8_t m_status;
81 uint8_t m_ontarget;
82 std::string m_statusStr;
83 std::string m_shutterStatusSr;
85 uint8_t m_synchro;
86 float m_vshift;
87 uint8_t m_cropMode;
88
89 // Flatbuffers verifier success/failure
90 bool m_verify{false};
91
92 // flatbuffer data length; used in ::verify
93 int L;
94
95 // Constructor
96 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_) {
97 // Save input parameters
98 m_saveTsMode = mode_;
99 m_saveTsXcen = xcen_;
100 m_saveTsYcen = ycen_;
101 m_saveTsWidth = width_;
102 m_saveTsHeight = height_;
103 m_saveTsXbin = xbin_;
104 m_saveTsYbin = ybin_;
105 m_saveTsExptime = exptime_;
106 m_saveTsFps = fps_;
107 m_saveTsEmGain = emGain_;
108 m_saveTsAdcSpeed = adcSpeed_;
109 m_saveTsTemp = temp_;
110 m_saveTsSetpt = setpt_;
111 m_saveTsStatus = status_;
112 m_saveTsOntarget = ontarget_;
113 m_saveTsStatusStr = statusStr_;
114 m_saveTsShutterStatusSr = shutterStatusSr_;
115 m_saveTsShutterState = shutterState_;
116 m_saveTsSynchro = synchro_;
117 m_saveTsVshift = vshift_;
118 m_saveTsCropMode = cropMode_;
119
120 // Create the flatbuffer messageT using the input parameters
121 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_);
122
123 // Retrieve flatbuffer pointer (if not an empty_log type) and length
124 void* buffPtr = ts.builder.GetBufferPointer();
126
127 // Retrieve the flatbuffer parameters for Catch2 comparison below
128 m_mode = std::string(MagAOX::logger::GetTelem_stdcam_fb(buffPtr)->mode()->c_str());
129 m_xcen = MagAOX::logger::GetTelem_stdcam_fb(buffPtr)->roi()->xcen();
130 m_ycen = MagAOX::logger::GetTelem_stdcam_fb(buffPtr)->roi()->ycen();
131 m_width = MagAOX::logger::GetTelem_stdcam_fb(buffPtr)->roi()->w();
132 m_height = MagAOX::logger::GetTelem_stdcam_fb(buffPtr)->roi()->h();
133 m_xbin = MagAOX::logger::GetTelem_stdcam_fb(buffPtr)->roi()->xbin();
134 m_ybin = MagAOX::logger::GetTelem_stdcam_fb(buffPtr)->roi()->ybin();
135 m_exptime = MagAOX::logger::GetTelem_stdcam_fb(buffPtr)->exptime();
137 m_emGain = MagAOX::logger::GetTelem_stdcam_fb(buffPtr)->emGain();
138 m_adcSpeed = MagAOX::logger::GetTelem_stdcam_fb(buffPtr)->adcSpeed();
139 m_temp = MagAOX::logger::GetTelem_stdcam_fb(buffPtr)->tempCtrl()->temp();
140 m_setpt = MagAOX::logger::GetTelem_stdcam_fb(buffPtr)->tempCtrl()->setpt();
141 m_status = MagAOX::logger::GetTelem_stdcam_fb(buffPtr)->tempCtrl()->status();
142 m_ontarget = MagAOX::logger::GetTelem_stdcam_fb(buffPtr)->tempCtrl()->ontarget();
143 m_statusStr = std::string(MagAOX::logger::GetTelem_stdcam_fb(buffPtr)->tempCtrl()->statusStr()->c_str());
144 m_shutterStatusSr = std::string(MagAOX::logger::GetTelem_stdcam_fb(buffPtr)->shutter()->statusStr()->c_str());
145 m_shutterState = MagAOX::logger::GetTelem_stdcam_fb(buffPtr)->shutter()->state();
146 m_synchro = MagAOX::logger::GetTelem_stdcam_fb(buffPtr)->synchro();
147 m_vshift = MagAOX::logger::GetTelem_stdcam_fb(buffPtr)->vshift();
148 m_cropMode = MagAOX::logger::GetTelem_stdcam_fb(buffPtr)->cropMode();
149
150 // Run the telem_stdcam verifier
151 m_verify = verify(ts);
152 }
153
154 // Run the flatbuffer Verifier for this log type
155 // - requires bufferPtrT (shared_ptr<char*>) to full log entry
156 // comprising log header plus flatbuffer log message
158
159 // Timestamp, prioriy (use nominal value here)
160 flatlogs::timespecX tsx{0,0};
162
163 // Create full log: log header(*); log message (+)
164 // * Log level (priority)
165 // * Event code (implicit in <MagAOX::logger::type>)
166 // * Timestamp
167 // * Message size (variable length; 1, 2, or 8 bytes)
168 // + Message (variable length)
169
170 // N.G. allocates space and writes pointer value to logBuffer
171 flatlogs::bufferPtrT logBuffer;
172 flatlogs::logHeader::createLog<MagAOX::logger::telem_stdcam>(logBuffer
173 , tsx, msg
174 , prio);
175 // Run full log through flatbuffer Verifier
176 return MagAOX::logger::telem_stdcam::verify(logBuffer,L);
177 }
178};
179
180SCENARIO( "Create telem_stdcam 0", "[a log item]")
181{
182 GIVEN("a telem_stdcam log code")
183 {
184 WHEN("random values for fields")
185 {
186 // Create flatbuffer
188 // Compare flatbuffer parameters
189 REQUIRE(ts.m_mode == telemStdcamMode_0);
190 REQUIRE(ts.m_xcen == telemStdcamXcen_0);
191 REQUIRE(ts.m_ycen == telemStdcamYcen_0);
192 REQUIRE(ts.m_width == telemStdcamWidth_0);
193 REQUIRE(ts.m_height == telemStdcamHeight_0);
194 REQUIRE(ts.m_xbin == telemStdcamXbin_0);
195 REQUIRE(ts.m_ybin == telemStdcamYbin_0);
196 REQUIRE(ts.m_exptime == telemStdcamExptime_0);
197 REQUIRE(ts.m_fps == telemStdcamFps_0);
198 REQUIRE(ts.m_emGain == telemStdcamEmGain_0);
199 REQUIRE(ts.m_adcSpeed == telemStdcamAdcSpeed_0);
200 REQUIRE(ts.m_temp == telemStdcamTemp_0);
201 REQUIRE(ts.m_setpt == telemStdcamSetpt_0);
202 REQUIRE(ts.m_status == telemStdcamStatus_0);
203 REQUIRE(ts.m_ontarget == telemStdcamOntarget_0);
204 REQUIRE(ts.m_statusStr == telemStdcamStatusStr_0);
207 REQUIRE(ts.m_synchro == telemStdcamSynchro_0);
208 REQUIRE(ts.m_vshift == telemStdcamVshift_0);
209 REQUIRE(ts.m_cropMode == telemStdcamCropMode_0);
210 REQUIRE(ts.m_verify);
211 }
212 }
213}
214
215const std::string telemStdcamMode_1 = "b13uj2xnwp"; // dummy mode
216const float telemStdcamXcen_1 = 0.633753; // dummy xcen
217const float telemStdcamYcen_1 = 0.379517; // dummy ycen
218const int telemStdcamWidth_1 = 760727924; // dummy width
219const int telemStdcamHeight_1 = -589714848; // dummy height
220const int telemStdcamXbin_1 = 1506803030; // dummy xbin
221const int telemStdcamYbin_1 = 264440513; // dummy ybin
222const float telemStdcamExptime_1 = 0.169911; // dummy exptime
223const float telemStdcamFps_1 = 0.175352; // dummy fps
224const float telemStdcamEmGain_1 = 0.516519; // dummy emGain
225const float telemStdcamAdcSpeed_1 = 0.982221; // dummy adcSpeed
226const float telemStdcamTemp_1 = 0.000305; // dummy temp
227const float telemStdcamSetpt_1 = 0.491747; // dummy setpt
228const uint8_t telemStdcamStatus_1 = 1; // dummy status
229const uint8_t telemStdcamOntarget_1 = 1; // dummy ontarget
230const std::string telemStdcamStatusStr_1 = "a5zmm6xf3r"; // dummy statusStr
231const std::string telemStdcamShutterStatusSr_1 = "0g3aonr7mu"; // dummy shutterStatusSr
232const int8_t telemStdcamShutterState_1 = 17; // dummy shutterState
233const uint8_t telemStdcamSynchro_1 = 65; // dummy synchro
234
235
236/** Class to encapsulate telem_stdcam flatbuffer data using
237 ** => types/telem_stdcam.hpp
238 ** => types/generated/telem_stdcam_generated.h
239 **/
241{
242public:
243 // Saved input parameter value; unused
244 std::string m_saveTsMode;
259 std::string m_saveTsStatusStr;
263
264 // Parameters retrieved from flatbuffer
265 std::string m_mode;
266 float m_xcen;
267 float m_ycen;
273 float m_fps;
274 float m_emGain;
276 float m_temp;
277 float m_setpt;
278 uint8_t m_status;
279 uint8_t m_ontarget;
280 std::string m_statusStr;
281 std::string m_shutterStatusSr;
283 uint8_t m_synchro;
284
285 // Flatbuffers verifier success/failure
286 bool m_verify{false};
287
288 // flatbuffer data length; used in ::verify
289 int L;
290
291 // Constructor
292 CTelemStdcam_1(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_) {
293 // Save input parameters
294 m_saveTsMode = mode_;
295 m_saveTsXcen = xcen_;
296 m_saveTsYcen = ycen_;
297 m_saveTsWidth = width_;
298 m_saveTsHeight = height_;
299 m_saveTsXbin = xbin_;
300 m_saveTsYbin = ybin_;
301 m_saveTsExptime = exptime_;
302 m_saveTsFps = fps_;
303 m_saveTsEmGain = emGain_;
304 m_saveTsAdcSpeed = adcSpeed_;
305 m_saveTsTemp = temp_;
306 m_saveTsSetpt = setpt_;
307 m_saveTsStatus = status_;
308 m_saveTsOntarget = ontarget_;
309 m_saveTsStatusStr = statusStr_;
310 m_saveTsShutterStatusSr = shutterStatusSr_;
311 m_saveTsShutterState = shutterState_;
312 m_saveTsSynchro = synchro_;
313
314 // Create the flatbuffer messageT using the input parameters
315 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_);
316
317 // Retrieve flatbuffer pointer (if not an empty_log type) and length
318 void* buffPtr = ts.builder.GetBufferPointer();
320
321 // Retrieve the flatbuffer parameters for Catch2 comparison below
322 m_mode = std::string(MagAOX::logger::GetTelem_stdcam_fb(buffPtr)->mode()->c_str());
323 m_xcen = MagAOX::logger::GetTelem_stdcam_fb(buffPtr)->roi()->xcen();
324 m_ycen = MagAOX::logger::GetTelem_stdcam_fb(buffPtr)->roi()->ycen();
325 m_width = MagAOX::logger::GetTelem_stdcam_fb(buffPtr)->roi()->w();
326 m_height = MagAOX::logger::GetTelem_stdcam_fb(buffPtr)->roi()->h();
327 m_xbin = MagAOX::logger::GetTelem_stdcam_fb(buffPtr)->roi()->xbin();
328 m_ybin = MagAOX::logger::GetTelem_stdcam_fb(buffPtr)->roi()->ybin();
329 m_exptime = MagAOX::logger::GetTelem_stdcam_fb(buffPtr)->exptime();
331 m_emGain = MagAOX::logger::GetTelem_stdcam_fb(buffPtr)->emGain();
332 m_adcSpeed = MagAOX::logger::GetTelem_stdcam_fb(buffPtr)->adcSpeed();
333 m_temp = MagAOX::logger::GetTelem_stdcam_fb(buffPtr)->tempCtrl()->temp();
334 m_setpt = MagAOX::logger::GetTelem_stdcam_fb(buffPtr)->tempCtrl()->setpt();
335 m_status = MagAOX::logger::GetTelem_stdcam_fb(buffPtr)->tempCtrl()->status();
336 m_ontarget = MagAOX::logger::GetTelem_stdcam_fb(buffPtr)->tempCtrl()->ontarget();
337 m_statusStr = std::string(MagAOX::logger::GetTelem_stdcam_fb(buffPtr)->tempCtrl()->statusStr()->c_str());
338 m_shutterStatusSr = std::string(MagAOX::logger::GetTelem_stdcam_fb(buffPtr)->shutter()->statusStr()->c_str());
339 m_shutterState = MagAOX::logger::GetTelem_stdcam_fb(buffPtr)->shutter()->state();
340 m_synchro = MagAOX::logger::GetTelem_stdcam_fb(buffPtr)->synchro();
341
342 // Run the telem_stdcam verifier
343 m_verify = verify(ts);
344 }
345
346 // Run the flatbuffer Verifier for this log type
347 // - requires bufferPtrT (shared_ptr<char*>) to full log entry
348 // comprising log header plus flatbuffer log message
350
351 // Timestamp, prioriy (use nominal value here)
352 flatlogs::timespecX tsx{0,0};
354
355 // Create full log: log header(*); log message (+)
356 // * Log level (priority)
357 // * Event code (implicit in <MagAOX::logger::type>)
358 // * Timestamp
359 // * Message size (variable length; 1, 2, or 8 bytes)
360 // + Message (variable length)
361
362 // N.G. allocates space and writes pointer value to logBuffer
363 flatlogs::bufferPtrT logBuffer;
364 flatlogs::logHeader::createLog<MagAOX::logger::telem_stdcam>(logBuffer
365 , tsx, msg
366 , prio);
367 // Run full log through flatbuffer Verifier
368 return MagAOX::logger::telem_stdcam::verify(logBuffer,L);
369 }
370};
371
372SCENARIO( "Create telem_stdcam 1", "[a log item]")
373{
374 GIVEN("a telem_stdcam log code")
375 {
376 WHEN("random values for fields")
377 {
378 // Create flatbuffer
380 // Compare flatbuffer parameters
381 REQUIRE(ts.m_mode == telemStdcamMode_1);
382 REQUIRE(ts.m_xcen == telemStdcamXcen_1);
383 REQUIRE(ts.m_ycen == telemStdcamYcen_1);
384 REQUIRE(ts.m_width == telemStdcamWidth_1);
385 REQUIRE(ts.m_height == telemStdcamHeight_1);
386 REQUIRE(ts.m_xbin == telemStdcamXbin_1);
387 REQUIRE(ts.m_ybin == telemStdcamYbin_1);
388 REQUIRE(ts.m_exptime == telemStdcamExptime_1);
389 REQUIRE(ts.m_fps == telemStdcamFps_1);
390 REQUIRE(ts.m_emGain == telemStdcamEmGain_1);
391 REQUIRE(ts.m_adcSpeed == telemStdcamAdcSpeed_1);
392 REQUIRE(ts.m_temp == telemStdcamTemp_1);
393 REQUIRE(ts.m_setpt == telemStdcamSetpt_1);
394 REQUIRE(ts.m_status == telemStdcamStatus_1);
395 REQUIRE(ts.m_ontarget == telemStdcamOntarget_1);
396 REQUIRE(ts.m_statusStr == telemStdcamStatusStr_1);
399 REQUIRE(ts.m_synchro == telemStdcamSynchro_1);
400 REQUIRE(ts.m_verify);
401 }
402 }
403}
404
405
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_)
bool verify(const typename MagAOX::logger::telem_stdcam::messageT &msg)
CTelemStdcam_1(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_)
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
const std::string telemStdcamStatusStr_1
const int telemStdcamHeight_1
SCENARIO("Create telem_stdcam 0", "[a log item]")
const int telemStdcamYbin_1
const float telemStdcamTemp_0
const float telemStdcamExptime_0
const float telemStdcamAdcSpeed_0
const std::string telemStdcamShutterStatusSr_1
const int telemStdcamWidth_1
const std::string telemStdcamMode_1
const float telemStdcamEmGain_0
const uint8_t telemStdcamStatus_0
const int telemStdcamXbin_0
const uint8_t telemStdcamCropMode_0
const int telemStdcamXbin_1
const std::string telemStdcamShutterStatusSr_0
const int telemStdcamHeight_0
const float telemStdcamExptime_1
const float telemStdcamFps_1
const float telemStdcamSetpt_0
const uint8_t telemStdcamStatus_1
const uint8_t telemStdcamSynchro_1
const float telemStdcamEmGain_1
const float telemStdcamYcen_1
const float telemStdcamTemp_1
const int8_t telemStdcamShutterState_1
const float telemStdcamYcen_0
const uint8_t telemStdcamOntarget_0
const int8_t telemStdcamShutterState_0
const int telemStdcamWidth_0
const uint8_t telemStdcamOntarget_1
const int telemStdcamYbin_0
const std::string telemStdcamStatusStr_0
const float telemStdcamAdcSpeed_1
const std::string telemStdcamMode_0
const float telemStdcamSetpt_1
const float telemStdcamXcen_0
const uint8_t telemStdcamSynchro_0
const float telemStdcamFps_0
const float telemStdcamVshift_0
const float telemStdcamXcen_1