Instrument Neutral Distributed Interface INDI 2.2.5
indi_shelyak_usis.h
Go to the documentation of this file.
1/*******************************************************************************
2 Copyright(c) 2022 Etienne Cochard. All rights reserved.
3
4 This program is free software; you can redistribute it and/or modify it
5 under the terms of the GNU General Public License as published by the Free
6 Software Foundation; either version 2 of the License, or (at your option)
7 any later version.
8
9 This program is distributed in the hope that it will be useful, but WITHOUT
10 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 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 The full GNU General Public License is included in this distribution in the
20 file called LICENSE.
21*******************************************************************************/
22
23#pragma once
24
25#include "defaultdevice.h"
27
28#ifdef _USE_SYSTEM_JSONLIB
29#include <nlohmann/json.hpp>
30#else
31#include <indijson.hpp>
32#endif
33
35
36#define MAX_FRAME_LENGTH 150
37#define MAX_NAME_LENGTH 25
38#define MAX_VALUE_LENGTH 125
39
42 char* parts[5];
43 int pcount;
44};
45
46#define ACTION_STOP 1
47#define ACTION_CALIB 2
48
49#define MAX_ACTION 8
50#define MAX_ENUMS 8
51
52class Action;
53
58
63
69
70struct EnumItem {
72 int index;
73 std::string val;
74};
75
76struct CmdItem {
78 std::string cmd;
79 std::string name;
80};
81
83 _text = 0x10,
84 _enum = 0x11,
85 _number = 0x12,
86
87 _eitm = 0x01,
88 _ecmd = 0x02,
89};
90
91class Action {
92public:
93 char uid[8];
94 std::string name;
95
97 union {
103 };
104
105public:
106 Action( uint32_t _uid, const std::string& _cmd, PropType _type ) {
107 sprintf( uid, "%04x", _uid );
108 name = _cmd;
109 type = _type;
110 }
111};
112
114{
115public:
118
119 bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override;
120 bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override;
121 bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override;
122
123 void update( );
124 static void __update( void* ptr );
125
126 const char *getDefaultName() override;
127
128private:
129 void genCatProps( const char* catName, json& categ );
130
131 bool initProperties() override;
132 bool updateProperties() override;
133 void clearProperties( );
134
135 bool Connect() override;
136 bool Disconnect() override;
137
138private:
139 int _serialPort; // file descriptor for serial port
140 json _config; // json configuration
141
142 uint32_t _guid;
143 std::vector<Action*> _actions;
144
145 bool sendCmd( UsisResponse* rsp, const char* text, ... );
146 bool _send( const char* text, va_list lst );
147 bool _receive( UsisResponse* response );
148 void scanProperties( );
149
150 bool readConfig( );
151 bool findBoard( const char* boardName, json* board_def );
152
153 Action* createAction( PropType type, const std::string& command );
154
155 Connection::Serial *serialConnection = nullptr;
156};
157
TextValue text
Action(uint32_t _uid, const std::string &_cmd, PropType _type)
EnumItem itm
char uid[8]
std::string name
NumValue num
EnumValue enm
PropType type
The Serial class manages connection with serial devices including Bluetooth. Serial communication is ...
Class to provide extended functionality for devices in addition to the functionality provided by INDI...
bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
const char * getDefaultName() override
static void __update(void *ptr)
bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override
a class to store JSON values
@ _number
@ _eitm
@ _ecmd
@ _text
@ _enum
#define MAX_FRAME_LENGTH
#define MAX_ENUMS
ISState
Switch state.
Definition indiapi.h:148
basic_json<> json
default specialization
uint16_t type
Definition pwc-ioctl.h:0
Action * parent
std::string cmd
std::string name
Action * parent
std::string val
ISwitchVectorProperty _vec
ISwitch _vals[MAX_ENUMS]
One number descriptor.
One switch descriptor.
One text descriptor.
EnumValue _act
INumberVectorProperty _vec
ITextVectorProperty _vec
char buffer[MAX_FRAME_LENGTH]
Number vector property descriptor.
Definition indiapi.h:317
Switch vector property descriptor.
Definition indiapi.h:365
Text vector property descriptor.
Definition indiapi.h:244