Instrument Neutral Distributed Interface INDI  1.9.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 { 0, 0 };
71  float focusMoveRequest { 0 };
72  float CalcTimeLeft(timeval, float);
73 
74  // Sync to a particular position
75  INumber SyncN[1];
76  INumberVectorProperty SyncNP;
77 
78  // Full Forward / Reverse
79  ISwitch FullMotionS[2];
80  ISwitchVectorProperty FullMotionSP;
81 
82 };
FocusMaster::ISNewNumber
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
Definition: focusmaster.cpp:191
FocusMaster::getDefaultName
const char * getDefaultName()
Definition: focusmaster.cpp:73
IPState
IPState
Property state.
Definition: indiapi.h:158
ISwitch
One switch descriptor.
hidapi.h
INumber
One number descriptor.
FocusMaster::Disconnect
bool Disconnect()
Disconnect from device.
Definition: focusmaster.cpp:66
indifocuser.h
FocusMaster::Connect
bool Connect()
Connect to the device. INDI::DefaultDevice implementation connects to appropriate connection interfac...
Definition: focusmaster.cpp:43
hid_device_
Definition: hid_libusb.c:93
FocusMaster::MoveRelFocuser
virtual IPState MoveRelFocuser(FocusDirection dir, uint32_t ticks)
MoveFocuser the focuser to an relative position.
Definition: focusmaster.cpp:253
_INumberVectorProperty
Number vector property descriptor.
Definition: indiapi.h:317
FocusMaster::ISNewSwitch
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
Definition: focusmaster.cpp:173
FocusMaster::~FocusMaster
virtual ~FocusMaster()=default
FocusMaster::TimerHit
void TimerHit()
Callback function to be called once SetTimer duration elapses.
Definition: focusmaster.cpp:123
FocusMaster::initProperties
virtual bool initProperties() override
Initilize properties initial state and value. The child class must implement this function.
Definition: focusmaster.cpp:78
FocusMaster::FocusMaster
FocusMaster()
Definition: focusmaster.cpp:37
INDI::FocuserInterface::FocusDirection
FocusDirection
Definition: indifocuserinterface.h:66
ISState
ISState
Switch state.
Definition: indiapi.h:148
INDI::Focuser
Definition: indifocuser.h:43
FocusMaster::MoveAbsFocuser
virtual IPState MoveAbsFocuser(uint32_t targetTicks)
MoveFocuser the focuser to an absolute position.
Definition: focusmaster.cpp:244
FocusMaster::updateProperties
virtual bool updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
Definition: focusmaster.cpp:105
FocusMaster::AbortFocuser
virtual bool AbortFocuser()
AbortFocuser all focus motion.
Definition: focusmaster.cpp:289
FocusMaster::MoveFocuser
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.
Definition: focusmaster.cpp:212
_ISwitchVectorProperty
Switch vector property descriptor.
Definition: indiapi.h:365
FocusMaster
Definition: focusmaster.h:26