Instrument Neutral Distributed Interface INDI  2.0.2
dmfc.h
Go to the documentation of this file.
1 /*
2  Pegasus DMFC Focuser
3  Copyright (C) 2017 Jasem Mutlaq (mutlaqja@ikarustech.com)
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Lesser General Public
7  License as published by the Free Software Foundation; either
8  version 2.1 of the License, or (at your option) any later version.
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  Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public
16  License along with this library; if not, write to the Free Software
17  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 
19 */
20 
21 #pragma once
22 
23 #include "indifocuser.h"
24 
25 class DMFC : public INDI::Focuser
26 {
27  public:
28  DMFC();
29  virtual ~DMFC() override = default;
30 
31  virtual bool Handshake() override;
32  const char *getDefaultName() override;
33  virtual void ISGetProperties(const char *dev) override;
34  virtual bool initProperties() override;
35  virtual bool updateProperties() override;
36  virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override;
37  virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override;
38 
39  protected:
40  virtual IPState MoveAbsFocuser(uint32_t targetTicks) override;
41  virtual IPState MoveRelFocuser(FocusDirection dir, uint32_t ticks) override;
42  virtual bool AbortFocuser() override;
43  virtual void TimerHit() override;
44 
45  virtual bool SyncFocuser(uint32_t ticks) override;
46  virtual bool ReverseFocuser(bool enabled) override;
47  virtual bool SetFocuserBacklash(int32_t steps) override;
48  virtual bool SetFocuserBacklashEnabled(bool enabled) override;
49  virtual bool saveConfigItems(FILE *fp) override;
50 
51  private:
52  bool updateFocusParams();
53  bool moveAbsolute(uint32_t newPosition);
54  bool moveRelative(int relativePosition);
55  bool setMaxSpeed(uint16_t speed);
56  bool setLedEnabled(bool enable);
57  bool setEncodersEnabled(bool enable);
58  bool setMotorType(uint8_t type);
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  // Motor Mode
71  ISwitch MotorTypeS[2];
72  ISwitchVectorProperty MotorTypeSP;
73  enum { MOTOR_DC, MOTOR_STEPPER };
74 
75  // Rotator Encoders
76  ISwitch EncoderS[2];
77  ISwitchVectorProperty EncoderSP;
78  enum { ENCODERS_ON, ENCODERS_OFF };
79 
80  // LED
81  ISwitch LEDS[2];
83  enum { LED_OFF, LED_ON };
84 
85  // Maximum Speed
86  INumber MaxSpeedN[1];
87  INumberVectorProperty MaxSpeedNP;
88 
89  // Firmware Version
90  IText FirmwareVersionT[1] {};
91  ITextVectorProperty FirmwareVersionTP;
92 };
Definition: dmfc.h:26
virtual bool SyncFocuser(uint32_t ticks) override
SyncFocuser Set current position to ticks without moving the focuser.
Definition: dmfc.cpp:230
virtual ~DMFC() override=default
virtual bool SetFocuserBacklashEnabled(bool enabled) override
SetFocuserBacklashEnabled Enables or disables the focuser backlash compensation.
Definition: dmfc.cpp:738
virtual void TimerHit() override
Callback function to be called once SetTimer duration elapses.
Definition: dmfc.cpp:796
virtual void ISGetProperties(const char *dev) override
define the driver's properties to the client. Usually, only a minimum set of properties are defined t...
Definition: dmfc.cpp:115
virtual bool saveConfigItems(FILE *fp) override
saveConfigItems Saves the Device Port and Focuser Presets in the configuration file
Definition: dmfc.cpp:842
virtual IPState MoveRelFocuser(FocusDirection dir, uint32_t ticks) override
MoveFocuser the focuser to an relative position.
Definition: dmfc.cpp:790
virtual bool ReverseFocuser(bool enabled) override
ReverseFocuser Reverse focuser motion direction.
Definition: dmfc.cpp:637
virtual IPState MoveAbsFocuser(uint32_t targetTicks) override
MoveFocuser the focuser to an absolute position.
Definition: dmfc.cpp:776
virtual bool AbortFocuser() override
AbortFocuser all focus motion.
Definition: dmfc.cpp:824
virtual bool updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
Definition: dmfc.cpp:138
virtual bool Handshake() override
perform handshake with device to check communication
Definition: dmfc.cpp:162
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
Definition: dmfc.cpp:352
DMFC()
Definition: dmfc.cpp:39
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
Definition: dmfc.cpp:302
const char * getDefaultName() override
Definition: dmfc.cpp:180
virtual bool SetFocuserBacklash(int32_t steps) override
SetFocuserBacklash Set the focuser backlash compensation value.
Definition: dmfc.cpp:713
virtual bool initProperties() override
Initilize properties initial state and value. The child class must implement this function.
Definition: dmfc.cpp:52
ISState
Switch state.
Definition: indiapi.h:150
IPState
Property state.
Definition: indiapi.h:160
__le16 type
Definition: pwc-ioctl.h:0
One number descriptor.
One switch descriptor.
One text descriptor.
Number vector property descriptor.
Definition: indiapi.h:319
Switch vector property descriptor.
Definition: indiapi.h:367
Text vector property descriptor.
Definition: indiapi.h:246