Instrument Neutral Distributed Interface INDI 2.2.5
ikunfocuser.h
Go to the documentation of this file.
1/*
2 INDI driver for IKunFocuser
3 Copyright (C) 2026 IKunFocuser contributors
4 SPDX-License-Identifier: LGPL-2.1-or-later
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
17#pragma once
18
20#include "indifocuser.h"
21
22#include <cstddef>
23#include <cstdint>
24
26{
27 public:
29 ~IKunFocuser() override = default;
30
31 const char *getDefaultName() override;
32 bool initProperties() override;
33 bool updateProperties() override;
34 bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override;
35 bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override;
36
37 protected:
38 bool Handshake() override;
39 IPState MoveAbsFocuser(uint32_t targetTicks) override;
40 IPState MoveRelFocuser(FocusDirection dir, uint32_t ticks) override;
41 bool AbortFocuser() override;
42 bool SyncFocuser(uint32_t ticks) override;
43 bool ReverseFocuser(bool enabled) override;
44 bool SetFocuserMaxPosition(uint32_t ticks) override;
45 bool SetFocuserSpeed(int speed) override;
46 void TimerHit() override;
47
48 private:
49 enum
50 {
51 HOLD_ON,
52 HOLD_OFF
53 };
54
55 enum
56 {
57 FIRMWARE_VERSION,
58 CONTROLLER_MODEL
59 };
60
61 bool sendCommand(const char *command, char *response, std::size_t responseSize, bool silent = false);
62 bool readMotionStatus(IKunFocuserProtocol::MotionStatus &status, bool silent = false);
63 bool readFullState();
64 bool setAcceleration(uint32_t acceleration);
65 bool setHold(bool enabled);
66 void applyMaximumPosition(uint32_t maximum);
67 void applyMotionStatus(const IKunFocuserProtocol::MotionStatus &status);
68 void markMotionAlert();
69
70 INDI::PropertyNumber AccelerationNP { 1 };
71 INDI::PropertySwitch HoldSP { 2 };
72 INDI::PropertyNumber TemperatureNP { 1 };
73 INDI::PropertyText FirmwareTP { 2 };
74
75 uint32_t m_LastPosition { 0 };
76 uint32_t m_FixedSpeed { 300 };
77 uint8_t m_CommunicationFailures { 0 };
78 uint8_t m_TemperaturePollCounter { 0 };
79 int m_FirmwareVersion { 0 };
80
81 static constexpr std::size_t RESPONSE_SIZE = 1024;
82 static constexpr uint8_t IO_TIMEOUT_SECONDS = 3;
83 static constexpr uint8_t MAX_COMMUNICATION_FAILURES = 3;
84};
const char * getDefaultName() override
IPState MoveRelFocuser(FocusDirection dir, uint32_t ticks) override
MoveFocuser the focuser to an relative position.
bool AbortFocuser() override
AbortFocuser all focus motion.
~IKunFocuser() override=default
IPState MoveAbsFocuser(uint32_t targetTicks) override
MoveFocuser the focuser to an absolute position.
bool Handshake() override
Performs a device-specific handshake after a connection is established. This method should be overrid...
bool SetFocuserSpeed(int speed) override
SetFocuserSpeed Set Focuser speed.
bool SyncFocuser(uint32_t ticks) override
SyncFocuser Set current position to ticks without moving the focuser.
bool updateProperties() override
Updates the state and definition of properties based on the current connection status....
bool SetFocuserMaxPosition(uint32_t ticks) override
SetFocuserMaxPosition Update focuser maximum position. It only updates the PresetNP property limits.
bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Processes incoming new switch states from the client for this device. Handles updates to FocuserInter...
void TimerHit() override
Callback function to be called once SetTimer duration elapses.
bool ReverseFocuser(bool enabled) override
ReverseFocuser Reverse focuser motion direction.
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...
bool initProperties() override
Initializes the default properties for the focuser device. Sets up standard INDI properties,...
ISState
Switch state.
Definition indiapi.h:148
IPState
Property state.
Definition indiapi.h:158