Instrument Neutral Distributed Interface INDI 2.2.5
tcfs.h
Go to the documentation of this file.
1/*
2 INDI Driver for Optec TCF-S Focuser
3
4 Copyright (C) 2010 Jasem Mutlaq ([email protected])
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#include "indifocuser.h"
25
26#include <string>
27
28#define TCFS_MAX_CMD 16
29#define TCFS_ERROR_BUFFER 1024
30
31class TCFS : public INDI::Focuser
32{
33 public:
35 {
36 FMMODE, // Focuser Manual Mode
37 FFMODE, // Focuser Free Mode
38 FAMODE, // Focuser Auto-A Mode
39 FBMODE, // Focuser Auto-B Mode
40 FCENTR, // Focus Center
41 FIN, // Focuser In “nnnn”
42 FOUT, // Focuser Out “nnnn”
43 FPOSRO, // Focuser Position Read Out
44 FTMPRO, // Focuser Temperature Read Out
45 FSLEEP, // Focuser Sleep
46 FWAKUP, // Focuser Wake Up
47 FHOME, // Focuser Home Command
48 FRSLOP, // Focuser Read Slope Command
49 FLSLOP, // Focuser Load Slope Command
50 FQUIET, // Focuser Quiet Command
51 FDELAY, // Focuser Load Delay Command
52 FRSIGN, // Focuser Read Slope Sign Command
53 FLSIGN, // Focuser Load Slope Sign Command
54 FFWVER, // Focuser Firmware Version
55 };
56
63
71
72 TCFS();
73 virtual ~TCFS() = default;
74
75 // Standard INDI interface functions
76 virtual bool Handshake() override;
77 virtual bool Disconnect() override;
78 const char *getDefaultName() override;
79 virtual bool initProperties() override;
80 virtual bool updateProperties() override;
81 virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override;
82 virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override;
83 virtual bool saveConfigItems(FILE *fp) override;
84
85 protected:
86 virtual IPState MoveAbsFocuser(uint32_t targetTicks) override;
87 virtual IPState MoveRelFocuser(FocusDirection dir, uint32_t ticks) override;
88 virtual void TimerHit() override;
89 void GetFocusParams();
90 bool SetManualMode();
91
92 private:
93 bool read_tcfs(char *response, bool silent = false);
94 bool dispatch_command(TCFSCommand command_type, int val = 0, TCFSMode m = MANUAL);
95
96 INumber FocusModeAN[3];
97 INumberVectorProperty FocusModeANP;
98 INumber FocusModeBN[3];
99 INumberVectorProperty FocusModeBNP;
100 ISwitch FocusTelemetryS[2];
101 ISwitchVectorProperty FocusTelemetrySP;
102 ISwitch FocusModeS[3];
103 ISwitchVectorProperty FocusModeSP;
104 ISwitch FocusPowerS[2];
105 ISwitchVectorProperty FocusPowerSP;
106 ISwitch FocusGotoS[4];
107 ISwitchVectorProperty FocusGotoSP;
108 INumber FocusTemperatureN[1];
109 INumberVectorProperty FocusTemperatureNP;
110 ISwitch FocusStartModeS[3];
111 ISwitchVectorProperty FocusStartModeSP;
112
113 unsigned int simulated_position { 3000 };
114 float simulated_temperature { 25.4 };
115 TCFSMode currentMode;
116
117 unsigned int targetTicks { 0 };
118 unsigned int targetPosition { 0 };
119 bool isTCFS3 { false };
120};
Definition tcfs.h:32
void GetFocusParams()
Definition tcfs.cpp:198
virtual bool saveConfigItems(FILE *fp) override
Definition tcfs.cpp:178
TCFS()
Definition tcfs.cpp:41
TCFSCommand
Definition tcfs.h:35
@ FDELAY
Definition tcfs.h:51
@ FQUIET
Definition tcfs.h:50
@ FPOSRO
Definition tcfs.h:43
@ FWAKUP
Definition tcfs.h:46
@ FBMODE
Definition tcfs.h:39
@ FMMODE
Definition tcfs.h:36
@ FAMODE
Definition tcfs.h:38
@ FFWVER
Definition tcfs.h:54
@ FOUT
Definition tcfs.h:42
@ FHOME
Definition tcfs.h:47
@ FLSIGN
Definition tcfs.h:53
@ FTMPRO
Definition tcfs.h:44
@ FFMODE
Definition tcfs.h:37
@ FSLEEP
Definition tcfs.h:45
@ FRSLOP
Definition tcfs.h:48
@ FRSIGN
Definition tcfs.h:52
@ FLSLOP
Definition tcfs.h:49
@ FCENTR
Definition tcfs.h:40
@ FIN
Definition tcfs.h:41
virtual bool Handshake() override
Performs a device-specific handshake after a connection is established. This method should be overrid...
Definition tcfs.cpp:251
TCFSError
Definition tcfs.h:65
@ ER_1
Definition tcfs.h:67
@ ER_3
Definition tcfs.h:69
@ ER_2
Definition tcfs.h:68
@ NO_ERROR
Definition tcfs.h:66
virtual bool initProperties() override
Initializes the default properties for the focuser device. Sets up standard INDI properties,...
Definition tcfs.cpp:53
const char * getDefaultName() override
Definition tcfs.cpp:1203
bool SetManualMode()
Definition tcfs.cpp:286
virtual IPState MoveRelFocuser(FocusDirection dir, uint32_t ticks) override
MoveFocuser the focuser to an relative position.
Definition tcfs.cpp:751
virtual ~TCFS()=default
virtual void TimerHit() override
Callback function to be called once SetTimer duration elapses.
Definition tcfs.cpp:925
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...
Definition tcfs.cpp:322
virtual bool updateProperties() override
Updates the state and definition of properties based on the current connection status....
Definition tcfs.cpp:142
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...
Definition tcfs.cpp:405
virtual bool Disconnect() override
Disconnect from device.
Definition tcfs.cpp:308
virtual IPState MoveAbsFocuser(uint32_t targetTicks) override
MoveFocuser the focuser to an absolute position.
Definition tcfs.cpp:744
TCFSMode
Definition tcfs.h:58
@ MANUAL
Definition tcfs.h:59
@ MODE_B
Definition tcfs.h:61
@ MODE_A
Definition tcfs.h:60
ISState
Switch state.
Definition indiapi.h:148
IPState
Property state.
Definition indiapi.h:158
One number descriptor.
One switch descriptor.
Number vector property descriptor.
Definition indiapi.h:317
Switch vector property descriptor.
Definition indiapi.h:365