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,
163 DOME_HAS_BACKLASH = 1 << 7
164 };
165
169 enum
170 {
173 CONNECTION_TCP = 1 << 2
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
344 virtual IPState Park();
345
352 virtual IPState UnPark();
353
359 virtual bool SetBacklash(int32_t steps);
360
366 virtual bool SetBacklashEnabled(bool enabled);
367
374 virtual IPState ControlShutter(ShutterOperation operation);
375
381 const char * GetShutterStatusString(ShutterState status);
382
388
397 bool InitPark();
398
403 bool isParked();
404
409 void SetParked(bool isparked);
410
414 double GetAxis1Park();
415
419 double GetAxis1ParkDefault();
420
425 void SetAxis1Park(double value);
426
431 void SetAxis1ParkDefault(double steps);
432
437 virtual bool SetCurrentPark();
438
443 virtual bool SetDefaultPark();
444
445 //Park
446 const char * LoadParkData();
447 bool WriteParkData();
448
457 bool GetTargetAz(double &Az, double &Alt, double &minAz, double &maxAz);
458
472 bool Intersection(point3D p1, point3D p2, double r, double &mu1, double &mu2);
473
483 bool OpticalCenter(point3D MountCenter, double dOpticalAxis, double Lat, double Ah, point3D &OP);
484
492 bool OpticalVector(double Az, double Alt, point3D &OV);
493
501 bool CheckHorizon(double HA, double dec, double lat);
502
508 virtual bool saveConfigItems(FILE * fp) override;
509
513 void UpdateMountCoords();
514
519 virtual void UpdateAutoSync();
520
522 virtual bool Handshake();
523
527 virtual void ActiveDevicesUpdated() {};
528
529 double Csc(double x);
530 double Sec(double x);
531
533
535
537
539
541
543
545
547
549
551
553
555 enum
556 {
560 };
561
562 // Switch to lock id mount is unparked
564
565 // Shutter control on Park/Unpark
567 enum
568 {
571 };
572
575
577
579 // 0 is East, 1 is West, 2 is as reported by mout, 3 as deducted by Hour Angle
580 // 4 ignore pier side and perform as in a fork mount
581 enum
582 {
588 };
589
590 int mountOTASide = 0; // Side of the telescope with respect of the mount, 1: west, -1: east, 0 not reported
592
593 // Backlash toggle
595
596 // Backlash steps
598
599 uint32_t capability;
601
603
604 // For Serial and TCP connections
605 int PortFD = -1;
606
609
610 // States
614
615 // Observer geographic coords. Snooped from mount driver.
617 // Do we have valid geographic coords from mount driver?
618 bool HaveLatLong = false;
619
620 // Mount horizontal and equatorial coords. Snoops from mount driver.
623 // Do we have valid coords from mount driver?
624 bool HaveRaDec = false;
625
626 private:
627 void processButton(const char * button_n, ISState state);
628 void triggerSnoop(const char * driverName, const char * propertyName);
633 void SyncParkStatus(bool isparked);
638 const char * LoadParkXML();
639
645 std::string GetHomeDirectory() const;
646
647 Controller * controller = nullptr;
648
649 bool IsParked = false;
650 bool IsMountParked = true;
651 bool IsLocked = true;
652 bool AutoSyncWarning = false;
653 bool UseHourAngle = false;
654
655 const char * ParkDeviceName;
656 const std::string ParkDataFileName;
657 INDI::Timer m_MountUpdateTimer;
658 //int m_HorizontalUpdateTimerID { -1 };
659 XMLEle * ParkdataXmlRoot, *ParkdeviceXml, *ParkstatusXml, *ParkpositionXml, *ParkpositionAxis1Xml;
660
661 double Axis1ParkPosition;
662 double Axis1DefaultParkPosition;
663
664 bool callHandshake();
665 uint8_t domeConnection = CONNECTION_SERIAL | CONNECTION_TCP;
666
667 // How often we update horizontal coordinates (10 seconds).
668 static constexpr uint32_t HORZ_UPDATE_TIMER { 10000 };
669};
670
671}
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 ...
Class to provide extended functionality for devices in addition to the functionality provided by INDI...
Class to provide general functionality of a Dome device.
Definition indidome.h:75
bool CanPark()
Definition indidome.h:242
INDI::PropertySwitch PresetGotoSP
Definition indidome.h:574
double prev_alt
Definition indidome.h:602
INDI::IHorizontalCoordinates mountHoriztonalCoords
Definition indidome.h:621
Connection::TCP * tcpConnection
Definition indidome.h:608
DomeState m_DomeState
Definition indidome.h:611
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:599
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:566
@ SHUTTER_OPEN_ON_UNPARK
Definition indidome.h:570
@ SHUTTER_CLOSE_ON_PARK
Definition indidome.h:569
INDI::PropertySwitch ParkOptionSP
Definition indidome.h:552
const char * GetShutterStatusString(ShutterState status)
getShutterStatusString
INDI::IEquatorialCoordinates mountEquatorialCoords
Definition indidome.h:622
bool CheckHorizon(double HA, double dec, double lat)
CheckHorizon Returns true if telescope points above horizon.
INDI::PropertyNumber DomeRelPosNP
Definition indidome.h:538
bool isParked()
isParked is dome currently parked?
bool HaveRaDec
Definition indidome.h:624
INDI::PropertyNumber DomeParamNP
Definition indidome.h:542
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.
@ DM_OTA_SIDE_EAST
Definition indidome.h:583
@ DM_OTA_SIDE_MOUNT
Definition indidome.h:585
@ DM_OTA_SIDE_IGNORE
Definition indidome.h:587
@ DM_OTA_SIDE_WEST
Definition indidome.h:584
@ DM_OTA_SIDE_HA
Definition indidome.h:586
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:550
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:270
ShutterState m_ShutterState
Definition indidome.h:612
double prev_dec
Definition indidome.h:602
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:602
void UpdateMountCoords()
updateCoords updates the horizontal coordinates (Az & Alt) of the mount from the snooped RA,...
IPState getMountState() const
void SetAxis1ParkDefault(double steps)
SetAxis1Park Set default AZ parking position.
ShutterOperation
Shutter operation command.
Definition indidome.h:114
@ SHUTTER_CLOSE
Definition indidome.h:116
INDI::PropertySwitch AbortSP
Definition indidome.h:540
INDI::PropertyNumber DomeSpeedNP
Definition indidome.h:532
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:105
double prev_az
Definition indidome.h:602
INDI::PropertyNumber DomeMeasurementsNP
Definition indidome.h:576
virtual void UpdateAutoSync()
UpdateAutoSync This function calculates the target dome azimuth from the mount's target coordinates g...
INDI::PropertyNumber DomeBacklashNP
Definition indidome.h:597
@ 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 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?
virtual void ActiveDevicesUpdated()
Definition indidome.h:527
INDI::PropertySwitch ParkSP
Definition indidome.h:548
int mountOTASide
Definition indidome.h:590
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: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
IPState m_MountState
Definition indidome.h:613
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:534
IGeographicCoordinates observer
Definition indidome.h:616
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:841
static void buttonHelper(const char *button_n, ISState state, void *context)
@ CONNECTION_SERIAL
Definition indidome.h:172
@ CONNECTION_TCP
Definition indidome.h:173
@ CONNECTION_NONE
Definition indidome.h:171
INDI::PropertySwitch DomeBacklashSP
Definition indidome.h:594
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:809
void setShutterState(const ShutterState &value)
@ ACTIVE_OUTPUT
Definition indidome.h:559
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:77
bool HasBacklash()
Definition indidome.h:274
void setDomeState(const DomeState &value)
@ MOUNT_IGNORED
Definition indidome.h:122
bool InitPark()
InitPark Loads parking data (stored in ~/.indi/ParkData.xml) that contains parking status and parking...
Connection::Serial * serialConnection
Definition indidome.h:607
INDI::PropertySwitch MountPolicySP
Definition indidome.h:563
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:591
INDI::PropertySwitch DomeShutterSP
Definition indidome.h:546
DomeParkData parkDataType
Definition indidome.h:600
ShutterState getShutterState() const
Definition indidome.h:291
virtual bool Handshake()
perform handshake with device to check communication
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 ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
Definition indidome.cpp:394
bool HaveLatLong
Definition indidome.h:618
virtual IPState ControlShutter(ShutterOperation operation)
Open or Close shutter.
enum INDI::Dome::@439 DomeConnection
INDI::PropertyText ActiveDeviceTP
Definition indidome.h:554
DomeState getDomeState() const
Definition indidome.h:285
INDI::PropertySwitch OTASideSP
Definition indidome.h:578
bool GetTargetAz(double &Az, double &Alt, double &minAz, double &maxAz)
GetTargetAz.
INDI::PropertyNumber DomeSyncNP
Definition indidome.h:544
uint8_t getDomeConnection() const
virtual IPState Move(DomeDirection dir, DomeMotionCommand operation)
Move the Dome in a particular direction.
INDI::PropertyNumber PresetNP
Definition indidome.h:573
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
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
double x
Definition indidome.h:34