Instrument Neutral Distributed Interface INDI 2.2.5
baader_dome.cpp
Go to the documentation of this file.
1/*******************************************************************************
2 Baader Planetarium Dome INDI Driver
3
4 Copyright(c) 2014 Jasem Mutlaq. All rights reserved.
5
6 Baader Dome INDI Driver
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 "baader_dome.h"
24
25#include "indicom.h"
26
27#include <cmath>
28#include <cstring>
29#include <memory>
30#include <termios.h>
31
32// We declare an auto pointer to BaaderDome.
33std::unique_ptr<BaaderDome> baaderDome(new BaaderDome());
34
35#define DOME_CMD 9 /* Dome command in bytes */
36#define DOME_BUF 16 /* Dome command buffer */
37#define DOME_TIMEOUT 3 /* 3 seconds comm timeout */
38
39#define SIM_SHUTTER_TIMER 5.0 /* Simulated Shutter closes/open in 5 seconds */
40#define SIM_FLAP_TIMER 5.0 /* Simulated Flap closes/open in 3 seconds */
41#define SIM_DOME_HI_SPEED 5.0 /* Simulated dome speed 5.0 degrees per second, constant */
42#define SIM_DOME_LO_SPEED 0.5 /* Simulated dome speed 0.5 degrees per second, constant */
43
60
62{
64
65 CalibrateSP[0].fill("Start", "", ISS_OFF);
68
69 DomeFlapSP[FLAP_OPEN].fill("FLAP_OPEN", "Open", ISS_OFF);
70 DomeFlapSP[FLAP_CLOSE].fill("FLAP_CLOSE", "Close", ISS_ON);
71 DomeFlapSP.fill(getDeviceName(), "DOME_FLAP", "Flap", MAIN_CONTROL_TAB, IP_RW,
72 ISR_1OFMANY, 60, IPS_OK);
73
75
77
78 return true;
79}
80
81/************************************************************************************
82 *
83* ***********************************************************************************/
85{
86 targetAz = 0;
87
88 if (UpdatePosition())
90
93
94 if (UpdateFlapStatus())
95 DomeFlapSP.apply(nullptr);
96
97 if (InitPark())
98 {
99 // If loading parking data is successful, we just set the default parking values.
101 }
102 else
103 {
104 // Otherwise, we set all parking data to default in case no parking data is found.
105 SetAxis1Park(0);
107 }
108
109 return true;
110}
111
112/************************************************************************************
113 *
114* ***********************************************************************************/
116{
117 return Ack();
118}
119
120/************************************************************************************
121 *
122* ***********************************************************************************/
124{
125 return (const char *)"Baader Dome";
126}
127
128/************************************************************************************
129 *
130* ***********************************************************************************/
132{
134
135 if (isConnected())
136 {
139
140 SetupParms();
141 }
142 else
143 {
146 }
147
148 return true;
149}
150
151/************************************************************************************
152 *
153* ***********************************************************************************/
154bool BaaderDome::ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n)
155{
156 if (dev != nullptr && strcmp(dev, getDeviceName()) == 0)
157 {
158 if (CalibrateSP.isNameMatch(name))
159 {
161
162 if (status == DOME_READY)
163 {
165 LOG_INFO("Dome is already calibrated.");
167 return true;
168 }
169
171 {
172 Abort();
173 LOG_INFO("Calibration aborted.");
177 return true;
178 }
179
181
182 LOG_INFO("Starting calibration procedure...");
183
185
186 calibrationStart = DomeAbsPosNP[0].getValue();
187
188 // Goal of procedure is to reach south point to hit sensor
190 if (calibrationTarget1 > 360)
191 calibrationTarget1 -= 360;
192
194 {
196 LOG_ERROR("Calibration failure due to dome motion failure.");
199 return false;
200 }
201
204 LOGF_INFO("Calibration is in progress. Moving to position %g.", calibrationTarget1);
206 return true;
207 }
208
209 if (DomeFlapSP.isNameMatch(name))
210 {
211 int ret = 0;
212 int prevStatus = DomeFlapSP.findOnSwitchIndex();
213 DomeFlapSP.update(states, names, n);
214 int FlapDome = DomeFlapSP.findOnSwitchIndex();
215
216 // No change of status, let's return
217 if (prevStatus == FlapDome)
218 {
221 }
222
223 // go back to prev status in case of failure
225 DomeFlapSP[prevStatus].setState(ISS_ON);
226
227 if (FlapDome == 0)
229 else
231
232 if (ret == 0)
233 {
236 DomeFlapSP[FlapDome].s = ISS_ON;
237 LOGF_INFO("Flap is %s", (FlapDome == 0 ? "open" : "closed"));
239 return true;
240 }
241 else if (ret == 1)
242 {
245 DomeFlapSP[FlapDome].setState(ISS_ON);
246 LOGF_INFO("Flap is %s", (FlapDome == 0 ? "opening" : "closing"));
248 return true;
249 }
250
252 LOGF_INFO("Flap failed to %s", (FlapDome == 0 ? "open" : "close"));
254 return false;
255 }
256 }
257
258 return INDI::Dome::ISNewSwitch(dev, name, states, names, n);
259}
260
261/************************************************************************************
262 *
263* ***********************************************************************************/
265{
266 int nbytes_written = 0, nbytes_read = 0, rc = -1;
267 char errstr[MAXRBUF];
268 char resp[DOME_BUF];
269 char status[DOME_BUF];
270
271 sim = isSimulation();
272
273 tcflush(PortFD, TCIOFLUSH);
274
275 if (!sim && (rc = tty_write(PortFD, "d#getflap", DOME_CMD, &nbytes_written)) != TTY_OK)
276 {
277 tty_error_msg(rc, errstr, MAXRBUF);
278 LOGF_ERROR("d#getflap Ack error: %s.", errstr);
279 return false;
280 }
281
282 LOG_DEBUG("CMD (d#getflap)");
283
284 if (sim)
285 {
286 strncpy(resp, "d#flapclo", DOME_BUF);
287 nbytes_read = DOME_CMD;
288 }
289 else if ((rc = tty_read(PortFD, resp, DOME_CMD, DOME_TIMEOUT, &nbytes_read)) != TTY_OK)
290 {
291 tty_error_msg(rc, errstr, MAXRBUF);
292 LOGF_ERROR("Ack error: %s.", errstr);
293 return false;
294 }
295
296 resp[nbytes_read] = '\0';
297
298 LOGF_DEBUG("RES (%s)", resp);
299
300 rc = sscanf(resp, "d#%s", status);
301
302 if (rc > 0)
303 return true;
304
305 return false;
306}
307
308/************************************************************************************
309 *
310* ***********************************************************************************/
312{
313 int nbytes_written = 0, nbytes_read = 0, rc = -1;
314 char errstr[MAXRBUF];
315 char resp[DOME_BUF];
316 char status[DOME_BUF];
317
318 tcflush(PortFD, TCIOFLUSH);
319
320 if (!sim && (rc = tty_write(PortFD, "d#getshut", DOME_CMD, &nbytes_written)) != TTY_OK)
321 {
322 tty_error_msg(rc, errstr, MAXRBUF);
323 LOGF_ERROR("d#getshut UpdateShutterStatus error: %s.", errstr);
324 return false;
325 }
326
327 LOG_DEBUG("CMD (d#getshut)");
328
329 if (sim)
330 {
332 strncpy(resp, "d#shutclo", DOME_CMD + 1);
334 strncpy(resp, "d#shutope", DOME_CMD + 1);
336 strncpy(resp, "d#shutrun", DOME_CMD + 1);
337 nbytes_read = DOME_CMD;
338 }
339 else if ((rc = tty_read(PortFD, resp, DOME_CMD, DOME_TIMEOUT, &nbytes_read)) != TTY_OK)
340 {
341 tty_error_msg(rc, errstr, MAXRBUF);
342 LOGF_ERROR("UpdateShutterStatus error: %s.", errstr);
343 return false;
344 }
345
346 resp[nbytes_read] = '\0';
347
348 LOGF_DEBUG("RES (%s)", resp);
349
350 rc = sscanf(resp, "d#shut%s", status);
351
352 if (rc > 0)
353 {
356
357 if (strcmp(status, "ope") == 0)
358 {
361
364 }
365 else if (strcmp(status, "clo") == 0)
366 {
369
372 }
373 else if (strcmp(status, "run") == 0)
374 {
377 }
378 else
379 {
382 LOGF_ERROR("Unknown Shutter status: %s.", resp);
383 }
384 return true;
385 }
386 return false;
387}
388
389/************************************************************************************
390 *
391* ***********************************************************************************/
393{
394 int nbytes_written = 0, nbytes_read = 0, rc = -1;
395 char errstr[MAXRBUF];
396 char resp[DOME_BUF];
397 unsigned short domeAz = 0;
398
399 tcflush(PortFD, TCIOFLUSH);
400
401 if (!sim && (rc = tty_write(PortFD, "d#getazim", DOME_CMD, &nbytes_written)) != TTY_OK)
402 {
403 tty_error_msg(rc, errstr, MAXRBUF);
404 LOGF_ERROR("d#getazim UpdatePosition error: %s.", errstr);
405 return false;
406 }
407
408 LOG_DEBUG("CMD (d#getazim)");
409
410 if (sim)
411 {
413 snprintf(resp, DOME_BUF, "d#azr%04d", MountAzToDomeAz(DomeAbsPosNP[0].getValue()));
414 else
415 snprintf(resp, DOME_BUF, "d#azi%04d", MountAzToDomeAz(DomeAbsPosNP[0].getValue()));
416 nbytes_read = DOME_CMD;
417 }
418 else if ((rc = tty_read(PortFD, resp, DOME_CMD, DOME_TIMEOUT, &nbytes_read)) != TTY_OK)
419 {
420 tty_error_msg(rc, errstr, MAXRBUF);
421 LOGF_ERROR("UpdatePosition error: %s.", errstr);
422 return false;
423 }
424
425 resp[nbytes_read] = '\0';
426
427 LOGF_DEBUG("RES (%s)", resp);
428
429 rc = sscanf(resp, "d#azr%hu", &domeAz);
430
431 if (rc > 0)
432 {
434 {
437 LOG_INFO("Dome is calibrated.");
439 CalibrateSP.apply(nullptr);
440 }
441 else if (status == DOME_CALIBRATING)
442 {
445 LOG_INFO("Calibration complete.");
448 }
449
450 DomeAbsPosNP[0].setValue(DomeAzToMountAz(domeAz));
451 return true;
452 }
453 else
454 {
455 rc = sscanf(resp, "d#azi%hu", &domeAz);
456 if (rc > 0)
457 {
458 DomeAbsPosNP[0].setValue(DomeAzToMountAz(domeAz));
459 return true;
460 }
461 }
462 return false;
463}
464
465/************************************************************************************
466 *
467* ***********************************************************************************/
468unsigned short BaaderDome::MountAzToDomeAz(double mountAz)
469{
470 int domeAz = 0;
471
472 domeAz = (mountAz) * 10.0 - 1800;
473
474 if (mountAz >= 0 && mountAz <= 179.9)
475 domeAz += 3600;
476
477 if (domeAz > 3599)
478 domeAz = 3599;
479 else if (domeAz < 0)
480 domeAz = 0;
481
482 return ((unsigned short)(domeAz));
483}
484
485/************************************************************************************
486 *
487* ***********************************************************************************/
488double BaaderDome::DomeAzToMountAz(unsigned short domeAz)
489{
490 double mountAz = 0;
491
492 mountAz = ((double)(domeAz + 1800)) / 10.0;
493
494 if (domeAz >= 1800)
495 mountAz -= 360;
496
497 if (mountAz > 360)
498 mountAz -= 360;
499 else if (mountAz < 0)
500 mountAz += 360;
501
502 return mountAz;
503}
504
505/************************************************************************************
506 *
507* ***********************************************************************************/
509{
510 if (!isConnected())
511 return; // No need to reset timer if we are not connected anymore
512
514
516 {
517 if (sim)
518 {
519 double speed = 0;
520 auto currentPosition = DomeAbsPosNP[0].getValue();
521 if (fabs(targetAz - currentPosition) > SIM_DOME_HI_SPEED)
522 speed = SIM_DOME_HI_SPEED;
523 else
524 speed = SIM_DOME_LO_SPEED;
525
527 {
528 // CW
529 if (DomeMotionSP[0].getState() == ISS_ON)
530 currentPosition += speed;
531 // CCW
532 else
533 currentPosition -= speed;
534 }
535 else
536 {
537 if (targetAz > DomeAbsPosNP[0].getValue())
538 {
539 currentPosition += speed;
540 }
541 else if (targetAz < DomeAbsPosNP[0].getValue())
542 {
543 currentPosition -= speed;
544 }
545 }
546
547 currentPosition = range360(speed);
548 DomeAbsPosNP[0].setValue(currentPosition);
549 }
550
551 if (std::abs(targetAz - DomeAbsPosNP[0].getValue()) < DomeParamNP[0].getValue())
552 {
553 DomeAbsPosNP[0].setValue(targetAz);
554 LOG_INFO("Dome reached requested azimuth angle.");
555
557 {
558 if (getDomeState() == DOME_PARKING)
559 SetParked(true);
560 else if (getDomeState() == DOME_UNPARKING)
561 SetParked(false);
562 else
564 }
565
567 {
569 {
570 LOG_INFO("Calibration stage 1 complete. Starting stage 2...");
571 calibrationTarget2 = DomeAbsPosNP[0].getValue() + 2;
575 }
577 {
578 LOGF_INFO("Calibration stage 2 complete. Returning to initial position %g...", calibrationStart);
582 }
584 {
586 LOG_INFO("Dome reached initial position.");
587 }
588 }
589 }
590
592 }
593 else
595
597
599 {
600 if (simShutterTimer-- <= 0)
601 {
602 simShutterTimer = 0;
604 }
605 }
606 else
608
610
611 if (sim && DomeFlapSP.getState() == IPS_BUSY)
612 {
613 if (simFlapTimer-- <= 0)
614 {
615 simFlapTimer = 0;
617 }
618 }
619 else
621
623}
624
625/************************************************************************************
626 *
627* ***********************************************************************************/
629{
630 int nbytes_written = 0, nbytes_read = 0, rc = -1;
631 char errstr[MAXRBUF];
632 char cmd[DOME_BUF];
633 char resp[DOME_BUF];
634
635 if (status == DOME_UNKNOWN)
636 {
637 LOG_WARN("Dome is not calibrated. Please calibrate dome before issuing any commands.");
638 return IPS_ALERT;
639 }
640
641 targetAz = az;
642
643 snprintf(cmd, DOME_BUF, "d#azi%04d", MountAzToDomeAz(targetAz));
644
645 tcflush(PortFD, TCIOFLUSH);
646
647 if (!sim && (rc = tty_write(PortFD, cmd, DOME_CMD, &nbytes_written)) != TTY_OK)
648 {
649 tty_error_msg(rc, errstr, MAXRBUF);
650 LOGF_ERROR("%s MoveAbsDome error: %s.", cmd, errstr);
651 return IPS_ALERT;
652 }
653
654 LOGF_DEBUG("CMD (%s)", cmd);
655
656 if (sim)
657 {
658 strncpy(resp, "d#gotmess", DOME_CMD + 1);
659 nbytes_read = DOME_CMD;
660 }
661 else if ((rc = tty_read(PortFD, resp, DOME_CMD, DOME_TIMEOUT, &nbytes_read)) != TTY_OK)
662 {
663 tty_error_msg(rc, errstr, MAXRBUF);
664 LOGF_ERROR("MoveAbsDome error: %s.", errstr);
665 return IPS_ALERT;
666 }
667
668 resp[nbytes_read] = '\0';
669
670 LOGF_DEBUG("RES (%s)", resp);
671
672 if (strcmp(resp, "d#gotmess") == 0)
673 return IPS_BUSY;
674
675 return IPS_ALERT;
676}
677
678/************************************************************************************
679 *
680* ***********************************************************************************/
682{
683 targetAz = range360(DomeAbsPosNP[0].getValue() + azDiff);
684 return MoveAbs(targetAz);
685}
686
687/************************************************************************************
688 *
689* ***********************************************************************************/
695
696/************************************************************************************
697 *
698* ***********************************************************************************/
700{
701 return IPS_OK;
702}
703
704/************************************************************************************
705 *
706* ***********************************************************************************/
708{
709 int nbytes_written = 0, nbytes_read = 0, rc = -1;
710 char errstr[MAXRBUF];
711 char cmd[DOME_BUF];
712 char resp[DOME_BUF];
713
714 memset(cmd, 0, sizeof(cmd));
715
716 if (operation == SHUTTER_OPEN)
717 {
718 targetShutter = operation;
719 strncpy(cmd, "d#opeshut", DOME_CMD + 1);
720 }
721 else
722 {
723 targetShutter = operation;
724 strncpy(cmd, "d#closhut", DOME_CMD + 1);
725 }
726
727 tcflush(PortFD, TCIOFLUSH);
728
729 if (!sim && (rc = tty_write(PortFD, cmd, DOME_CMD, &nbytes_written)) != TTY_OK)
730 {
731 tty_error_msg(rc, errstr, MAXRBUF);
732 LOGF_ERROR("%s ControlDomeShutter error: %s.", cmd, errstr);
733 return IPS_ALERT;
734 }
735
736 LOGF_DEBUG("CMD (%s)", cmd);
737
738 if (sim)
739 {
741 strncpy(resp, "d#gotmess", DOME_CMD + 1);
742 nbytes_read = DOME_CMD;
743 }
744 else if ((rc = tty_read(PortFD, resp, DOME_CMD, DOME_TIMEOUT, &nbytes_read)) != TTY_OK)
745 {
746 tty_error_msg(rc, errstr, MAXRBUF);
747 LOGF_ERROR("ControlDomeShutter error: %s.", errstr);
748 return IPS_ALERT;
749 }
750
751 resp[nbytes_read] = '\0';
752
753 LOGF_DEBUG("RES (%s)", resp);
754
755 if (strcmp(resp, "d#gotmess") == 0)
756 {
758 return IPS_BUSY;
759 }
760 return IPS_ALERT;
761}
762
763/************************************************************************************
764 *
765* ***********************************************************************************/
767{
768 LOGF_INFO("Attempting to abort dome motion by stopping at %g", DomeAbsPosNP[0].getValue());
769 MoveAbs(DomeAbsPosNP[0].getValue());
770 return true;
771}
772
773/************************************************************************************
774 *
775* ***********************************************************************************/
777{
778 switch (status)
779 {
780 case FLAP_OPENED:
781 return "Flap is open.";
782 break;
783 case FLAP_CLOSED:
784 return "Flap is closed.";
785 break;
786 case FLAP_MOVING:
787 return "Flap is in motion.";
788 break;
789 case FLAP_UNKNOWN:
790 default:
791 return "Flap status is unknown.";
792 break;
793 }
794}
795
796/************************************************************************************
797 *
798* ***********************************************************************************/
800{
801 int nbytes_written = 0, nbytes_read = 0, rc = -1;
802 char errstr[MAXRBUF];
803 char cmd[DOME_BUF];
804 char resp[DOME_BUF];
805
806 memset(cmd, 0, sizeof(cmd));
807
808 if (operation == FLAP_OPEN)
809 {
810 targetFlap = operation;
811 strncpy(cmd, "d#opeflap", DOME_CMD + 1);
812 }
813 else
814 {
815 targetFlap = operation;
816 strncpy(cmd, "d#cloflap", DOME_CMD + 1);
817 }
818
819 tcflush(PortFD, TCIOFLUSH);
820
821 if (!sim && (rc = tty_write(PortFD, cmd, DOME_CMD, &nbytes_written)) != TTY_OK)
822 {
823 tty_error_msg(rc, errstr, MAXRBUF);
824 LOGF_ERROR("%s ControlDomeFlap error: %s.", cmd, errstr);
825 return -1;
826 }
827
828 LOGF_DEBUG("CMD (%s)", cmd);
829
830 if (sim)
831 {
833 strncpy(resp, "d#gotmess", DOME_CMD + 1);
834 nbytes_read = DOME_CMD;
835 }
836 else if ((rc = tty_read(PortFD, resp, DOME_CMD, DOME_TIMEOUT, &nbytes_read)) != TTY_OK)
837 {
838 tty_error_msg(rc, errstr, MAXRBUF);
839 LOGF_ERROR("ControlDomeFlap error: %s.", errstr);
840 return -1;
841 }
842
843 resp[nbytes_read] = '\0';
844
845 LOGF_DEBUG("RES (%s)", resp);
846
847 if (strcmp(resp, "d#gotmess") == 0)
848 {
850 return 1;
851 }
852 return -1;
853}
854
855/************************************************************************************
856 *
857* ***********************************************************************************/
859{
860 int nbytes_written = 0, nbytes_read = 0, rc = -1;
861 char errstr[MAXRBUF];
862 char resp[DOME_BUF];
863 char status[DOME_BUF];
864
865 tcflush(PortFD, TCIOFLUSH);
866
867 if (!sim && (rc = tty_write(PortFD, "d#getflap", DOME_CMD, &nbytes_written)) != TTY_OK)
868 {
869 tty_error_msg(rc, errstr, MAXRBUF);
870 LOGF_ERROR("d#getflap UpdateflapStatus error: %s.", errstr);
871 return false;
872 }
873
874 LOG_DEBUG("CMD (d#getflap)");
875
876 if (sim)
877 {
879 strncpy(resp, "d#flapclo", DOME_CMD + 1);
880 else if (simFlapStatus == FLAP_OPENED)
881 strncpy(resp, "d#flapope", DOME_CMD + 1);
882 else if (simFlapStatus == FLAP_MOVING)
883 strncpy(resp, "d#flaprun", DOME_CMD + 1);
884 nbytes_read = DOME_CMD;
885 }
886 else if ((rc = tty_read(PortFD, resp, DOME_CMD, DOME_TIMEOUT, &nbytes_read)) != TTY_OK)
887 {
888 tty_error_msg(rc, errstr, MAXRBUF);
889 LOGF_ERROR("UpdateflapStatus error: %s.", errstr);
890 return false;
891 }
892
893 resp[nbytes_read] = '\0';
894
895 LOGF_DEBUG("RES (%s)", resp);
896
897 rc = sscanf(resp, "d#flap%s", status);
898
899 if (rc > 0)
900 {
903
904 if (strcmp(status, "ope") == 0)
905 {
908
911 }
912 else if (strcmp(status, "clo") == 0)
913 {
916
919 }
920 else if (strcmp(status, "run") == 0)
921 {
924 }
925 else
926 {
929 LOGF_ERROR("Unknown flap status: %s.", resp);
930 }
931 return true;
932 }
933 return false;
934}
935
936/************************************************************************************
937 *
938* ***********************************************************************************/
940{
941 int nbytes_written = 0, nbytes_read = 0, rc = -1;
942 char errstr[MAXRBUF];
943 char cmd[DOME_BUF];
944 char resp[DOME_BUF];
945
946 strncpy(cmd, "d#encsave", DOME_CMD + 1);
947
948 tcflush(PortFD, TCIOFLUSH);
949
950 if (!sim && (rc = tty_write(PortFD, cmd, DOME_CMD, &nbytes_written)) != TTY_OK)
951 {
952 tty_error_msg(rc, errstr, MAXRBUF);
953 LOGF_ERROR("%s SaveEncoderPosition error: %s.", cmd, errstr);
954 return false;
955 }
956
957 LOGF_DEBUG("CMD (%s)", cmd);
958
959 if (sim)
960 {
961 strncpy(resp, "d#gotmess", DOME_CMD + 1);
962 nbytes_read = DOME_CMD;
963 }
964 else if ((rc = tty_read(PortFD, resp, DOME_CMD, DOME_TIMEOUT, &nbytes_read)) != TTY_OK)
965 {
966 tty_error_msg(rc, errstr, MAXRBUF);
967 LOGF_ERROR("SaveEncoderPosition error: %s.", errstr);
968 return false;
969 }
970
971 resp[nbytes_read] = '\0';
972
973 LOGF_DEBUG("RES (%s)", resp);
974
975 return strcmp(resp, "d#gotmess") == 0;
976}
977
978/************************************************************************************
979 *
980* ***********************************************************************************/
982{
983 // Only save if calibration is complete
986
988}
989
990/************************************************************************************
991 *
992* ***********************************************************************************/
994{
995 SetAxis1Park(DomeAbsPosNP[0].getValue());
996 return true;
997}
998/************************************************************************************
999 *
1000* ***********************************************************************************/
1001
1003{
1004 // By default set position to 90
1005 SetAxis1Park(90);
1006 return true;
1007}
#define DOME_TIMEOUT
#define SIM_SHUTTER_TIMER
#define SIM_DOME_HI_SPEED
#define DOME_CMD
std::unique_ptr< BaaderDome > baaderDome(new BaaderDome())
#define SIM_DOME_LO_SPEED
#define SIM_FLAP_TIMER
#define DOME_BUF
FlapStatus simFlapStatus
Definition baader_dome.h:97
int ControlDomeFlap(FlapOperation operation)
virtual IPState MoveAbs(double az) override
Move the Dome to an absolute azimuth.
bool UpdateShutterStatus()
bool SaveEncoderPosition()
CalibrationStage calibrationStage
Definition baader_dome.h:86
FlapOperation targetFlap
Definition baader_dome.h:92
unsigned short MountAzToDomeAz(double mountAz)
virtual bool saveConfigItems(FILE *fp) override
saveConfigItems Saves the Device Port and Dome Presets in the configuration file
const char * GetFlapStatusString(FlapStatus status)
double simFlapTimer
Definition baader_dome.h:95
double calibrationTarget1
Definition baader_dome.h:89
INDI::PropertySwitch DomeFlapSP
Definition baader_dome.h:82
double calibrationTarget2
Definition baader_dome.h:90
virtual const char * getDefaultName() override
virtual bool Handshake() override
perform handshake with device to check communication
virtual bool updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
virtual IPState ControlShutter(ShutterOperation operation) override
Open or Close shutter.
FlapStatus flapStatus
Definition baader_dome.h:85
ShutterState simShutterStatus
Definition baader_dome.h:96
double simShutterTimer
Definition baader_dome.h:94
bool UpdateFlapStatus()
bool UpdatePosition()
virtual bool SetDefaultPark() override
SetDefaultPark Set default coordinates/encoders value as the desired parking position.
bool SetupParms()
@ CALIBRATION_UNKNOWN
Definition baader_dome.h:31
@ CALIBRATION_STAGE1
Definition baader_dome.h:32
@ CALIBRATION_STAGE3
Definition baader_dome.h:34
@ CALIBRATION_COMPLETE
Definition baader_dome.h:35
@ CALIBRATION_STAGE2
Definition baader_dome.h:33
virtual bool SetCurrentPark() override
SetCurrentPark Set current coordinates/encoders value as the desired parking position.
virtual bool Abort() override
Abort all dome motion.
virtual bool initProperties() override
Initialize properties initial state and value. The child class must implement this function.
virtual IPState UnPark() override
UnPark dome. The action of the Unpark command is dome specific, but it may include opening the shutte...
ShutterOperation targetShutter
Definition baader_dome.h:91
double calibrationStart
Definition baader_dome.h:88
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.
double targetAz
Definition baader_dome.h:87
virtual IPState MoveRel(double azDiff) override
Move the Dome to an relative position.
INDI::PropertySwitch CalibrateSP
Definition baader_dome.h:80
virtual void TimerHit() override
Callback function to be called once SetTimer duration elapses.
double DomeAzToMountAz(unsigned short domeAz)
DomeStatus status
Definition baader_dome.h:84
bool isConnected() const
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.
bool isSimulation() const
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.
const char * GetShutterStatusString(ShutterState status)
getShutterStatusString
INDI::PropertyNumber DomeRelPosNP
Definition indidome.h:538
INDI::PropertyNumber DomeParamNP
Definition indidome.h:542
@ DOME_UNPARKING
Definition indidome.h:135
ShutterState m_ShutterState
Definition indidome.h:612
void SetAxis1Park(double value)
SetRAPark Set current AZ parking position. The data park file (stored in ~/.indi/ParkData....
void SetAxis1ParkDefault(double steps)
SetAxis1Park Set default AZ parking position.
ShutterOperation
Shutter operation command.
Definition indidome.h:114
@ SHUTTER_CLOSE
Definition indidome.h:116
virtual bool initProperties() override
Initialize properties initial state and value. The child class must implement this function.
Definition indidome.cpp:105
@ 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_HAS_VARIABLE_SPEED
Definition indidome.h:162
double GetAxis1Park()
@ 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:284
INDI::PropertyNumber DomeAbsPosNP
Definition indidome.h:536
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
Definition indidome.cpp:503
INDI::PropertySwitch DomeMotionSP
Definition indidome.h:534
virtual bool saveConfigItems(FILE *fp) override
saveConfigItems Saves the Device Port and Dome Presets in the configuration file
void setDomeState(const DomeState &value)
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::PropertySwitch DomeShutterSP
Definition indidome.h:546
DomeState getDomeState() const
Definition indidome.h:285
void setState(IPState state)
void apply(const char *format,...) const ATTRIBUTE_FORMAT_PRINTF(2
bool isNameMatch(const char *otherName) const
bool update(const ISState states[], const char *const names[], int n)
void fill(const char *device, const char *name, const char *label, const char *group, IPerm permission, ISRule rule, double timeout, IPState state)
const char * MAIN_CONTROL_TAB
MAIN_CONTROL_TAB Where all the primary controls for the device are located.
ISState
Switch state.
Definition indiapi.h:148
@ ISS_OFF
Definition indiapi.h:149
@ ISS_ON
Definition indiapi.h:150
@ IP_RW
Definition indiapi.h:184
IPState
Property state.
Definition indiapi.h:158
@ IPS_BUSY
Definition indiapi.h:161
@ IPS_ALERT
Definition indiapi.h:162
@ IPS_IDLE
Definition indiapi.h:159
@ IPS_OK
Definition indiapi.h:160
@ ISR_1OFMANY
Definition indiapi.h:171
@ ISR_ATMOST1
Definition indiapi.h:172
int tty_write(int fd, const char *buf, int nbytes, int *nbytes_written)
Writes a buffer to fd.
Definition indicom.c:418
int tty_read(int fd, char *buf, int nbytes, int timeout, int *nbytes_read)
read buffer from terminal
Definition indicom.c:548
double range360(double r)
range360 Limits an angle to be between 0-360 degrees.
Definition indicom.c:1321
void tty_error_msg(int err_code, char *err_msg, int err_msg_len)
Retrieve the tty error message.
Definition indicom.c:1243
Implementations for common driver routines.
@ TTY_OK
Definition indicom.h:54
#define MAXRBUF
Definition indidriver.c:52
#define LOGF_INFO(fmt,...)
Definition indilogger.h:82
#define LOG_DEBUG(txt)
Definition indilogger.h:75
#define LOG_WARN(txt)
Definition indilogger.h:73
#define LOGF_DEBUG(fmt,...)
Definition indilogger.h:83
#define LOG_ERROR(txt)
Shorter logging macros. In order to use these macros, the function (or method) "getDeviceName()" must...
Definition indilogger.h:72
#define LOGF_ERROR(fmt,...)
Definition indilogger.h:80
#define LOG_INFO(txt)
Definition indilogger.h:74
#define getDeviceName
uint8_t cmd[4]
Definition pwc-ioctl.h:2