11 #ifndef app_indiDriver_hpp
12 #define app_indiDriver_hpp
14 #include "../../INDI/libcommon/IndiDriver.hpp"
15 #include "../../INDI/libcommon/IndiElement.hpp"
17 #include "../../INDI/libcommon/IndiClient.hpp"
34 const std::string & hostAddress,
36 ) : pcf::IndiClient( clientName,
"none",
"1.7", hostAddress, hostPort)
46 processIndiRequests(
false);
51 template<
class _parentT>
86 const std::string &szName,
87 const std::string &szDriverVersion,
88 const std::string &szProtocolVersion
125 template<
class parentT>
127 const std::string &szName,
128 const std::string &szDriverVersion,
129 const std::string &szProtocolVersion
130 ) : pcf::IndiDriver(szName, szDriverVersion, szProtocolVersion)
137 fd = open( parent->driverInName().c_str(), O_RDWR);
140 parentT::template log<logger::software_error>({__FILE__, __LINE__, errno,
"Error opening input INDI FIFO."});
147 fd = open( parent->driverOutName().c_str(), O_RDWR);
150 parentT::template log<logger::software_error>({__FILE__, __LINE__, errno,
"Error opening output INDI FIFO."});
160 fd = open( parent->driverCtrlName().c_str(), O_RDWR);
163 parentT::template log<logger::software_error>({__FILE__, __LINE__, errno,
"Error opening control INDI FIFO."});
168 int wrno = write(fd, &c, 1);
171 parentT::template log<logger::software_error>({__FILE__, __LINE__, errno,
"Error writing to control INDI FIFO."});
179 template<
class parentT>
182 if(m_outGoing)
delete m_outGoing;
185 template<
class parentT>
188 if(m_parent) m_parent->handleDefProperty(
ipRecv);
191 template<
class parentT>
194 if(m_parent) m_parent->handleGetProperties(
ipRecv);
197 template<
class parentT>
200 if(m_parent) m_parent->handleNewProperty(
ipRecv);
203 template<
class parentT>
206 if(m_parent) m_parent->handleSetProperty(
ipRecv);
209 template<
class parentT>
212 processIndiRequests(
false);
215 template<
class parentT>
221 template<
class parentT>
225 if( m_outGoing !=
nullptr)
227 if(m_outGoing->getQuitProcess())
229 parentT::template log<logger::text_log>(
"INDI client disconnected.");
230 m_outGoing->quitProcess();
231 m_outGoing->deactivate();
233 m_outGoing =
nullptr;
238 if( m_outGoing ==
nullptr)
242 m_outGoing =
new indiClient(m_parent->configName()+
"-client", m_serverIPAddress, m_serverPort);
243 m_outGoing->activate();
247 parentT::template log<logger::software_error>({__FILE__, __LINE__,
"Exception thrown while creating IndiClient connection"});
251 if(m_outGoing ==
nullptr)
253 parentT::template log<logger::software_error>({__FILE__, __LINE__,
"Failed to allocate IndiClient connection"});
257 parentT::template log<logger::text_log>(
"INDI client connected and activated");
262 m_outGoing->sendNewProperty(
ipRecv);
263 if(m_outGoing->getQuitProcess())
265 parentT::template log<logger::software_error>({__FILE__, __LINE__,
"INDI client appears to be disconnected -- NEW not sent."});
274 catch(std::exception & e)
276 parentT::template log<logger::software_error>({__FILE__, __LINE__, std::string(
"Exception from IndiClient: ") + e.what()});
281 parentT::template log<logger::software_error>({__FILE__, __LINE__,
"Exception from IndiClient"});
286 parentT::template log<logger::software_error>({__FILE__, __LINE__,
"fall through in sendNewProperty"});
The base-class for MagAO-X applications.
Simple INDI Client class.
void execute()
Implementation of the pcf::IndiClient interface, called by activate to actually begins the INDI event...
indiClient(const std::string &clientName, const std::string &hostAddress, const int hostPort)
Constructor, which establishes the INDI client connection.
~indiDriver()
D'tor, deletes the IndiClient pointer.
virtual void handleSetProperty(const pcf::IndiProperty &ipRecv)
virtual void handleDefProperty(const pcf::IndiProperty &ipRecv)
bool m_good
Flag to hold the status of this connection.
int m_serverPort
The port of the server for the INDI Client connection.
virtual void execute(void)
Define the execute virtual function. This runs the processIndiRequests function in this thread,...
indiDriver(parentT *parent, const std::string &szName, const std::string &szDriverVersion, const std::string &szProtocolVersion)
Public c'tor.
virtual void handleNewProperty(const pcf::IndiProperty &ipRecv)
virtual int sendNewProperty(const pcf::IndiProperty &ipRecv)
Send a newProperty command to another INDI driver.
indiClient * m_outGoing
An INDI Client is used to send commands to other drivers.
virtual void handleGetProperties(const pcf::IndiProperty &ipRecv)
std::string m_serverIPAddress
The IP address of the server for the INDI Client connection.
_parentT parentT
The parent MagAOX app.
parentT * m_parent
This objects parent class.
bool good()
Get the value of the good flag.
virtual void update()
Define the update virt. func. here so the uptime message isn't sent.
const pcf::IndiProperty & ipRecv