Instrument Neutral Distributed Interface INDI 2.2.5
gemini_flatpanel.h
Go to the documentation of this file.
1#pragma once
2
3#include "defaultdevice.h"
8#include <memory>
9
10#define GEMINI_DEVICE_ID 99
11
12namespace Connection
13{
14class Serial;
15}
16
17// Forward declaration for the adapter
19
21{
22 public:
24 virtual ~GeminiFlatpanel() = default;
25 virtual const char *getDefaultName() override;
26
27 void ISGetProperties(const char *deviceName) override;
28 virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override;
29 virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override;
30 virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override;
31 virtual bool ISSnoopDevice(XMLEle *root) override;
32
33 protected:
34 bool initProperties() override;
35 bool updateProperties() override;
36 bool saveConfigItems(FILE *fp) override;
39
40 void TimerHit() override;
41
42 // From LightBoxInterface
43 bool SetLightBoxBrightness(uint16_t value) override;
44 bool EnableLightBox(bool enable) override;
45
46 // From DustCapInterface
47 virtual IPState ParkCap() override;
48 virtual IPState UnParkCap() override;
49 virtual IPState AbortCap() override;
50
51 // UI interactions
52 void startConfiguration();
53 void endConfiguration();
54 bool validateOperation();
55 bool validateCalibrationOperation(int direction);
56 void onMove(int direction);
57 void onSetPosition(int direction);
58 void cleanupSwitch(INDI::PropertySwitch &currentSwitch, int switchIndex);
59 void onBeepChange();
60
61 private:
62 // Serial connection
63 bool Handshake();
64 int PortFD{-1};
65
66 Connection::Serial *serialConnection{nullptr};
67
68 // Adapter for firmware-specific functionality
69 std::unique_ptr<GeminiFlatpanelAdapter> adapter;
70
71 // Note: Simulation state now managed by GeminiFlatpanelSimulationAdapter
72
73 // Device revision
74 int deviceRevision{-1};
75 char commandTerminator{'\n'};
76
77 // State variables
78 int prevCoverStatus{-1};
79 int prevLightStatus{-1};
80 int prevMotorStatus{-1};
81 int prevBrightness{-1};
82 int configStatus{GEMINI_CONFIG_NOTREADY};
83
84 // Devices that support a Low/High brightness mode (Rev2/Lite) no longer expose a
85 // separate BRIGHTNESS_MODE switch. Instead, LightIntensityNP's range is doubled
86 // (0-255 = Low, 256-511 = High) and SetLightBoxBrightness() decodes which half was
87 // requested -- previewing the single-continuous-range behavior Gemini has said
88 // they plan to move the firmware to (see indilib/indi#2487). Tracked purely
89 // in-memory since the firmware exposes no way to read back the active mode.
90 int brightnessMode{GEMINI_BRIGHTNESS_MODE_LOW};
91
92 // State update methods
93 bool updateCoverStatus(char coverStatus);
94 bool updateLightStatus(char lightStatus);
95 bool updateMotorStatus(char motorStatus);
96 bool updateBrightness(int brightness);
97 void updateConfigStatus();
98
99 // Commands
100 bool sendCommand(const char *command, char *response, int timeout = SERIAL_TIMEOUT_SEC);
101 bool pingRevision1();
102 bool pingRevision2();
103 bool getFirmwareVersion(int *version);
104 bool getConfigStatus();
105 bool getBrightness(int *const brightness);
106 bool setBrightness(int value);
107 bool lightOn();
108 bool lightOff();
109 bool openCover();
110 bool closeCover();
111 bool getStatus(int *const coverStatus, int *const lightStatus, int *const motorStatus);
112 bool move(uint16_t value, int direction);
113 bool setClosePosition();
114 bool setOpenPosition();
115 bool setBeep(bool enable);
116 bool setBrightnessMode(int mode);
117 bool applyUnifiedBrightness(int unifiedValue, bool forceMode);
118
119 // Helper functions
120 bool extractIntValue(const char *response, int startPos, int *value);
121 bool formatCommand(char commandLetter, char *commandString, int value = NO_VALUE);
122
123 // Status properties
124 enum
125 {
126 STATUS_COVER,
127 STATUS_LIGHT,
128 STATUS_MOTOR,
129 STATUS_N
130 };
131 INDI::PropertyText StatusTP{STATUS_N};
132 INDI::PropertyText ConfigurationTP{1};
133 INDI::PropertySwitch BeepSP{2};
134
135 // Limit properties
136 enum
137 {
138 MOVEMENT_LIMITS_45,
139 MOVEMENT_LIMITS_10,
140 MOVEMENT_LIMITS_01,
141 MOVEMENT_LIMITS_N
142 };
143 INDI::PropertySwitch ClosedPositionSP{MOVEMENT_LIMITS_N};
144 INDI::PropertySwitch SetClosedSP{1};
145 INDI::PropertySwitch OpenPositionSP{MOVEMENT_LIMITS_N};
146 INDI::PropertySwitch SetOpenSP{1};
147 INDI::PropertySwitch ConfigureSP{1};
148
149 // Device selection property
150 enum
151 {
152 DEVICE_AUTO,
153 DEVICE_REV1,
154 DEVICE_REV2,
155 DEVICE_LITE,
156 DEVICE_PRO,
157 DEVICE_N
158 };
159 INDI::PropertySwitch DeviceTypeSP{DEVICE_N};
160};
The Serial class manages connection with serial devices including Bluetooth. Serial communication is ...
Abstract adapter interface for Gemini Flatpanel firmware versions.
virtual IPState UnParkCap() override
unPark dust cap (open cover). Must be implemented by child.
bool saveConfigItems(FILE *fp) override
saveConfigItems Save specific properties in the provide config file handler. Child class usually over...
virtual bool ISSnoopDevice(XMLEle *root) override
Process a snoop event from INDI server. This function is called when a snooped property is updated in...
bool updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
virtual const char * getDefaultName() override
bool EnableLightBox(bool enable) override
EnableLightBox Turn on/off on a light box. Must be implemented in the child class.
bool validateCalibrationOperation(int direction)
virtual IPState AbortCap() override
Abort motion. Must be implemented by child.
bool SetLightBoxBrightness(uint16_t value) override
setBrightness Set light level. Must be implemented in the child class, if supported.
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
void onSetPosition(int direction)
void ISGetProperties(const char *deviceName) override
define the driver's properties to the client. Usually, only a minimum set of properties are defined t...
void TimerHit() override
Callback function to be called once SetTimer duration elapses.
void onMove(int direction)
bool initProperties() override
Initialize properties initial state and value. The child class must implement this function.
virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override
Process the client newSwitch command.
virtual ~GeminiFlatpanel()=default
virtual IPState ParkCap() override
Park dust cap (close cover). Must be implemented by child.
void cleanupSwitch(INDI::PropertySwitch &currentSwitch, int switchIndex)
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
Class to provide extended functionality for devices in addition to the functionality provided by INDI...
#define NO_VALUE
#define SERIAL_TIMEOUT_SEC
@ GEMINI_CONFIG_NOTREADY
@ GEMINI_BRIGHTNESS_MODE_LOW
ISState
Switch state.
Definition indiapi.h:148
IPState
Property state.
Definition indiapi.h:158
Combines all INDI Connection Plugins. Each INDI connection plugin is responsible of managing communic...
Definition arduino_st4.h:34