Debian Codegraph @

maxdomeiidriver.h

raw
1 /*
2 Max Dome II Driver
3 Copyright (C) 2009 Ferran Casarramona ([email protected])
4 Refactored by Juan Menendez
5
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with this library; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19
20 */
21
22 #pragma once
23
24 // Direction fo azimuth movement
25 #define MAXDOMEII_EW_DIR 0x01
26 #define MAXDOMEII_WE_DIR 0x02
27
28 // Azimuth motor status. When motor is idle, sometimes returns 0, sometimes 4. After connect, it returns 5
29 enum AzStatus
30 {
31 AS_IDLE = 1,
32 AS_MOVING_WE,
33 AS_MOVING_EW,
34 AS_IDLE2,
35 AS_ERROR
36 };
37
38 // Shutter status
39 enum ShStatus
40 {
41 SS_CLOSED = 0,
42 SS_OPENING,
43 SS_OPEN,
44 SS_CLOSING,
45 SS_ABORTED,
46 SS_ERROR
47 };
48
49 extern const char *ErrorMessages[];
50
51 void hexDump(char *buf, const char *data, int size);
52
53
54 class MaxDomeIIDriver
55 {
56 public:
57 MaxDomeIIDriver() { fd = 0; }
58
59 const char *getDeviceName();
60 void SetPortFD(int port_fd);
61 void SetDevice(const char *name);
62
63 int Connect(const char *device);
64 int Disconnect();
65
66 int AbortAzimuth();
67 int HomeAzimuth();
68 int GotoAzimuth(int nDir, int nTicks);
69 int Status(ShStatus *shStatus, AzStatus *azStatus,
70 unsigned *azimuthPos, unsigned *homePos);
71 int Ack();
72 int SetPark(int nParkOnShutter, int nTicks);
73 int SetTicksPerTurn(int nTicks);
74 int Park();
75
76 // Shutter commands
77 int OpenShutter();
78 int OpenUpperShutterOnly();
79 int CloseShutter();
80 int AbortShutter();
81 int ExitShutter();
82
83 protected:
84 int ReadResponse();
85 int SendCommand(char cmdId, const char *payload, int payloadLen);
86
87 private:
88 int fd;
89 char buffer[16];
90 };