45 InputTP[FullyOpened].
fill(
"FULLY_OPENED",
"Fully Opened",
"Comma separated indexes");
46 InputTP[FullyClosed].
fill(
"FULLY_CLOSED",
"Fully Closed",
"Comma separated indexes");
51 LimitSwitchLP[FullyOpened].
fill(
"FULLY_OPENED",
"Fully Opened",
IPS_IDLE);
52 LimitSwitchLP[FullyClosed].
fill(
"FULLY_CLOSED",
"Fully Closed",
IPS_IDLE);
56 OutputTP[OpenRoof].
fill(
"OPEN_ROOF",
"Open Roof",
"Comma separated indexes");
57 OutputTP[CloseRoof].
fill(
"CLOSE_ROOF",
"Close Roof",
"Comma separated indexes");
75bool UniversalROR::setupParms()
82 if (m_FullClosedLimitSwitch != m_FullOpenLimitSwitch)
84 if (m_FullClosedLimitSwitch && !
isParked())
86 else if (m_FullOpenLimitSwitch &&
isParked())
97void UniversalROR::checkConnectionStatus()
102 if (!m_Client->isConnected())
104 m_ConnectionAttempts++;
105 if (m_ConnectionAttempts >= MAX_CONNECTION_ATTEMPTS)
107 LOG_ERROR(
"Devices did not connect within the timeout period. Please check your configuration.");
108 m_ConnectionAttempts = 0;
110 m_ConnectionTimer.
stop();
115 m_ConnectionTimer.
start(5000);
121 m_ConnectionAttempts = 0;
122 m_ConnectionTimer.
stop();
129 m_ConnectionAttempts = 0;
132 if (!m_Client || !m_Client->isConnected())
136 m_Client->connectServer();
144 LOG_ERROR(
"ROR Client is not initialized. Specify the input and output drivers in Options tab.");
150 if (!m_Client->isConnected())
152 LOG_INFO(
"ROR Client initialized but devices not connected yet. Will sync when devices connect.");
155 m_ConnectionTimer.
stop();
156 m_ConnectionTimer.
callOnTimeout(std::bind(&UniversalROR::checkConnectionStatus,
this));
157 m_ConnectionTimer.
start(5000);
164 if (m_Client->isConnected())
166 LOG_INFO(
"All devices connected. Syncing indexes...");
172 LOG_INFO(
"Waiting for devices to connect...");
184 m_ConnectionTimer.
stop();
186 m_InputFullyOpened.clear();
187 m_InputFullyClosed.clear();
196 return "Universal ROR";
217 InputTP.
update(texts, names, n);
223 if (m_Client && m_Client->isConnected())
226 LOG_INFO(
"Indexes updated. Will sync when devices connect.");
234 OutputTP.
update(texts, names, n);
240 if (m_Client && m_Client->isConnected())
243 LOG_INFO(
"Indexes updated. Will sync when devices connect.");
287 if (m_FullClosedLimitSwitch == m_FullOpenLimitSwitch && m_Client && m_Client->isConnected())
291 m_Client->syncFullyOpenedState();
292 m_Client->syncFullyClosedState();
300 if (m_FullOpenLimitSwitch)
312 if (m_FullClosedLimitSwitch)
323 else if (
isParked() && m_FullClosedLimitSwitch ==
false && m_FullOpenLimitSwitch ==
false)
348 if (dir ==
DOME_CW && m_FullOpenLimitSwitch)
350 LOG_WARN(
"Roof is already fully opened.");
353 else if (dir ==
DOME_CCW && m_FullClosedLimitSwitch)
355 LOG_WARN(
"Roof is already fully closed.");
368 m_Client->openRoof();
372 LOG_ERROR(
"Failed to open roof. ROR Client is not connected!");
380 m_Client->closeRoof();
384 LOG_ERROR(
"Failed to close roof. ROR Client is not connected!");
418 LOG_INFO(
"Roll off is unparking...");
431 return m_Client->stop();
447 if (input.empty() || output.empty())
451 if (m_Client && m_Client->inputDevice() == input && m_Client->outputDevice() == output)
455 m_Client->setFullyClosedCallback([&](
bool on)
457 m_FullClosedLimitSwitch = on;
459 LimitSwitchLP.
apply();
461 m_Client->setFullyOpenedCallback([&](
bool on)
463 m_FullOpenLimitSwitch = on;
465 LimitSwitchLP.
apply();
467 m_Client->setConnectionCallback([&](
bool connected)
471 LOG_INFO(
"Devices connected. Syncing indexes...");
476 m_Client->watchDevice(input.c_str());
477 m_Client->watchDevice(output.c_str());
478 m_Client->connectServer();
485bool UniversalROR::syncIndexes()
491 auto fullyOpenedList = extract(InputTP[FullyOpened].
getText());
492 if (!fullyOpenedList.empty() && fullyOpenedList != m_InputFullyOpened)
494 m_InputFullyOpened = fullyOpenedList;
495 m_Client->setInputFullyOpened(m_InputFullyOpened);
499 auto fullyClosedList = extract(InputTP[FullyClosed].
getText());
500 if (!fullyClosedList.empty() && fullyClosedList != m_InputFullyClosed)
502 m_InputFullyClosed = fullyClosedList;
503 m_Client->setInputFullyClosed(m_InputFullyClosed);
507 auto openRoofList = extract(OutputTP[OpenRoof].
getText());
508 if (!openRoofList.empty() && openRoofList != m_OutputOpenRoof)
510 m_OutputOpenRoof = openRoofList;
511 m_Client->setOutputOpenRoof(m_OutputOpenRoof);
515 auto closeRoofList = extract(OutputTP[CloseRoof].
getText());
516 if (!closeRoofList.empty() && closeRoofList != m_OutputCloseRoof)
518 m_OutputCloseRoof = closeRoofList;
519 m_Client->setOutputCloseRoof(m_OutputCloseRoof);
528std::vector<uint8_t> UniversalROR::extract(
const std::string &text)
530 std::vector<uint8_t> result;
531 std::regex pattern(R
"(\d+)");
533 std::string remaining = text;
535 while (std::regex_search(remaining, matches, pattern))
537 result.push_back(std::stoi(matches[0]));
538 remaining = matches.suffix().str();
INDI::PropertyText getText(const char *name) const
virtual bool saveConfig(bool silent=false, const char *property=nullptr)
Save the current properties in a configuration file.
void setVersion(uint16_t vMajor, uint16_t vMinor)
Set driver version information to be defined in DRIVER_INFO property as vMajor.vMinor.
virtual bool deleteProperty(const char *propertyName)
Delete a property and unregister it. It will also be deleted from all clients.
uint32_t getPollingPeriod() const
getPollingPeriod Return the polling period.
void defineProperty(INumberVectorProperty *property)
void addAuxControls()
Add Debug, Simulation, and Configuration options to the driver.
int SetTimer(uint32_t ms)
Set a timer to call the function TimerHit after ms milliseconds.
void SetParked(bool isparked)
SetParked Change the mount parking status. The data park file (stored in ~/.indi/ParkData....
void SetDomeCapability(uint32_t cap)
SetDomeCapability set the dome capabilities. All capabilities must be initialized.
void setDomeConnection(const uint8_t &value)
setDomeConnection Set Dome connection mode. Child class should call this in the constructor before Do...
bool isParked()
isParked is dome currently parked?
virtual bool initProperties() override
Initialize properties initial state and value. The child class must implement this function.
bool isLocked()
isLocked, is the dome currently locked?
virtual bool updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
INDI::PropertySwitch DomeMotionSP
virtual bool ISSnoopDevice(XMLEle *root) override
Process a snoop event from INDI server. This function is called when a snooped property is updated in...
virtual bool saveConfigItems(FILE *fp) override
saveConfigItems Saves the Device Port and Dome Presets in the configuration file
virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override
Process the client newSwitch command.
bool InitPark()
InitPark Loads parking data (stored in ~/.indi/ParkData.xml) that contains parking status and parking...
void SetParkDataType(DomeParkData type)
setParkDataType Sets the type of parking data stored in the park data file and presented to the user.
INDI::PropertyText ActiveDeviceTP
virtual IPState Move(DomeDirection dir, DomeMotionCommand operation)
Move the Dome in a particular direction.
void setState(IPState state)
void apply(const char *format,...) const ATTRIBUTE_FORMAT_PRINTF(2
bool load()
load Attempt to load property values from configuration file.
void save(FILE *f) const
save Save property to configuration file.
bool isNameMatch(const char *otherName) const
void fill(const char *device, const char *name, const char *label, const char *group, IPState state)
bool update(const char *const texts[], const char *const names[], int n)
void fill(const char *device, const char *name, const char *label, const char *group, IPerm permission, double timeout, IPState state)
void callOnTimeout(const std::function< void()> &callback)
void start()
Starts or restarts the timer with the timeout specified in interval.
void stop()
Stops the timer.
bool Disconnect() override
Disconnect from device.
const char * getDefaultName() override
virtual bool initProperties() override
Initialize properties initial state and value. The child class must implement this function.
virtual bool Abort() override
Abort all dome motion.
virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override
Process the client newSwitch command.
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
virtual IPState Park() override
Goto Park Position. The park position is an absolute azimuth value.
bool updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
void TimerHit() override
Callback function to be called once SetTimer duration elapses.
bool Connect() override
Connect to the device. INDI::DefaultDevice implementation connects to appropriate connection interfac...
virtual IPState UnPark() override
UnPark dome. The action of the Unpark command is dome specific, but it may include opening the shutte...
virtual void ActiveDevicesUpdated() override
virtual IPState Move(DomeDirection dir, DomeMotionCommand operation) override
Move the Dome in a particular direction.
virtual bool saveConfigItems(FILE *fp) override
saveConfigItems Saves the Device Port and Dome Presets in the configuration file
virtual bool ISSnoopDevice(XMLEle *root) override
Process a snoop event from INDI server. This function is called when a snooped property is updated in...
const char * MAIN_CONTROL_TAB
MAIN_CONTROL_TAB Where all the primary controls for the device are located.
const char * OPTIONS_TAB
OPTIONS_TAB Where all the driver's options are located. Those may include auxiliary controls,...
#define DEBUG(priority, msg)
Macro to print log messages. Example of usage of the Logger: DEBUG(DBG_DEBUG, "hello " << "world");.
#define LOG_ERROR(txt)
Shorter logging macros. In order to use these macros, the function (or method) "getDeviceName()" must...
std::unique_ptr< UniversalROR > ror(new UniversalROR())