11 #include "../../libMagAOX/libMagAOX.hpp"
12 #include "../../magaox_git_version.h"
153 config.add(
"temp.warning",
"",
"temp.warning", argType::Required,
"temp",
"warning",
false,
"float",
"Temperature at which to issue a warning. Default is 30.");
154 config.add(
"temp.alert",
"",
"temp.alert", argType::Required,
"temp",
"alert",
false,
"float",
"Temperature at which to issue an alert. Default is 35.");
155 config.add(
"temp.emergency",
"",
"temp.emergency", argType::Required,
"temp",
"emergency",
false,
"float",
"Temperature at which to issue an emergency. Default is 40.");
157 config.add(
"humid.warning",
"",
"humid.warning", argType::Required,
"humid",
"warning",
false,
"float",
"Humidity at which to issue a warning. Default is 18.");
158 config.add(
"humid.alert",
"",
"humid.alert", argType::Required,
"humid",
"alert",
false,
"float",
"Humidity at which to issue an alert. Default is 20.");
159 config.add(
"humid.emergency",
"",
"humid.emergency", argType::Required,
"humid",
"emergency",
false,
"float",
"Humidity at which to issue an emergency. Default is 22.");
194 indi::addNumberElement<float>(
m_indiP_temp,
"current", -20., 120., 0,
"%0.1f");
199 indi::addNumberElement<float>(
m_indiP_rh,
"current", 0., 100., 0,
"%0.1f");
232 return log<software_error,0>({__FILE__, __LINE__});
236 pcf::IndiProperty::PropertyStateType rhState = pcf::IndiProperty::Ok;
241 rhState = pcf::IndiProperty::Alert;
246 rhState = pcf::IndiProperty::Alert;
251 rhState = pcf::IndiProperty::Alert;
254 pcf::IndiProperty::PropertyStateType tState = pcf::IndiProperty::Ok;
259 tState = pcf::IndiProperty::Alert;
264 tState = pcf::IndiProperty::Alert;
269 tState = pcf::IndiProperty::Alert;
283 return log<software_error,0>({__FILE__, __LINE__});
310 std::stringstream logs;
312 log<text_log>(logs.str());
321 std::stringstream logs;
323 log<text_log>(logs.str());
328 elevatedPrivileges elPriv(
this);
337 std::stringstream logs;
339 log<text_log>(logs.str());
368 return log<
software_error, -1>({__FILE__, __LINE__,
"Error parsing temp, no EOT"});
372 return log<
software_error, -1>({__FILE__, __LINE__,
"Error parsing temp, no value"});
376 return log<
software_error, -1>({__FILE__, __LINE__,
"Error parsing temp, does not begin with digit"});
397 return log<
software_error, -1>({__FILE__, __LINE__,
"Error parsing humid, no EOT"});
401 return log<
software_error, -1>({__FILE__, __LINE__,
"Error parsing humid, no value"});
405 return log<
software_error, -1>({__FILE__, __LINE__,
"Error parsing temp, does not begin with digit"});
431 static float lastTemp = -99;
432 static float lastRH = -99;
434 if(force ||
m_temp != lastTemp ||
m_rh != lastRH)
The base-class for MagAO-X applications.
void updateIfChanged(pcf::IndiProperty &p, const std::string &el, const T &newVal, pcf::IndiProperty::PropertyStateType ipState=pcf::IndiProperty::Ok)
Update an INDI property element value if it has changed.
stateCodes::stateCodeT state()
Get the current state code.
int stateLogged()
Updates and returns the value of m_stateLogged. Will be 0 on first call after a state change,...
static int log(const typename logT::messageT &msg, logPrioT level=logPrio::LOG_DEFAULT)
Make a log entry.
int createROIndiNumber(pcf::IndiProperty &prop, const std::string &propName, const std::string &propLabel="", const std::string &propGroup="")
Create a ReadOnly INDI Number property.
int registerIndiPropertyReadOnly(pcf::IndiProperty &prop)
Register an INDI property which is read only.
std::mutex m_indiMutex
Mutex for locking INDI communications.
The MagAO-X RH-USB monitoring class.
float m_warnTemp
This is abnormally high if the system is working, but still safe.
virtual int appLogic()
Implementation of the FSM for rhusbMon.
int recordRH(bool force=false)
float m_emergTemp
Must shutdown immediately.
virtual int appStartup()
Startup function.
virtual void loadConfig()
virtual int appShutdown()
Shutdown the app.
int loadConfigImpl(mx::app::appConfigurator &_config)
Implementation of loadConfig logic, separated for testing.
int recordTelem(const telem_rhusb *)
int readProbe()
Read current values from the RH-USB probe.
friend class rhusbMon_test
float m_alertTemp
This is the actual limit, shut down should occur.
pcf::IndiProperty m_indiP_temp
pcf::IndiProperty m_indiP_rh
int connect()
Connect to the probe.
float m_warnHumid
This is abnormally high if the system is working, but still safe.
virtual void setupConfig()
~rhusbMon() noexcept
D'tor, declared and defined for noexcept.
float m_emergHumid
Must shutdown immediately.
float m_alertHumid
This is the actual limit, shut down should occur.
@ OPERATING
The device is operating, other than homing.
@ NODEVICE
No device exists for the application to control.
@ FAILURE
The application has failed, should be used when m_shutdown is set for an error.
@ ERROR
The application has encountered an error, from which it is recovering (with or without intervention)
@ CONNECTED
The application has connected to the device or service.
@ NOTCONNECTED
The application is not connected to the device or service.
int ttyWriteRead(std::string &strRead, const std::string &strWrite, const std::string &eot, bool swallowEcho, int fd, int timeoutWrite, int timeoutRead)
Write to a tty on an open file descriptor, then get the result.
std::string ttyErrorString(int ec)
Get a text explanation of a TTY_E_ error code.
int parseH(float &humid, const std::string &str)
Parse the RH probe H humidity command.
int parseC(float &temp, const std::string &str)
Parse the RH probe C temp command.
std::unique_lock< std::mutex > lock(m_indiMutex)
constexpr static logPrioT LOG_ALERT
This should only be used if some action is required by operators to keep the system safe.
constexpr static logPrioT LOG_EMERGENCY
Normal operations of the entire system should be shut down immediately.
constexpr static logPrioT LOG_WARNING
A condition has occurred which may become an error, but the process continues.
Parsers for the MagAO-X RH USB monitor.
An input/output capable device.
unsigned m_writeTimeout
The write timeout [msec].
int loadConfig(mx::app::appConfigurator &config)
Load the device section from an application configurator.
int setupConfig(mx::app::appConfigurator &config)
Setup an application configurator for the device section.
unsigned m_readTimeout
The read timeout [msec].
A device base class which saves telemetry.
int loadConfig(appConfigurator &config)
Load the device section from an application configurator.
int appLogic()
Perform telemeter application logic.
int setupConfig(appConfigurator &config)
Setup an application configurator for the device section.
int checkRecordTimes(const telT &tel, telTs... tels)
Check the time of the last record for each telemetry type and make an entry if needed.
Software CRITICAL log entry.
Log entry recording the build-time git state.
A USB device as a TTY device.
std::string m_deviceName
The device path name, e.g. /dev/ttyUSB0.
int m_fileDescrip
The file descriptor.
int connect()
Connect to the device.
int getDeviceName()
Get the device name from udev using the vendor, product, and serial number.
std::string m_idProduct
The product id 4-digit code.
int setupConfig(mx::app::appConfigurator &config)
Setup an application configurator for the USB section.
std::string m_serial
The serial number.
int loadConfig(mx::app::appConfigurator &config)
Load the USB section from an application configurator.
std::string m_idVendor
The vendor id 4-digit code.
#define TTY_E_DEVNOTFOUND