12#include "../../libMagAOX/libMagAOX.hpp"
13#include "../../magaox_git_version.h"
169 config.add(
"device.address",
177 "The device I.P. address." );
179 config.add(
"device.port",
187 "The device port. Default is 502." );
189 config.add(
"device.inputOnly",
197 "List of channels which are input-only." );
203 config(
m_port,
"device.port" );
205 std::vector<int>
ino;
206 config(
ino,
"device.inputOnly" );
208 for(
size_t i = 0;
i <
ino.size(); ++
i )
327 if(
newMb ==
nullptr )
332 newMb->modbus_set_slave_id( 1 );
344 if( !
newMb->modbus_set_timeouts( 2, 0 ) )
493 if(
m_mb ==
nullptr )
502 catch( std::exception &
e )
548 if(
ipRecv.find(
"current" ) )
553 if(
ipRecv.find(
"target" ) )
595 if(
m_mb ==
nullptr )
604 catch( std::exception &
e )
The base-class for XWCTk 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 shutdown()
Get the value of the shutdown flag.
int m_powerState
Current power state, 1=On, 0=Off, -1=Unk.
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.
bool powerOnWaitElapsed()
This method tests whether the power on wait time has elapsed.
unsigned long m_powerOnWait
Default time in sec to wait for device to boot after power on.
std::mutex m_indiMutex
Mutex for locking INDI communications.
virtual void setupConfig()
Setup the configuration system (called by MagAOXApp::setup())
pcf::IndiProperty m_indiP_ch11
virtual void loadConfig()
load the configuration system results (called by MagAOXApp::setup())
virtual int appLogic()
Implementation of the FSM for the Siglent SDG.
pcf::IndiProperty m_indiP_ch02
pcf::IndiProperty m_indiP_ch14
virtual int appStartup()
Startup functions.
~xt1121Ctrl() noexcept
Destructor.
virtual int appShutdown()
Do any needed shutdown tasks. Currently nothing in this app.
pcf::IndiProperty m_indiP_ch07
std::string m_address
The I.P. address of the device.
void closeModbus()
Close and delete the current modbus object under m_modbusMutex.
uint16_t m_port
The port to use. Default is 502 for modbus.
pcf::IndiProperty m_indiP_ch10
int getState()
Get the current state of the outlets.
pcf::IndiProperty m_indiP_ch00
pcf::IndiProperty m_indiP_ch08
pcf::IndiProperty m_indiP_ch06
std::mutex m_modbusMutex
Protects m_mb lifetime and all modbus socket I/O.
pcf::IndiProperty m_indiP_ch15
pcf::IndiProperty m_indiP_ch01
pcf::IndiProperty m_indiP_ch05
xt1121Ctrl()
Default c'tor.
std::atomic< bool > m_callbacksEnabled
Gates INDI callbacks during shutdown/teardown.
pcf::IndiProperty m_indiP_ch09
virtual int whilePowerOff()
Implementation of the while-powered-off FSM.
modbus * m_mb
The modbus protocol communication object.
virtual int onPowerOff()
Implementation of the on-power-off FSM logic.
pcf::IndiProperty m_indiP_ch12
pcf::IndiProperty m_indiP_ch03
pcf::IndiProperty m_indiP_ch13
pcf::IndiProperty m_indiP_ch04
int channelSetCallback(size_t chNo, pcf::IndiProperty &ipToSet, const pcf::IndiProperty &ipRecv)
Callback worker to actually set or clear a channel and send it to the device.
void modbus_read_input_registers(int address, int amount, uint16_t *buffer)
void modbus_write_registers(int address, int amount, uint16_t *value)
#define INDI_NEWCALLBACK_DEFN(class, prop)
Define the callback for a new property request.
#define REG_INDI_NEWPROP(prop, propName, type)
Register a NEW INDI property with the class, using the standard callback name.
#define INDI_NEWCALLBACK_DECL(class, prop)
Declare the callback for a new property request, and declare and define the static wrapper.
#define INDI_VALIDATE_CALLBACK_PROPS(prop1, prop2)
Standard check for matching INDI properties in a callback.
const pcf::IndiProperty & ipRecv
std::unique_lock< std::mutex > lock(m_indiMutex)
static constexpr logPrioT LOG_WARNING
A condition has occurred which may become an error, but the process continues.
static constexpr logPrioT LOG_ERROR
An error has occured which the software will attempt to correct.
@ OPERATING
The device is operating, other than homing.
@ ERROR
The application has encountered an error, from which it is recovering (with or without intervention)
@ READY
The device is ready for operation, but is not operating.
@ CONNECTED
The application has connected to the device or service.
@ NOTCONNECTED
The application is not connected to the device or service.
@ POWERON
The device power is on.
Software CRITICAL log entry.
Utility class for managing Acromag xt12XX digital I/O channels.
int setRegisters(uint16_t registers[numRegisters])
Set registers based on current channel states.
int setChannel(size_t chNo)
Set a channel to true.
static constexpr int numRegisters
The number of registers needed for the number of channels.
int channel(size_t chNo)
Gets the current state of a channel.
int setInputOnly(size_t chNo)
Set a channel to be input only.
int clearChannel(size_t chNo)
Set a channel to false.
int readRegisters(uint16_t registers[numRegisters])
Read channel states from the registers.
Utility class for managing Acromag xt12XX digital I/O channels.