Instrument Neutral Distributed Interface INDI 2.2.5
nfocus.h
Go to the documentation of this file.
1/*
2 NFocus DC Relative Focuser
3
4 Copyright (C) 2019 Jasem Mutlaq ([email protected])
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
46class NFocus : public INDI::Focuser
47{
48 public:
49 NFocus();
50
51 virtual bool Handshake() override;
52 const char *getDefaultName() override;
53 virtual bool initProperties() override;
54 virtual bool updateProperties() override;
55 virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override;
56
57 protected:
58 virtual void TimerHit() override;
59 virtual IPState MoveRelFocuser(FocusDirection dir, uint32_t ticks) override;
60 virtual bool AbortFocuser() override;
61
62 bool saveConfigItems(FILE *fp) override;
63
64 private:
65 bool readTemperature();
66 bool readMotorSettings();
67 bool setMotorSettings(double onTime, double offTime, double fastDelay);
68
69 // Utility
70 bool sendCommand(const char * cmd, char * res = nullptr, int cmd_len = -1, int res_len = -1);
71 bool getStartupValues();
72 void hexDump(char * buf, const char * data, int size);
73 bool isMoving();
74
78 INumber TemperatureN[1];
79 INumberVectorProperty TemperatureNP;
80
81 INumber SettingsN[3];
82 INumberVectorProperty SettingsNP;
83 enum
84 {
85 SETTING_ON_TIME,
86 SETTING_OFF_TIME,
87 SETTING_MODE_DELAY,
88 };
89
93 uint16_t m_TargetPosition { 0 };
94 uint16_t m_TemperatureCounter { 0 };
95
99 static constexpr const char * SETTINGS_TAB = "Settings";
100 // '#' is the stop char
101 static const char NFOCUS_STOP_CHAR { 0x23 };
102 // Update temperature every 10x POLLMS. For 500ms, we would
103 // update the temperature one every 5 seconds.
104 static constexpr const uint8_t NFOCUS_TEMPERATURE_FREQ {10};
105 // Wait up to a maximum of 3 seconds for serial input
106 static constexpr const uint8_t NFOCUS_TIMEOUT {3};
107 // Maximum buffer for sending/receiving.
108 static constexpr const uint8_t NFOCUS_LEN {64};
109};
The NFocus class Handles communication and control with nFocus DC focuser.
Definition nfocus.h:47
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...
Definition nfocus.cpp:229
virtual IPState MoveRelFocuser(FocusDirection dir, uint32_t ticks) override
MoveFocuser the focuser to an relative position.
Definition nfocus.cpp:307
virtual bool AbortFocuser() override
AbortFocuser all focus motion.
Definition nfocus.cpp:314
virtual void TimerHit() override
Callback function to be called once SetTimer duration elapses.
Definition nfocus.cpp:319
virtual bool Handshake() override
Performs a device-specific handshake after a connection is established. This method should be overrid...
Definition nfocus.cpp:92
bool saveConfigItems(FILE *fp) override
Definition nfocus.cpp:377
virtual bool initProperties() override
Initializes the default properties for the focuser device. Sets up standard INDI properties,...
Definition nfocus.cpp:38
const char * getDefaultName() override
Definition nfocus.cpp:87
NFocus()
Definition nfocus.cpp:32
virtual bool updateProperties() override
Updates the state and definition of properties based on the current connection status....
Definition nfocus.cpp:65
IPState
Property state.
Definition indiapi.h:158
uint8_t cmd[4]
Definition pwc-ioctl.h:2
One number descriptor.
Number vector property descriptor.
Definition indiapi.h:317