-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcommandparameter.cpp
92 lines (76 loc) · 2.51 KB
/
commandparameter.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
87
88
89
90
91
92
#include "commandparameter.h"
commandparameter::commandparameter(QObject *parent) :
QObject(parent)
{
}
void commandparameter::stringParsing(QString PackedCommandParameter)
{
QStringList tobeParse;
tobeParse = PackedCommandParameter.split ("##");
QString str = tobeParse.at(1);
QStringList strlist = str.split(";");
for(int i=0;i<strlist.count();i++)
{
QStringList strstrlist=strlist.at(i).split("=");
for(int j=0;j<strstrlist.count();)
{
qDebug("Field:%s",strstrlist.at(j++).toLocal8Bit().data());
qDebug("Value:%s",strstrlist.at(j++).toLocal8Bit().data());
if (strcmp (strstrlist.at(j++).toLocal8Bit() , "DataTime"))
{
this->DataTime = strstrlist.at(j++).toLocal8Bit().data();
}
else if (strcmp(strstrlist.at(j++).toLocal8Bit() , "S01_Rtd"))
{
this->S01_Rtd = strstrlist.at(j++).toLocal8Bit().data();
}
else if (strcmp(strstrlist.at(j++).toLocal8Bit() , "Z12_Rtd"))
{
this->Z12_Rtd = strstrlist.at(j++).toLocal8Bit().data();
}
else if (strcmp(strstrlist.at(j++).toLocal8Bit() , "B03_Rtd"))
{
this->B03_Rtd = strstrlist.at(j++).toLocal8Bit().data();
}
else if (strcmp(strstrlist.at(j++).toLocal8Bit() , "PW"))
{
this->PW = strstrlist.at(j++).toLocal8Bit().data();
}
// else if (strcmp(strstrlist.at(j++).toLocal8Bit() , "CP"))
// {
// this->CP = strstrlist.at(j++).toLocal8Bit().data();
// }
else
{
}
}
}
}
QString commandparameter::generateCommandParameter()
{
CP = "";
QDateTime _generagedtime = QDateTime::currentDateTime ();
this->DataTime = (_generagedtime.toString ("yyyyMMddhhmmsszzz"));
CP.append ("DataTime="+this->DataTime+";");
if (!this->S01_Rtd.operator == (""))
{
CP.append ("S01-Rtd="+this->S01_Rtd+";");
}
if (!this->Z12_Rtd.operator == (""))
{
CP.append ("12-Rtd="+this->Z12_Rtd+";");
}
if (!this->B03_Rtd.operator == (""))
{
CP.append ("B03-Rtd="+this->B03_Rtd+";");
}
if (!this->PW.operator == (""))
{
CP.append ("PW="+this->PW+";");
}
if (this->CP.right (1) == (";"))
{
this->CP = this->CP.mid (0,this->CP.length ()-1);
}
return CP;
}