Instrument Neutral Distributed Interface INDI 2.2.5
dreamfocuser.h
Go to the documentation of this file.
1/*
2 INDI Driver for DreamFocuser
3
4 Copyright (C) 2016 Piotr Dlugosz
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#ifndef DREAMFOCUSER_H
23#define DREAMFOCUSER_H
24
25#include <string>
26
27#include <indidevapi.h>
28#include <indicom.h>
29#include <indifocuser.h>
30
31using namespace std;
32
33#define DREAMFOCUSER_STEP_SIZE 32
34#define DREAMFOCUSER_ERROR_BUFFER 1024
35
36
38{
39
40 public:
41
43 {
44 char M = 'M';
45 char k;
46 unsigned char a;
47 unsigned char b;
48 unsigned char c;
49 unsigned char d;
50 unsigned char addr = '\0';
51 unsigned char z;
52 };
53
55
56 const char *getDefaultName() override;
57 virtual bool initProperties() override;
58 virtual bool updateProperties() override;
59 //virtual bool saveConfigItems(FILE *fp) override;
60 //virtual bool ISNewNumber (const char *dev, const char *name, double values[], char *names[], int n) override;
61 virtual bool ISNewSwitch (const char *dev, const char *name, ISState *states, char *names[], int n) override;
62
63 protected:
64 virtual bool Handshake() override;
65 virtual void TimerHit() override;
66 virtual bool SyncFocuser(uint32_t ticks) override;
67
68 virtual IPState MoveAbsFocuser(uint32_t ticks) override;
69 virtual IPState MoveRelFocuser(FocusDirection dir, uint32_t ticks) override;
70 virtual bool AbortFocuser() override;
71
72 private:
73
74 INDI::PropertyNumber TemperatureNP {1};
75
76 INDI::PropertyNumber WeatherNP {2};
77 enum
78 {
79 FOCUS_HUMIDITY,
80 FOCUS_DEWPOINT
81 };
82
83 INDI::PropertySwitch ParkSP {2};
84
85 INDI::PropertySwitch StatusSP {3};
86 enum
87 {
88 ABSOLUTE,
89 MOVING,
90 PARKED
91 };
92
93 //INumber SetBacklashN[1];
94 //INumberVectorProperty SetBacklashNP;
95
96 unsigned char calculate_checksum(DreamFocuserCommand c);
97 bool send_command(char k, uint32_t l = 0, unsigned char addr = 0);
98 bool read_response();
99 bool dispatch_command(char k, uint32_t l = 0, unsigned char addr = 0);
100
101 bool getTemperature();
102 bool getStatus();
103 bool getPosition();
104 bool getMaxPosition();
105 bool setPosition(int32_t position);
106 bool setSync(uint32_t position = 0);
107 bool setPark();
108
109 // Variables
110 float currentTemperature;
111 float currentHumidity;
112 int32_t currentPosition;
113 int32_t currentMaxPosition;
114 bool isAbsolute;
115 bool isMoving;
116 unsigned char isParked;
117 bool isVcc12V;
118 DreamFocuserCommand currentResponse;
119};
120
121#endif
virtual bool Handshake() override
Performs a device-specific handshake after a connection is established. This method should be overrid...
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Processes incoming new switch states from the client for this device. Handles updates to FocuserInter...
const char * getDefaultName() override
virtual bool initProperties() override
Initializes the default properties for the focuser device. Sets up standard INDI properties,...
virtual void TimerHit() override
Callback function to be called once SetTimer duration elapses.
virtual IPState MoveRelFocuser(FocusDirection dir, uint32_t ticks) override
MoveFocuser the focuser to an relative position.
virtual bool updateProperties() override
Updates the state and definition of properties based on the current connection status....
virtual IPState MoveAbsFocuser(uint32_t ticks) override
MoveFocuser the focuser to an absolute position.
virtual bool AbortFocuser() override
AbortFocuser all focus motion.
virtual bool SyncFocuser(uint32_t ticks) override
SyncFocuser Set current position to ticks without moving the focuser.
ISState
Switch state.
Definition indiapi.h:148
IPState
Property state.
Definition indiapi.h:158
Implementations for common driver routines.
Interface to the reference INDI C API device implementation on the Device Driver side.