Instrument Neutral Distributed Interface INDI 2.2.5
deepskydad_af1.h
Go to the documentation of this file.
1/*
2 Deep Sky Dad AF1
3
4 Copyright (C) 2019 Pavle Gartner
5
6 Based on Moonline driver.
7 Copyright (C) 2013-2019 Jasem Mutlaq ([email protected])
8
9 This library is free software; you can redistribute it and/or
10 modify it under the terms of the GNU Lesser General Public
11 License as published by the Free Software Foundation; either
12 version 2.1 of the License, or (at your option) any later version.
13
14 This library is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 Lesser General Public License for more details.
18
19 You should have received a copy of the GNU Lesser General Public
20 License along with this library; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22
23*/
24
25#pragma once
26
27#include "indifocuser.h"
28
29#include <chrono>
30
32{
33 public:
35 virtual ~DeepSkyDadAF1() override = default;
36
37 typedef enum { FULL, HALF, QUARTER, EIGHT } FocusStepMode;
38
41
42 const char * getDefaultName() override;
43 virtual bool initProperties() override;
44 virtual bool updateProperties() override;
45 virtual bool ISNewSwitch(const char * dev, const char * name, ISState * states, char * names[], int n) override;
46 virtual bool ISNewNumber(const char * dev, const char * name, double values[], char * names[], int n) override;
47
48 static void timedMoveHelper(void * context);
49 protected:
50 /*
51 * @brief Handshake Try to communicate with Focuser and see if there is a valid response.
52 * @return True if communication is successful, false otherwise.
53 */
54 virtual bool Handshake() override;
55
63 virtual IPState MoveFocuser(FocusDirection dir, int speed, uint16_t duration) override;
64
65 virtual bool SetFocuserMaxPosition(uint32_t ticks) override;
66
72 virtual IPState MoveAbsFocuser(uint32_t targetTicks) override;
73
80 virtual IPState MoveRelFocuser(FocusDirection dir, uint32_t ticks) override;
81
82 virtual bool SyncFocuser(uint32_t ticks) override;
83 virtual bool ReverseFocuser(bool enabled) override;
84 virtual bool AbortFocuser() override;
85 virtual void TimerHit() override;
86 virtual bool saveConfigItems(FILE * fp) override;
87
88 private:
89 bool Ack();
97 bool sendCommand(const char * cmd, char * res = nullptr);
98 bool sendCommandSet(const char * cmd);
99
100 // Get initial focuser parameter when we first connect
101 void GetFocusParams();
102 bool readStepMode();
103 bool readPosition();
104 bool readMaxPosition();
105 bool readMaxMovement();
106 bool readSettleBuffer();
107 bool readIdleCoilsTimeout();
108 bool readCoilsMode();
109 bool readCurrentMove();
110 bool readCurrentHold();
111 bool isMoving();
112
113 void timedMoveCallback();
114
115 bool MoveFocuser(uint32_t position);
116
117
118 double targetPos { 0 }, lastPos { 0 };
119
120
121 // Step modes
122 INDI::PropertySwitch StepModeSP {4};
123
124 // Coils mode
125 INDI::PropertySwitch CoilsModeSP {3};
126
127 //Current move
128 INDI::PropertySwitch CurrentMoveSP {4};
129
130 //Current hold
131 INDI::PropertySwitch CurrentHoldSP {4};
132
133 // Max movement
134 INDI::PropertyNumber FocusMaxMoveNP {1};
135
136 // Settle buffer
137 INDI::PropertyNumber SettleBufferNP {1};
138
139 // Idle coils timeout (ms)
140 INumber IdleCoilsTimeoutN[1];
141 INumberVectorProperty IdleCoilsTimeoutNP;
142
143 // Response Buffer
144
145 static const uint8_t DSD_RES { 32 };
146 static const char DSD_DEL { ')' };
147 static const uint8_t DSD_TIMEOUT { 3 };
148};
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...
virtual bool updateProperties() override
Updates the state and definition of properties based on the current connection status....
virtual ~DeepSkyDadAF1() override=default
static void timedMoveHelper(void *context)
const char * getDefaultName() override
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Processes incoming new number values from the client for this device. Handles updates to FocuserInter...
virtual IPState MoveAbsFocuser(uint32_t targetTicks) override
MoveAbsFocuser Move to an absolute target position.
virtual bool AbortFocuser() override
AbortFocuser all focus motion.
virtual void TimerHit() override
Callback function to be called once SetTimer duration elapses.
virtual bool initProperties() override
Initializes the default properties for the focuser device. Sets up standard INDI properties,...
virtual bool Handshake() override
Performs a device-specific handshake after a connection is established. This method should be overrid...
virtual bool ReverseFocuser(bool enabled) override
ReverseFocuser Reverse focuser motion direction.
virtual IPState MoveFocuser(FocusDirection dir, int speed, uint16_t duration) override
MoveFocuser Move focuser in a specific direction and speed for period of time.
virtual IPState MoveRelFocuser(FocusDirection dir, uint32_t ticks) override
MoveRelFocuser Move focuser for a relative amount of ticks in a specific direction.
virtual bool saveConfigItems(FILE *fp) override
virtual bool SetFocuserMaxPosition(uint32_t ticks) override
SetFocuserMaxPosition Update focuser maximum position. It only updates the PresetNP property limits.
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
uint8_t cmd[4]
Definition pwc-ioctl.h:2
One number descriptor.
Number vector property descriptor.
Definition indiapi.h:317