12 #include "../../libMagAOX/libMagAOX.hpp"
13 #include "../../magaox_git_version.h"
163 int moveTo(
const double & filters );
190 config.add(
"stage.serialNumber",
"",
"stage.serialNumber", argType::Required,
"stage",
"serialNumber",
false,
"string",
"The device serial number.");
202 config(serNum,
"stage.serialNumber");
248 hsfw_wheel_info *devs, *cur_dev;
253 devs = enumerate_wheels();
267 snprintf(logs,
sizeof(logs),
"Device Found - type: %04hx %04hx serial_number: %ls",cur_dev->vendor_id, cur_dev->product_id, cur_dev->serial_number);
273 cur_dev = cur_dev->next;
275 wheels_free_enumeration(devs);
292 hsfw_wheel_info *devs, *cur_dev;
293 devs = enumerate_wheels();
310 cur_dev = cur_dev->next;
315 wheels_free_enumeration(devs);
327 m_wheel = open_hsfw(cur_dev->vendor_id, cur_dev->product_id, cur_dev->serial_number);
350 if (get_hsfw_status(
m_wheel, &status) < 0)
353 log<software_error>({__FILE__, __LINE__,
"error from get_hsfw_status"});
357 if (status.error_state != 0)
362 m_pos = status.position;
364 if(!status.is_homed && !status.is_homing)
374 else if( status.is_homing)
379 else if (status.is_moving)
411 log<software_error>({__FILE__, __LINE__});
436 log<software_error>({__FILE__,__LINE__});
450 log<software_error>({__FILE__,__LINE__});
456 log<software_error>({__FILE__, __LINE__});
473 log<software_error>({__FILE__,__LINE__,
"libhswf error"});
501 double ffilters = filters;
504 while(ffilters < 8.5) ffilters += 8;
507 return log<
software_error,-1>({__FILE__,__LINE__,
"error getting modulo filter number"});
514 if( move_hsfw(
m_wheel, (
unsigned short) (ffilters + 0.5)) < 0)
Internal class to manage setuid privilege escalation with RAII.
The base-class for MagAO-X applications.
stateCodes::stateCodeT state()
Get the current state code.
int powerState()
Returns the current power state.
int powerStateTarget()
Returns the target power state.
void updateSwitchIfChanged(pcf::IndiProperty &p, const std::string &el, const pcf::IndiElement::SwitchStateType &newVal, pcf::IndiProperty::PropertyStateType ipState=pcf::IndiProperty::Ok)
Update an INDI switch element value if it has changed.
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.
std::mutex m_indiMutex
Mutex for locking INDI communications.
MagAO-X standard motion stage interface.
int loadConfig(mx::app::appConfigurator &config)
load the configuration system results
int onPowerOff()
Actions on power off.
bool m_powerOnHome
If true, then the motor is homed at startup (by this software or actual power on)
std::string m_presetNotation
Notation used to refer to a preset, should be singular, as in "preset" or "filter".
float m_preset_target
The target numerical preset position [1.0 is index 0 in the preset name vector].
pcf::IndiProperty m_indiP_home
Command the stage to home. .
int updateINDI()
Update the INDI properties for this device controller.
int setupConfig(mx::app::appConfigurator &config)
Setup the configuration system.
int whilePowerOff()
Actions while powered off.
int8_t m_moving
Whether or not the stage is moving. -2 means powered off, -1 means not homed, 0 means not moving,...
pcf::IndiProperty m_indiP_stop
Command the stage to halt.
float m_preset
The current numerical preset position [1.0 is index 0 in the preset name vector].
int recordStage(bool force=false)
virtual int whilePowerOff()
This method is called while the power is off, once per FSM loop.
std::wstring m_serialNumber
virtual void setupConfig()
Setup the configuration system (called by MagAOXApp::setup())
virtual int onPowerOff()
This method is called when the change to poweroff is detected.
int startHoming()
Start a high-level homing sequence.
~hsfwCtrl() noexcept
D'tor, declared and defined for noexcept.
virtual void loadConfig()
load the configuration system results (called by MagAOXApp::setup())
virtual int appShutdown()
Do any needed shutdown tasks. Currently nothing in this app.
virtual int appLogic()
Implementation of the FSM for the TTM Modulator.
int stop()
Stop the wheel motion immediately.
int recordTelem(const telem_stage *)
int home()
Start a low-level homing sequence.
int recordStage(bool force=false)
virtual int appStartup()
Startup functions.
int moveTo(const double &filters)
Move to an absolute position in filter units.
@ OPERATING
The device is operating, other than homing.
@ POWEROFF
The device power is off.
@ NODEVICE
No device exists for the application to control.
@ NOTHOMED
The device has not been homed.
@ HOMING
The device is homing.
@ READY
The device is ready for operation, but is not operating.
@ CONNECTED
The application has connected to the device or service.
@ UNINITIALIZED
The application is unitialized, the default.
@ INITIALIZED
The application has been initialized, set just before calling appStartup().
@ NOTCONNECTED
The application is not connected to the device or service.
@ POWERON
The device power is on.
constexpr static logPrioT LOG_CRITICAL
The process can not continue and will shut down (fatal)
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 stdMotionStage status.