-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbacnetdata.cpp
86 lines (71 loc) · 2 KB
/
bacnetdata.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#include "bacnetdata.h"
#include "bacnetcoder.h"
#include "bacnettagparser.h"
#include "bacnetdefaultobject.h"
using namespace Bacnet;
BacnetDataInterface::BacnetDataInterface()
{
}
BacnetDataInterface::~BacnetDataInterface()
{}
qint32 BacnetDataInterface::toRawTagEnclosed_helper(quint8 *ptrStart, quint16 buffLength, quint8 tagNumber)
{
qint32 ret;
qint32 total(0);
quint8 *actualPtr(ptrStart);
ret = BacnetCoder::openingTagToRaw(actualPtr, buffLength, tagNumber);
if (ret < 0)
return -1;
total += ret;
actualPtr += ret;
buffLength -= ret;
ret = toRaw(actualPtr, buffLength);
if (ret < 0)
return -2;
actualPtr += ret;
total += ret;
buffLength -= ret;
ret = BacnetCoder::closingTagToRaw(actualPtr, buffLength, tagNumber);
if (ret<0)
return -3;
total += ret;
return total;
}
qint32 BacnetDataInterface::fromRawTagEnclosed_helper(BacnetTagParser &parser, quint8 tagNum)
{
qint32 total(0);
qint32 ret;
ret = parser.parseNext();
if (ret <0 || !parser.isOpeningTag(tagNum))
return -1;
total += ret;
ret = fromRaw(parser);
if (ret<0)
return -2;
total += ret;
ret = parser.parseNext();
if (ret<0 || !parser.isClosingTag(tagNum))
return -3;
total += ret;
return total;
}
qint32 BacnetDataInterface::fromRawChoiceValue_helper(BacnetTagParser &parser, QList<DataType::DataType> choices, Bacnet::BacnetDataInterface *choiceValue)
{
Q_CHECK_PTR(choiceValue);
Q_ASSERT(!choices.isEmpty());
qint32 ret;
bool isContext;
ret = parser.nextTagNumber(&isContext);
if (ret < 0 || ret >= choices.size())
return -1;
choiceValue = BacnetDefaultObject::createDataType(choices.at(ret));
Q_CHECK_PTR(choiceValue);
return choiceValue->fromRaw(parser);
}
DEFINE_VISITABLE_FUNCTION(BacnetDataInterface)
BacnetDataInterface *BacnetDataInterface::getValue(quint32 arrayIndex)
{
if (arrayIndex == ArrayIndexNotPresent)
return this;
return 0;
}