Instrument Neutral Distributed Interface INDI 2.2.5
xagyl_wheel.h
Go to the documentation of this file.
1/*******************************************************************************
2 Copyright(c) 2020 Jasem Mutlaq. All rights reserved.
3 Copyright(c) 2020 Justin Husted.
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License version 2 as published by the Free Software Foundation.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
18*******************************************************************************/
19
20#pragma once
21
22#include "indifilterwheel.h"
23
25{
26 public:
44
45 XAGYLWheel();
46 virtual ~XAGYLWheel() override;
47
48 virtual bool initProperties() override;
49 virtual bool updateProperties() override;
50
51 virtual bool ISNewSwitch(const char *dev, const char *name,
52 ISState *states, char *names[], int n) override;
53 virtual bool ISNewNumber(const char *dev, const char *name,
54 double values[], char *names[], int n) override;
55
56 protected:
57 const char *getDefaultName() override;
58
59 bool Handshake() override;
60
61 bool SelectFilter(int) override;
62 bool saveConfigItems(FILE *fp) override;
63
64 private:
65 bool setMaximumSpeed(int value);
66 bool setRelativeCommand(SET_COMMAND command, int value);
67
68 void initOffset();
69
70 bool getStartupData();
71 bool getFirmwareInfo();
72 bool getSettingInfo();
73
74 bool getFilterPosition();
75 bool getMaximumSpeed();
76 bool getJitter();
77 bool getThreshold();
78 bool getMaxFilterSlots();
79 bool getPulseWidth();
80
81 // Calibration offset
82 bool getOffset(int filter);
83 bool setOffset(int filter, int shift);
84
85 // Reset
86 bool reset(int value);
87
91 bool receiveResponse(char * res, bool optional = false);
92 bool sendCommand(const char * cmd, char * res);
93 void hexDump(char * buf, const char * data, int size);
94
98
99 // Firmware info
100 ITextVectorProperty FirmwareInfoTP;
101 IText FirmwareInfoT[3] {};
102 enum
103 {
104 FIRMWARE_PRODUCT,
105 FIRMWARE_VERSION,
106 FIRMWARE_SERIAL,
107 };
108
109 // Settings
110 INumberVectorProperty SettingsNP;
111 INumber SettingsN[4];
112 enum
113 {
114 SETTING_SPEED,
115 SETTING_JITTER,
116 SETTING_THRESHOLD,
117 SETTING_PW,
118 };
119
120 // Filter Offset
121 INumberVectorProperty OffsetNP;
122 INumber *OffsetN { nullptr };
123
124 // Reset
125 ISwitchVectorProperty ResetSP;
126 ISwitch ResetS[4];
127 enum
128 {
129 COMMAND_REBOOT,
130 COMMAND_INIT,
131 COMMAND_CLEAR_CALIBRATION,
132 COMMAND_PERFORM_CALIBRAITON,
133 };
134
135 uint8_t m_FirmwareVersion { 0 };
136
140 static constexpr const char * SETTINGS_TAB = "Settings";
141
142 // 0xA is the stop char
143 static const char DRIVER_STOP_CHAR { 0xA };
144
145 // Wait up to a maximum of 15 seconds for normal serial input
146 static constexpr const int DRIVER_TIMEOUT {15};
147
148 // Some commands optionally return an extra string.
149 static constexpr const int OPTIONAL_TIMEOUT {1};
150
151 // Maximum buffer for sending/receiving.
152 static constexpr const int DRIVER_LEN {64};
153};
virtual bool updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
bool Handshake() override
perform handshake with device to check communication
virtual ~XAGYLWheel() override
virtual bool initProperties() override
Initialize properties initial state and value. The child class must implement this function.
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
@ INFO_FILTER_POSITION
Definition xagyl_wheel.h:31
@ INFO_PRODUCT_NAME
Definition xagyl_wheel.h:29
@ INFO_FIRMWARE_VERSION
Definition xagyl_wheel.h:30
@ INFO_SERIAL_NUMBER
Definition xagyl_wheel.h:32
bool saveConfigItems(FILE *fp) override
saveConfigItems Save specific properties in the provide config file handler. Child class usually over...
bool SelectFilter(int) override
Select a new filter position.
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
const char * getDefaultName() override
ISState
Switch state.
Definition indiapi.h:148
uint8_t cmd[4]
Definition pwc-ioctl.h:2
One number descriptor.
One switch descriptor.
One text descriptor.
Number vector property descriptor.
Definition indiapi.h:317
Switch vector property descriptor.
Definition indiapi.h:365
Text vector property descriptor.
Definition indiapi.h:244