10 #ifndef logger_types_telem_stdcam_hpp
11 #define logger_types_telem_stdcam_hpp
13 #include "generated/telem_stdcam_generated.h"
52 const uint8_t & status,
53 const uint8_t & ontarget,
54 const std::string & statusStr,
55 const std::string & shutterStatusSr,
65 auto _statusStr =
builder.CreateString(statusStr);
66 auto _tempCtrl = CreateTempCtrl(
builder,
temp, setpt, status, ontarget, _statusStr);
68 auto _shutterStatusStr =
builder.CreateString(shutterStatusSr);
71 auto fp = CreateTelem_stdcam_fb(
builder, _mode, _roi,
exptime,
fps,
emGain,
adcSpeed, _tempCtrl, _shutter,
synchro,
vshift,
cropMode);
89 const uint8_t & status,
90 const uint8_t & ontarget,
91 const std::string & statusStr,
92 const std::string & shutterStatusSr,
100 auto _statusStr =
builder.CreateString(statusStr);
101 auto _tempCtrl = CreateTempCtrl(
builder,
temp, setpt, status, ontarget, _statusStr);
103 auto _shutterStatusStr =
builder.CreateString(shutterStatusSr);
106 auto fp = CreateTelem_stdcam_fb(
builder, _mode, _roi,
exptime,
fps,
emGain,
adcSpeed, _tempCtrl, _shutter,
synchro, 0, -1);
117 return VerifyTelem_stdcam_fbBuffer(verifier);
125 static_cast<void>(len);
127 auto fbs = GetTelem_stdcam_fb(msgBuffer);
129 std::string
msg =
"[stdcam] ";
131 if(fbs->mode() !=
nullptr)
134 msg += fbs->mode()->c_str();
138 if(fbs->roi() !=
nullptr)
141 msg += std::to_string(fbs->roi()->xcen());
143 msg += std::to_string(fbs->roi()->ycen());
145 msg += std::to_string(fbs->roi()->w());
147 msg += std::to_string(fbs->roi()->h());
149 msg += std::to_string(fbs->roi()->xbin());
151 msg += std::to_string(fbs->roi()->ybin());
156 msg += std::to_string(fbs->exptime());
158 msg += std::to_string(fbs->fps());
160 msg += std::to_string(fbs->emGain());
162 msg += std::to_string(fbs->adcSpeed());
164 if(fbs->tempCtrl() !=
nullptr)
167 msg += std::to_string(fbs->tempCtrl()->temp());
169 msg += std::to_string(fbs->tempCtrl()->setpt());
170 msg +=
" tempctr-stat: ";
171 msg += std::to_string(fbs->tempCtrl()->status());
172 msg +=
" tempctr-ontgt: ";
173 msg += std::to_string(fbs->tempCtrl()->ontarget());
175 if(fbs->tempCtrl()->statusStr())
177 msg +=
" tempctr-statstr: ";
178 msg += fbs->tempCtrl()->statusStr()->c_str();
182 if(fbs->shutter() !=
nullptr)
184 if(fbs->shutter()->statusStr())
186 msg +=
" shutter-statstr: ";
187 msg += fbs->shutter()->statusStr()->c_str();
190 if( fbs->shutter()->state() == -1)
194 else if( fbs->shutter()->state() == 0)
198 else if( fbs->shutter()->state() == 1)
205 if(fbs->synchro())
msg +=
"ON";
209 if(fbs->vshift() == 0)
msg +=
"---";
210 else msg += std::to_string(fbs->vshift());
213 if(fbs->cropMode()==-1)
msg +=
"---";
214 else if(fbs->cropMode()==1)
msg +=
"ON";
221 static std::string
mode(
void * msgBuffer )
223 auto fbs = GetTelem_stdcam_fb(msgBuffer);
224 if(fbs->mode() !=
nullptr)
226 return std::string(fbs->mode()->c_str());
231 static float xcen(
void * msgBuffer )
233 auto fbs = GetTelem_stdcam_fb(msgBuffer);
234 if(fbs->roi() !=
nullptr)
return fbs->roi()->xcen();
238 static float ycen(
void * msgBuffer )
240 auto fbs = GetTelem_stdcam_fb(msgBuffer);
241 if(fbs->roi() !=
nullptr)
return fbs->roi()->ycen();
245 static int width(
void * msgBuffer )
247 auto fbs = GetTelem_stdcam_fb(msgBuffer);
248 if(fbs->roi() !=
nullptr)
return fbs->roi()->w();
254 auto fbs = GetTelem_stdcam_fb(msgBuffer);
255 if(fbs->roi() !=
nullptr)
return fbs->roi()->h();
259 static int xbin(
void * msgBuffer )
261 auto fbs = GetTelem_stdcam_fb(msgBuffer);
262 if(fbs->roi() !=
nullptr)
return fbs->roi()->xbin();
266 static int ybin(
void * msgBuffer )
268 auto fbs = GetTelem_stdcam_fb(msgBuffer);
269 if(fbs->roi() !=
nullptr)
return fbs->roi()->ybin();
275 auto fbs = GetTelem_stdcam_fb(msgBuffer);
276 return fbs->exptime();
279 static float fps(
void * msgBuffer )
281 auto fbs = GetTelem_stdcam_fb(msgBuffer);
287 auto fbs = GetTelem_stdcam_fb(msgBuffer);
288 return fbs->emGain();
293 auto fbs = GetTelem_stdcam_fb(msgBuffer);
294 return fbs->adcSpeed();
297 static float temp(
void * msgBuffer )
299 auto fbs = GetTelem_stdcam_fb(msgBuffer);
300 if(fbs->tempCtrl() !=
nullptr)
return fbs->tempCtrl()->temp();
306 auto fbs = GetTelem_stdcam_fb(msgBuffer);
307 if(fbs->tempCtrl() !=
nullptr)
return fbs->tempCtrl()->setpt();
313 auto fbs = GetTelem_stdcam_fb(msgBuffer);
314 if(fbs->tempCtrl() !=
nullptr)
return fbs->tempCtrl()->status();
320 auto fbs = GetTelem_stdcam_fb(msgBuffer);
321 if(fbs->tempCtrl() !=
nullptr)
return fbs->tempCtrl()->ontarget();
327 auto fbs = GetTelem_stdcam_fb(msgBuffer);
328 if(fbs->tempCtrl() !=
nullptr)
330 if(fbs->tempCtrl()->statusStr())
return fbs->tempCtrl()->statusStr()->c_str();
338 auto fbs = GetTelem_stdcam_fb(msgBuffer);
339 if(fbs->shutter() !=
nullptr)
341 if(fbs->shutter()->statusStr())
return fbs->shutter()->statusStr()->c_str();
349 auto fbs = GetTelem_stdcam_fb(msgBuffer);
350 if(fbs->shutter() !=
nullptr)
352 if( fbs->shutter()->state() == -1)
return "UNKNOWN";
353 else if( fbs->shutter()->state() == 0)
return "SHUT";
354 else if( fbs->shutter()->state() == 1)
return "OPEN";
355 else return "INVALID";
357 else return "INVALID";
362 auto fbs = GetTelem_stdcam_fb(msgBuffer);
363 return fbs->synchro();
368 auto fbs = GetTelem_stdcam_fb(msgBuffer);
369 return fbs->vshift();
374 auto fbs = GetTelem_stdcam_fb(msgBuffer);
377 if(fbs->cropMode() == 1)
return true;
388 if(member ==
"mode")
return logMetaDetail({
"MODE", logMeta::valTypes::String, logMeta::metaTypes::State,
reinterpret_cast<void*
>(&
mode)});
389 else if(member ==
"xcen")
return logMetaDetail({
"ROI XCEN", logMeta::valTypes::Float, logMeta::metaTypes::State,
reinterpret_cast<void*
>(&
xcen)});
390 else if(member ==
"ycen")
return logMetaDetail({
"ROI YCEN", logMeta::valTypes::Float, logMeta::metaTypes::State,
reinterpret_cast<void*
>(&
ycen)});
391 else if(member ==
"width")
return logMetaDetail({
"ROI WIDTH", logMeta::valTypes::Int, logMeta::metaTypes::State,
reinterpret_cast<void*
>(&
width)});
392 else if(member ==
"height")
return logMetaDetail({
"ROI HEIGHT", logMeta::valTypes::Int, logMeta::metaTypes::State,
reinterpret_cast<void*
>(&
height)});
393 else if(member ==
"xbin")
return logMetaDetail({
"ROI XBIN", logMeta::valTypes::Int, logMeta::metaTypes::State,
reinterpret_cast<void*
>(&
xbin)});
394 else if(member ==
"ybin")
return logMetaDetail({
"ROI YBIN", logMeta::valTypes::Int, logMeta::metaTypes::State,
reinterpret_cast<void*
>(&
ybin)});
395 else if(member ==
"exptime")
return logMetaDetail({
"EXPTIME", logMeta::valTypes::Float, logMeta::metaTypes::State,
reinterpret_cast<void*
>(&
exptime)});
396 else if(member ==
"fps")
return logMetaDetail({
"FPS", logMeta::valTypes::Float, logMeta::metaTypes::State,
reinterpret_cast<void*
>(&
fps)});
397 else if(member ==
"emGain")
return logMetaDetail({
"EMGAIN", logMeta::valTypes::Float, logMeta::metaTypes::State,
reinterpret_cast<void*
>(&
emGain)});
398 else if(member ==
"adcSpeed")
return logMetaDetail({
"ADC SPEED", logMeta::valTypes::Float, logMeta::metaTypes::State,
reinterpret_cast<void*
>(&
adcSpeed)});
399 else if(member ==
"temp")
return logMetaDetail({
"TEMP", logMeta::valTypes::Float, logMeta::metaTypes::Continuous,
reinterpret_cast<void*
>(&
temp)});
400 else if(member ==
"tempSetpt")
return logMetaDetail({
"TEMP SETPT", logMeta::valTypes::Float, logMeta::metaTypes::State,
reinterpret_cast<void*
>(&
tempSetpt)});
401 else if(member ==
"tempStatus")
return logMetaDetail({
"TEMP STATUS", logMeta::valTypes::Int, logMeta::metaTypes::Continuous,
reinterpret_cast<void*
>(&
tempStatus)});
402 else if(member ==
"tempOnTarget")
return logMetaDetail({
"TEMP ONTGT", logMeta::valTypes::Int, logMeta::metaTypes::Continuous,
reinterpret_cast<void*
>(&
tempOnTarget)});
403 else if(member ==
"tempStatusStr")
return logMetaDetail({
"TEMP STATUSSTR", logMeta::valTypes::String, logMeta::metaTypes::State,
reinterpret_cast<void*
>(&
tempStatusStr)});
404 else if(member ==
"shutterStatusStr")
return logMetaDetail({
"SHUTTER STATUS", logMeta::valTypes::String, logMeta::metaTypes::State,
reinterpret_cast<void*
>(&
shutterStatusStr)});
405 else if(member ==
"shutterState")
return logMetaDetail({
"SHUTTER", logMeta::valTypes::String, logMeta::metaTypes::State,
reinterpret_cast<void*
>(&
shutterState)});
406 else if(member ==
"synchro")
return logMetaDetail({
"SYNCHRO", logMeta::valTypes::Bool, logMeta::metaTypes::State,
reinterpret_cast<void*
>(&
synchro)});
407 else if(member ==
"vshift")
return logMetaDetail({
"VSHIFTSPD", logMeta::valTypes::Float, logMeta::metaTypes::State,
reinterpret_cast<void*
>(&
vshift)});
408 else if(member ==
"cropMode")
return logMetaDetail({
"CROPMODE", logMeta::valTypes::Bool, logMeta::metaTypes::State,
reinterpret_cast<void*
>(&
cropMode)});
411 std::cerr <<
"No string member " << member <<
" in telem_stdcam\n";
The MagAO-X logger flatbuffer log base type.
uint16_t eventCodeT
The type of an event code (16-bit unsigned int).
msgLen2T msgLenT
The type used to refer to the message length, regardless of length.
int8_t logPrioT
The type of the log priority code.
static void * messageBuffer(bufferPtrT &logBuffer)
Get the message buffer address.
std::shared_ptr< char > bufferPtrT
The log entry buffer smart pointer.
constexpr static 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)
Construct from components, without vShift and cropMode for backwards compat.
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)
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 int xbin(void *msgBuffer)
static float xcen(void *msgBuffer)
static int ybin(void *msgBuffer)
static float exptime(void *msgBuffer)
static int width(void *msgBuffer)