Instrument Neutral Distributed Interface INDI  1.9.5
aaf2.h
Go to the documentation of this file.
1 /*
2  Arduino ASCOM Focuser 2 (AAF2) INDI Focuser
3 
4  Copyright (C) 2019 Jasem Mutlaq (mutlaqja@ikarustech.com)
5 
6  This library is free software; you can redistribute it and/or
7  modify it under the terms of the GNU Lesser General Public
8  License as published by the Free Software Foundation; either
9  version 2.1 of the License, or (at your option) any later version.
10 
11  This library is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  Lesser General Public License for more details.
15 
16  You should have received a copy of the GNU Lesser General Public
17  License along with this library; if not, write to the Free Software
18  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 
20 */
21 
22 #pragma once
23 
24 #include "indifocuser.h"
25 
26 class AAF2 : public INDI::Focuser
27 {
28  public:
29  AAF2();
30  virtual ~AAF2() override = default;
31 
32  const char * getDefaultName() override;
33  virtual bool initProperties() override;
34  virtual bool updateProperties() override;
35 
36  protected:
41  virtual bool Handshake() override;
42 
48  virtual IPState MoveAbsFocuser(uint32_t targetTicks) override;
49 
56  virtual IPState MoveRelFocuser(FocusDirection dir, uint32_t ticks) override;
57 
63  virtual bool SyncFocuser(uint32_t ticks) override;
64 
65  virtual bool AbortFocuser() override;
66  virtual void TimerHit() override;
67 
68  private:
69  bool Ack();
77  bool sendCommand(const char * cmd, char * res = nullptr);
78 
79  // Read and update Temperature
80  bool readTemperature();
81  // Read and update Position
82  bool readPosition();
83  // Read Version
84  bool readVersion();
85  // Are we moving?
86  bool isMoving();
87 
88  // Read Only Temperature Reporting
89  INumber TemperatureN[1];
90  INumberVectorProperty TemperatureNP;
91 
92  double targetPos { 0 }, lastPos { 0 }, lastTemperature { 0 };
93 
94  // AAF2 Buffer
95  static const uint8_t DRIVER_RES { 32 };
96  // AAF2 Delimeter
97  static const char DRIVER_DEL { '#' };
98  // AAF2 Tiemout
99  static const uint8_t DRIVER_TIMEOUT { 3 };
100 };
AAF2::SyncFocuser
virtual bool SyncFocuser(uint32_t ticks) override
SyncFocuser Set the supplied position as the current focuser position.
Definition: aaf2.cpp:222
cmd
__u8 cmd[4]
Definition: pwc-ioctl.h:4
IPState
IPState
Property state.
Definition: indiapi.h:158
INumber
One number descriptor.
AAF2::AAF2
AAF2()
Definition: aaf2.cpp:35
AAF2::MoveRelFocuser
virtual IPState MoveRelFocuser(FocusDirection dir, uint32_t ticks) override
MoveRelFocuser Move focuser for a relative amount of ticks in a specific direction.
Definition: aaf2.cpp:245
AAF2::MoveAbsFocuser
virtual IPState MoveAbsFocuser(uint32_t targetTicks) override
MoveAbsFocuser Move to an absolute target position.
Definition: aaf2.cpp:229
AAF2::AbortFocuser
virtual bool AbortFocuser() override
AbortFocuser all focus motion.
Definition: aaf2.cpp:309
indifocuser.h
_INumberVectorProperty
Number vector property descriptor.
Definition: indiapi.h:317
AAF2::updateProperties
virtual bool updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
Definition: aaf2.cpp:68
AAF2::Handshake
virtual bool Handshake() override
Handshake Try to communicate with Focuser and see if there is a valid response.
Definition: aaf2.cpp:86
AAF2::TimerHit
virtual void TimerHit() override
Callback function to be called once SetTimer duration elapses.
Definition: aaf2.cpp:265
AAF2
Definition: aaf2.h:26
INDI::FocuserInterface::FocusDirection
FocusDirection
Definition: indifocuserinterface.h:66
AAF2::getDefaultName
const char * getDefaultName() override
Definition: aaf2.cpp:101
AAF2::initProperties
virtual bool initProperties() override
Initilize properties initial state and value. The child class must implement this function.
Definition: aaf2.cpp:43
AAF2::~AAF2
virtual ~AAF2() override=default
INDI::Focuser
Definition: indifocuser.h:43