Instrument Neutral Distributed Interface INDI  1.9.5
robofocus.h
Go to the documentation of this file.
1 /*
2  RoboFocus
3  Copyright (C) 2006 Markus Wildi (markus.wildi@datacomm.ch)
4  2011 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 class RoboFocus : public INDI::Focuser
27 {
28  public:
29  RoboFocus();
30  virtual ~RoboFocus() override = default;
31 
32  virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override;
33  virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override;
34 
35  protected:
36  virtual bool Handshake() override;
37  const char *getDefaultName() override;
38  virtual bool initProperties() override;
39  virtual bool updateProperties() override;
40  virtual IPState MoveAbsFocuser(uint32_t targetTicks) override;
41  virtual IPState MoveRelFocuser(FocusDirection dir, uint32_t ticks) override;
42  virtual bool AbortFocuser() override;
43  virtual void TimerHit() override;
44  virtual bool saveConfigItems(FILE *fp) override;
45  virtual bool SyncFocuser(uint32_t ticks) override;
46  virtual bool SetFocuserBacklash(int32_t steps) override;
47 
48  private:
49  unsigned char CheckSum(char *rf_cmd);
50  unsigned char CalculateSum(const char *rf_cmd);
51  int SendCommand(char *rf_cmd);
52  int ReadResponse(char *buf);
53  void GetFocusParams();
54 
55  int updateRFPosition(double *value);
56  int updateRFTemperature(double *value);
57  int updateRFBacklash(double *value);
58  int updateRFFirmware(char *rf_cmd);
59  int updateRFMotorSettings(double *duty, double *delay, double *ticks);
60  int updateRFPositionRelativeInward(double value);
61  int updateRFPositionRelativeOutward(double value);
62  int updateRFPositionAbsolute(double value);
63  int updateRFPowerSwitches(int s, int new_sn, int *cur_s1LL, int *cur_s2LR, int *cur_s3RL, int *cur_s4RR);
64  int updateRFMaxPosition(double *value);
65  int updateRFSetPosition(const double *value);
66 
67  int ReadUntilComplete(char *buf, int timeout);
68 
69  int timerID { -1 };
70  double targetPos { 0 };
71  double simulatedTemperature { 0 };
72  double simulatedPosition { 0 };
73 
74  INumber TemperatureN[1];
75  INumberVectorProperty TemperatureNP;
76 
77  INumber SettingsN[3];
78  INumberVectorProperty SettingsNP;
79 
80  ISwitch PowerSwitchesS[4];
81  ISwitchVectorProperty PowerSwitchesSP;
82 
83  INumber MinMaxPositionN[2];
84  INumberVectorProperty MinMaxPositionNP;
85 
86  INumber MaxTravelN[1];
87  INumberVectorProperty MaxTravelNP;
88 
89  INumber SetRegisterPositionN[1];
90  INumberVectorProperty SetRegisterPositionNP;
91 
92  INumber RelMovementN[1];
93  INumberVectorProperty RelMovementNP;
94 
95  INumber AbsMovementN[1];
96  INumberVectorProperty AbsMovementNP;
97 
98  // INumber SetBacklashN[1];
99  // INumberVectorProperty SetBacklashNP;
100 };
IPState
IPState
Property state.
Definition: indiapi.h:158
ISwitch
One switch descriptor.
INumber
One number descriptor.
RoboFocus::ISNewSwitch
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
Definition: robofocus.cpp:913
RoboFocus::AbortFocuser
virtual bool AbortFocuser() override
AbortFocuser all focus motion.
Definition: robofocus.cpp:1504
RoboFocus::SyncFocuser
virtual bool SyncFocuser(uint32_t ticks) override
SyncFocuser Set current position to ticks without moving the focuser.
Definition: robofocus.cpp:864
RoboFocus::MoveRelFocuser
virtual IPState MoveRelFocuser(FocusDirection dir, uint32_t ticks) override
MoveFocuser the focuser to an relative position.
Definition: robofocus.cpp:1420
RoboFocus::TimerHit
virtual void TimerHit() override
Callback function to be called once SetTimer duration elapses.
Definition: robofocus.cpp:1433
RoboFocus::saveConfigItems
virtual bool saveConfigItems(FILE *fp) override
saveConfigItems Saves the Device Port and Focuser Presets in the configuration file
Definition: robofocus.cpp:1425
indifocuser.h
RoboFocus::RoboFocus
RoboFocus()
Definition: robofocus.cpp:54
RoboFocus::ISNewNumber
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
Definition: robofocus.cpp:991
RoboFocus::MoveAbsFocuser
virtual IPState MoveAbsFocuser(uint32_t targetTicks) override
MoveFocuser the focuser to an absolute position.
Definition: robofocus.cpp:1398
_INumberVectorProperty
Number vector property descriptor.
Definition: indiapi.h:317
RoboFocus::~RoboFocus
virtual ~RoboFocus() override=default
name
const char * name
Definition: indiserver.c:116
RoboFocus::SetFocuserBacklash
virtual bool SetFocuserBacklash(int32_t steps) override
SetFocuserBacklash Set the focuser backlash compensation value.
Definition: robofocus.cpp:1514
RoboFocus::Handshake
virtual bool Handshake() override
perform handshake with device to check communication
Definition: robofocus.cpp:168
RoboFocus
Definition: robofocus.h:26
INDI::FocuserInterface::FocusDirection
FocusDirection
Definition: indifocuserinterface.h:66
RoboFocus::getDefaultName
const char * getDefaultName() override
Definition: robofocus.cpp:191
ISState
ISState
Switch state.
Definition: indiapi.h:148
RoboFocus::initProperties
virtual bool initProperties() override
Initilize properties initial state and value. The child class must implement this function.
Definition: robofocus.cpp:59
INDI::Focuser
Definition: indifocuser.h:43
RoboFocus::updateProperties
virtual bool updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
Definition: robofocus.cpp:132
_ISwitchVectorProperty
Switch vector property descriptor.
Definition: indiapi.h:365