Instrument Neutral Distributed Interface INDI 2.2.5
gemini_flatpanel_adapters.h
Go to the documentation of this file.
1#pragma once
2
3#include <cstdint>
4
5// Forward declaration to avoid circular dependencies
7
8// Constants that may be needed by adapters
9#define GEMINI_MIN_BRIGHTNESS 0
10#define GEMINI_MAX_BRIGHTNESS 255
11#define SERIAL_TIMEOUT_SEC 10
12#define SERIAL_TIMEOUT_SEC_LONG 120
13#define NO_VALUE 1000 // Used to indicate that no value is provided
14// Note: MAXRBUF is already defined in INDI headers
15
16// Gemini device constants
25
33
39
40// Status constants used by all adapters
48
54
60
66
72
80{
81 public:
82 virtual ~GeminiFlatpanelAdapter() = default;
83
84 // Device detection and identification
85
90 virtual bool ping() = 0;
91
96 virtual int getRevision() const = 0;
97
103 virtual bool getFirmwareVersion(int *version) = 0;
104
105 // Capability checks
106
111 virtual bool supportsBeep() const = 0;
112
117 virtual bool supportsDustCap() const = 0;
118
123 virtual bool supportsBrightnessMode() const = 0;
124
125 // Basic device commands (supported by all revisions)
126
132 virtual bool getConfigStatus(int *status) = 0;
133
139 virtual bool getBrightness(int *brightness) = 0;
140
146 virtual bool setBrightness(int value) = 0;
147
152 virtual bool lightOn() = 0;
153
158 virtual bool lightOff() = 0;
159
164 virtual bool openCover() = 0;
165
170 virtual bool closeCover() = 0;
171
179 virtual bool getStatus(int *coverStatus, int *lightStatus, int *motorStatus) = 0;
180
181 // Motion/calibration commands
182
189 virtual bool move(uint16_t value, int direction) = 0;
190
195 virtual bool setClosePosition() = 0;
196
201 virtual bool setOpenPosition() = 0;
202
203 // Advanced commands (may not be supported by all revisions)
204
210 virtual bool setBeep(bool enable) = 0;
211
217 virtual bool setBrightnessMode(int mode) = 0;
218
219 // Communication setup
220
225 virtual char getCommandTerminator() const = 0;
226
231 virtual void setupCommunication(int portFD) = 0;
232};
233
244{
245 private:
246 int portFD;
247
248 // Internal helper methods for Rev1 protocol
249
257 bool formatCommand(char commandLetter, char *commandString, int value = NO_VALUE);
258
267 bool sendCommand(const char *command, char *response, int timeout = SERIAL_TIMEOUT_SEC, bool log = true);
268
276 bool extractIntValue(const char *response, int startPos, int *value);
277
278 public:
280
281 // Device detection and identification
282 bool ping() override;
283 int getRevision() const override
284 {
285 return GEMINI_REVISION_1;
286 }
287 bool getFirmwareVersion(int *version) override;
288
289 // Capability checks
290 bool supportsBeep() const override
291 {
292 return false;
293 }
294 bool supportsDustCap() const override
295 {
296 return true;
297 }
298 bool supportsBrightnessMode() const override
299 {
300 return false;
301 }
302
303 // Basic device commands
304 bool getConfigStatus(int *status) override;
305 bool getBrightness(int *brightness) override;
306 bool setBrightness(int value) override;
307 bool lightOn() override;
308 bool lightOff() override;
309 bool openCover() override;
310 bool closeCover() override;
311 bool getStatus(int *coverStatus, int *lightStatus, int *motorStatus) override;
312
313 // Motion/calibration commands
314 bool move(uint16_t value, int direction) override;
315 bool setClosePosition() override;
316 bool setOpenPosition() override;
317
318 // Advanced commands (not supported by Rev1)
319 bool setBeep(bool enable) override
320 {
321 (void)enable; // Not supported
322 return false;
323 }
324 bool setBrightnessMode(int mode) override
325 {
326 (void)mode; // Not supported
327 return false;
328 }
329
330 // Communication setup
331 char getCommandTerminator() const override
332 {
333 return '\n';
334 }
335 void setupCommunication(int portFD) override
336 {
337 this->portFD = portFD;
338 }
339};
340
352{
353 private:
354 int portFD;
355
356 // Internal helper methods for Rev2 protocol
357
365 bool formatCommand(char commandLetter, char *commandString, int value = NO_VALUE);
366
375 bool sendCommand(const char *command, char *response, int timeout = SERIAL_TIMEOUT_SEC, bool log = true);
376
384 bool extractIntValue(const char *response, int startPos, int *value);
385
386 public:
388
389 // Device detection and identification
390 bool ping() override;
391 int getRevision() const override
392 {
393 return GEMINI_REVISION_2;
394 }
395 bool getFirmwareVersion(int *version) override;
396
397 // Capability checks
398 bool supportsBeep() const override
399 {
400 return true;
401 }
402 bool supportsDustCap() const override
403 {
404 return true;
405 }
406 bool supportsBrightnessMode() const override
407 {
408 return true;
409 }
410
411 // Basic device commands
412 bool getConfigStatus(int *status) override;
413 bool getBrightness(int *brightness) override;
414 bool setBrightness(int value) override;
415 bool lightOn() override;
416 bool lightOff() override;
417 bool openCover() override;
418 bool closeCover() override;
419 bool getStatus(int *coverStatus, int *lightStatus, int *motorStatus) override;
420
421 // Motion/calibration commands
422 bool move(uint16_t value, int direction) override;
423 bool setClosePosition() override;
424 bool setOpenPosition() override;
425
426 // Advanced commands (fully supported by Rev2)
427 bool setBeep(bool enable) override;
428 bool setBrightnessMode(int mode) override;
429
430 // Communication setup
431 char getCommandTerminator() const override
432 {
433 return '#';
434 }
435 void setupCommunication(int portFD) override
436 {
437 this->portFD = portFD;
438 }
439};
440
452{
453 private:
454 int portFD;
455
456 // Internal helper methods for Lite protocol
457
465 bool formatCommand(char commandLetter, char *commandString, int value = NO_VALUE);
466
475 bool sendCommand(const char *command, char *response, int timeout = SERIAL_TIMEOUT_SEC, bool log = true);
476
484 bool extractIntValue(const char *response, int startPos, int *value);
485
486 public:
488
489 // Device detection and identification
490 bool ping() override;
491 int getRevision() const override
492 {
494 }
495 bool getFirmwareVersion(int *version) override;
496
497 // Capability checks
498 bool supportsBeep() const override
499 {
500 return true;
501 }
502 bool supportsDustCap() const override
503 {
504 return false; // Lite version is not motorized
505 }
506 bool supportsBrightnessMode() const override
507 {
508 return true;
509 }
510
511 // Basic device commands
512 bool getConfigStatus(int *status) override;
513 bool getBrightness(int *brightness) override;
514 bool setBrightness(int value) override;
515 bool lightOn() override;
516 bool lightOff() override;
517 bool openCover() override; // Not supported, always returns false
518 bool closeCover() override; // Not supported, always returns false
519 bool getStatus(int *coverStatus, int *lightStatus, int *motorStatus) override;
520
521 // Motion/calibration commands (not supported by Lite)
522 bool move(uint16_t value, int direction) override
523 {
524 (void)value;
525 (void)direction;
526 return false;
527 }
528 bool setClosePosition() override
529 {
530 return false;
531 }
532 bool setOpenPosition() override
533 {
534 return false;
535 }
536
537 // Advanced commands (fully supported by Lite)
538 bool setBeep(bool enable) override;
539 bool setBrightnessMode(int mode) override;
540
541 // Communication setup
542 char getCommandTerminator() const override
543 {
544 return '#';
545 }
546 void setupCommunication(int portFD) override
547 {
548 this->portFD = portFD;
549 }
550};
551
563{
564 private:
565 int portFD;
566
567 // Internal helper methods for Pro protocol
568
576 bool formatCommand(char commandLetter, char *commandString, int value = NO_VALUE);
577
586 bool sendCommand(const char *command, char *response, int timeout = SERIAL_TIMEOUT_SEC, bool log = true);
587
595 bool extractIntValue(const char *response, int startPos, int *value);
596
597 public:
599
600 // Device detection and identification
601 bool ping() override;
602 int getRevision() const override
603 {
604 return GEMINI_REVISION_PRO;
605 }
606 bool getFirmwareVersion(int *version) override;
607
608 // Capability checks
609 bool supportsBeep() const override
610 {
611 return false;
612 }
613 bool supportsDustCap() const override
614 {
615 return true;
616 }
617 bool supportsBrightnessMode() const override
618 {
619 return false;
620 }
621
622 // Basic device commands
623 bool getConfigStatus(int *status) override;
624 bool getBrightness(int *brightness) override;
625 bool setBrightness(int value) override;
626 bool lightOn() override;
627 bool lightOff() override;
628 bool openCover() override; // Not supported, always returns false
629 bool closeCover() override; // Not supported, always returns false
630 bool getStatus(int *coverStatus, int *lightStatus, int *motorStatus) override;
631
632 // Motion/calibration commands
633 bool move(uint16_t value, int direction) override;
634 bool setClosePosition() override;
635 bool setOpenPosition() override;
636
637 // Advanced commands (fully supported by Pro)
638 bool setBeep(bool enable) override;
639 bool setBrightnessMode(int mode) override;
640
641 // Communication setup
642 char getCommandTerminator() const override
643 {
644 return '#';
645 }
646 void setupCommunication(int portFD) override
647 {
648 this->portFD = portFD;
649 }
650};
651
659{
660 public:
661 GeminiFlatpanelSimulationAdapter(bool simulateRev2Features = true);
662
663 // Device detection and identification
664 bool ping() override;
665 int getRevision() const override;
666 bool getFirmwareVersion(int *version) override;
667
668 // Capability checks
669 bool supportsBeep() const override;
670 bool supportsDustCap() const override;
671 bool supportsBrightnessMode() const override;
672
673 // Basic device commands
674 bool getConfigStatus(int *status) override;
675 bool getBrightness(int *brightness) override;
676 bool setBrightness(int value) override;
677 bool lightOn() override;
678 bool lightOff() override;
679 bool openCover() override;
680 bool closeCover() override;
681 bool getStatus(int *coverStatus, int *lightStatus, int *motorStatus) override;
682
683 // Motion/calibration commands
684 bool move(uint16_t value, int direction) override;
685 bool setClosePosition() override;
686 bool setOpenPosition() override;
687
688 // Advanced commands
689 bool setBeep(bool enable) override;
690 bool setBrightnessMode(int mode) override;
691
692 // Communication setup
693 char getCommandTerminator() const override;
694 void setupCommunication(int portFD) override;
695
696 private:
697 // Simulation state
698 enum SimulationIndex
699 {
700 SIM_MOTOR = 0,
701 SIM_LIGHT,
702 SIM_COVER,
703 SIM_BRIGHTNESS,
704 SIM_CONFIG_STATUS,
705 SIM_BEEP_ENABLED,
706 SIM_BRIGHTNESS_MODE,
707 SIM_N
708 };
709
710 int simulationValues[SIM_N];
711 bool simulateRev2Features;
712 int simulatedRevision;
713 int simulatedFirmwareVersion;
714};
715
void log(const std::string &log)
Definition Utils.cpp:161
Abstract adapter interface for Gemini Flatpanel firmware versions.
virtual bool getFirmwareVersion(int *version)=0
Get the firmware version from the device.
virtual char getCommandTerminator() const =0
Get the command terminator character for this revision.
virtual bool setOpenPosition()=0
Set the current position as the open position.
virtual bool openCover()=0
Open the dust cover.
virtual bool supportsBeep() const =0
Check if device supports beep functionality.
virtual bool supportsBrightnessMode() const =0
Check if device supports brightness mode selection (high/low)
virtual bool move(uint16_t value, int direction)=0
Move the cover by a specified amount.
virtual bool getConfigStatus(int *status)=0
Get the current configuration status.
virtual bool supportsDustCap() const =0
Check if device supports dust cap functionality.
virtual ~GeminiFlatpanelAdapter()=default
virtual bool closeCover()=0
Close the dust cover.
virtual void setupCommunication(int portFD)=0
Set up communication parameters for this revision.
virtual bool setBeep(bool enable)=0
Enable or disable beep functionality.
virtual bool getBrightness(int *brightness)=0
Get the current brightness level.
virtual bool lightOff()=0
Turn the light off.
virtual bool getStatus(int *coverStatus, int *lightStatus, int *motorStatus)=0
Get the current device status.
virtual bool lightOn()=0
Turn the light on.
virtual bool setBrightness(int value)=0
Set the brightness level.
virtual bool setClosePosition()=0
Set the current position as the closed position.
virtual int getRevision() const =0
Get the firmware revision this adapter supports.
virtual bool setBrightnessMode(int mode)=0
Set the brightness mode (high/low)
virtual bool ping()=0
Ping the device to check if it responds to this adapter's protocol.
Concrete adapter implementation for Gemini Flatpanel Lite firmware.
bool getBrightness(int *brightness) override
Get the current brightness level.
bool setOpenPosition() override
Set the current position as the open position.
bool move(uint16_t value, int direction) override
Move the cover by a specified amount.
bool setBrightnessMode(int mode) override
Set the brightness mode (high/low)
bool supportsDustCap() const override
Check if device supports dust cap functionality.
bool openCover() override
Open the dust cover.
bool lightOff() override
Turn the light off.
bool closeCover() override
Close the dust cover.
bool lightOn() override
Turn the light on.
bool ping() override
Ping the device to check if it responds to this adapter's protocol.
char getCommandTerminator() const override
Get the command terminator character for this revision.
bool getConfigStatus(int *status) override
Get the current configuration status.
bool supportsBeep() const override
Check if device supports beep functionality.
int getRevision() const override
Get the firmware revision this adapter supports.
void setupCommunication(int portFD) override
Set up communication parameters for this revision.
bool getStatus(int *coverStatus, int *lightStatus, int *motorStatus) override
Get the current device status.
bool setBrightness(int value) override
Set the brightness level.
bool setBeep(bool enable) override
Enable or disable beep functionality.
bool setClosePosition() override
Set the current position as the closed position.
bool getFirmwareVersion(int *version) override
Get the firmware version from the device.
bool supportsBrightnessMode() const override
Check if device supports brightness mode selection (high/low)
Concrete adapter implementation for Gemini Pro firmware.
bool supportsBeep() const override
Check if device supports beep functionality.
bool lightOff() override
Turn the light off.
bool setOpenPosition() override
Set the current position as the open position.
bool openCover() override
Open the dust cover.
bool setClosePosition() override
Set the current position as the closed position.
bool getBrightness(int *brightness) override
Get the current brightness level.
bool move(uint16_t value, int direction) override
Move the cover by a specified amount.
bool supportsBrightnessMode() const override
Check if device supports brightness mode selection (high/low)
bool setBrightness(int value) override
Set the brightness level.
bool getConfigStatus(int *status) override
Get the current configuration status.
void setupCommunication(int portFD) override
Set up communication parameters for this revision.
bool setBeep(bool enable) override
Enable or disable beep functionality.
bool supportsDustCap() const override
Check if device supports dust cap functionality.
bool lightOn() override
Turn the light on.
bool setBrightnessMode(int mode) override
Set the brightness mode (high/low)
char getCommandTerminator() const override
Get the command terminator character for this revision.
int getRevision() const override
Get the firmware revision this adapter supports.
bool getStatus(int *coverStatus, int *lightStatus, int *motorStatus) override
Get the current device status.
bool getFirmwareVersion(int *version) override
Get the firmware version from the device.
bool closeCover() override
Close the dust cover.
bool ping() override
Ping the device to check if it responds to this adapter's protocol.
Concrete adapter implementation for Gemini Flatpanel Revision 1 firmware.
bool setClosePosition() override
Set the current position as the closed position.
bool getConfigStatus(int *status) override
Get the current configuration status.
bool supportsDustCap() const override
Check if device supports dust cap functionality.
bool move(uint16_t value, int direction) override
Move the cover by a specified amount.
bool getFirmwareVersion(int *version) override
Get the firmware version from the device.
bool lightOff() override
Turn the light off.
int getRevision() const override
Get the firmware revision this adapter supports.
bool setBrightnessMode(int mode) override
Set the brightness mode (high/low)
bool openCover() override
Open the dust cover.
bool lightOn() override
Turn the light on.
bool supportsBeep() const override
Check if device supports beep functionality.
bool supportsBrightnessMode() const override
Check if device supports brightness mode selection (high/low)
bool getBrightness(int *brightness) override
Get the current brightness level.
bool setBeep(bool enable) override
Enable or disable beep functionality.
void setupCommunication(int portFD) override
Set up communication parameters for this revision.
bool setBrightness(int value) override
Set the brightness level.
char getCommandTerminator() const override
Get the command terminator character for this revision.
bool closeCover() override
Close the dust cover.
bool getStatus(int *coverStatus, int *lightStatus, int *motorStatus) override
Get the current device status.
bool ping() override
Ping the device to check if it responds to this adapter's protocol.
bool setOpenPosition() override
Set the current position as the open position.
Concrete adapter implementation for Gemini Flatpanel Revision 2 firmware.
bool getStatus(int *coverStatus, int *lightStatus, int *motorStatus) override
Get the current device status.
bool lightOff() override
Turn the light off.
bool getConfigStatus(int *status) override
Get the current configuration status.
bool supportsBeep() const override
Check if device supports beep functionality.
bool setBrightness(int value) override
Set the brightness level.
char getCommandTerminator() const override
Get the command terminator character for this revision.
bool setBrightnessMode(int mode) override
Set the brightness mode (high/low)
int getRevision() const override
Get the firmware revision this adapter supports.
void setupCommunication(int portFD) override
Set up communication parameters for this revision.
bool supportsBrightnessMode() const override
Check if device supports brightness mode selection (high/low)
bool setClosePosition() override
Set the current position as the closed position.
bool setOpenPosition() override
Set the current position as the open position.
bool setBeep(bool enable) override
Enable or disable beep functionality.
bool openCover() override
Open the dust cover.
bool getFirmwareVersion(int *version) override
Get the firmware version from the device.
bool move(uint16_t value, int direction) override
Move the cover by a specified amount.
bool getBrightness(int *brightness) override
Get the current brightness level.
bool supportsDustCap() const override
Check if device supports dust cap functionality.
bool ping() override
Ping the device to check if it responds to this adapter's protocol.
bool lightOn() override
Turn the light on.
bool closeCover() override
Close the dust cover.
Simulation adapter for testing and development.
bool getBrightness(int *brightness) override
Get the current brightness level.
bool supportsBrightnessMode() const override
Check if device supports brightness mode selection (high/low)
bool setBeep(bool enable) override
Enable or disable beep functionality.
bool setBrightnessMode(int mode) override
Set the brightness mode (high/low)
bool closeCover() override
Close the dust cover.
bool supportsDustCap() const override
Check if device supports dust cap functionality.
bool openCover() override
Open the dust cover.
int getRevision() const override
Get the firmware revision this adapter supports.
bool getFirmwareVersion(int *version) override
Get the firmware version from the device.
bool lightOn() override
Turn the light on.
bool getStatus(int *coverStatus, int *lightStatus, int *motorStatus) override
Get the current device status.
bool setClosePosition() override
Set the current position as the closed position.
void setupCommunication(int portFD) override
Set up communication parameters for this revision.
char getCommandTerminator() const override
Get the command terminator character for this revision.
bool setBrightness(int value) override
Set the brightness level.
bool supportsBeep() const override
Check if device supports beep functionality.
bool getConfigStatus(int *status) override
Get the current configuration status.
bool lightOff() override
Turn the light off.
bool move(uint16_t value, int direction) override
Move the cover by a specified amount.
bool setOpenPosition() override
Set the current position as the open position.
bool ping() override
Ping the device to check if it responds to this adapter's protocol.
#define NO_VALUE
#define SERIAL_TIMEOUT_SEC
@ GEMINI_REVISION_UNKNOWN
@ GEMINI_CONFIG_NOTREADY
@ GEMINI_COVER_STATUS_TIMED_OUT
@ GEMINI_COVER_STATUS_CLOSED
@ GEMINI_COVER_STATUS_OPEN
@ GEMINI_COVER_STATUS_MOVING
@ GEMINI_DIRECTION_OPEN
@ GEMINI_DIRECTION_CLOSE
@ GEMINI_BRIGHTNESS_MODE_HIGH
@ GEMINI_BRIGHTNESS_MODE_LOW
@ GEMINI_MOTOR_STATUS_STOPPED
@ GEMINI_MOTOR_STATUS_RUNNING
@ GEMINI_LIGHT_STATUS_ON
@ GEMINI_LIGHT_STATUS_OFF