4 #include "tronostools_global.h"
5 #include "objectdescription.h"
33 ReadWrite = Read | Write,
36 Input = Write | Volatile,
37 Output = Read | Volatile,
38 Variable = Read | Write,
39 Setting = Variable | Save,
41 Exchange = Dual | ReadWrite | Volatile,
42 SecretVar = ReadWrite | Hidden,
43 SecretSetting = Setting | Hidden
78 MMD = Minimum | Maximum | Default,
104 typedef unsigned int UInt_t;
105 typedef long long LongLong_t;
106 typedef unsigned long long ULongLong_t;
107 typedef double Double_t;
109 typedef short Short_t;
111 typedef unsigned long ULong_t;
112 typedef unsigned short UShort_t;
113 typedef unsigned char UChar_t;
114 typedef float Float_t;
115 typedef signed char SChar_t;
116 typedef QString String_t;
118 template<
typename T>
static Type typeOfVar(T &var) {(void)var;
return Common;}
119 #define DeclareTypeOfVar(Tp) static Type typeOfVar(Tp##_t &) {return Tp;}
121 DeclareTypeOfVar(Bool)
122 DeclareTypeOfVar(Int)
123 DeclareTypeOfVar(UInt)
124 DeclareTypeOfVar(LongLong)
125 DeclareTypeOfVar(ULongLong)
126 DeclareTypeOfVar(Double)
127 DeclareTypeOfVar(Long)
128 DeclareTypeOfVar(Short)
129 DeclareTypeOfVar(Char)
130 DeclareTypeOfVar(ULong)
131 DeclareTypeOfVar(UShort)
132 DeclareTypeOfVar(UChar)
133 DeclareTypeOfVar(Float)
134 DeclareTypeOfVar(SChar)
135 DeclareTypeOfVar(String)
149 ExtendedInfo() : RMIP(10), autoPeriodMs(0), needTimestamp(false) {}
152 const void *mReadPtr =
nullptr;
153 void *mWritePtr =
nullptr;
155 ExtendedInfo m_extInfo;
156 bool m_changed =
false;
157 unsigned long m_timestamp = 0;
159 int sizeofType(Type type)
const;
161 bool doRead(QByteArray &ba,
const void *ptr)
const;
162 bool doWrite(
const QByteArray &ba,
void *ptr);
164 virtual void requestEvent()
const {}
165 virtual void receiveEvent() {}
166 virtual void valueChangeEvent() {}
169 friend class ComponentProxyONB;
186 static ONBObject<T> &create(QString name, T &var, Flags flags=ReadWrite)
189 unsigned short sz = (
unsigned short)
sizeof(T);
190 Type t = typeOfVar(var);
193 obj->mReadPtr = &var;
194 obj->mDesc.readSize = sz;
195 obj->mDesc.rType = t;
199 obj->mWritePtr = &var;
200 obj->mDesc.writeSize = sz;
201 obj->mDesc.wType = t;
203 obj->mDesc.
flags = flags;
204 obj->mDesc.
name = name;
215 template<
typename T,
int N>
216 static ONBObject<T> &create(QString name, T (&var)[N], Flags flags=ReadWrite)
219 unsigned short sz =
static_cast<unsigned short>(
sizeof(T)) * N;
220 Type t = typeOfVar(var[0]);
223 obj->mReadPtr = &var;
224 obj->mDesc.readSize = sz;
225 obj->mDesc.rType = t;
229 obj->mWritePtr = &var;
230 obj->mDesc.writeSize = sz;
231 obj->mDesc.wType = t;
233 obj->mDesc.
flags = flags | Array;
234 obj->mDesc.
name = name;
241 bool descChanged =
false;
242 unsigned short sz = (
unsigned short)
sizeof(T);
243 Type t = typeOfVar(var);
244 if (mDesc.
flags & Read)
252 if (mDesc.
flags & Write)
263 void setId(
unsigned char oid,
unsigned char group = 0) {mDesc.
id = oid; mDesc.
group = group;}
267 QByteArray read()
const;
272 bool read(QByteArray &ba)
const;
277 virtual bool readMeta(QByteArray &ba, MetaValue
id)
const {(void)
id;
return read(ba);}
279 bool write(
const QByteArray &ba);
281 virtual bool writeMeta(
const QByteArray &ba, MetaValue
id) {(void)ba; (void)
id;
return false;}
309 int RMIP()
const {
return m_extInfo.RMIP;}
342 QJsonObject createJsonInfo()
const;
345 #endif // OBJECTINFO_H
QString name() const
Get name of the object.
Definition: ObjectInfo.h:303
bool isWritable() const
Test an access flag.
Definition: ObjectInfo.h:318
bool hasMinimum() const
Test a meta-value flag.
Definition: ObjectInfo.h:328
bool isHidden() const
Test an access flag.
Definition: ObjectInfo.h:321
ONB Object description.
Definition: objectdescription.h:44
unsigned long timestamp() const
Get timestamp of the last received value.
Definition: ObjectInfo.h:312
The base for the ONB component.
Definition: ComponentBase.h:97
bool isStorable() const
Test an access flag.
Definition: ObjectInfo.h:319
bool hasMimeType() const
Test a meta-value flag.
Definition: ObjectInfo.h:332
const ObjectDescription & description() const
Get description of the object.
Definition: ObjectInfo.h:299
bool hasMaximum() const
Test a meta-value flag.
Definition: ObjectInfo.h:329
Component-side ONB Object.
Definition: ObjectInfo.h:9
bool isFunction() const
Test an access flag.
Definition: ObjectInfo.h:322
bool isArray() const
Test an access flag.
Definition: ObjectInfo.h:323
ONB Object base interface.
Definition: ObjectInfo.h:16
Flags
Access flags of the Object.
Definition: ObjectInfo.h:20
bool isDual() const
Test an access flag.
Definition: ObjectInfo.h:320
QString name
Name of the object.
Definition: objectdescription.h:55
bool hasExtInfo() const
Test a meta-value flag.
Definition: ObjectInfo.h:336
bool hasDefault() const
Test a meta-value flag.
Definition: ObjectInfo.h:330
Flags flags() const
Get access flags.
Definition: ObjectInfo.h:306
bool hasUnit() const
Test a meta-value flag.
Definition: ObjectInfo.h:334
bool hasHint() const
Test a meta-value flag.
Definition: ObjectInfo.h:333
bool isVolatile() const
Test an access flag.
Definition: ObjectInfo.h:316
bool hasStep() const
Test a meta-value flag.
Definition: ObjectInfo.h:331
int RMIP() const
Get default sampling interval.
Definition: ObjectInfo.h:309
bool isEnum() const
Test a meta-value flag.
Definition: ObjectInfo.h:337
bool hasOptions() const
Test a meta-value flag.
Definition: ObjectInfo.h:335
bool isReadable() const
Test an access flag.
Definition: ObjectInfo.h:317