Instrument Neutral Distributed Interface INDI 2.2.5
indidome.h
Go to the documentation of this file.
1/*******************************************************************************
2 INDI Dome Base Class
3 Copyright(c) 2014 Jasem Mutlaq. All rights reserved.
4
5 The code used calculate dome target AZ and ZD is written by Ferran Casarramona, and adapted from code from Markus Wildi.
6 The transformations are based on the paper Matrix Method for Coordinates Transformation written by Toshimi Taki (http://www.asahi-net.or.jp/~zs3t-tk).
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#pragma once
24
25#include "defaultdevice.h"
26#include "libastro.h"
27#include "inditimer.h"
28
29#include <string>
30
31// Defines a point in a 3 dimension space
32typedef struct
33{
34 double x, y, z;
35} point3D;
36
37namespace Connection
38{
39class Serial;
40class TCP;
41}
42
71namespace INDI
72{
73
74class Dome : public DefaultDevice
75{
76 public:
90
101
109
118
125
141
153
154 enum
155 {
156 DOME_CAN_ABORT = 1 << 0,
159 DOME_CAN_PARK = 1 << 3,
160 DOME_CAN_SYNC = 1 << 4,
164 };
165
169 enum
170 {
175
176 Dome();
177 virtual ~Dome();
178
179 virtual bool initProperties() override;
180 virtual void ISGetProperties(const char * dev) override;
181 virtual bool updateProperties() override;
182 virtual bool ISNewNumber(const char * dev, const char * name, double values[], char * names[], int n) override;
183 virtual bool ISNewSwitch(const char * dev, const char * name, ISState * states, char * names[], int n) override;
184 virtual bool ISNewText(const char * dev, const char * name, char * texts[], char * names[], int n) override;
185 virtual bool ISSnoopDevice(XMLEle * root) override;
186
187 static void buttonHelper(const char * button_n, ISState state, void * context);
188
194 void setDomeConnection(const uint8_t &value);
195
199 uint8_t getDomeConnection() const;
200
204 uint32_t GetDomeCapability() const
205 {
206 return capability;
207 }
208
213 void SetDomeCapability(uint32_t cap);
214
218 bool CanAbort()
219 {
220 return capability & DOME_CAN_ABORT;
221 }
222
227 {
229 }
230
235 {
237 }
238
242 bool CanPark()
243 {
244 return capability & DOME_CAN_PARK;
245 }
246
250 bool CanSync()
251 {
252 return capability & DOME_CAN_SYNC;
253 }
254
259 {
261 }
262
267 {
269 }
270
275 {
277 }
278
283 bool isLocked();
284
286 {
287 return m_DomeState;
288 }
289 void setDomeState(const DomeState &value);
290
292 {
293 return m_ShutterState;
294 }
295 void setShutterState(const ShutterState &value);
296
297 IPState getMountState() const;
298
299 protected:
305 virtual bool SetSpeed(double rpm);
306
311 virtual IPState Move(DomeDirection dir, DomeMotionCommand operation);
312
318 virtual IPState MoveAbs(double az);
319
325 virtual IPState MoveRel(double azDiff);
326
331 virtual bool Sync(double az);
332
337 virtual bool Abort();
338
347 virtual IPState Park();
348
358 virtual IPState UnPark();
359
365 virtual bool SetBacklash(int32_t steps);
366
372 virtual bool SetBacklashEnabled(bool enabled);
373
383 virtual IPState ControlShutter(ShutterOperation operation);
384
394 {
395 m_ShutterParkPolicyHandledByDriver = enabled;
396 }
397
403 const char * GetShutterStatusString(ShutterState status);
404
410
419 bool InitPark();
420
425 bool isParked();
426
431 void SetParked(bool isparked);
432
436 double GetAxis1Park();
437
441 double GetAxis1ParkDefault();
442
447 void SetAxis1Park(double value);
448
453 void SetAxis1ParkDefault(double steps);
454
459 virtual bool SetCurrentPark();
460
465 virtual bool SetDefaultPark();
466
467 //Park
468 const char * LoadParkData();
469 bool WriteParkData();
470
479 bool GetTargetAz(double &Az, double &Alt, double &minAz, double &maxAz);
480
494 bool Intersection(point3D p1, point3D p2, double r, double &mu1, double &mu2);
495
505 bool OpticalCenter(point3D MountCenter, double dOpticalAxis, double Lat, double Ah, point3D &OP);
506
514 bool OpticalVector(double Az, double Alt, point3D &OV);
515
523 bool CheckHorizon(double HA, double dec, double lat);
524
530 virtual bool saveConfigItems(FILE * fp) override;
531
535 void UpdateMountCoords();
536
541 virtual void UpdateAutoSync();
542
544 virtual bool Handshake();
545
549 virtual void ActiveDevicesUpdated() {};
550
551 double Csc(double x);
552 double Sec(double x);
553
555
557
559
561
563
565
567
569
571
573
575
577 enum
578 {
582 };
583
584 // Switch to lock id mount is unparked
586
587 // Shutter control on Park/Unpark
589 enum
590 {
593 };
594
597
599
601 // 0 is East, 1 is West, 2 is as reported by mout, 3 as deducted by Hour Angle
602 // 4 ignore pier side and perform as in a fork mount
603 enum
604 {
610 };
611
612 int mountOTASide = 0; // Side of the telescope with respect of the mount, 1: west, -1: east, 0 not reported
614
615 // Backlash toggle
617
618 // Backlash steps
620
621 uint32_t capability;
623
625
626 // For Serial and TCP connections
627 int PortFD = -1;
628
631
632 // States
636
637 // Observer geographic coords. Snooped from mount driver.
639 // Do we have valid geographic coords from mount driver?
640 bool HaveLatLong = false;
641
642 // Mount horizontal and equatorial coords. Snoops from mount driver.
645 // Do we have valid coords from mount driver?
646 bool HaveRaDec = false;
647
648 private:
649 void processButton(const char * button_n, ISState state);
650 void triggerSnoop(const char * driverName, const char * propertyName);
655 void SyncParkStatus(bool isparked);
660 const char * LoadParkXML();
661
667 std::string GetHomeDirectory() const;
668
669 Controller * controller = nullptr;
670
671 bool IsParked = false;
672 bool IsMountParked = true;
673 bool IsLocked = true;
674 bool AutoSyncWarning = false;
675 bool UseHourAngle = false;
676
677 const char * ParkDeviceName;
678 const std::string ParkDataFileName;
679 INDI::Timer m_MountUpdateTimer;
680 //int m_HorizontalUpdateTimerID { -1 };
681 XMLEle * ParkdataXmlRoot, *ParkdeviceXml, *ParkstatusXml, *ParkpositionXml, *ParkpositionAxis1Xml;
682
683 double Axis1ParkPosition;
684 double Axis1DefaultParkPosition;
685
686 bool callHandshake();
687 uint8_t domeConnection = CONNECTION_SERIAL | CONNECTION_TCP;
688
690 // Shutter park policy.
691 // A park (or unpark) that operates the shutter completes only when both
692 // the dome motion and the shutter operation are complete.
694 enum ShutterParkSequence
695 {
696 SHUTTER_SEQUENCE_NONE,
697 SHUTTER_SEQUENCE_PARK,
698 SHUTTER_SEQUENCE_UNPARK
699 };
700
702 bool isShutterAt(ShutterOperation operation) const;
704 bool isShutterKnownAt(ShutterOperation operation) const;
706 void shutterParkMotionDone();
708 void checkShutterParkSequence();
710 void cancelShutterParkSequence();
711
712 bool m_ShutterParkPolicyHandledByDriver {false};
713 ShutterParkSequence m_ShutterParkSequence {SHUTTER_SEQUENCE_NONE};
714 bool m_ShutterParkCommandSent {false};
715 bool m_ShutterParkMotionDone {false};
716 bool m_ShutterParkShutterDone {false};
717 bool m_ShutterParkShutterFailed {false};
718 INDI::Timer m_ShutterParkTimer;
719 static constexpr uint32_t SHUTTER_PARK_POLL_INTERVAL { 1000 };
720
721 // How often we update horizontal coordinates (10 seconds).
722 static constexpr uint32_t HORZ_UPDATE_TIMER { 10000 };
723};
724
725}
The Serial class manages connection with serial devices including Bluetooth. Serial communication is ...
The TCP class manages connection with devices over the network via TCP/IP. Upon successful connection...
The Controller class provides functionality to access a controller (e.g. joystick) input and send it ...
bool CanPark()
Definition indidome.h:242
INDI::PropertySwitch PresetGotoSP
Definition indidome.h:596
double prev_alt
Definition indidome.h:624
INDI::IHorizontalCoordinates mountHoriztonalCoords
Definition indidome.h:643
Connection::TCP * tcpConnection
Definition indidome.h:630
DomeState m_DomeState
Definition indidome.h:633
@ CONNECTION_SERIAL
Definition indidome.h:172
@ CONNECTION_TCP
Definition indidome.h:173
@ CONNECTION_NONE
Definition indidome.h:171
virtual IPState UnPark()
UnPark dome. The action of the Unpark command is dome specific, but it may include opening the shutte...
uint32_t capability
Definition indidome.h:621
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...
INDI::PropertySwitch ShutterParkPolicySP
Definition indidome.h:588
INDI::PropertySwitch ParkOptionSP
Definition indidome.h:574
const char * GetShutterStatusString(ShutterState status)
getShutterStatusString
INDI::IEquatorialCoordinates mountEquatorialCoords
Definition indidome.h:644
@ DM_OTA_SIDE_EAST
Definition indidome.h:605
@ DM_OTA_SIDE_MOUNT
Definition indidome.h:607
@ DM_OTA_SIDE_IGNORE
Definition indidome.h:609
@ DM_OTA_SIDE_WEST
Definition indidome.h:606
@ DM_OTA_SIDE_HA
Definition indidome.h:608
bool CheckHorizon(double HA, double dec, double lat)
CheckHorizon Returns true if telescope points above horizon.
INDI::PropertyNumber DomeRelPosNP
Definition indidome.h:560
@ SHUTTER_OPEN_ON_UNPARK
Definition indidome.h:592
@ SHUTTER_CLOSE_ON_PARK
Definition indidome.h:591
bool isParked()
isParked is dome currently parked?
bool HaveRaDec
Definition indidome.h:646
INDI::PropertyNumber DomeParamNP
Definition indidome.h:564
bool OpticalCenter(point3D MountCenter, double dOpticalAxis, double Lat, double Ah, point3D &OP)
OpticalCenter This function calculates the distance from the optical axis to the Dome center.
DomeState
Dome status.
Definition indidome.h:130
@ DOME_UNPARKING
Definition indidome.h:135
@ DOME_UNPARKED
Definition indidome.h:137
INDI::PropertyNumber ParkPositionNP
Definition indidome.h:572
virtual bool SetSpeed(double rpm)
SetSpeed Set Dome speed. This does not initiate motion, it sets the speed for the next motion command...
virtual bool Sync(double az)
Sync sets the dome current azimuth as the supplied azimuth position.
virtual void ISGetProperties(const char *dev) override
define the driver's properties to the client. Usually, only a minimum set of properties are defined t...
Definition indidome.cpp:273
ShutterState m_ShutterState
Definition indidome.h:634
double prev_dec
Definition indidome.h:624
bool CanRelMove()
Definition indidome.h:234
void SetAxis1Park(double value)
SetRAPark Set current AZ parking position. The data park file (stored in ~/.indi/ParkData....
double prev_ra
Definition indidome.h:624
void UpdateMountCoords()
updateCoords updates the horizontal coordinates (Az & Alt) of the mount from the snooped RA,...
ShutterOperation
Shutter operation command.
Definition indidome.h:114
@ SHUTTER_CLOSE
Definition indidome.h:116
IPState getMountState() const
void SetAxis1ParkDefault(double steps)
SetAxis1Park Set default AZ parking position.
INDI::PropertySwitch AbortSP
Definition indidome.h:562
INDI::PropertyNumber DomeSpeedNP
Definition indidome.h:554
DomeMotionCommand
Definition indidome.h:97
@ MOTION_STOP
Definition indidome.h:99
@ MOTION_START
Definition indidome.h:98
double Csc(double x)
virtual bool initProperties() override
Initialize properties initial state and value. The child class must implement this function.
Definition indidome.cpp:108
double prev_az
Definition indidome.h:624
INDI::PropertyNumber DomeMeasurementsNP
Definition indidome.h:598
virtual void UpdateAutoSync()
UpdateAutoSync This function calculates the target dome azimuth from the mount's target coordinates g...
INDI::PropertyNumber DomeBacklashNP
Definition indidome.h:619
virtual IPState MoveRel(double azDiff)
Move the Dome to an relative position.
double GetAxis1Park()
uint32_t GetDomeCapability() const
GetDomeCapability returns the capability of the dome.
Definition indidome.h:204
bool CanSync()
Definition indidome.h:250
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
bool isLocked()
isLocked, is the dome currently locked?
@ 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_HAS_BACKLASH
Definition indidome.h:163
@ DOME_CAN_ABORT
Definition indidome.h:156
@ DOME_CAN_SYNC
Definition indidome.h:160
@ DOME_HAS_VARIABLE_SPEED
Definition indidome.h:162
virtual void ActiveDevicesUpdated()
Definition indidome.h:549
INDI::PropertySwitch ParkSP
Definition indidome.h:570
int mountOTASide
Definition indidome.h:612
bool HasVariableSpeed()
Definition indidome.h:266
virtual bool SetBacklash(int32_t steps)
SetBacklash Set the dome backlash compensation value.
double GetAxis1ParkDefault()
virtual IPState Park()
Goto Park Position. The park position is an absolute azimuth value.
const char * LoadParkData()
virtual bool updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
Definition indidome.cpp:287
INDI::PropertyNumber DomeAbsPosNP
Definition indidome.h:558
DomeMeasurements
Measurements necessary for dome-slit synchronization. All values are in meters. The displacements are...
Definition indidome.h:82
@ DM_NORTH_DISPLACEMENT
Definition indidome.h:85
@ DM_EAST_DISPLACEMENT
Definition indidome.h:86
@ DM_SHUTTER_WIDTH
Definition indidome.h:84
@ DM_DOME_RADIUS
Definition indidome.h:83
@ DM_OTA_OFFSET
Definition indidome.h:88
@ DM_UP_DISPLACEMENT
Definition indidome.h:87
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
Definition indidome.cpp:508
IPState m_MountState
Definition indidome.h:635
virtual bool SetDefaultPark()
SetDefaultPark Set default coordinates/encoders value as the desired parking position.
bool Intersection(point3D p1, point3D p2, double r, double &mu1, double &mu2)
Intersection Calculate the intersection of a ray and a sphere. The line segment is defined from p1 to...
virtual bool SetBacklashEnabled(bool enabled)
SetBacklashEnabled Enables or disables the dome backlash compensation.
double Sec(double x)
virtual IPState MoveAbs(double az)
Move the Dome to an absolute azimuth.
bool CanAbort()
Definition indidome.h:218
INDI::PropertySwitch DomeMotionSP
Definition indidome.h:556
IGeographicCoordinates observer
Definition indidome.h:638
virtual bool ISSnoopDevice(XMLEle *root) override
Process a snoop event from INDI server. This function is called when a snooped property is updated in...
Definition indidome.cpp:856
@ ACTIVE_OUTPUT
Definition indidome.h:581
static void buttonHelper(const char *button_n, ISState state, void *context)
INDI::PropertySwitch DomeBacklashSP
Definition indidome.h:616
virtual bool saveConfigItems(FILE *fp) override
saveConfigItems Saves the Device Port and Dome Presets in the configuration file
virtual bool SetCurrentPark()
SetCurrentPark Set current coordinates/encoders value as the desired parking position.
bool CanAbsMove()
Definition indidome.h:226
@ PARK_AZ_ENCODER
Definition indidome.h:107
virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override
Process the client newSwitch command.
Definition indidome.cpp:824
void setShutterState(const ShutterState &value)
bool OpticalVector(double Az, double Alt, point3D &OV)
OpticalVector This function calculates a second point for determining the optical axis.
virtual ~Dome()
Definition indidome.cpp:80
bool HasBacklash()
Definition indidome.h:274
void setDomeState(const DomeState &value)
@ MOUNT_IGNORED
Definition indidome.h:122
void SetShutterParkPolicyHandledByDriver(bool enabled)
SetShutterParkPolicyHandledByDriver By default, INDI::Dome applies the shutter park policy (DOME_SHUT...
Definition indidome.h:393
bool InitPark()
InitPark Loads parking data (stored in ~/.indi/ParkData.xml) that contains parking status and parking...
Connection::Serial * serialConnection
Definition indidome.h:629
INDI::PropertySwitch MountPolicySP
Definition indidome.h:585
void SetParkDataType(DomeParkData type)
setParkDataType Sets the type of parking data stored in the park data file and presented to the user.
bool WriteParkData()
INDI::PropertySwitch DomeAutoSyncSP
Definition indidome.h:613
INDI::PropertySwitch DomeShutterSP
Definition indidome.h:568
DomeParkData parkDataType
Definition indidome.h:622
ShutterState getShutterState() const
Definition indidome.h:291
virtual bool Handshake()
perform handshake with device to check communication
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
Definition indidome.cpp:399
bool HaveLatLong
Definition indidome.h:640
virtual IPState ControlShutter(ShutterOperation operation)
Open or Close shutter.
INDI::PropertyText ActiveDeviceTP
Definition indidome.h:576
DomeState getDomeState() const
Definition indidome.h:285
INDI::PropertySwitch OTASideSP
Definition indidome.h:600
bool GetTargetAz(double &Az, double &Alt, double &minAz, double &maxAz)
GetTargetAz.
INDI::PropertyNumber DomeSyncNP
Definition indidome.h:566
uint8_t getDomeConnection() const
virtual IPState Move(DomeDirection dir, DomeMotionCommand operation)
Move the Dome in a particular direction.
INDI::PropertyNumber PresetNP
Definition indidome.h:595
virtual bool Abort()
Abort all dome motion.
The Timer class provides repetitive and single-shot timers.
Definition inditimer.h:41
double dec
ISState
Switch state.
Definition indiapi.h:148
IPState
Property state.
Definition indiapi.h:158
*brief user defined string literal for JSON values *sa std::size_t n
struct xml_ele_ XMLEle
Definition lilxml.h:81
Combines all INDI Connection Plugins. Each INDI connection plugin is responsible of managing communic...
Definition arduino_st4.h:34
Namespace to encapsulate INDI client, drivers, and mediator classes.
uint16_t type
Definition pwc-ioctl.h:0
Holds the connection mode of the Dome.
double y
Definition indidome.h:34
double x
Definition indidome.h:34
double z
Definition indidome.h:34