10#include "../../libMagAOX/libMagAOX.hpp"
11#include "../../magaox_git_version.h"
15#include <mx/math/gslInterpolation.hpp>
16#include <mx/ioutils/readColumns.hpp>
87 mx::app::appConfigurator &
_config );
140 config.add(
"k.zero",
148 "The k-mirror zero position. Default is -40.0." );
150 config.add(
"k.sign",
158 "The k-mirror rotation sign. Default is +1." );
160 config.add(
"k.devName",
168 "The device name of the k-mirrorstage. Default is 'stagek'" );
170 config.add(
"tcs.devName",
178 "The device name of the TCS Interface providing 'teldata.zd'. Default is 'tcsi'" );
180 config.add(
"tracking.updateInterval",
182 "tracking.updateInterval",
188 "The interval at which to update positions, in seconds. Default is 10 secs." );
217 m_indiP_kpos = pcf::IndiProperty( pcf::IndiProperty::Number );
229 const double now = mx::sys::get_curr_time();
236 if( !
lock.owns_lock() )
256 if( !std::isfinite(
k ) )
262 std::cerr <<
"Sending k-mirror to: " <<
k <<
"\n";
281 if( !
ipRecv.find(
"toggle" ) )
284 if(
ipRecv[
"toggle"].getSwitchState() == pcf::IndiElement::On )
286 updateSwitchIfChanged( m_indiP_tracking,
"toggle", pcf::IndiElement::On,
INDI_IDLE );
289 std::lock_guard<std::mutex> guard( m_indiMutex );
294 log<text_log>(
"started K-mirror rotation tracking" );
298 updateSwitchIfChanged( m_indiP_tracking,
"toggle", pcf::IndiElement::Off,
INDI_IDLE );
301 std::lock_guard<std::mutex> guard( m_indiMutex );
306 log<text_log>(
"stopped K-mirror rotation tracking" );
316 if( !
ipRecv.find(
"zd" ) )
323 zd =
ipRecv[
"zd"].get<
float>();
325 catch(
const std::exception &e )
327 log<software_error>( { __FILE__, __LINE__, std::string(
"exception reading teldata.zd: " ) + e.what() } );
332 log<software_error>( { __FILE__, __LINE__,
"unknown exception reading teldata.zd" } );
336 if( !std::isfinite( zd ) )
338 log<software_error>( { __FILE__, __LINE__,
"received non-finite teldata.zd" } );
343 std::lock_guard<std::mutex> guard( m_indiMutex );
The base-class for XWCTk applications.
stateCodes::stateCodeT state()
Get the current state code.
int registerIndiPropertyNew(pcf::IndiProperty &prop, int(*)(void *, const pcf::IndiProperty &))
Register an INDI property which is exposed for others to request a New Property for.
int createStandardIndiToggleSw(pcf::IndiProperty &prop, const std::string &name, const std::string &label="", const std::string &group="")
Create a standard R/W INDI switch with a single toggle element.
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.
int sendNewProperty(const pcf::IndiProperty &ipSend, const std::string &el, const T &newVal)
Send a newProperty command to another device (using the INDI Client interface)
The MagAO-X K-mirror tracker.
pcf::IndiProperty m_indiP_tracking
The INDI toggle used to enable or disable tracking.
virtual void loadConfig()
Load configuration values.
pcf::IndiProperty m_indiP_teldata
The subscribed TCS property providing zenith distance updates.
~kTracker() noexcept
D'tor, declared and defined for noexcept.
bool m_haveZD
True once at least one valid zenith distance has been received.
float m_zero
The starting point for the K-mirror at zd = 0.
virtual int appShutdown()
Shutdown the app.
pcf::IndiProperty m_indiP_kpos
The outbound K-mirror stage position command property.
float m_zd
The most recent finite zenith distance received from the TCS interface.
virtual void setupConfig()
Set up configuration entries.
float m_updateInterval
The interval at which to update positions, in seconds. Default is 10 secs.
double m_lastUpdate
Timestamp of the last stage command dispatched by the tracker.
INDI_SETCALLBACK_DECL(kTracker, m_indiP_teldata)
Handle incoming telescope data updates.
INDI_NEWCALLBACK_DECL(kTracker, m_indiP_tracking)
Handle new tracking toggle requests.
int loadConfigImpl(mx::app::appConfigurator &_config)
Implementation of loadConfig logic, separated for testing.
friend class kTracker_test
virtual int appStartup()
Startup function.
int m_sign
The sign to apply to the zenith distance to rotate the K-mirror.
std::string m_tcsDevName
The device name of the TCS interface providing 'teldata.zd'. Default is 'tcsi'.
std::string m_devName
The device name of the K-mirror stage. Default is 'stagek'.
bool m_tracking
True when automatic K-mirror updates are enabled.
virtual int appLogic()
Implementation of the FSM for kTracker.
#define INDI_NEWCALLBACK_DEFN(class, prop)
Define the callback for a new property request.
#define INDI_NEWCALLBACK(prop)
Get the name of the static callback wrapper for a new property.
#define INDI_SETCALLBACK_DEFN(class, prop)
Define the callback for a set property request.
#define REG_INDI_SETPROP(prop, devName, propName)
Register a SET INDI property with the class, using the standard callback name.
#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)
@ READY
The device is ready for operation, but is not operating.