Instrument Neutral Distributed Interface INDI 2.2.5
pegasus_focuscube3.h
Go to the documentation of this file.
1/*******************************************************************************
2 Copyright(c) 2023 Chrysikos Efstathios. All rights reserved.
3
4 Pegasus FocusCube
5
6 This program is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 2 of the License, or (at your option)
9 any later version.
10
11 This program is distributed in the hope that it will be useful, but WITHOUT
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 more details.
15
16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA.
20
21 The full GNU General Public License is included in this distribution in the
22 file called LICENSE.
23*******************************************************************************/
24#pragma once
25
26#include "indifocuser.h"
27
29{
30 public:
32 virtual ~PegasusFocusCube3() override = default;
33
34 virtual bool Handshake() override;
35 const char *getDefaultName() override;
36 virtual bool initProperties() override;
37 virtual bool updateProperties() override;
38 virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override;
39
40 protected:
41 virtual IPState MoveAbsFocuser(uint32_t targetTicks) override;
42 virtual IPState MoveRelFocuser(FocusDirection dir, uint32_t ticks) override;
43 virtual bool AbortFocuser() override;
44 virtual void TimerHit() override;
45
46 virtual bool SyncFocuser(uint32_t ticks) override;
47 virtual bool ReverseFocuser(bool enabled) override;
48 virtual bool SetFocuserBacklash(int32_t steps) override;
49
50
51 char stopChar { 0xD };
52 static constexpr const uint8_t PEGASUS_TIMEOUT {3};
53 static constexpr const uint8_t PEGASUS_LEN {128};
54 int PortFD { -1 };
55 bool setupComplete { false };
56 bool sendCommand(const char *cmd, char *res);
57 std::vector<std::string> split(const std::string &input, const std::string &regex);
58
59 private:
60 bool updateFocusParams();
61 bool setSpeed(uint16_t speed);
62 bool move(uint32_t newPosition);
63 std::string getFirmwareVersion();
64
65 uint32_t currentPosition { 0 };
66 uint32_t targetPosition { 0 };
67 bool isMoving = false;
68
69
70 INDI::PropertyNumber TemperatureNP {1};
71 INDI::PropertyText FirmwareVersionTP {1};
72 INDI::PropertyNumber SpeedNP {1};
73
74
75};
virtual ~PegasusFocusCube3() override=default
virtual bool initProperties() override
Initializes the default properties for the focuser device. Sets up standard INDI properties,...
virtual bool SetFocuserBacklash(int32_t steps) override
SetFocuserBacklash Set the focuser backlash compensation value.
static constexpr const uint8_t PEGASUS_LEN
virtual bool ReverseFocuser(bool enabled) override
ReverseFocuser Reverse focuser motion direction.
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Processes incoming new number values from the client for this device. Handles updates to FocuserInter...
virtual bool SyncFocuser(uint32_t ticks) override
SyncFocuser Set current position to ticks without moving the focuser.
static constexpr const uint8_t PEGASUS_TIMEOUT
bool sendCommand(const char *cmd, char *res)
virtual bool updateProperties() override
Updates the state and definition of properties based on the current connection status....
virtual bool AbortFocuser() override
AbortFocuser all focus motion.
virtual IPState MoveAbsFocuser(uint32_t targetTicks) override
MoveFocuser the focuser to an absolute position.
const char * getDefaultName() override
virtual IPState MoveRelFocuser(FocusDirection dir, uint32_t ticks) override
MoveFocuser the focuser to an relative position.
virtual void TimerHit() override
Callback function to be called once SetTimer duration elapses.
std::vector< std::string > split(const std::string &input, const std::string &regex)
virtual bool Handshake() override
Performs a device-specific handshake after a connection is established. This method should be overrid...
IPState
Property state.
Definition indiapi.h:158
uint8_t cmd[4]
Definition pwc-ioctl.h:2