Instrument Neutral Distributed Interface INDI  1.9.5
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 };
DMFC
Definition: dmfc.h:25
DMFC::AbortFocuser
virtual bool AbortFocuser() override
AbortFocuser all focus motion.
Definition: dmfc.cpp:823
DMFC::DMFC
DMFC()
Definition: dmfc.cpp:39
DMFC::ISGetProperties
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
IPState
IPState
Property state.
Definition: indiapi.h:158
ISwitch
One switch descriptor.
INumber
One number descriptor.
DMFC::saveConfigItems
virtual bool saveConfigItems(FILE *fp) override
saveConfigItems Saves the Device Port and Focuser Presets in the configuration file
Definition: dmfc.cpp:841
DMFC::initProperties
virtual bool initProperties() override
Initilize properties initial state and value. The child class must implement this function.
Definition: dmfc.cpp:52
indifocuser.h
_ITextVectorProperty
Text vector property descriptor.
Definition: indiapi.h:244
type
__le16 type
Definition: pwc-ioctl.h:2
_INumberVectorProperty
Number vector property descriptor.
Definition: indiapi.h:317
DMFC::~DMFC
virtual ~DMFC() override=default
IText
One text descriptor.
DMFC::SetFocuserBacklashEnabled
virtual bool SetFocuserBacklashEnabled(bool enabled) override
SetFocuserBacklashEnabled Enables or disables the focuser backlash compensation.
Definition: dmfc.cpp:737
DMFC::getDefaultName
const char * getDefaultName() override
Definition: dmfc.cpp:180
DMFC::TimerHit
virtual void TimerHit() override
Callback function to be called once SetTimer duration elapses.
Definition: dmfc.cpp:795
DMFC::updateProperties
virtual bool updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
Definition: dmfc.cpp:138
DMFC::SyncFocuser
virtual bool SyncFocuser(uint32_t ticks) override
SyncFocuser Set current position to ticks without moving the focuser.
Definition: dmfc.cpp:230
name
const char * name
Definition: indiserver.c:116
DMFC::ISNewNumber
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::ReverseFocuser
virtual bool ReverseFocuser(bool enabled) override
ReverseFocuser Reverse focuser motion direction.
Definition: dmfc.cpp:636
DMFC::SetFocuserBacklash
virtual bool SetFocuserBacklash(int32_t steps) override
SetFocuserBacklash Set the focuser backlash compensation value.
Definition: dmfc.cpp:712
INDI::FocuserInterface::FocusDirection
FocusDirection
Definition: indifocuserinterface.h:66
ISState
ISState
Switch state.
Definition: indiapi.h:148
INDI::Focuser
Definition: indifocuser.h:43
DMFC::ISNewSwitch
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
DMFC::MoveAbsFocuser
virtual IPState MoveAbsFocuser(uint32_t targetTicks) override
MoveFocuser the focuser to an absolute position.
Definition: dmfc.cpp:775
DMFC::MoveRelFocuser
virtual IPState MoveRelFocuser(FocusDirection dir, uint32_t ticks) override
MoveFocuser the focuser to an relative position.
Definition: dmfc.cpp:789
_ISwitchVectorProperty
Switch vector property descriptor.
Definition: indiapi.h:365
DMFC::Handshake
virtual bool Handshake() override
perform handshake with device to check communication
Definition: dmfc.cpp:162