Debian Codegraph @

maxdomeii.h

raw
1 /*
2 MaxDome II
3 Copyright (C) 2009 Ferran Casarramona ([email protected])
4
5 Migrated to INDI::Dome by Jasem Mutlaq (2014)
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or (at your option) any later version.
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 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20
21 */
22
23 #pragma once
24
25 #include <indidome.h>
26 #include "maxdomeiidriver.h"
27
28 #define MD_AZIMUTH_IDLE 0
29 #define MD_AZIMUTH_MOVING 1
30 #define MD_AZIMUTH_HOMING 2
31
32 class MaxDomeII : public INDI::Dome
33 {
34 public:
35 MaxDomeII();
36 ~MaxDomeII();
37
38 virtual const char *getDefaultName() override;
39 virtual bool initProperties() override;
40 virtual bool updateProperties() override;
41 virtual bool saveConfigItems(FILE *fp) override;
42
43 virtual bool Disconnect() override;
44 virtual bool Handshake() override;
45
46 virtual void TimerHit() override;
47
48 virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override;
49 virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override;
50
51 virtual IPState MoveAbs(double az) override;
52 virtual IPState Move(DomeDirection dir, DomeMotionCommand operation) override;
53
54 //virtual IPState Home();
55 virtual bool Abort() override;
56
57 protected:
58 // Parking
59 IPState ConfigurePark(int nCSBP, double ParkAzimuth);
60 virtual bool SetCurrentPark() override;
61 virtual bool SetDefaultPark() override;
62 virtual IPState ControlShutter(ShutterOperation operation) override;
63
64 /*******************************************************/
65 /* Misc routines
66 ********************************************************/
67 int AzimuthDistance(int nPos1, int nPos2);
68 double TicksToAzimuth(int nTicks);
69 int AzimuthToTicks(double nAzimuth);
70 int handle_driver_error(int *error, int *nRetry); // Handles errors returned by driver
71
72 ISwitch ShutterModeS[2];
73 ISwitchVectorProperty ShutterModeSP;
74
75 INumber ShutterOperationAzimuthN[1];
76 INumberVectorProperty ShutterOperationAzimuthNP;
77
78 ISwitch ShutterConflictS[2];
79 ISwitchVectorProperty ShutterConflictSP;
80
81 ISwitch HomeS[1];
82 ISwitchVectorProperty HomeSP;
83
84 INumber TicksPerTurnN[1];
85 INumberVectorProperty TicksPerTurnNP;
86
87 INumber WatchDogN[1];
88 INumberVectorProperty WatchDogNP;
89
90 INumber HomeAzimuthN[1];
91 INumberVectorProperty HomeAzimuthNP;
92
93 INumber HomePosRN[1];
94 INumberVectorProperty HomePosRNP;
95
96 private:
97 int nTicksPerTurn; // Number of ticks per turn of azimuth dome
98 unsigned nCurrentTicks; // Position as reported by the MaxDome II
99 int nCloseShutterBeforePark; // 0 no close shutter
100 double nParkPosition; // Park position
101 double nHomeAzimuth; // Azimuth of home position
102 int nHomeTicks; // Ticks from 0 azimuth to home
103 int nTimeSinceShutterStart; // Timer since shutter movement has started, in order to check timeouts
104 int nTimeSinceAzimuthStart; // Timer since azimuth movement has started, in order to check timeouts
105 int nTargetAzimuth;
106 int nTimeSinceLastCommunication; // Used by Watch Dog
107
108 double prev_az, prev_alt;
109
110 bool SetupParms();
111
112 MaxDomeIIDriver driver;
113 };