-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathdlt645.cpp
More file actions
194 lines (143 loc) · 5.65 KB
/
dlt645.cpp
File metadata and controls
194 lines (143 loc) · 5.65 KB
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
/*
* Bohdan Zikranets, bohdan@kts-intek.com.ua KTS-INTEK, 2019
*/
#include "dlt645.h"
#include "dt645encoderdecoder.h"
#include <QtCore>
#include <QDebug>
#include <QTime>
///[!] meter-plugin-shared
#include "shared/meterpluginhelper.h"
///[!] type-converter
#include "src/base/prettyvalues.h"
#include "src/base/convertatype.h"
#include "ucmetereventcodes.h"
#include "moji_defy.h"
#include "matildalimits.h"
#include "myucmmeterstypes.h"
#include "definedpollcodes.h"
#define PLG_4_MATILDA 1
#define PLG_4_PC 1 //Parametrization
//-----------------------------------------------------------------------------
QString DT645::getMeterType(){ return QString("DLT645"); }
QString DT645::getMeterAddrsAndPsswdRegExp(){ return QString("%1%2").arg("^(0|[1-9][0-8]{10}[0-9]|[1-9]{11}[0-8])$").arg("^([0-9]{4})$");}
quint16 DT645::getPluginVersion(){ return PLG_VER_RELEASE; }
quint8 DT645::getPasswdType(){ return UCM_PSWRD_DIGIT; }
QString DT645::getVersion(){ return QString("DLT645 v0.0.1 %1").arg(QString(BUILDDATE)); }
QByteArray DT645::getDefPasswd()
{
return QByteArray("1234");
}
QString DT645::getSupportedMeterList(){ return QString("DLT645-97,DDSF22,DDSD22");}
quint8 DT645::getMaxTariffNumber(const QString &version){ Q_UNUSED(version); return 4; }
QStringList DT645::getEnrgList4thisMeter(const quint8 &pollCode, const QString &version){ return DT645EncoderDecoder::getSupportedEnrg(pollCode, version); }
quint8 DT645::getMeterTypeTag(){ return UC_METER_ELECTRICITY; }
//-----------------------------------------------------------------------------
Mess2meterRezult DT645::mess2meter(const Mess2meterArgs &pairAboutMeter)
{
return encoderdecoder.mess2meter(pairAboutMeter);
}
//-----------------------------------------------------------------------------
QVariantHash DT645::decodeMeterData(const DecodeMeterMess &threeHash)
{
return encoderdecoder.decodeMeterData(threeHash);
}
//-----------------------------------------------------------------------------
QVariantHash DT645::helloMeter(const QVariantHash &hashMeterConstData)
{
QVariantHash hash;
/*
* bool data7EPt = hashMessage.value("data7EPt", false).toBool();
* QByteArray endSymb = hashMessage.value("endSymb", QByteArray("\r\n")).toByteArray();
* QByteArray currNI = hashMeterConstData.value("NI").toByteArray();
* hashMessage.value("message")
*/
hash.insert("quickCRC", true);
hash.insert("endSymb", QByteArray(1, quint8(DLT645_END_FRAME)));
hash.insert("message", encoderdecoder.getReadMessage(hashMeterConstData, DLT645_METER_SN));
//7E 52 FF FF FE FF DC 46 7E
return hash;
}
//-----------------------------------------------------------------------------
QString DT645::meterTypeFromMessage(const QByteArray &readArr)
{
const DT645EncoderDecoder::MessageValidatorResult result = encoderdecoder.messageIsValid(readArr, QByteArray());
if(result.isValid){
return getMeterType();
}
return "";
}
//-----------------------------------------------------------------------------
QVariantHash DT645::isItYour(const QByteArray &arr)
{
QByteArray dest;
const DT645EncoderDecoder::MessageValidatorResult result = encoderdecoder.messageIsValidExt(arr, QByteArray(), false, dest);
if(result.isValid){
QVariantHash hash;
hash.insert("nodeID", dest + "\r\n");
encoderdecoder.insertDefaultHashMessageValues(hash);
return hash;
}
return QVariantHash();
}
//-----------------------------------------------------------------------------
QVariantHash DT645::isItYourRead(const QByteArray &arr)
{
const DT645EncoderDecoder::MessageValidatorResult result = encoderdecoder.messageIsValid(arr, QByteArray());
if(result.isValid){
QVariantHash hash;
hash.insert("Tak", true);
return hash;
}
return QVariantHash();
}
//-----------------------------------------------------------------------------
QByteArray DT645::niChanged(const QByteArray &arr)
{
Q_UNUSED(arr);
return QByteArray();
}
//-----------------------------------------------------------------------------
QVariantHash DT645::meterSn2NI(const QString &meterSn)
{
/*
* hard - без варіантів (жорстко), від старого до нового ф-ту
* altr - альтернатива для стандартного варіанту
* <keys> : <QStringList>
*/
QVariantHash h;
const QString sn = DT645EncoderDecoder::calcMeterAddr(meterSn);
if(!sn.isEmpty())
h.insert("hard", sn.split(";"));
return h;
}
//-----------------------------------------------------------------------------
Mess2meterRezult DT645::messParamPamPam(const Mess2meterArgs &pairAboutMeter)
{
return encoderdecoder.messParamPamPam(pairAboutMeter);
}
//-----------------------------------------------------------------------------
QVariantHash DT645::decodeParamPamPam(const DecodeMeterMess &threeHash)
{
return encoderdecoder.decodeParamPamPam(threeHash);
}
//-----------------------------------------------------------------------------
QVariantHash DT645::how2logout(const QVariantHash &hashConstData, const QVariantHash &hashTmpData)
{
Q_UNUSED(hashConstData);
Q_UNUSED(hashTmpData);
return QVariantHash();
}
//-----------------------------------------------------------------------------
QVariantHash DT645::getDoNotSleep(const quint8 &minutes)
{
Q_UNUSED(minutes);
return QVariantHash();
}
//-----------------------------------------------------------------------------
QVariantHash DT645::getGoToSleep(const quint8 &seconds)
{
Q_UNUSED(seconds);
return QVariantHash();
}
//-----------------------------------------------------------------------------