Instrument Neutral Distributed Interface INDI  2.0.2
integra.h
Go to the documentation of this file.
1 /*
2  Gemini Telescope Design Integra85 Focusing Rotator.
3  Copyright (C) 2017 Hans Lambermont
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 #pragma once
21 
22 #include "indifocuser.h"
23 #include "indirotatorinterface.h"
24 
26 {
27  public:
28 
29  typedef enum { MOTOR_FOCUS, MOTOR_ROTATOR } MotorType;
30 
32 
33  // these are used for sanity checks only
34  const int wellKnownIntegra85FocusMax = 188600;
35  const int wellKnownIntegra85RotateMax = 61802;
36 
38  {
43  };
44 
45  Integra();
46  virtual ~Integra() = default;
47 
48  virtual bool Handshake() override;
49  const char * getDefaultName() override;
50  virtual bool initProperties() override;
51  virtual bool updateProperties() override;
52  virtual bool ISNewNumber (const char * dev, const char * name, double values[], char * names[], int n) override;
53  virtual bool ISNewSwitch (const char * dev, const char * name, ISState * states, char * names[], int n) override;
54 
55  protected:
56  // Focuser
57  virtual IPState MoveAbsFocuser(uint32_t targetTicks) override;
58  virtual IPState MoveRelFocuser(FocusDirection dir, uint32_t ticks) override;
59  virtual bool AbortFocuser() override;
60 
61  // Rotator
62  virtual IPState MoveRotator(double angle) override;
63  virtual bool AbortRotator() override;
64  virtual bool SyncRotator(double angle) override;
65  virtual bool ReverseRotator(bool enabled) override;
66 
67  // Misc.
68  virtual bool saveConfigItems(FILE *fp) override;
69  virtual void TimerHit() override;
70 
71  private:
72  bool genericIntegraCommand(const char *name, const char *cmd, const char *expectStart, char *returnValueString);
73  bool integraGetCommand(const char *name, int command, char *returnValueString );
74  bool integraMotorGetCommand(const char *name, int command, MotorType motor, char *returnValueString);
75  bool integraMotorSetCommand(const char *name, int command, MotorType motor, int value, char *returnValueString);
76  bool getFirmware();
77  bool getFocuserType();
78  bool gotoMotor(MotorType type, int32_t position);
79  bool relativeGotoMotor(MotorType type, int32_t relativePosition);
80  bool getPosition(MotorType type);
81  bool stopMotor(MotorType type);
82  bool isMotorMoving(MotorType type);
83  bool getTemperature();
84  bool findHome();
85  bool abortHome();
86  bool isHomingComplete();
87  void cleanPrint(const char *cmd, char *cleancmd);
88  bool saveToEEPROM();
89  bool getMaxPosition(MotorType type);
90  uint32_t rotatorDegreesToTicks(double angle);
91  double rotatorTicksToDegrees(uint32_t ticks);
92 
93  INumber MaxPositionN[2];
94  INumberVectorProperty MaxPositionNP;
95 
96  INumber SensorN[2];
97  INumberVectorProperty SensorNP;
98  enum { SENSOR_TEMPERATURE };
99 
100  ISwitch FindHomeS[HOMING_COUNT];
101  ISwitchVectorProperty FindHomeSP;
102 
103  INumber RotatorAbsPosN[1];
104  INumberVectorProperty RotatorAbsPosNP;
105 
106  double lastTemperature { 0 };
107  int timeToReadTemperature = 0;
108  double rotatorTicksPerDegree { 0 };
109  double rotatorDegreesPerTick = 0.0;
110  uint32_t lastFocuserPosition { 0 };
111  bool haveReadFocusPositionAtLeastOnce = false;
112  uint32_t lastRotatorPosition { 0 };
113  bool haveReadRotatorPositionAtLeastOnce = false;
114  uint32_t targetPosition { 0 };
115  FirmwareVersion firmwareVersion { VERSION_20170125 };
116 };
Integra()
Definition: integra.cpp:80
virtual bool initProperties() override
Initilize properties initial state and value. The child class must implement this function.
Definition: integra.cpp:89
const char * getDefaultName() override
Definition: integra.cpp:194
virtual bool AbortRotator() override
AbortRotator Abort all motion.
Definition: integra.cpp:846
virtual bool ReverseRotator(bool enabled) override
ReverseRotator Reverse the direction of the rotator. CW is usually the normal direction,...
Definition: integra.cpp:893
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
Definition: integra.cpp:480
INTEGRA_HOMING_STATE
Definition: integra.h:38
@ HOMING_START
Definition: integra.h:40
@ HOMING_ABORT
Definition: integra.h:41
@ HOMING_COUNT
Definition: integra.h:42
@ HOMING_IDLE
Definition: integra.h:39
FirmwareVersion
Definition: integra.h:31
@ VERSION_20171220
Definition: integra.h:31
@ VERSION_20170125
Definition: integra.h:31
virtual IPState MoveRotator(double angle) override
MoveRotator Go to specific angle.
Definition: integra.cpp:828
const int wellKnownIntegra85RotateMax
Definition: integra.h:35
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
Definition: integra.cpp:418
virtual bool SyncRotator(double angle) override
SyncRotator Set current angle as the supplied angle without moving the rotator.
Definition: integra.cpp:882
virtual void TimerHit() override
Callback function to be called once SetTimer duration elapses.
Definition: integra.cpp:538
virtual IPState MoveAbsFocuser(uint32_t targetTicks) override
MoveFocuser the focuser to an absolute position.
Definition: integra.cpp:502
virtual bool saveConfigItems(FILE *fp) override
saveConfigItems Saves the Device Port and Focuser Presets in the configuration file
Definition: integra.cpp:818
virtual IPState MoveRelFocuser(FocusDirection dir, uint32_t ticks) override
MoveFocuser the focuser to an relative position.
Definition: integra.cpp:517
virtual bool Handshake() override
perform handshake with device to check communication
Definition: integra.cpp:179
MotorType
Definition: integra.h:29
@ MOTOR_FOCUS
Definition: integra.h:29
@ MOTOR_ROTATOR
Definition: integra.h:29
virtual bool updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
Definition: integra.cpp:147
virtual bool AbortFocuser() override
AbortFocuser all focus motion.
Definition: integra.cpp:687
virtual ~Integra()=default
const int wellKnownIntegra85FocusMax
Definition: integra.h:34
ISState
Switch state.
Definition: indiapi.h:150
IPState
Property state.
Definition: indiapi.h:160
__le16 type
Definition: pwc-ioctl.h:0
__u8 cmd[4]
Definition: pwc-ioctl.h:2
One number descriptor.
One switch descriptor.
Number vector property descriptor.
Definition: indiapi.h:319
Switch vector property descriptor.
Definition: indiapi.h:367