Instrument Neutral Distributed Interface INDI 2.2.5
camelot.h
Go to the documentation of this file.
1/*
2 INDI Camelot Rotator
3 Copyright (C) 2025 Jasem Mutlaq ([email protected])
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
25#include <memory>
26#include <string>
27#include <vector>
28
29class Camelot : public INDI::Rotator
30{
31 public:
32 Camelot();
33 virtual ~Camelot() = default;
34
35 const char *getDefaultName() override;
36
37 bool initProperties() override;
38 bool updateProperties() override;
39 bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override;
40 bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override;
41
42 protected:
43 // Rotator specific functions
44 IPState MoveRotator(double degrees) override;
45 bool SyncRotator(double degrees) override;
46 bool AbortRotator() override;
47 bool ReverseRotator(bool enabled) override;
48
49 // Device specific functions
50 bool Handshake() override;
51 void TimerHit() override;
52 bool saveConfigItems(FILE *fp) override;
53
54 private:
55 enum RotatorSpeed
56 {
57 SPEED_FAST,
58 SPEED_MEDIUM,
59 SPEED_SLOW
60 };
61
62 enum RotatorPower
63 {
64 POWER_NORMAL,
65 POWER_HOLD
66 };
67
68 bool queryStatus();
69
73
84 bool sendCommand(const char * cmd, char * res = nullptr, int cmd_len = -1, int res_len = -1);
85 void hexDump(char * buf, const char * data, uint32_t size);
86
87 // Properties
88 INDI::PropertySwitch RotatorSpeedSP { 3 };
89 INDI::PropertyNumber RotatorPowerNP { 2 };
90
94 static constexpr const uint8_t DRIVER_STOP_CHAR {0x23};
95 static constexpr const uint8_t DRIVER_TIMEOUT {2};
96 static constexpr const uint8_t DRIVER_LEN {64};
97};
bool SyncRotator(double degrees) override
SyncRotator Set current angle as the supplied angle without moving the rotator.
Definition camelot.cpp:192
bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
Definition camelot.cpp:203
bool updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
Definition camelot.cpp:72
Camelot()
Definition camelot.cpp:37
bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
Definition camelot.cpp:225
bool Handshake() override
perform handshake with device to check communication
Definition camelot.cpp:139
const char * getDefaultName() override
Definition camelot.cpp:131
bool saveConfigItems(FILE *fp) override
Save configuration items.
Definition camelot.cpp:324
bool AbortRotator() override
AbortRotator Abort all motion.
Definition camelot.cpp:175
bool ReverseRotator(bool enabled) override
ReverseRotator Reverse the direction of the rotator. CW is usually the normal direction,...
Definition camelot.cpp:183
bool initProperties() override
Initialize properties initial state and value. The child class must implement this function.
Definition camelot.cpp:45
IPState MoveRotator(double degrees) override
MoveRotator Go to specific angle.
Definition camelot.cpp:159
virtual ~Camelot()=default
void TimerHit() override
Callback function to be called once SetTimer duration elapses.
Definition camelot.cpp:282
ISState
Switch state.
Definition indiapi.h:148
IPState
Property state.
Definition indiapi.h:158
uint8_t cmd[4]
Definition pwc-ioctl.h:2