Instrument Neutral Distributed Interface INDI  2.0.2
rigel_dome.cpp
Go to the documentation of this file.
1 /*******************************************************************************
2  Rigel Systems Dome INDI Driver
3 
4  Copyright(c) 2019 Jasem Mutlaq. All rights reserved.
5 
6  Based on Protocol extracted from https://github.com/rpineau/RigelDome
7 
8  This library is free software; you can redistribute it and/or
9  modify it under the terms of the GNU Library General Public
10  License version 2 as published by the Free Software Foundation.
11  .
12  This library is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  Library General Public License for more details.
16  .
17  You should have received a copy of the GNU Library General Public License
18  along with this library; see the file COPYING.LIB. If not, write to
19  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20  Boston, MA 02110-1301, USA.
21 *******************************************************************************/
22 
23 #include "rigel_dome.h"
24 #include "indicom.h"
26 
27 #include <cmath>
28 #include <cstring>
29 #include <regex>
30 #include <memory>
31 #include <termios.h>
32 
33 // We declare an auto pointer to RigelDome.
34 static std::unique_ptr<RigelDome> rigelDome(new RigelDome());
35 
36 #define DOME_CMD 9 /* Dome command in bytes */
37 #define DOME_BUF 16 /* Dome command buffer */
38 #define DOME_TIMEOUT 3 /* 3 seconds comm timeout */
39 
40 #define SIM_SHUTTER_TIMER 5.0 /* Simulated Shutter closes/open in 5 seconds */
41 #define SIM_FLAP_TIMER 5.0 /* Simulated Flap closes/open in 3 seconds */
42 #define SIM_DOME_HI_SPEED 5.0 /* Simulated dome speed 5.0 degrees per second, constant */
43 #define SIM_DOME_LO_SPEED 0.5 /* Simulated dome speed 0.5 degrees per second, constant */
44 
46 {
47  setVersion(1, 0);
48 
54 }
55 
57 {
59 
60  IUFillSwitch(&OperationS[OPERATION_FIND_HOME], "OPERATION_FIND_HOME", "Find Home", ISS_OFF);
61  IUFillSwitch(&OperationS[OPERATION_CALIBRATE], "OPERATION_CALIBRATE", "Calibrate", ISS_OFF);
62  IUFillSwitchVector(&OperationSP, OperationS, 2, getDeviceName(), "OPERATION", "Operation", MAIN_CONTROL_TAB, IP_RW,
63  ISR_ATMOST1, 0, IPS_IDLE);
64 
65  IUFillText(&InfoT[INFO_FIRMWARE], "FIRMWARE", "Version", "NA");
66  IUFillText(&InfoT[INFO_MODEL], "MODEL", "Model", "NA");
67  IUFillText(&InfoT[INFO_TICKS], "TICKS_PER_REV", "Ticks/Rev", "NA");
68  IUFillText(&InfoT[INFO_BATTERY], "BATTERY", "Battery", "NA");
69  IUFillTextVector(&InfoTP, InfoT, 4, getDeviceName(), "FIRMWARE_INFO", "Info", INFO_TAB, IP_RO, 60, IPS_IDLE);
70 
71  IUFillNumber(&HomePositionN[AXIS_AZ], "HOME_AZ", "AZ D:M:S", "%10.6m", 0.0, 360.0, 0.0, 0);
72  IUFillNumberVector(&HomePositionNP, HomePositionN, 1, getDeviceName(), "DOME_HOME_POSITION", "Home Position",
73  SITE_TAB, IP_RW, 60, IPS_IDLE);
74 
76 
78 
80 
81  return true;
82 }
83 
84 /************************************************************************************
85  *
86 * ***********************************************************************************/
87 bool RigelDome::getStartupValues()
88 {
89  targetAz = 0;
90 
91  InfoTP.s = (readFirmware() && readModel() && readStepsPerRevolution()) ? IPS_OK : IPS_ALERT;
92  if (HasShutter())
93  readBatteryLevels();
94  IDSetText(&InfoTP, nullptr);
95 
96  if (readPosition())
97  IDSetNumber(&DomeAbsPosNP, nullptr);
98 
99  if (readShutterStatus())
100  IDSetSwitch(&DomeShutterSP, nullptr);
101 
102  if (readHomePosition())
103  IDSetNumber(&HomePositionNP, nullptr);
104 
105  if (InitPark())
106  {
107  // If loading parking data is successful, we just set the default parking values.
109  }
110  else
111  {
112  // Otherwise, we set all parking data to default in case no parking data is found.
113  SetAxis1Park(0);
115  }
116 
117  return true;
118 }
119 
120 /************************************************************************************
121  *
122 * ***********************************************************************************/
124 {
125  char res[DRIVER_LEN] = {0};
126  sendCommand("PULSAR", res); // send dummy command to flush serial line
127 
128  bool rc = readShutterStatus();
129  if (rc)
130  {
131  if (m_rawShutterState != S_NotFitted)
133  }
134 
135  return rc;
136 }
137 
138 /************************************************************************************
139  *
140 * ***********************************************************************************/
142 {
143  return "Rigel Dome";
144 }
145 
146 /************************************************************************************
147  *
148 * ***********************************************************************************/
150 {
152 
153  if (isConnected())
154  {
155  defineProperty(&OperationSP);
156  defineProperty(&InfoTP);
157  defineProperty(&HomePositionNP);
158 
159  getStartupValues();
160  }
161  else
162  {
163  deleteProperty(OperationSP.name);
164  deleteProperty(InfoTP.name);
165  deleteProperty(HomePositionNP.name);
166  }
167 
168  return true;
169 }
170 
171 /************************************************************************************
172  *
173 * ***********************************************************************************/
174 bool RigelDome::ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n)
175 {
176  if (dev != nullptr && strcmp(dev, getDeviceName()) == 0)
177  {
178  if (!strcmp(OperationSP.name, name))
179  {
180  const char *requestedOperation = IUFindOnSwitchName(states, names, n);
181  if (!strcmp(requestedOperation, OperationS[OPERATION_FIND_HOME].name))
182  {
183  if (home())
184  {
185  IUResetSwitch(&OperationSP);
186  OperationS[OPERATION_FIND_HOME].s = ISS_ON;
187  OperationSP.s = IPS_BUSY;
188  LOG_INFO("Dome is moving to home position...");
190  }
191  else
192  {
193  OperationSP.s = IPS_ALERT;
194  }
195  }
196  else if (!strcmp(requestedOperation, OperationS[OPERATION_CALIBRATE].name))
197  {
198  if (calibrate())
199  {
200  IUResetSwitch(&OperationSP);
201  OperationS[OPERATION_CALIBRATE].s = ISS_ON;
202  OperationSP.s = IPS_BUSY;
203  LOG_INFO("Dome is calibrating...");
205  }
206  else
207  {
208  OperationSP.s = IPS_ALERT;
209  }
210  }
211 
212  IDSetSwitch(&OperationSP, nullptr);
213  return true;
214  }
215  }
216 
217  return INDI::Dome::ISNewSwitch(dev, name, states, names, n);
218 }
219 
220 /************************************************************************************
221  *
222 * ***********************************************************************************/
223 bool RigelDome::ISNewNumber(const char * dev, const char * name, double values[], char * names[], int n)
224 {
225  if (dev != nullptr && strcmp(dev, getDeviceName()) == 0)
226  {
227  if (strcmp(name, HomePositionNP.name) == 0)
228  {
229  IUUpdateNumber(&HomePositionNP, values, names, n);
230  HomePositionNP.s = IPS_OK;
231  float homeAz = HomePositionN[AXIS_AZ].value;
232  setHome(homeAz);
233  LOGF_INFO("Setting home position to %3.1f", homeAz);
234  IDSetNumber(&HomePositionNP, nullptr);
235  return true;
236  }
237  }
238 
239  return INDI::Dome::ISNewNumber(dev, name, values, names, n);
240 }
241 
242 /************************************************************************************
243  *
244 * ***********************************************************************************/
246 {
247  if (!isConnected())
248  return; // No need to reset timer if we are not connected anymore
249 
250  readState();
251 
252  bool isMoving = (m_rawMotorState != M_Idle && m_rawMotorState != M_MovingAtSideral);
253 
254  if (DomeAbsPosNP.s == IPS_BUSY && isMoving == false)
255  {
256  bool isHoming = (OperationSP.s == IPS_BUSY && OperationS[OPERATION_FIND_HOME].s == ISS_ON);
257  bool isCalibrating = (OperationSP.s == IPS_BUSY && OperationS[OPERATION_CALIBRATE].s == ISS_ON);
258 
259  if (isHoming)
260  {
261  LOG_INFO("Dome completed homing...");
262  IUResetSwitch(&OperationSP);
263  OperationSP.s = IPS_OK;
264  IDSetSwitch(&OperationSP, nullptr);
266  }
267  else if (isCalibrating)
268  {
269  LOG_INFO("Dome completed calibration...");
270  IUResetSwitch(&OperationSP);
271  OperationSP.s = IPS_OK;
272  IDSetSwitch(&OperationSP, nullptr);
274  }
275  else if (getDomeState() == DOME_PARKING)
276  {
277  SetParked(true);
278  LOG_INFO("Dome is parked.");
279  }
280  else
281  {
282  LOGF_INFO("Dome reached requested azimuth: %.3f Degrees", DomeAbsPosN[0].value);
284  }
285  }
286  else
287  {
288  if (DomeAbsPosNP.s != IPS_BUSY && isMoving)
290 
291  IDSetNumber(&DomeAbsPosNP, nullptr);
292  }
293 
294  if (HasShutter())
295  {
296  ShutterState newShutterState = parseShutterState(m_rawShutterState);
297  if (newShutterState != getShutterState())
298  {
299  setShutterState(newShutterState);
300  }
301 
302  if (readBatteryLevels())
303  IDSetText(&InfoTP, nullptr);
304  }
305 
307 }
308 
313 {
314  char cmd[DRIVER_LEN] = {0}, res[DRIVER_LEN] = {0};
315 
316  snprintf(cmd, DRIVER_LEN, "GO %3.1f", az);
317  if (sendCommand(cmd, res) == false)
318  return IPS_ALERT;
319 
320  return (res[0] == 'A') ? IPS_BUSY : IPS_ALERT;
321 }
322 
327 {
328  targetAz = DomeAbsPosN[0].value + azDiff;
329 
330  if (targetAz < DomeAbsPosN[0].min)
331  targetAz += DomeAbsPosN[0].max;
332  if (targetAz > DomeAbsPosN[0].max)
333  targetAz -= DomeAbsPosN[0].max;
334 
335  // It will take a few cycles to reach final position
336  return MoveAbs(targetAz);
337 }
338 
342 bool RigelDome::Sync(double az)
343 {
344  char cmd[DRIVER_LEN] = {0}, res[DRIVER_LEN] = {0};
345 
346  snprintf(cmd, DRIVER_LEN, "ANGLE K %3.1f", az);
347  if (sendCommand(cmd, res) == false)
348  return false;
349 
350  return (res[0] == 'A');
351 }
352 
357 {
358  targetAz = GetAxis1Park();
359  if (setParkAz(targetAz))
360  {
361  char res[DRIVER_LEN] = {0};
362  if (sendCommand("GO P", res) == false)
363  return IPS_ALERT;
364  return (res[0] == 'A' ? IPS_BUSY : IPS_ALERT);
365  }
366 
367  return IPS_ALERT;
368 }
369 
373 bool RigelDome::home()
374 {
375  char res[DRIVER_LEN] = {0};
376  if (sendCommand("GO H", res) == false)
377  return false;
378 
379  return (res[0] == 'A');
380 }
381 
385 bool RigelDome::calibrate()
386 {
387  char res[DRIVER_LEN] = {0};
388  if (sendCommand("CALIBRATE", res) == false)
389  return false;
390 
391  return (res[0] == 'A');
392 }
393 
397 bool RigelDome::setHome(double az)
398 {
399  char cmd[DRIVER_LEN] = {0}, res[DRIVER_LEN] = {0};
400 
401  snprintf(cmd, DRIVER_LEN, "HOME %3.1f", az);
402  if (sendCommand(cmd, res) == false)
403  return false;
404 
405  return (res[0] == 'A');
406 }
407 
412 {
413  return IPS_OK;
414 }
415 
420 {
421  char res[DRIVER_LEN] = {0};
422 
423  if (operation == SHUTTER_OPEN)
424  {
425  m_TargetShutter = operation;
426  sendCommand("OPEN", res);
427  }
428  else
429  {
430  m_TargetShutter = operation;
431  sendCommand("CLOSE", res);
432  }
433 
434  return (res[0] == 'A') ? IPS_BUSY : IPS_ALERT;
435 }
436 
441 {
442  if (sendCommand("STOP"))
443  {
444  if (OperationSP.s == IPS_BUSY)
445  {
446  LOGF_INFO("%s is aborted.", OperationS[OPERATION_CALIBRATE].s == ISS_ON ? "Calibration" : "Finding home");
447  IUResetSwitch(&OperationSP);
448  OperationSP.s = IPS_ALERT;
449  IDSetSwitch(&OperationSP, nullptr);
450  }
451  else if (getShutterState() == SHUTTER_MOVING)
452  {
454  IDSetSwitch(&DomeShutterSP, nullptr);
455  LOG_WARN("Shutter motion aborted!");
456  }
457  else
458  {
459  LOG_WARN("Dome motion aborted.");
460  }
461 
462  return true;
463  }
464 
465  return false;
466 }
467 
472 {
473  SetAxis1Park(DomeAbsPosN[0].value);
474  return true;
475 }
476 
481 {
482  // By default set position to 90
483  SetAxis1Park(90);
484  return true;
485 }
486 
490 bool RigelDome::setShutterConnected(bool enabled)
491 {
492  char cmd[DRIVER_LEN] = {0};
493  snprintf(cmd, DRIVER_LEN, "BBOND %d", enabled ? 1 : 0);
494  return sendCommand(cmd);
495 }
496 
500 bool RigelDome::isShutterConnected()
501 {
502  char res[DRIVER_LEN] = {0};
503  if (sendCommand("BBOND", res) == false)
504  return false;
505  bool rc = (std::stoi(res) != 0);
506  LOGF_DEBUG("Shutter is %s.", (rc ? "connected" : "disconnected"));
507  return rc;
508 }
509 
513 bool RigelDome::readStepsPerRevolution()
514 {
515  char res[DRIVER_LEN] = {0};
516  if (sendCommand("ENCREV", res) == false)
517  return false;
518 
519  IUSaveText(&InfoT[INFO_TICKS], res);
520  return true;
521 }
522 
526 bool RigelDome::readBatteryLevels()
527 {
528  char res[DRIVER_LEN] = {0};
529  if (sendCommand("BAT", res) == false)
530  return false;
531 
532  int percent = 0;
533  double volts = 0;
534 
535  if (sscanf(res, "%d %lf", &percent, &volts) != 2)
536  return false;
537 
538  char levels[DRIVER_LEN] = {0};
539  snprintf(levels, DRIVER_LEN, "%.2fv (%d%%)", volts / 1000.0, percent);
540  IUSaveText(&InfoT[INFO_BATTERY], levels);
541  return true;
542 }
543 
547 bool RigelDome::readPosition()
548 {
549  char res[DRIVER_LEN] = {0};
550  if (sendCommand("ANGLE", res) == false)
551  return false;
552 
553  DomeAbsPosN[0].value = std::stod(res);
554  return true;
555 }
556 
557 bool RigelDome::readHomePosition()
558 {
559  char res[DRIVER_LEN] = {0};
560 
561  if (sendCommand("HOME", res) == false)
562  return false;
563 
564  HomePositionN[0].value = std::stod(res);
565  return true;
566 }
567 
571 bool RigelDome::setParkAz(double az)
572 {
573  char cmd[DRIVER_LEN] = {0}, res[DRIVER_LEN] = {0};
574 
575  snprintf(cmd, DRIVER_LEN, "PARK %3.1f", az);
576  if (sendCommand(cmd, res) == false)
577  return false;
578 
579  return res[0] == 'A';
580 }
581 
585 bool RigelDome::readState()
586 {
587  char res[DRIVER_LEN] = {0};
588  if (sendCommand("V", res) == false)
589  return false;
590 
591  std::vector<std::string> fields = split(res, "\t");
592  if (fields.size() < 13)
593  return false;
594 
595  DomeAbsPosN[0].value = std::stod(fields[0]);
596  m_rawMotorState = static_cast<RigelMotorState>(std::stoi(fields[1]));
597  m_rawShutterState = static_cast<RigelShutterState>(std::stoi(fields[5]));
598  return true;
599 }
600 
604 INDI::Dome::ShutterState RigelDome::parseShutterState(int state)
605 {
606  switch (state)
607  {
608  case S_Open:
609  return SHUTTER_OPENED;
610 
611  case S_Opening:
612  return SHUTTER_MOVING;
613 
614  case S_Closed:
615  return SHUTTER_CLOSED;
616 
617  case S_Closing:
618  return SHUTTER_MOVING;
619 
620  case S_Error:
621  return SHUTTER_ERROR;
622 
623  default:
624  return SHUTTER_UNKNOWN;
625  }
626 }
630 bool RigelDome::readShutterStatus()
631 {
632  char res[DRIVER_LEN] = {0};
633  if (sendCommand("SHUTTER", res) == false)
634  return false;
635 
636  m_rawShutterState = static_cast<RigelShutterState>(std::stoi(res));
637  return true;
638 }
639 
643 bool RigelDome::readFirmware()
644 {
645  char res[DRIVER_LEN] = {0};
646 
647  if (sendCommand("VER", res) == false)
648  return false;
649 
650  IUSaveText(&InfoT[INFO_FIRMWARE], res);
651 
652  return true;
653 }
654 
658 bool RigelDome::readModel()
659 {
660  char res[DRIVER_LEN] = {0};
661 
662  if (sendCommand("PULSAR", res) == false)
663  return false;
664 
665  IUSaveText(&InfoT[INFO_MODEL], res);
666 
667  return true;
668 }
669 
673 bool RigelDome::sendCommand(const char * cmd, char * res, int cmd_len, int res_len)
674 {
675  int nbytes_written = 0, nbytes_read = 0, rc = -1;
676 
677  tcflush(PortFD, TCIOFLUSH);
678 
679  if (cmd_len > 0)
680  {
681  char hex_cmd[DRIVER_LEN * 3] = {0};
682  hexDump(hex_cmd, cmd, cmd_len);
683  LOGF_DEBUG("CMD <%s>", hex_cmd);
684  rc = tty_write(PortFD, cmd, cmd_len, &nbytes_written);
685  }
686  else
687  {
688  LOGF_DEBUG("CMD <%s>", cmd);
689 
690  char formatted_command[DRIVER_LEN] = {0};
691  snprintf(formatted_command, DRIVER_LEN, "%s\r", cmd);
692  rc = tty_write_string(PortFD, formatted_command, &nbytes_written);
693  }
694 
695  if (rc != TTY_OK)
696  {
697  char errstr[MAXRBUF] = {0};
698  tty_error_msg(rc, errstr, MAXRBUF);
699  LOGF_ERROR("Serial write error: %s.", errstr);
700  return false;
701  }
702 
703  if (res == nullptr)
704  return true;
705 
706  if (res_len > 0)
707  rc = tty_read(PortFD, res, res_len, DRIVER_TIMEOUT, &nbytes_read);
708  else
709  rc = tty_nread_section(PortFD, res, DRIVER_LEN, DRIVER_STOP_CHAR, DRIVER_TIMEOUT, &nbytes_read);
710 
711  if (rc != TTY_OK)
712  {
713  char errstr[MAXRBUF] = {0};
714  tty_error_msg(rc, errstr, MAXRBUF);
715  LOGF_ERROR("Serial read error: %s.", errstr);
716  return false;
717  }
718 
719  if (res_len > 0)
720  {
721  char hex_res[DRIVER_LEN * 3] = {0};
722  hexDump(hex_res, res, res_len);
723  LOGF_DEBUG("RES <%s>", hex_res);
724  }
725  else
726  {
727  // Remove extra \r
728  res[nbytes_read - 1] = 0;
729  LOGF_DEBUG("RES <%s>", res);
730  }
731 
732  tcflush(PortFD, TCIOFLUSH);
733 
734  return true;
735 }
736 
740 void RigelDome::hexDump(char * buf, const char * data, int size)
741 {
742  for (int i = 0; i < size; i++)
743  sprintf(buf + 3 * i, "%02X ", static_cast<uint8_t>(data[i]));
744 
745  if (size > 0)
746  buf[3 * size - 1] = '\0';
747 }
748 
752 std::vector<std::string> RigelDome::split(const std::string &input, const std::string &regex)
753 {
754  // passing -1 as the submatch index parameter performs splitting
755  std::regex re(regex);
756  std::sregex_token_iterator
757  first{input.begin(), input.end(), re, -1},
758  last;
759  return {first, last};
760 }
761 
766 {
767  double target;
768 
769  if (operation == MOTION_START)
770  {
771  target = DomeAbsPosN[0].value;
772  if(dir == DOME_CW)
773  {
774  target += 5;
775  }
776  else
777  {
778  target -= 5;
779  }
780 
781  if(target < 0)
782  target += 360;
783  if(target >= 360)
784  target -= 360;
785  }
786  else
787  {
788  target = DomeAbsPosN[0].value;
789  }
790 
791  MoveAbs(target);
792 
793  return ((operation == MOTION_START) ? IPS_BUSY : IPS_OK);
794 
795 }
void setDefaultBaudRate(BaudRate newRate)
setDefaultBaudRate Set default baud rate. The default baud rate is 9600 unless otherwise changed by t...
bool isConnected() const
Definition: basedevice.cpp:520
const char * getDeviceName() const
Definition: basedevice.cpp:821
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.
void defineProperty(INumberVectorProperty *property)
uint32_t getCurrentPollingPeriod() const
getCurrentPollingPeriod Return the current polling period.
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.
@ DOME_CAN_PARK
Definition: indidome.h:159
@ DOME_CAN_ABS_MOVE
Definition: indidome.h:157
@ DOME_HAS_SHUTTER
Definition: indidome.h:161
@ DOME_CAN_REL_MOVE
Definition: indidome.h:158
@ DOME_CAN_ABORT
Definition: indidome.h:156
@ DOME_CAN_SYNC
Definition: indidome.h:160
void SetParked(bool isparked)
SetParked Change the mount parking status. The data park file (stored in ~/.indi/ParkData....
Definition: indidome.cpp:1633
void SetDomeCapability(uint32_t cap)
SetDomeCapability set the dome capabilities. All capabilities must be initialized.
Definition: indidome.cpp:1561
@ DOME_PARKING
Definition: indidome.h:134
@ DOME_MOVING
Definition: indidome.h:132
@ DOME_SYNCED
Definition: indidome.h:133
void SetAxis1Park(double value)
SetRAPark Set current AZ parking position. The data park file (stored in ~/.indi/ParkData....
Definition: indidome.cpp:1861
INumber DomeAbsPosN[1]
Definition: indidome.h:534
void SetAxis1ParkDefault(double steps)
SetAxis1Park Set default AZ parking position.
Definition: indidome.cpp:1868
ShutterOperation
Shutter operation command.
Definition: indidome.h:114
@ SHUTTER_OPEN
Definition: indidome.h:115
int PortFD
Definition: indidome.h:617
DomeMotionCommand
Definition: indidome.h:97
@ MOTION_START
Definition: indidome.h:98
virtual bool initProperties() override
Initilize properties initial state and value. The child class must implement this function.
Definition: indidome.cpp:93
INumberVectorProperty DomeAbsPosNP
Definition: indidome.h:533
double GetAxis1Park()
Definition: indidome.cpp:1851
uint32_t GetDomeCapability() const
GetDomeCapability returns the capability of the dome.
Definition: indidome.h:204
ISwitchVectorProperty DomeShutterSP
Definition: indidome.h:548
bool HasShutter()
Definition: indidome.h:258
@ SHUTTER_ERROR
Definition: indidome.h:151
@ SHUTTER_MOVING
Definition: indidome.h:149
@ SHUTTER_UNKNOWN
Definition: indidome.h:150
@ SHUTTER_OPENED
Definition: indidome.h:147
@ SHUTTER_CLOSED
Definition: indidome.h:148
virtual bool updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
Definition: indidome.cpp:279
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
Definition: indidome.cpp:492
void setShutterState(const ShutterState &value)
Definition: indidome.cpp:1119
void setDomeState(const DomeState &value)
Definition: indidome.cpp:1156
bool InitPark()
InitPark Loads parking data (stored in ~/.indi/ParkData.xml) that contains parking status and parking...
Definition: indidome.cpp:1644
Connection::Serial * serialConnection
Definition: indidome.h:619
void SetParkDataType(DomeParkData type)
setParkDataType Sets the type of parking data stored in the park data file and presented to the user.
Definition: indidome.cpp:1587
ShutterState getShutterState() const
Definition: indidome.h:291
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
Definition: indidome.cpp:390
DomeState getDomeState() const
Definition: indidome.h:285
virtual bool SetCurrentPark() override
SetCurrentPark Set current coordinates/encoders value as the desired parking position.
Definition: rigel_dome.cpp:471
@ M_MovingAtSideral
Definition: rigel_dome.h:30
virtual bool SetDefaultPark() override
SetDefaultPark Set default coordinates/encoders value as the desired parking position.
Definition: rigel_dome.cpp:480
virtual IPState ControlShutter(ShutterOperation operation) override
Open or Close shutter.
Definition: rigel_dome.cpp:419
virtual IPState UnPark() override
UnPark dome. The action of the Unpark command is dome specific, but it may include opening the shutte...
Definition: rigel_dome.cpp:411
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
Definition: rigel_dome.cpp:174
virtual void TimerHit() override
Callback function to be called once SetTimer duration elapses.
Definition: rigel_dome.cpp:245
virtual bool Sync(double az) override
Sync sets the dome current azimuth as the supplied azimuth position.
Definition: rigel_dome.cpp:342
virtual bool initProperties() override
Initilize properties initial state and value. The child class must implement this function.
Definition: rigel_dome.cpp:56
virtual IPState Move(DomeDirection dir, DomeMotionCommand operation) override
Move the Dome in a particular direction.
Definition: rigel_dome.cpp:765
virtual IPState MoveAbs(double az) override
Move the Dome to an absolute azimuth.
Definition: rigel_dome.cpp:312
virtual bool Abort() override
Abort all dome motion.
Definition: rigel_dome.cpp:440
virtual IPState Park() override
Goto Park Position. The park position is an absolute azimuth value.
Definition: rigel_dome.cpp:356
virtual bool updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
Definition: rigel_dome.cpp:149
RigelShutterState
Definition: rigel_dome.h:29
@ S_NotFitted
Definition: rigel_dome.h:29
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
Definition: rigel_dome.cpp:223
virtual const char * getDefaultName() override
Definition: rigel_dome.cpp:141
virtual IPState MoveRel(double azDiff) override
Move the Dome to an relative position.
Definition: rigel_dome.cpp:326
virtual bool Handshake() override
perform handshake with device to check communication
Definition: rigel_dome.cpp:123
const char * MAIN_CONTROL_TAB
MAIN_CONTROL_TAB Where all the primary controls for the device are located.
const char * SITE_TAB
SITE_TAB Where all site information setting are located.
double max(void)
double min(void)
ISState
Switch state.
Definition: indiapi.h:150
@ ISS_OFF
Definition: indiapi.h:151
@ ISS_ON
Definition: indiapi.h:152
@ IP_RW
Definition: indiapi.h:186
@ IP_RO
Definition: indiapi.h:184
IPState
Property state.
Definition: indiapi.h:160
@ IPS_BUSY
Definition: indiapi.h:163
@ IPS_ALERT
Definition: indiapi.h:164
@ IPS_IDLE
Definition: indiapi.h:161
@ IPS_OK
Definition: indiapi.h:162
@ ISR_ATMOST1
Definition: indiapi.h:174
@ AXIS_AZ
Definition: indibasetypes.h:42
int tty_write(int fd, const char *buf, int nbytes, int *nbytes_written)
Writes a buffer to fd.
Definition: indicom.c:424
int tty_read(int fd, char *buf, int nbytes, int timeout, int *nbytes_read)
read buffer from terminal
Definition: indicom.c:482
int tty_write_string(int fd, const char *buf, int *nbytes_written)
Writes a null terminated string to fd.
Definition: indicom.c:474
void tty_error_msg(int err_code, char *err_msg, int err_msg_len)
Retrieve the tty error message.
Definition: indicom.c:1167
int tty_nread_section(int fd, char *buf, int nsize, char stop_char, int timeout, int *nbytes_read)
read buffer from terminal with a delimiter
Definition: indicom.c:666
Implementations for common driver routines.
@ TTY_OK
Definition: indicom.h:150
void IUFillNumberVector(INumberVectorProperty *nvp, INumber *np, int nnp, const char *dev, const char *name, const char *label, const char *group, IPerm p, double timeout, IPState s)
Assign attributes for a number vector property. The vector's auxiliary elements will be set to NULL.
Definition: indidevapi.c:272
void IUResetSwitch(ISwitchVectorProperty *svp)
Reset all switches in a switch vector property to OFF.
Definition: indidevapi.c:148
void IUFillTextVector(ITextVectorProperty *tvp, IText *tp, int ntp, const char *dev, const char *name, const char *label, const char *group, IPerm p, double timeout, IPState s)
Assign attributes for a text vector property. The vector's auxiliary elements will be set to NULL.
Definition: indidevapi.c:291
const char * IUFindOnSwitchName(ISState *states, char *names[], int n)
Returns the name of the first ON switch it finds in the supplied arguments.
Definition: indidevapi.c:137
void IUSaveText(IText *tp, const char *newtext)
Function to reliably save new text in a IText.
Definition: indidevapi.c:36
void IUFillSwitch(ISwitch *sp, const char *name, const char *label, ISState s)
Assign attributes for a switch property. The switch's auxiliary elements will be set to NULL.
Definition: indidevapi.c:158
void IUFillText(IText *tp, const char *name, const char *label, const char *initialText)
Assign attributes for a text property. The text's auxiliary elements will be set to NULL.
Definition: indidevapi.c:198
void IUFillNumber(INumber *np, const char *name, const char *label, const char *format, double min, double max, double step, double value)
Assign attributes for a number property. The number's auxiliary elements will be set to NULL.
Definition: indidevapi.c:180
void IUFillSwitchVector(ISwitchVectorProperty *svp, ISwitch *sp, int nsp, const char *dev, const char *name, const char *label, const char *group, IPerm p, ISRule r, double timeout, IPState s)
Assign attributes for a switch vector property. The vector's auxiliary elements will be set to NULL.
Definition: indidevapi.c:235
void IDSetNumber(const INumberVectorProperty *nvp, const char *fmt,...)
Definition: indidriver.c:1211
void IDSetSwitch(const ISwitchVectorProperty *svp, const char *fmt,...)
Definition: indidriver.c:1231
int IUUpdateNumber(INumberVectorProperty *nvp, double values[], char *names[], int n)
Update all numbers in a number vector property.
Definition: indidriver.c:1362
void IDSetText(const ITextVectorProperty *tvp, const char *fmt,...)
Definition: indidriver.c:1191
#define LOGF_INFO(fmt,...)
Definition: indilogger.h:82
#define LOG_WARN(txt)
Definition: indilogger.h:73
#define LOGF_DEBUG(fmt,...)
Definition: indilogger.h:83
#define LOGF_ERROR(fmt,...)
Definition: indilogger.h:80
#define LOG_INFO(txt)
Definition: indilogger.h:74
#define MAXRBUF
Definition: indiserver.cpp:102
__u8 cmd[4]
Definition: pwc-ioctl.h:2
char name[MAXINDINAME]
Definition: indiapi.h:323
char name[MAXINDINAME]
Definition: indiapi.h:371
char name[MAXINDINAME]
Definition: indiapi.h:250