Instrument Neutral Distributed Interface INDI  1.9.5
pegasus_focuscube.h
Go to the documentation of this file.
1 /*******************************************************************************
2  Copyright(c) 2021 Chrysikos Efstathios. All rights reserved.
3 
4  Pegasus FocusCube
5 
6  This program is free software; you can redistribute it and/or modify it
7  under the terms of the GNU General Public License as published by the Free
8  Software Foundation; either version 2 of the License, or (at your option)
9  any later version.
10 
11  This program is distributed in the hope that it will be useful, but WITHOUT
12  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14  more details.
15 
16  You should have received a copy of the GNU Library General Public License
17  along with this library; see the file COPYING.LIB. If not, write to
18  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19  Boston, MA 02110-1301, USA.
20 
21  The full GNU General Public License is included in this distribution in the
22  file called LICENSE.
23 *******************************************************************************/
24 #pragma once
25 
26 #include "indifocuser.h"
27 
29 {
30  public:
32  virtual ~PegasusFocusCube() override = default;
33 
34  virtual bool Handshake() override;
35  const char *getDefaultName() override;
36  virtual bool initProperties() override;
37  virtual bool updateProperties() override;
38  virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override;
39  virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override;
40 
41  protected:
42  virtual IPState MoveAbsFocuser(uint32_t targetTicks) override;
43  virtual IPState MoveRelFocuser(FocusDirection dir, uint32_t ticks) override;
44  virtual bool AbortFocuser() override;
45  virtual void TimerHit() override;
46 
47  virtual bool SyncFocuser(uint32_t ticks) override;
48  virtual bool ReverseFocuser(bool enabled) override;
49  virtual bool SetFocuserBacklash(int32_t steps) override;
50  virtual bool SetFocuserBacklashEnabled(bool enabled) override;
51  virtual bool saveConfigItems(FILE *fp) override;
52 
53  private:
54  bool updateFocusParams();
55  bool move(uint32_t newPosition);
56  bool setMaxSpeed(uint16_t speed);
57  bool setLedEnabled(bool enable);
58  bool setEncodersEnabled(bool enable);
59  bool ack();
60  void ignoreResponse();
61 
62  uint32_t currentPosition { 0 };
63  uint32_t targetPosition { 0 };
64  bool isMoving = false;
65 
66  // Temperature probe
67  INumber TemperatureN[1];
68  INumberVectorProperty TemperatureNP;
69 
70 
71  // Rotator Encoders
72  ISwitch EncoderS[2];
73  ISwitchVectorProperty EncoderSP;
74  enum { ENCODERS_ON, ENCODERS_OFF };
75 
76  // LED
77  ISwitch LEDS[2];
79  enum { LED_OFF, LED_ON };
80 
81  // Maximum Speed
82  INumber MaxSpeedN[1];
83  INumberVectorProperty MaxSpeedNP;
84 
85  // Firmware Version
86  IText FirmwareVersionT[1] {};
87  ITextVectorProperty FirmwareVersionTP;
88 };
PegasusFocusCube::updateProperties
virtual bool updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
Definition: pegasus_focuscube.cpp:113
IPState
IPState
Property state.
Definition: indiapi.h:158
PegasusFocusCube
Definition: pegasus_focuscube.h:28
ISwitch
One switch descriptor.
PegasusFocusCube::SetFocuserBacklashEnabled
virtual bool SetFocuserBacklashEnabled(bool enabled) override
SetFocuserBacklashEnabled Enables or disables the focuser backlash compensation.
Definition: pegasus_focuscube.cpp:641
INumber
One number descriptor.
PegasusFocusCube::~PegasusFocusCube
virtual ~PegasusFocusCube() override=default
PegasusFocusCube::ISNewSwitch
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
Definition: pegasus_focuscube.cpp:248
PegasusFocusCube::PegasusFocusCube
PegasusFocusCube()
Definition: pegasus_focuscube.cpp:42
PegasusFocusCube::Handshake
virtual bool Handshake() override
perform handshake with device to check communication
Definition: pegasus_focuscube.cpp:137
PegasusFocusCube::getDefaultName
const char * getDefaultName() override
Definition: pegasus_focuscube.cpp:150
indifocuser.h
_ITextVectorProperty
Text vector property descriptor.
Definition: indiapi.h:244
_INumberVectorProperty
Number vector property descriptor.
Definition: indiapi.h:317
PegasusFocusCube::SyncFocuser
virtual bool SyncFocuser(uint32_t ticks) override
SyncFocuser Set current position to ticks without moving the focuser.
Definition: pegasus_focuscube.cpp:200
IText
One text descriptor.
PegasusFocusCube::SetFocuserBacklash
virtual bool SetFocuserBacklash(int32_t steps) override
SetFocuserBacklash Set the focuser backlash compensation value.
Definition: pegasus_focuscube.cpp:616
name
const char * name
Definition: indiserver.c:116
PegasusFocusCube::AbortFocuser
virtual bool AbortFocuser() override
AbortFocuser all focus motion.
Definition: pegasus_focuscube.cpp:713
INDI::FocuserInterface::FocusDirection
FocusDirection
Definition: indifocuserinterface.h:66
PegasusFocusCube::ISNewNumber
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
Definition: pegasus_focuscube.cpp:276
ISState
ISState
Switch state.
Definition: indiapi.h:148
PegasusFocusCube::MoveRelFocuser
virtual IPState MoveRelFocuser(FocusDirection dir, uint32_t ticks) override
MoveFocuser the focuser to an relative position.
Definition: pegasus_focuscube.cpp:664
INDI::Focuser
Definition: indifocuser.h:43
PegasusFocusCube::ReverseFocuser
virtual bool ReverseFocuser(bool enabled) override
ReverseFocuser Reverse focuser motion direction.
Definition: pegasus_focuscube.cpp:540
PegasusFocusCube::TimerHit
virtual void TimerHit() override
Callback function to be called once SetTimer duration elapses.
Definition: pegasus_focuscube.cpp:685
PegasusFocusCube::MoveAbsFocuser
virtual IPState MoveAbsFocuser(uint32_t targetTicks) override
MoveFocuser the focuser to an absolute position.
Definition: pegasus_focuscube.cpp:650
PegasusFocusCube::initProperties
virtual bool initProperties() override
Initilize properties initial state and value. The child class must implement this function.
Definition: pegasus_focuscube.cpp:53
_ISwitchVectorProperty
Switch vector property descriptor.
Definition: indiapi.h:365
PegasusFocusCube::saveConfigItems
virtual bool saveConfigItems(FILE *fp) override
saveConfigItems Saves the Device Port and Focuser Presets in the configuration file
Definition: pegasus_focuscube.cpp:731