Instrument Neutral Distributed Interface INDI  1.9.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 (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  {
62  };
63 
64  enum TCFSError
65  {
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 };
TCFS::FQUIET
@ FQUIET
Definition: tcfs.h:50
TCFS::FHOME
@ FHOME
Definition: tcfs.h:47
TCFS::FRSIGN
@ FRSIGN
Definition: tcfs.h:52
TCFS::FPOSRO
@ FPOSRO
Definition: tcfs.h:43
TCFS::Handshake
virtual bool Handshake() override
perform handshake with device to check communication
Definition: tcfs.cpp:249
IPState
IPState
Property state.
Definition: indiapi.h:158
TCFS::FRSLOP
@ FRSLOP
Definition: tcfs.h:48
TCFS::MANUAL
@ MANUAL
Definition: tcfs.h:59
ISwitch
One switch descriptor.
TCFS::FDELAY
@ FDELAY
Definition: tcfs.h:51
TCFS::FFWVER
@ FFWVER
Definition: tcfs.h:54
TCFS::ER_1
@ ER_1
Definition: tcfs.h:67
INumber
One number descriptor.
TCFS::Disconnect
virtual bool Disconnect() override
Disconnect from device.
Definition: tcfs.cpp:306
TCFS::FMMODE
@ FMMODE
Definition: tcfs.h:36
TCFS::ISNewNumber
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
Definition: tcfs.cpp:320
TCFS::TimerHit
virtual void TimerHit() override
Callback function to be called once SetTimer duration elapses.
Definition: tcfs.cpp:923
TCFS::FLSLOP
@ FLSLOP
Definition: tcfs.h:49
TCFS::TCFSMode
TCFSMode
Definition: tcfs.h:57
TCFS::~TCFS
virtual ~TCFS()=default
indifocuser.h
TCFS::FFMODE
@ FFMODE
Definition: tcfs.h:37
TCFS::GetFocusParams
void GetFocusParams()
Definition: tcfs.cpp:196
TCFS::MoveAbsFocuser
virtual IPState MoveAbsFocuser(uint32_t targetTicks) override
MoveFocuser the focuser to an absolute position.
Definition: tcfs.cpp:742
TCFS::ER_2
@ ER_2
Definition: tcfs.h:68
TCFS::FAMODE
@ FAMODE
Definition: tcfs.h:38
TCFS::FTMPRO
@ FTMPRO
Definition: tcfs.h:44
_INumberVectorProperty
Number vector property descriptor.
Definition: indiapi.h:317
TCFS::ER_3
@ ER_3
Definition: tcfs.h:69
TCFS::MoveRelFocuser
virtual IPState MoveRelFocuser(FocusDirection dir, uint32_t ticks) override
MoveFocuser the focuser to an relative position.
Definition: tcfs.cpp:749
TCFS::FCENTR
@ FCENTR
Definition: tcfs.h:40
TCFS::FIN
@ FIN
Definition: tcfs.h:41
TCFS
Definition: tcfs.h:31
TCFS::FOUT
@ FOUT
Definition: tcfs.h:42
TCFS::TCFSError
TCFSError
Definition: tcfs.h:64
TCFS::FSLEEP
@ FSLEEP
Definition: tcfs.h:45
TCFS::initProperties
virtual bool initProperties() override
Initilize properties initial state and value. The child class must implement this function.
Definition: tcfs.cpp:54
TCFS::FBMODE
@ FBMODE
Definition: tcfs.h:39
TCFS::TCFSCommand
TCFSCommand
Definition: tcfs.h:34
name
const char * name
Definition: indiserver.c:116
TCFS::saveConfigItems
virtual bool saveConfigItems(FILE *fp) override
saveConfigItems Saves the Device Port and Focuser Presets in the configuration file
Definition: tcfs.cpp:176
TCFS::FLSIGN
@ FLSIGN
Definition: tcfs.h:53
TCFS::ISNewSwitch
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
Definition: tcfs.cpp:403
TCFS::FWAKUP
@ FWAKUP
Definition: tcfs.h:46
TCFS::getDefaultName
const char * getDefaultName() override
Definition: tcfs.cpp:1201
INDI::FocuserInterface::FocusDirection
FocusDirection
Definition: indifocuserinterface.h:66
TCFS::NO_ERROR
@ NO_ERROR
Definition: tcfs.h:66
TCFS::MODE_A
@ MODE_A
Definition: tcfs.h:60
ISState
ISState
Switch state.
Definition: indiapi.h:148
TCFS::updateProperties
virtual bool updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
Definition: tcfs.cpp:140
INDI::Focuser
Definition: indifocuser.h:43
TCFS::SetManualMode
bool SetManualMode()
Definition: tcfs.cpp:284
_ISwitchVectorProperty
Switch vector property descriptor.
Definition: indiapi.h:365
TCFS::TCFS
TCFS()
Definition: tcfs.cpp:42
TCFS::MODE_B
@ MODE_B
Definition: tcfs.h:61