Instrument Neutral Distributed Interface INDI  2.0.2
focusmaster.h
Go to the documentation of this file.
1 /*******************************************************************************
2  Copyright(c) 2017 Jasem Mutlaq. All rights reserved.
3 
4  Televue FocusMaster Driver.
5 
6  This library is free software; you can redistribute it and/or
7  modify it under the terms of the GNU Library General Public
8  License version 2 as published by the Free Software Foundation.
9  .
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Library General Public License for more details.
14  .
15  You should have received a copy of the GNU Library General Public License
16  along with this library; see the file COPYING.LIB. If not, write to
17  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  Boston, MA 02110-1301, USA.
19 *******************************************************************************/
20 
21 #pragma once
22 
23 #include "indifocuser.h"
24 #include "hidapi.h"
25 
26 class FocusMaster : public INDI::Focuser
27 {
28  public:
29 
30  FocusMaster();
31  virtual ~FocusMaster() = default;
32 
33  virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override;
34  virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override;
35 
36  const char *getDefaultName();
37  virtual bool initProperties() override;
38  virtual bool updateProperties() override;
39 
40  bool Connect();
41  bool Disconnect();
42 
43  void TimerHit();
44 
45  virtual IPState MoveFocuser(FocusDirection dir, int speed, uint16_t duration);
46  virtual IPState MoveAbsFocuser(uint32_t targetTicks);
47  virtual IPState MoveRelFocuser(FocusDirection dir, uint32_t ticks);
48 
49  virtual bool AbortFocuser();
50 
51  private:
59  bool sendCommand(const uint8_t *command, char *response = nullptr);
60 
61  bool setPosition(uint32_t ticks);
62  bool getPosition(uint32_t *ticks);
63 
64  bool sync(uint32_t ticks);
65 
66  hid_device *handle { nullptr };
67 
68  //uint32_t targetPosition { 0 };
69 
70  struct timeval focusMoveStart
71  {
72  0, 0
73  };
74  float focusMoveRequest { 0 };
75  float CalcTimeLeft(timeval, float);
76 
77  // Sync to a particular position
78  INumber SyncN[1];
79  INumberVectorProperty SyncNP;
80 
81  // Full Forward / Reverse
82  ISwitch FullMotionS[2];
83  ISwitchVectorProperty FullMotionSP;
84 
85 };
const char * getDefaultName()
Definition: focusmaster.cpp:73
virtual ~FocusMaster()=default
virtual bool initProperties() override
Initilize properties initial state and value. The child class must implement this function.
Definition: focusmaster.cpp:78
bool Connect()
Connect to the device. INDI::DefaultDevice implementation connects to appropriate connection interfac...
Definition: focusmaster.cpp:43
bool Disconnect()
Disconnect from device.
Definition: focusmaster.cpp:66
virtual IPState MoveRelFocuser(FocusDirection dir, uint32_t ticks)
MoveFocuser the focuser to an relative position.
virtual IPState MoveFocuser(FocusDirection dir, int speed, uint16_t duration)
MoveFocuser the focuser in a particular direction with a specific speed for a finite duration.
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
void TimerHit()
Callback function to be called once SetTimer duration elapses.
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
virtual bool AbortFocuser()
AbortFocuser all focus motion.
virtual bool updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
virtual IPState MoveAbsFocuser(uint32_t targetTicks)
MoveFocuser the focuser to an absolute position.
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