Instrument Neutral Distributed Interface INDI  2.0.2
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 (mutlaqja@ikarustech.com)
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 
31 class 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 
57  enum TCFSMode
58  {
61  MODE_B
62  };
63 
64  enum TCFSError
65  {
69  ER_3
70  };
71 
72  TCFS();
73  virtual ~TCFS() = default;
74 
75  // Standard INDI interface fucntions
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:199
virtual bool saveConfigItems(FILE *fp) override
saveConfigItems Saves the Device Port and Focuser Presets in the configuration file
Definition: tcfs.cpp:179
TCFS()
Definition: tcfs.cpp:42
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
perform handshake with device to check communication
Definition: tcfs.cpp:252
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
Initilize properties initial state and value. The child class must implement this function.
Definition: tcfs.cpp:54
const char * getDefaultName() override
Definition: tcfs.cpp:1204
bool SetManualMode()
Definition: tcfs.cpp:287
virtual IPState MoveRelFocuser(FocusDirection dir, uint32_t ticks) override
MoveFocuser the focuser to an relative position.
Definition: tcfs.cpp:752
virtual ~TCFS()=default
virtual void TimerHit() override
Callback function to be called once SetTimer duration elapses.
Definition: tcfs.cpp:926
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
Definition: tcfs.cpp:323
virtual bool updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
Definition: tcfs.cpp:143
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
Definition: tcfs.cpp:406
virtual bool Disconnect() override
Disconnect from device.
Definition: tcfs.cpp:309
virtual IPState MoveAbsFocuser(uint32_t targetTicks) override
MoveFocuser the focuser to an absolute position.
Definition: tcfs.cpp:745
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:150
IPState
Property state.
Definition: indiapi.h:160
One number descriptor.
One switch descriptor.
Number vector property descriptor.
Definition: indiapi.h:319
Switch vector property descriptor.
Definition: indiapi.h:367