Instrument Neutral Distributed Interface INDI 2.2.5
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
25#ifdef _USE_SYSTEM_HIDAPILIB
26#include <hidapi/hidapi.h>
27#else
28#include <indi_hidapi.h>
29#endif
30
31
33{
34 public:
35
37 virtual ~FocusMaster() = default;
38
39 virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override;
40 virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override;
41
42 const char *getDefaultName();
43 virtual bool initProperties() override;
44 virtual bool updateProperties() override;
45
46 bool Connect();
47 bool Disconnect();
48
49 void TimerHit();
50
51 virtual IPState MoveFocuser(FocusDirection dir, int speed, uint16_t duration);
52 virtual IPState MoveAbsFocuser(uint32_t targetTicks);
53 virtual IPState MoveRelFocuser(FocusDirection dir, uint32_t ticks);
54
55 virtual bool AbortFocuser();
56
57 private:
65 bool sendCommand(const uint8_t *command, char *response = nullptr);
66
67 bool setPosition(uint32_t ticks);
68 bool getPosition(uint32_t *ticks);
69
70 bool sync(uint32_t ticks);
71
72 hid_device *handle { nullptr };
73
74 //uint32_t targetPosition { 0 };
75
76 struct timeval focusMoveStart
77 {
78 0, 0
79 };
80 float focusMoveRequest { 0 };
81 float CalcTimeLeft(timeval, float);
82
83 // Sync to a particular position
84 INumber SyncN[1];
86
87 // Full Forward / Reverse
88 ISwitch FullMotionS[2];
89 ISwitchVectorProperty FullMotionSP;
90
91};
const char * getDefaultName()
virtual ~FocusMaster()=default
virtual bool initProperties() override
Initializes the default properties for the focuser device. Sets up standard INDI properties,...
bool Connect()
Connect to the device. INDI::DefaultDevice implementation connects to appropriate connection interfac...
bool Disconnect()
Disconnect from device.
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
Processes incoming new switch states from the client for this device. Handles updates to FocuserInter...
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
Processes incoming new number values from the client for this device. Handles updates to FocuserInter...
virtual bool AbortFocuser()
AbortFocuser all focus motion.
virtual bool updateProperties() override
Updates the state and definition of properties based on the current connection status....
virtual IPState MoveAbsFocuser(uint32_t targetTicks)
MoveFocuser the focuser to an absolute position.
ISState
Switch state.
Definition indiapi.h:148
IPState
Property state.
Definition indiapi.h:158
One number descriptor.
One switch descriptor.
Number vector property descriptor.
Definition indiapi.h:317
Switch vector property descriptor.
Definition indiapi.h:365