Instrument Neutral Distributed Interface INDI  1.9.2
perfectstar.h
Go to the documentation of this file.
1 /*******************************************************************************
2  Copyright(c) 2015 Jasem Mutlaq. All rights reserved.
3 
4  PerfectStar Focuser
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 PerfectStar : public INDI::Focuser
27 {
28  public:
29  // Perfect Star (PS) status
30  typedef enum { PS_NOOP, PS_IN, PS_OUT, PS_GOTO, PS_SETPOS, PS_LOCKED, PS_HALT = 0xFF } PS_STATUS;
31 
32  PerfectStar();
33  virtual ~PerfectStar() override = default;
34 
35  virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override;
36 
37  const char *getDefaultName() override;
38  virtual bool initProperties() override;
39  virtual bool updateProperties() override;
40  //virtual bool saveConfigItems(FILE *fp) override;
41 
42  virtual bool Connect() override;
43  virtual bool Disconnect() override;
44 
45  virtual void TimerHit() override;
46 
47  virtual IPState MoveAbsFocuser(uint32_t targetTicks) override;
48  virtual IPState MoveRelFocuser(FocusDirection dir, uint32_t ticks) override;
49  virtual bool AbortFocuser() override;
50  virtual bool SyncFocuser(uint32_t ticks) override;
51 
52  private:
53  bool setPosition(uint32_t ticks);
54  bool getPosition(uint32_t *ticks);
55 
56  bool setStatus(PS_STATUS targetStatus);
57  bool getStatus(PS_STATUS *currentStatus);
58 
59  //bool sync(uint32_t ticks);
60 
61  hid_device *handle { nullptr };
62  PS_STATUS status { PS_NOOP };
63  bool sim { false };
64  uint32_t simPosition { 0 };
65  uint32_t targetPosition { 0 };
66 
67  // Max position in ticks
68 // INumber MaxPositionN[1];
69 // INumberVectorProperty MaxPositionNP;
70 
71 // // Sync to a particular position
72 // INumber SyncN[1];
73 // INumberVectorProperty SyncNP;
74 };
PerfectStar::PS_SETPOS
@ PS_SETPOS
Definition: perfectstar.h:66
PerfectStar::MoveAbsFocuser
virtual IPState MoveAbsFocuser(uint32_t targetTicks) override
MoveFocuser the focuser to an absolute position.
Definition: perfectstar.cpp:235
PerfectStar::ISNewNumber
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
Definition: perfectstar.cpp:186
PerfectStar::PS_NOOP
@ PS_NOOP
Definition: perfectstar.h:66
IPState
IPState
Property state.
Definition: indiapi.h:158
PerfectStar::PS_IN
@ PS_IN
Definition: perfectstar.h:66
hidapi.h
PerfectStar::PS_STATUS
PS_STATUS
Definition: perfectstar.h:48
PerfectStar::initProperties
virtual bool initProperties() override
Initilize properties initial state and value. The child class must implement this function.
Definition: perfectstar.cpp:79
PerfectStar::SyncFocuser
virtual bool SyncFocuser(uint32_t ticks) override
SyncFocuser Set current position to ticks without moving the focuser.
Definition: perfectstar.cpp:582
PerfectStar::PS_GOTO
@ PS_GOTO
Definition: perfectstar.h:66
PerfectStar::getDefaultName
const char * getDefaultName() override
Definition: perfectstar.cpp:74
indifocuser.h
PerfectStar::Disconnect
virtual bool Disconnect() override
Disconnect from device.
Definition: perfectstar.cpp:63
hid_device_
Definition: hid_libusb.c:93
PerfectStar::PS_OUT
@ PS_OUT
Definition: perfectstar.h:66
PerfectStar::MoveRelFocuser
virtual IPState MoveRelFocuser(FocusDirection dir, uint32_t ticks) override
MoveFocuser the focuser to an relative position.
Definition: perfectstar.cpp:254
PerfectStar::Connect
virtual bool Connect() override
Connect to the device. INDI::DefaultDevice implementation connects to appropriate connection interfac...
Definition: perfectstar.cpp:40
PerfectStar::AbortFocuser
virtual bool AbortFocuser() override
AbortFocuser all focus motion.
Definition: perfectstar.cpp:576
PerfectStar::updateProperties
virtual bool updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
Definition: perfectstar.cpp:106
PerfectStar::TimerHit
virtual void TimerHit() override
Callback function to be called once SetTimer duration elapses.
Definition: perfectstar.cpp:124
PerfectStar::PS_LOCKED
@ PS_LOCKED
Definition: perfectstar.h:66
PerfectStar
Definition: perfectstar.h:26
PerfectStar::~PerfectStar
virtual ~PerfectStar() override=default
PerfectStar::PerfectStar
PerfectStar()
Definition: perfectstar.cpp:34
INDI::FocuserInterface::FocusDirection
FocusDirection
Definition: indifocuserinterface.h:66
INDI::Focuser
Definition: indifocuser.h:43
PerfectStar::PS_HALT
@ PS_HALT
Definition: perfectstar.h:66