API
 
Loading...
Searching...
No Matches
telem_stdcam.hpp
Go to the documentation of this file.
1/** \file telem_stdcam.hpp
2 * \brief The MagAO-X logger telem_stdcam log type.
3 * \author Jared R. Males (jaredmales@gmail.com)
4 *
5 * \ingroup logger_types_files
6 *
7 * History:
8 * - 2018-09-06 created by JRM
9 */
10#ifndef logger_types_telem_stdcam_hpp
11#define logger_types_telem_stdcam_hpp
12
14#include "flatbuffer_log.hpp"
15
16namespace MagAOX
17{
18namespace logger
19{
20
21
22/// Log entry recording stdcam stage specific status.
23/** \ingroup logger_types
24 */
26{
27 ///The event code
29
30 ///The default level
32
33 static timespec lastRecord; ///< The timestamp of the last time this log was recorded. Used by the telemetry system.
34
35 ///The type of the input message
36 struct messageT : public fbMessage
37 {
38 ///Construct from components
39 messageT( const std::string & mode, ///<[in]
40 const float & xcen, ///<[in]
41 const float & ycen, ///<[in]
42 const int & width, ///<[in]
43 const int & height, ///<[in]
44 const int & xbin, ///<[in]
45 const int & ybin, ///<[in]
46 const float & exptime, ///<[in]
47 const float & fps, ///<[in]
48 const float & emGain, ///<[in]
49 const float & adcSpeed, ///<[in]
50 const float & temp, ///<[in]
51 const float & setpt, ///<[in]
52 const uint8_t & status, ///<[in]
53 const uint8_t & ontarget, ///<[in]
54 const std::string & statusStr, ///<[in]
55 const std::string & shutterStatusSr, ///<[in]
56 const int8_t & shutterState, ///<[in]
57 const uint8_t & synchro, ///<[in]
58 const float & vshift, ///<[in]
59 const uint8_t & cropMode, ///<[in]
60 const std::string & readout_speed ///<[in]
61 )
62 {
63 auto _mode = builder.CreateString(mode);
64 auto _roi = CreateROI(builder,xcen, ycen, width, height, xbin, ybin);
65
66 auto _statusStr = builder.CreateString(statusStr);
67 auto _tempCtrl = CreateTempCtrl(builder, temp, setpt, status, ontarget, _statusStr);
68
69 auto _shutterStatusStr = builder.CreateString(shutterStatusSr);
70 auto _shutter = CreateShutter(builder, _shutterStatusStr, shutterState);
71
72 auto _readoutSpeed = builder.CreateString(readout_speed);
73
74 auto fp = CreateTelem_stdcam_fb(builder, _mode, _roi, exptime, fps, emGain, adcSpeed, _tempCtrl, _shutter, synchro, vshift, cropMode, _readoutSpeed);
75 builder.Finish(fp);
76 }
77
78 };
79
80 static bool verify( flatlogs::bufferPtrT & logBuff, ///< [in] Buffer containing the flatbuffer serialized message.
81 flatlogs::msgLenT len ///< [in] length of msgBuffer.
82 )
83 {
84 auto verifier = flatbuffers::Verifier( static_cast<uint8_t*>(flatlogs::logHeader::messageBuffer(logBuff)), static_cast<size_t>(len));
85 return VerifyTelem_stdcam_fbBuffer(verifier);
86 }
87
88 ///Get the message formatted for human consumption.
89 static std::string msgString( void * msgBuffer, /**< [in] Buffer containing the flatbuffer serialized message.*/
90 flatlogs::msgLenT len /**< [in] [unused] length of msgBuffer.*/
91 )
92 {
93 static_cast<void>(len);
94
95 auto fbs = GetTelem_stdcam_fb(msgBuffer);
96
97 std::string msg = "[stdcam] ";
98
99 if(fbs->mode() != nullptr)
100 {
101 msg+= "mode: ";
102 msg += fbs->mode()->c_str();
103 msg += " ";
104 }
105
106 if(fbs->roi() != nullptr)
107 {
108 msg += "ROI-x: ";
109 msg += std::to_string(fbs->roi()->xcen());
110 msg += " y: ";
111 msg += std::to_string(fbs->roi()->ycen());
112 msg += " w: ";
113 msg += std::to_string(fbs->roi()->w());
114 msg += " h: ";
115 msg += std::to_string(fbs->roi()->h());
116 msg += " xbin: ";
117 msg += std::to_string(fbs->roi()->xbin());
118 msg += " ybin: ";
119 msg += std::to_string(fbs->roi()->ybin());
120 msg += " ";
121 }
122
123 msg += "expt: ";
124 msg += std::to_string(fbs->exptime());
125 msg += " fps: ";
126 msg += std::to_string(fbs->fps());
127 msg += " emG: ";
128 msg += std::to_string(fbs->emGain());
129 msg += " adc: ";
130 msg += std::to_string(fbs->adcSpeed());
131
132 if(fbs->tempCtrl() != nullptr)
133 {
134 msg += " temp: ";
135 msg += std::to_string(fbs->tempCtrl()->temp());
136 msg += " setpt: ";
137 msg += std::to_string(fbs->tempCtrl()->setpt());
138 msg += " tempctr-stat: ";
139 msg += std::to_string(fbs->tempCtrl()->status());
140 msg += " tempctr-ontgt: ";
141 msg += std::to_string(fbs->tempCtrl()->ontarget());
142
143 if(fbs->tempCtrl()->statusStr())
144 {
145 msg += " tempctr-statstr: ";
146 msg += fbs->tempCtrl()->statusStr()->c_str();
147 }
148 }
149
150 if(fbs->shutter() != nullptr)
151 {
152 if(fbs->shutter()->statusStr())
153 {
154 msg += " shutter-statstr: ";
155 msg += fbs->shutter()->statusStr()->c_str();
156 }
157 msg+= " shutter: ";
158 if( fbs->shutter()->state() == -1)
159 {
160 msg += "UNKN";
161 }
162 else if( fbs->shutter()->state() == 0)
163 {
164 msg += "SHUT";
165 }
166 else if( fbs->shutter()->state() == 1)
167 {
168 msg += "OPEN";
169 }
170 }
171
172 msg += " Sync: ";
173 if(fbs->synchro()) msg += "ON";
174 else msg += "OFF";
175
176 msg += " vshift: ";
177 if(fbs->vshift() == 0) msg += "---";
178 else msg += std::to_string(fbs->vshift());
179
180 msg += " crop: ";
181 if(fbs->cropMode()==-1) msg += "---";
182 else if(fbs->cropMode()==1) msg += "ON";
183 else msg += "OFF";
184
185 if(fbs->readout_speed() != nullptr)
186 {
187 if(fbs->readout_speed()->size() > 0)
188 {
189 msg += " rospd: ";
190 msg += fbs->readout_speed()->c_str();
191 }
192 }
193
194 return msg;
195
196 }
197
198 static std::string mode( void * msgBuffer )
199 {
200 auto fbs = GetTelem_stdcam_fb(msgBuffer);
201 if(fbs->mode() != nullptr)
202 {
203 return std::string(fbs->mode()->c_str());
204 }
205 else return "";
206 }
207
208 static float xcen( void * msgBuffer )
209 {
210 auto fbs = GetTelem_stdcam_fb(msgBuffer);
211 if(fbs->roi() != nullptr) return fbs->roi()->xcen();
212 else return -1;
213 }
214
215 static float ycen( void * msgBuffer )
216 {
217 auto fbs = GetTelem_stdcam_fb(msgBuffer);
218 if(fbs->roi() != nullptr) return fbs->roi()->ycen();
219 else return -1;
220 }
221
222 static int width( void * msgBuffer )
223 {
224 auto fbs = GetTelem_stdcam_fb(msgBuffer);
225 if(fbs->roi() != nullptr) return fbs->roi()->w();
226 else return -1;
227 }
228
229 static int height( void * msgBuffer )
230 {
231 auto fbs = GetTelem_stdcam_fb(msgBuffer);
232 if(fbs->roi() != nullptr) return fbs->roi()->h();
233 else return -1;
234 }
235
236 static int xbin( void * msgBuffer )
237 {
238 auto fbs = GetTelem_stdcam_fb(msgBuffer);
239 if(fbs->roi() != nullptr) return fbs->roi()->xbin();
240 else return -1;
241 }
242
243 static int ybin( void * msgBuffer )
244 {
245 auto fbs = GetTelem_stdcam_fb(msgBuffer);
246 if(fbs->roi() != nullptr) return fbs->roi()->ybin();
247 else return -1;
248 }
249
250 static float exptime( void * msgBuffer )
251 {
252 auto fbs = GetTelem_stdcam_fb(msgBuffer);
253 return fbs->exptime();
254 }
255
256 static float fps( void * msgBuffer )
257 {
258 auto fbs = GetTelem_stdcam_fb(msgBuffer);
259 return fbs->fps();
260 }
261
262 static float emGain( void * msgBuffer )
263 {
264 auto fbs = GetTelem_stdcam_fb(msgBuffer);
265 return fbs->emGain();
266 }
267
268 static float adcSpeed( void * msgBuffer )
269 {
270 auto fbs = GetTelem_stdcam_fb(msgBuffer);
271 return fbs->adcSpeed();
272 }
273
274 static float temp( void * msgBuffer )
275 {
276 auto fbs = GetTelem_stdcam_fb(msgBuffer);
277 if(fbs->tempCtrl() != nullptr) return fbs->tempCtrl()->temp();
278 else return -9999;
279 }
280
281 static float tempSetpt( void * msgBuffer )
282 {
283 auto fbs = GetTelem_stdcam_fb(msgBuffer);
284 if(fbs->tempCtrl() != nullptr) return fbs->tempCtrl()->setpt();
285 else return -9999;
286 }
287
288 static int tempStatus( void * msgBuffer )
289 {
290 auto fbs = GetTelem_stdcam_fb(msgBuffer);
291 if(fbs->tempCtrl() != nullptr) return fbs->tempCtrl()->status();
292 else return -9999;
293 }
294
295 static int tempOnTarget( void * msgBuffer )
296 {
297 auto fbs = GetTelem_stdcam_fb(msgBuffer);
298 if(fbs->tempCtrl() != nullptr) return fbs->tempCtrl()->ontarget();
299 else return -9999;
300 }
301
302 static std::string tempStatusStr( void * msgBuffer )
303 {
304 auto fbs = GetTelem_stdcam_fb(msgBuffer);
305 if(fbs->tempCtrl() != nullptr)
306 {
307 if(fbs->tempCtrl()->statusStr()) return fbs->tempCtrl()->statusStr()->c_str();
308 else return "";
309 }
310 else return "";
311 }
312
313 static std::string shutterStatusStr( void * msgBuffer)
314 {
315 auto fbs = GetTelem_stdcam_fb(msgBuffer);
316 if(fbs->shutter() != nullptr)
317 {
318 if(fbs->shutter()->statusStr()) return fbs->shutter()->statusStr()->c_str();
319 else return "";
320 }
321 else return "";
322 }
323
324 static std::string shutterState( void * msgBuffer )
325 {
326 auto fbs = GetTelem_stdcam_fb(msgBuffer);
327 if(fbs->shutter() != nullptr)
328 {
329 if( fbs->shutter()->state() == -1) return "UNKNOWN";
330 else if( fbs->shutter()->state() == 0) return "SHUT";
331 else if( fbs->shutter()->state() == 1) return "OPEN";
332 else return "INVALID";
333 }
334 else return "INVALID";
335 }
336
337 static bool synchro( void * msgBuffer )
338 {
339 auto fbs = GetTelem_stdcam_fb(msgBuffer);
340 return fbs->synchro();
341 }
342
343 static float vshift( void * msgBuffer )
344 {
345 auto fbs = GetTelem_stdcam_fb(msgBuffer);
346 return fbs->vshift();
347 }
348
349 static bool cropMode( void * msgBuffer )
350 {
351 auto fbs = GetTelem_stdcam_fb(msgBuffer);
352
353 //slightly different because define a default to indicated not-used.
354 if(fbs->cropMode() == 1) return true;
355 else return false;
356 }
357
358 static std::string readout_speed( void * msgBuffer )
359 {
360 auto fbs = GetTelem_stdcam_fb(msgBuffer);
361 if(fbs->readout_speed() != nullptr)
362 {
363 return std::string(fbs->readout_speed()->c_str());
364 }
365 else return "";
366 }
367
368 /// Get the logMetaDetail for a member by name
369 /**
370 * \returns the a logMetaDetail filled in with the appropriate details
371 * \returns an empty logMetaDetail if member not recognized
372 */
373 static logMetaDetail getAccessor( const std::string & member /**< [in] the name of the member */ )
374 {
375 if(member == "mode") return logMetaDetail({"MODE", logMeta::valTypes::String, logMeta::metaTypes::State, reinterpret_cast<void*>(&mode)});
376 else if(member == "xcen") return logMetaDetail({"ROI XCEN", logMeta::valTypes::Float, logMeta::metaTypes::State, reinterpret_cast<void*>(&xcen)});
377 else if(member == "ycen") return logMetaDetail({"ROI YCEN", logMeta::valTypes::Float, logMeta::metaTypes::State, reinterpret_cast<void*>(&ycen)});
378 else if(member == "width") return logMetaDetail({"ROI WIDTH", logMeta::valTypes::Int, logMeta::metaTypes::State, reinterpret_cast<void*>(&width)});
379 else if(member == "height") return logMetaDetail({"ROI HEIGHT", logMeta::valTypes::Int, logMeta::metaTypes::State, reinterpret_cast<void*>(&height)});
380 else if(member == "xbin") return logMetaDetail({"ROI XBIN", logMeta::valTypes::Int, logMeta::metaTypes::State, reinterpret_cast<void*>(&xbin)});
381 else if(member == "ybin") return logMetaDetail({"ROI YBIN", logMeta::valTypes::Int, logMeta::metaTypes::State, reinterpret_cast<void*>(&ybin)});
382 else if(member == "exptime") return logMetaDetail({"EXPTIME", logMeta::valTypes::Float, logMeta::metaTypes::State, reinterpret_cast<void*>(&exptime)});
383 else if(member == "fps") return logMetaDetail({"FPS", logMeta::valTypes::Float, logMeta::metaTypes::State, reinterpret_cast<void*>(&fps)});
384 else if(member == "emGain") return logMetaDetail({"EMGAIN", logMeta::valTypes::Float, logMeta::metaTypes::State, reinterpret_cast<void*>(&emGain)});
385 else if(member == "adcSpeed") return logMetaDetail({"ADC SPEED", logMeta::valTypes::Float, logMeta::metaTypes::State, reinterpret_cast<void*>(&adcSpeed)});
386 else if(member == "temp") return logMetaDetail({"TEMP", logMeta::valTypes::Float, logMeta::metaTypes::Continuous, reinterpret_cast<void*>(&temp)});
387 else if(member == "tempSetpt") return logMetaDetail({"TEMP SETPT", logMeta::valTypes::Float, logMeta::metaTypes::State, reinterpret_cast<void*>(&tempSetpt)});
388 else if(member == "tempStatus") return logMetaDetail({"TEMP STATUS", logMeta::valTypes::Int, logMeta::metaTypes::Continuous, reinterpret_cast<void*>(&tempStatus)});
389 else if(member == "tempOnTarget") return logMetaDetail({"TEMP ONTGT", logMeta::valTypes::Int, logMeta::metaTypes::Continuous, reinterpret_cast<void*>(&tempOnTarget)});
390 else if(member == "tempStatusStr") return logMetaDetail({"TEMP STATUSSTR", logMeta::valTypes::String, logMeta::metaTypes::State, reinterpret_cast<void*>(&tempStatusStr)});
391 else if(member == "shutterStatusStr") return logMetaDetail({"SHUTTER STATUS", logMeta::valTypes::String, logMeta::metaTypes::State, reinterpret_cast<void*>(&shutterStatusStr)});
392 else if(member == "shutterState") return logMetaDetail({"SHUTTER", logMeta::valTypes::String, logMeta::metaTypes::State, reinterpret_cast<void*>(&shutterState)});
393 else if(member == "synchro") return logMetaDetail({"SYNCHRO", logMeta::valTypes::Bool, logMeta::metaTypes::State, reinterpret_cast<void*>(&synchro)});
394 else if(member == "vshift") return logMetaDetail({"VERT SHIFT SPEED", logMeta::valTypes::Float, logMeta::metaTypes::State, reinterpret_cast<void*>(&vshift)});
395 else if(member == "cropMode") return logMetaDetail({"CROP MODE", logMeta::valTypes::Bool, logMeta::metaTypes::State, reinterpret_cast<void*>(&cropMode)});
396 else if(member == "readout_speed") return logMetaDetail({"READOUT SPEED", logMeta::valTypes::String, logMeta::metaTypes::State, reinterpret_cast<void*>(&readout_speed)});
397 else
398 {
399 std::cerr << "No member " << member << " in telem_stdcam\n";
400 return logMetaDetail();
401 }
402 }
403
404}; //telem_stdcam
405
406
407
408} //namespace logger
409} //namespace MagAOX
410
411#endif //logger_types_telem_stdcam_hpp
412
The MagAO-X logger flatbuffer log base type.
uint16_t eventCodeT
The type of an event code (16-bit unsigned int).
Definition logDefs.hpp:40
msgLen2T msgLenT
The type used to refer to the message length, regardless of length.
Definition logDefs.hpp:69
int8_t logPrioT
The type of the log priority code.
Definition logDefs.hpp:21
static void * messageBuffer(bufferPtrT &logBuffer)
Get the message buffer address.
std::shared_ptr< char > bufferPtrT
The log entry buffer smart pointer.
Definition logHeader.hpp:58
static constexpr flatlogs::eventCodeT TELEM_STDCAM
Definition logCodes.hpp:48
const MagAOX::logger::Telem_stdcam_fb * GetTelem_stdcam_fb(const void *buf)
inline ::flatbuffers::Offset< ROI > CreateROI(::flatbuffers::FlatBufferBuilder &_fbb, float xcen=0.0f, float ycen=0.0f, int32_t w=0, int32_t h=0, int32_t xbin=0, int32_t ybin=0)
inline ::flatbuffers::Offset< Telem_stdcam_fb > CreateTelem_stdcam_fb(::flatbuffers::FlatBufferBuilder &_fbb, ::flatbuffers::Offset<::flatbuffers::String > mode=0, ::flatbuffers::Offset< MagAOX::logger::ROI > roi=0, float exptime=0.0f, float fps=0.0f, float emGain=0.0f, float adcSpeed=0.0f, ::flatbuffers::Offset< MagAOX::logger::TempCtrl > tempCtrl=0, ::flatbuffers::Offset< MagAOX::logger::Shutter > shutter=0, uint8_t synchro=0, float vshift=0.0f, int8_t cropMode=-1, ::flatbuffers::Offset<::flatbuffers::String > readout_speed=0)
bool VerifyTelem_stdcam_fbBuffer(::flatbuffers::Verifier &verifier)
inline ::flatbuffers::Offset< TempCtrl > CreateTempCtrl(::flatbuffers::FlatBufferBuilder &_fbb, float temp=0.0f, float setpt=0.0f, bool status=false, bool ontarget=false, ::flatbuffers::Offset<::flatbuffers::String > statusStr=0)
inline ::flatbuffers::Offset< Shutter > CreateShutter(::flatbuffers::FlatBufferBuilder &_fbb, ::flatbuffers::Offset<::flatbuffers::String > statusStr=0, int32_t state=0)
Definition dm.hpp:28
static constexpr logPrioT LOG_TELEM
A telemetry recording.
Message type for resolving log messages with a f.b. builder.
flatbuffers::FlatBufferBuilder builder
Base class for logs consisting of a flatbuffer message.
The type of the input message.
messageT(const std::string &mode, const float &xcen, const float &ycen, const int &width, const int &height, const int &xbin, const int &ybin, const float &exptime, const float &fps, const float &emGain, const float &adcSpeed, const float &temp, const float &setpt, const uint8_t &status, const uint8_t &ontarget, const std::string &statusStr, const std::string &shutterStatusSr, const int8_t &shutterState, const uint8_t &synchro, const float &vshift, const uint8_t &cropMode, const std::string &readout_speed)
Construct from components.
Log entry recording stdcam stage specific status.
static float temp(void *msgBuffer)
static bool synchro(void *msgBuffer)
static std::string shutterStatusStr(void *msgBuffer)
static const flatlogs::eventCodeT eventCode
The event code.
static bool cropMode(void *msgBuffer)
static float vshift(void *msgBuffer)
static std::string shutterState(void *msgBuffer)
static timespec lastRecord
The timestamp of the last time this log was recorded. Used by the telemetry system.
static float tempSetpt(void *msgBuffer)
static logMetaDetail getAccessor(const std::string &member)
Get the logMetaDetail for a member by name.
static int tempStatus(void *msgBuffer)
static const flatlogs::logPrioT defaultLevel
The default level.
static float adcSpeed(void *msgBuffer)
static int tempOnTarget(void *msgBuffer)
static std::string tempStatusStr(void *msgBuffer)
static float ycen(void *msgBuffer)
static bool verify(flatlogs::bufferPtrT &logBuff, flatlogs::msgLenT len)
static int height(void *msgBuffer)
static std::string msgString(void *msgBuffer, flatlogs::msgLenT len)
Get the message formatted for human consumption.
static float fps(void *msgBuffer)
static float emGain(void *msgBuffer)
static std::string mode(void *msgBuffer)
static std::string readout_speed(void *msgBuffer)
static int xbin(void *msgBuffer)
static float xcen(void *msgBuffer)
static int ybin(void *msgBuffer)
static float exptime(void *msgBuffer)
static int width(void *msgBuffer)