Instrument Neutral Distributed Interface INDI  1.9.5
activefocuser.h
Go to the documentation of this file.
1 /*
2  ActiveFocuser driver for Takahashi CCA-250 and Mewlon-250/300CRS
3  Driver written by Alvin FREY <https://afrey.fr> for Optique Unterlinden and Takahashi Europe
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Lesser General Public
6  License as published by the Free Software Foundation; either
7  version 2.1 of the License, or (at your option) any later version.
8  This library is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  Lesser General Public License for more details.
12  You should have received a copy of the GNU Lesser General Public
13  License along with this library; if not, write to the Free Software
14  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
15 */
16 
17 #pragma once
18 #include <cmath>
19 #include <memory>
20 #include <cstring>
21 #include <sstream>
22 #include <unistd.h>
23 #include "hidapi.h"
24 #include "indifocuser.h"
25 
26 class ActiveFocuser : public INDI::Focuser {
27 public:
28 
29  ActiveFocuser();
30 
32 
33  const char *getDefaultName() override;
34 
35  void ISGetProperties(const char *dev) override;
36 
37  virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override;
38 
39  virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override;
40 
41  void TimerHit() override;
42 
43 protected:
44 
45  bool initProperties() override;
46 
47  bool updateProperties() override;
48 
49  bool Connect() override;
50 
51  bool Disconnect() override;
52 
53  bool AbortFocuser() override;
54 
55  IPState MoveAbsFocuser(uint32_t targetTicks) override;
56 
57  IPState MoveRelFocuser(FocusDirection dir, uint32_t ticks) override;
58 
59 private:
60 
61  hid_device *hid_handle;
62 
63  double internalTicks{0};
64  // double initTicks{0}; // #PS: unused
65 
66  // Hardware version display
67  ITextVectorProperty HardwareVersionNP;
68  IText HardwareVersionN[1];
69 
70  // Software version display
71  ITextVectorProperty SoftwareVersionNP;
72  IText SoftwareVersionN[1];
73 
74  // Air Temperature in celsius degrees
75  INumberVectorProperty AirTemperatureNP;
76  INumber AirTemperatureN[1];
77 
78  // Mirror Temperature in celsius degrees
79  INumberVectorProperty MirrorTemperatureNP;
80  INumber MirrorTemperatureN[1];
81 
82  // Tube Temperature in celsius degrees
83  INumberVectorProperty TubeTemperatureNP;
84  INumber TubeTemperatureN[1];
85 
86  // Fan State switch
87  ISwitch FanS[2];
89 
90 };
ActiveFocuser::~ActiveFocuser
~ActiveFocuser()
Definition: activefocuser.cpp:45
IPState
IPState
Property state.
Definition: indiapi.h:158
ISwitch
One switch descriptor.
ActiveFocuser
Definition: activefocuser.h:26
ActiveFocuser::AbortFocuser
bool AbortFocuser() override
AbortFocuser all focus motion.
Definition: activefocuser.cpp:300
hidapi.h
INumber
One number descriptor.
ActiveFocuser::ISNewNumber
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
Definition: activefocuser.cpp:291
indifocuser.h
_ITextVectorProperty
Text vector property descriptor.
Definition: indiapi.h:244
hid_device_
Definition: hid_libusb.c:93
_INumberVectorProperty
Number vector property descriptor.
Definition: indiapi.h:317
IText
One text descriptor.
ActiveFocuser::updateProperties
bool updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
Definition: activefocuser.cpp:211
ActiveFocuser::initProperties
bool initProperties() override
Initilize properties initial state and value. The child class must implement this function.
Definition: activefocuser.cpp:126
ActiveFocuser::ISGetProperties
void ISGetProperties(const char *dev) override
define the driver's properties to the client. Usually, only a minimum set of properties are defined t...
Definition: activefocuser.cpp:117
ActiveFocuser::getDefaultName
const char * getDefaultName() override
Definition: activefocuser.cpp:111
ActiveFocuser::ISNewSwitch
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
Definition: activefocuser.cpp:239
ActiveFocuser::Connect
bool Connect() override
Connect to the device. INDI::DefaultDevice implementation connects to appropriate connection interfac...
Definition: activefocuser.cpp:62
name
const char * name
Definition: indiserver.c:116
ActiveFocuser::Disconnect
bool Disconnect() override
Disconnect from device.
Definition: activefocuser.cpp:91
INDI::FocuserInterface::FocusDirection
FocusDirection
Definition: indifocuserinterface.h:66
ActiveFocuser::MoveAbsFocuser
IPState MoveAbsFocuser(uint32_t targetTicks) override
MoveFocuser the focuser to an absolute position.
Definition: activefocuser.cpp:327
ISState
ISState
Switch state.
Definition: indiapi.h:148
ActiveFocuser::MoveRelFocuser
IPState MoveRelFocuser(FocusDirection dir, uint32_t ticks) override
MoveFocuser the focuser to an relative position.
Definition: activefocuser.cpp:368
INDI::Focuser
Definition: indifocuser.h:43
ActiveFocuser::TimerHit
void TimerHit() override
Callback function to be called once SetTimer duration elapses.
Definition: activefocuser.cpp:381
_ISwitchVectorProperty
Switch vector property descriptor.
Definition: indiapi.h:365
ActiveFocuser::ActiveFocuser
ActiveFocuser()
Definition: activefocuser.cpp:37