Instrument Neutral Distributed Interface INDI 2.2.5
ifwoptec.h
Go to the documentation of this file.
1/*******************************************************************************
2 Copyright(c) 2016 Philippe Besson. All rights reserved.
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License version 2 as published by the Free Software Foundation.
7
8 This library is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 Library General Public License for more details.
12
13 You should have received a copy of the GNU Library General Public License
14 along with this library; see the file COPYING.LIB. If not, write to
15 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16 Boston, MA 02110-1301, USA.
17*******************************************************************************/
18
19#pragma once
20
21#include "indifilterwheel.h"
22
23#define VERSION 0
24#define SUBVERSION 2
25
26#define OPTEC_TIMEOUT 5
27#define OPTEC_TIMEOUT_MOVE 10
28#define OPTEC_TIMEOUT_WHOME 40
29#define OPTEC_TIMEOUT_FIRMWARE 1
30
31#define OPTEC_MAX_FILTER 9
32#define OPTEC_LEN_FLTNAME 8
33#define OPTEC_MAXLEN_CMD ((OPTEC_MAX_FILTER)*OPTEC_LEN_FLTNAME) + 10
34#define OPTEC_MAXLEN_RESP OPTEC_MAX_FILTER *OPTEC_LEN_FLTNAME
35#define OPTEC_MAXLEN_NAMES OPTEC_MAX_FILTER *OPTEC_LEN_FLTNAME
36
37#define OPTEC_WAIT_DATA_OK 5
38
39#define filterSim5 "RED GREEN BLUE H-ALPHA LIGHT "
40#define filterSim6 "RED GREEN BLUE H-ALPHA LIGHT OIII "
41#define filterSim8 "RED GREEN BLUE H-ALPHA LIGHT OIII IR-CUT SII "
42#define filterSim9 "RED GREEN BLUE H-ALPHA LIGHT OIII IR-CUT SII ORANGE "
43
44/*******************************************************************************
45 Define text message error from IFW
46*******************************************************************************/
47#define MER1 "the number of steps to find position 1 is excessive"
48#define MER2 "the SBIG pulse does not have the proper width for the IFW"
49#define MER3 "the filter ID is not found/send successfully"
50#define MER4 "the wheel is stuck in a position"
51#define MER5 "the filter number is not in the set (1, 2, 3, 4, 5)"
52#define MER6 "the wheel is slipping and takes too many steps to the next position"
53#define MERO "Unknown error received from IFW"
54
55#define PRINT_ER(error) \
56 if (!strcmp(error, "ER=1")) \
57 LOGF_ERROR("%s -> %s", error, MER1); \
58 else if (!strcmp(error, "ER=2")) \
59 LOGF_ERROR("%s -> %s", error, MER2); \
60 else if (!strcmp(error, "ER=3")) \
61 LOGF_ERROR("%s -> %s", error, MER3); \
62 else if (!strcmp(error, "ER=4")) \
63 LOGF_ERROR("%s -> %s", error, MER4); \
64 else if (!strcmp(error, "ER=5")) \
65 LOGF_ERROR("%s -> %s", error, MER5); \
66 else if (!strcmp(error, "ER=6")) \
67 LOGF_ERROR("%s -> %s", error, MER6); \
68 else if (!strcmp(error, "ER=0")) \
69 LOGF_ERROR("%s -> %s", error, MERO);
70
71#define DEBUGTAG() DEBUGF(INDI::Logger::DBG_EXTRA_1, "DEBUG -> Function %s() is executing", __FUNCTION__);
72
73/*******************************************************************************
74* Class FilterIFW
75*******************************************************************************/
77{
78 private:
79 public:
80 FilterIFW();
81 virtual ~FilterIFW() = default;
82
83 virtual bool initProperties() override;
84 virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override;
85 virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override;
86
87 protected:
88 virtual bool updateProperties() override;
89 virtual bool Handshake() override;
90 virtual bool Disconnect() override;
91 bool WriteTTY(char *command);
92 bool ReadTTY(char *resp, char *simulation, int timeout);
93 virtual const char *getDefaultName() override;
94 bool moveHome();
95 virtual bool SelectFilter(int) override;
96 virtual void TimerHit() override;
97 virtual bool saveConfigItems(FILE *fp) override;
98 virtual void simulationTriggered(bool enable) override;
99 virtual bool loadConfig(bool silent = false, const char *property = nullptr) override;
100 virtual bool SetFilterNames() override;
101 virtual bool GetFilterNames() override;
102 bool GetWheelID();
103 int GetFilterPos();
104 bool GetFirmware();
105
106 // Filter Wheel ID
109
110 // Home function
113
114 //Simulation, number of filter function
117
118 // CharSet unrestricted for FilterNames
121
122 // Firmware of the IFW
125
126 //Filter position in simulation mode
128
129 // Filter name list for simulation
131};
virtual ~FilterIFW()=default
ITextVectorProperty WheelIDTP
Definition ifwoptec.h:107
ISwitch FilterNbrS[4]
Definition ifwoptec.h:116
virtual bool updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
Definition ifwoptec.cpp:104
int GetFilterPos()
Definition ifwoptec.cpp:799
virtual bool loadConfig(bool silent=false, const char *property=nullptr) override
Load the last saved configuration file.
Definition ifwoptec.cpp:976
ISwitch HomeS[1]
Definition ifwoptec.h:112
virtual void TimerHit() override
Callback function to be called once SetTimer duration elapses.
Definition ifwoptec.cpp:436
bool GetFirmware()
Definition ifwoptec.cpp:904
virtual void simulationTriggered(bool enable) override
Inform driver that the simulation option was triggered. This function is called after setSimulation i...
Definition ifwoptec.cpp:419
virtual bool GetFilterNames() override
Obtains a list of filter names from the hardware and initializes the FilterNameTP property....
Definition ifwoptec.cpp:524
bool WriteTTY(char *command)
Definition ifwoptec.cpp:140
ISwitch CharSetS[2]
Definition ifwoptec.h:120
virtual bool Disconnect() override
Disconnect from device.
Definition ifwoptec.cpp:237
bool GetWheelID()
Definition ifwoptec.cpp:752
bool ReadTTY(char *resp, char *simulation, int timeout)
Definition ifwoptec.cpp:165
bool moveHome()
Definition ifwoptec.cpp:846
ISwitchVectorProperty CharSetSP
Definition ifwoptec.h:119
virtual bool saveConfigItems(FILE *fp) override
saveConfigItems Save specific properties in the provide config file handler. Child class usually over...
Definition ifwoptec.cpp:963
ISwitchVectorProperty HomeSP
Definition ifwoptec.h:111
ITextVectorProperty FirmwareTP
Definition ifwoptec.h:123
ISwitchVectorProperty FilterNbrSP
Definition ifwoptec.h:115
virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override
Process the client newSwitch command.
Definition ifwoptec.cpp:270
virtual bool SetFilterNames() override
Set filter names as defined by the client for each filter position. The desired filter names are stor...
Definition ifwoptec.cpp:654
IText WheelIDT[1]
Definition ifwoptec.h:108
char filterSim[OPTEC_MAXLEN_NAMES+1]
Definition ifwoptec.h:130
virtual const char * getDefaultName() override
Definition ifwoptec.cpp:54
virtual bool SelectFilter(int) override
Select a new filter position.
Definition ifwoptec.cpp:444
virtual bool initProperties() override
Initialize properties initial state and value. The child class must implement this function.
Definition ifwoptec.cpp:62
virtual bool Handshake() override
perform handshake with device to check communication
Definition ifwoptec.cpp:205
IText FirmwareT[1]
Definition ifwoptec.h:124
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
Definition ifwoptec.cpp:319
int actualSimFilter
Definition ifwoptec.h:127
#define OPTEC_MAXLEN_NAMES
Definition ifwoptec.h:35
ISState
Switch state.
Definition indiapi.h:148
One switch descriptor.
One text descriptor.
Switch vector property descriptor.
Definition indiapi.h:365
Text vector property descriptor.
Definition indiapi.h:244