Instrument Neutral Distributed Interface INDI  2.0.2
pyxis.h
Go to the documentation of this file.
1 /*
2  Optec Pyrix Rotator
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 "indirotator.h"
24 #include "string.h"
25 
26 class Pyxis : public INDI::Rotator
27 {
28  public:
29 
30  Pyxis();
31  virtual ~Pyxis() = default;
32 
33  virtual bool Handshake() override;
34  const char * getDefaultName() override;
35  virtual bool initProperties() override;
36  virtual bool updateProperties() override;
37 
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  // Rotator Overrides
43  virtual IPState HomeRotator() override;
44  virtual IPState MoveRotator(double angle) override;
45  virtual bool ReverseRotator(bool enabled) override;
46 
47  // Misc.
48  virtual void TimerHit() override;
49 
50  private:
51  // Check if connection is OK
52  bool Ack();
53  bool isMotionComplete();
54  bool getPA(uint16_t &PA);
55  int getReverseStatus();
56  bool setSteppingMode(uint8_t mode);
57  bool setRotationRate(uint8_t rate);
58  bool sleepController();
59  bool wakeupController();
60  std::string getVersion() ;
61 
62  void queryParams();
63 
64  // Rotation Rate
65  INumber RotationRateN[1];
66  INumberVectorProperty RotationRateNP;
67 
68  // Stepping
69  ISwitch SteppingS[2];
70  ISwitchVectorProperty SteppingSP;
71  enum { FULL_STEP, HALF_STEP};
72 
73  // Power
74  ISwitch PowerS[2];
75  ISwitchVectorProperty PowerSP;
76  enum { POWER_SLEEP, POWER_WAKEUP};
77 
78  // Firmware version; tells us if 2 inch or 3 inch device
79  IText FirmwareT[1] {};
80  ITextVectorProperty FirmwareTP;
81  IText ModelT[1] {};
82  ITextVectorProperty ModelTP;
83 
84  uint16_t targetPA = {0};
85 
86  // Direction of rotation; 1->angle increasing; -1->angle decreasing
87  int direction = 1 ;
88 };
Definition: pyxis.h:27
virtual IPState HomeRotator() override
HomeRotator Go to home position.
Definition: pyxis.cpp:440
virtual bool updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
Definition: pyxis.cpp:106
Pyxis()
Definition: pyxis.cpp:49
virtual bool initProperties() override
Initilize properties initial state and value. The child class must implement this function.
Definition: pyxis.cpp:57
const char * getDefaultName() override
Definition: pyxis.cpp:101
virtual IPState MoveRotator(double angle) override
MoveRotator Go to specific angle.
Definition: pyxis.cpp:461
virtual ~Pyxis()=default
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
Definition: pyxis.cpp:223
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
Definition: pyxis.cpp:246
virtual void TimerHit() override
Callback function to be called once SetTimer duration elapses.
Definition: pyxis.cpp:525
virtual bool ReverseRotator(bool enabled) override
ReverseRotator Reverse the direction of the rotator. CW is usually the normal direction,...
Definition: pyxis.cpp:502
virtual bool Handshake() override
perform handshake with device to check communication
Definition: pyxis.cpp:92
ISState
Switch state.
Definition: indiapi.h:150
IPState
Property state.
Definition: indiapi.h:160
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