Instrument Neutral Distributed Interface INDI  1.9.2
indipropertyview_driver.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2021 by Pawel Soja <kernel32.pl@gmail.com>
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Lesser General Public
6  License as published by the Free Software Foundation; either
7  version 2.1 of the License, or (at your option) any later version.
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  Lesser General Public License for more details.
13 
14  You should have received a copy of the GNU Lesser General Public
15  License along with this library; if not, write to the Free Software
16  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18 
19 #include "indipropertyview.h"
20 #include "indidriver.h"
21 
22 namespace INDI
23 {
24 
25 template <>
26 void PropertyView<IText>::vapply(const char *format, va_list arg) const
27 { IDSetTextVA(this, format, arg); }
28 
29 template <>
30 void PropertyView<IText>::vdefine(const char *format, va_list arg) const
31 { IDDefTextVA(this, format, arg); }
32 
33 template <>
34 void PropertyView<INumber>::vapply(const char *format, va_list arg) const
35 { IDSetNumberVA(this, format, arg); }
36 
37 template <>
38 void PropertyView<INumber>::vdefine(const char *format, va_list arg) const
39 { IDDefNumberVA(this, format, arg); }
40 
41 template <>
42 void PropertyView<ISwitch>::vapply(const char *format, va_list arg) const
43 { IDSetSwitchVA(this, format, arg); }
44 
45 template <>
46 void PropertyView<ISwitch>::vdefine(const char *format, va_list arg) const
47 { IDDefSwitchVA(this, format, arg); }
48 
49 template <>
50 void PropertyView<ILight>::vapply(const char *format, va_list arg) const
51 { IDSetLightVA(this, format, arg); }
52 
53 template <>
54 void PropertyView<ILight>::vdefine(const char *format, va_list arg) const
55 { IDDefLightVA(this, format, arg); }
56 
57 template <>
58 void PropertyView<IBLOB>::vapply(const char *format, va_list arg) const
59 { IDSetBLOBVA(this, format, arg); }
60 
61 template <>
62 void PropertyView<IBLOB>::vdefine(const char *format, va_list arg) const
63 { IDDefBLOBVA(this, format, arg); }
64 
65 template <typename T>
66 void PropertyView<T>::apply(const char *format, ...) const
67 { va_list ap; va_start(ap, format); this->vapply(format, ap); va_end(ap); }
68 
69 template <typename T>
70 void PropertyView<T>::define(const char *format, ...) const
71 { va_list ap; va_start(ap, format); this->vdefine(format, ap); va_end(ap); }
72 
73 template <> template <>
75  const char *device, const char *name, const char *label, const char *group,
76  IPerm permission, double timeout, IPState state
77 )
78 {
80  this, begin(), count(), device, name, label, group,
81  permission, timeout, state
82  );
83 }
84 
85 template <> template <>
87  const char *device, const char *name, const char *label, const char *group,
88  IPerm permission, double timeout, IPState state
89 )
90 {
92  this, begin(), count(), device, name, label, group,
93  permission, timeout, state
94  );
95 }
96 
97 template <> template <>
99  const char *device, const char *name, const char *label, const char *group,
100  IPerm permission, ISRule rule, double timeout, IPState state
101 )
102 {
104  this, begin(), count(), device, name, label, group,
105  permission, rule, timeout, state
106  );
107 }
108 
109 template <> template <>
111  const char *device, const char *name, const char *label, const char *group,
112  IPState state
113 )
114 {
116  this, begin(), count(), device, name, label, group,
117  state
118  );
119 }
120 
121 template <> template <>
123  const char *device, const char *name, const char *label, const char *group,
124  IPerm permission, double timeout, IPState state
125 )
126 {
128  this, begin(), count(), device, name, label, group,
129  permission, timeout, state
130  );
131 }
132 
133 template <> template<>
134 bool PropertyView<IText>::update(const char * const texts[], const char * const names[], int n)
135 { return IUUpdateText(this, const_cast<char**>(texts), const_cast<char**>(names), n) == 0; }
136 
137 template <> template<>
138 bool PropertyView<INumber>::update(const double values[], const char * const names[], int n)
139 { return IUUpdateNumber(this, const_cast<double*>(values), const_cast<char**>(names), n) == 0; }
140 
141 template <> template<>
142 bool PropertyView<ISwitch>::update(const ISState states[], const char * const names[], int n)
143 { return IUUpdateSwitch(this, const_cast<ISState*>(states), const_cast<char**>(names), n) == 0; }
144 
145 template <> template<>
147  const int sizes[], const int blobsizes[], const char *const blobs[], const char *const formats[],
148  const char * const names[], int n
149 )
150 {
151  return IUUpdateBLOB(
152  this,
153  const_cast<int *>(sizes), const_cast<int *>(blobsizes),
154  const_cast<char **>(blobs), const_cast<char **>(formats),
155  const_cast<char **>(names), n
156  ) == 0;
157 }
158 
159 template <> template<>
161 { IUUpdateMinMax(this); }
162 
163 void WidgetView<IText>::fill(const char *name, const char *label, const char *initialText)
164 { IUFillText(this, name, label, initialText); }
165 
166 
167 void WidgetView<ISwitch>::fill(const char *name, const char *label, ISState state)
168 { IUFillSwitch(this, name, label, state); }
169 
170 
171 void WidgetView<ILight>::fill(const char *name, const char *label, IPState state)
172 { IUFillLight(this, name, label, state); }
173 
174 void WidgetView<INumber>::fill(const char *name, const char *label, const char *format,
175  double min, double max, double step, double value)
176 { IUFillNumber(this, name, label, format, min, max, step, value); }
177 
178 void WidgetView<IBLOB>::fill(const char *name, const char *label, const char *format)
179 { IUFillBLOB(this, name, label, format); }
180 
181 template struct PropertyView<INumber>;
182 template struct PropertyView<IText>;
183 template struct PropertyView<ISwitch>;
184 template struct PropertyView<ILight>;
185 template struct PropertyView<IBLOB>;
186 
187 }
IUUpdateMinMax
void IUUpdateMinMax(const INumberVectorProperty *nvp)
Function to update the min and max elements of a number in the client.
Definition: indidriver.c:1849
IPState
IPState
Property state.
Definition: indiapi.h:158
min
double min(void)
IDSetBLOBVA
void void void void void void void void void void IDSetBLOBVA(const IBLOBVectorProperty *b, const char *msg, va_list arg) ATTRIBUTE_FORMAT_PRINTF(2
indidriver.h
IUFillNumber
void IUFillNumber(INumber *np, const char *name, const char *label, const char *format, double min, double max, double step, double value)
Assign attributes for a number property. The number's auxiliary elements will be set to NULL.
Definition: indidriver.c:348
INDI::PropertyView< T >::define
void define() const
Definition: indipropertyview.h:180
IUFillTextVector
void IUFillTextVector(ITextVectorProperty *tvp, IText *tp, int ntp, const char *dev, const char *name, const char *label, const char *group, IPerm p, double timeout, IPState s)
Assign attributes for a text vector property. The vector's auxiliary elements will be set to NULL.
Definition: indidriver.c:477
IUFillLight
void IUFillLight(ILight *lp, const char *name, const char *label, IPState s)
Assign attributes for a light property. The light's auxiliary elements will be set to NULL.
Definition: indidriver.c:334
IUFillText
void IUFillText(IText *tp, const char *name, const char *label, const char *initialText)
Assign attributes for a text property. The text's auxiliary elements will be set to NULL.
Definition: indidriver.c:369
IDDefTextVA
void void IDDefTextVA(const ITextVectorProperty *t, const char *msg, va_list arg) ATTRIBUTE_FORMAT_PRINTF(2
IUUpdateText
int IUUpdateText(ITextVectorProperty *tvp, char *texts[], char *names[], int n)
Update all text members in a text vector property.
Definition: indidriver.c:259
max
double max(void)
device
hid_device * device
Definition: activefocuser_utils.cpp:92
begin
JsonIterator begin(JsonValue o)
Definition: gason.h:104
INDI::WidgetView
Definition: indipropertyview.h:38
INDI::PropertyView::vapply
void vapply(const char *format, va_list args) const
IUFillSwitchVector
void IUFillSwitchVector(ISwitchVectorProperty *svp, ISwitch *sp, int nsp, const char *dev, const char *name, const char *label, const char *group, IPerm p, ISRule r, double timeout, IPState s)
Assign attributes for a switch vector property. The vector's auxiliary elements will be set to NULL.
Definition: indidriver.c:412
IUFillNumberVector
void IUFillNumberVector(INumberVectorProperty *nvp, INumber *np, int nnp, const char *dev, const char *name, const char *label, const char *group, IPerm p, double timeout, IPState s)
Assign attributes for a number vector property. The vector's auxiliary elements will be set to NULL.
Definition: indidriver.c:455
IDDefSwitchVA
void void void void void void IDDefSwitchVA(const ISwitchVectorProperty *s, const char *msg, va_list arg) ATTRIBUTE_FORMAT_PRINTF(2
IUUpdateSwitch
int IUUpdateSwitch(ISwitchVectorProperty *svp, ISState *states, char *names[], int n)
Update all switches in a switch vector property.
Definition: indidriver.c:171
IPerm
IPerm
Permission hint, with respect to client.
Definition: indiapi.h:181
IUFillBLOB
void IUFillBLOB(IBLOB *bp, const char *name, const char *label, const char *format)
Assign attributes for a BLOB property. The BLOB's data and auxiliary elements will be set to NULL.
Definition: indidriver.c:390
INDI::PropertyView
Provides decorator for Low-Level IXXXVectorProperty/IXXX.
Definition: indipropertyview.h:39
IDDefBLOBVA
void void void void void void void void void void IDDefBLOBVA(const IBLOBVectorProperty *b, const char *msg, va_list arg) ATTRIBUTE_FORMAT_PRINTF(2
IDSetLightVA
void void void void void void void void IDSetLightVA(const ILightVectorProperty *l, const char *msg, va_list arg) ATTRIBUTE_FORMAT_PRINTF(2
INDI
Namespace to encapsulate INDI client, drivers, and mediator classes.
Definition: AlignmentSubsystemForClients.cpp:11
IDSetNumberVA
void void void void IDSetNumberVA(const INumberVectorProperty *n, const char *msg, va_list arg) ATTRIBUTE_FORMAT_PRINTF(2
IUUpdateNumber
int IUUpdateNumber(INumberVectorProperty *nvp, double values[], char *names[], int n)
Update all numbers in a number vector property.
Definition: indidriver.c:225
IUUpdateBLOB
int IUUpdateBLOB(IBLOBVectorProperty *bvp, int sizes[], int blobsizes[], char *blobs[], char *formats[], char *names[], int n)
Update all BLOB members in a BLOB vector property.
Definition: indidriver.c:285
IDSetTextVA
void void IDSetTextVA(const ITextVectorProperty *t, const char *msg, va_list arg) ATTRIBUTE_FORMAT_PRINTF(2
ISState
ISState
Switch state.
Definition: indiapi.h:148
IDDefNumberVA
void void void void IDDefNumberVA(const INumberVectorProperty *n, const char *msg, va_list arg) ATTRIBUTE_FORMAT_PRINTF(2
indipropertyview.h
ISRule
ISRule
Switch vector rule hint.
Definition: indiapi.h:170
IDDefLightVA
void void void void void void void void IDDefLightVA(const ILightVectorProperty *l, const char *msg, va_list arg) ATTRIBUTE_FORMAT_PRINTF(2
IUFillBLOBVector
void IUFillBLOBVector(IBLOBVectorProperty *bvp, IBLOB *bp, int nbp, const char *dev, const char *name, const char *label, const char *group, IPerm p, double timeout, IPState s)
Assign attributes for a BLOB vector property. The vector's auxiliary elements will be set to NULL.
Definition: indidriver.c:499
IDSetSwitchVA
void void void void void void IDSetSwitchVA(const ISwitchVectorProperty *s, const char *msg, va_list arg) ATTRIBUTE_FORMAT_PRINTF(2
IUFillLightVector
void IUFillLightVector(ILightVectorProperty *lvp, ILight *lp, int nlp, const char *dev, const char *name, const char *label, const char *group, IPState s)
Assign attributes for a light vector property. The vector's auxiliary elements will be set to NULL.
Definition: indidriver.c:435
IUFillSwitch
void IUFillSwitch(ISwitch *sp, const char *name, const char *label, ISState s)
Assign attributes for a switch property. The switch's auxiliary elements will be set to NULL.
Definition: indidriver.c:320