-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdevicemanagementservice.cpp
166 lines (124 loc) · 4.71 KB
/
devicemanagementservice.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
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
#include "devicemanagementservice.h"
DeviceManagementService::DeviceManagementService(QString serviceName, QString serviceType, int portNumber,QString version):HttpService( serviceName,serviceType, portNumber,version)
{
qDebug()<<Q_FUNC_INFO;
// connect(timer, &QTimer::timeout, this, &CustomerInformationService::slotTedOdesliNaPanely);
deviceStates.insert(StateDefective,"defective");
deviceStates.insert(StateWarning,"warning");
deviceStates.insert(StateNotavailable,"notavailable");
deviceStates.insert(StateRunning,"running");
deviceStates.insert(StateReadyForShutdown ,"readyForShutdown");
updateInternalVariables();
connect(this, &HttpService::signalParameterChange,this, &DeviceManagementService::slotSetParameters);
}
void DeviceManagementService::serviceContentUpdate() //deprecated?
{
qDebug() << Q_FUNC_INFO;
}
void DeviceManagementService::updateInternalVariables()
{
qDebug() << Q_FUNC_INFO<<" "<<mServiceName<<" "<<mVersion;
QString bodyDeviceInformationResponse="";
QString bodyAllSubdeviceInformationResponse="";
QString bodyDeviceConfigurationResponse="";
QString bodyDeviceStatusInformationResponse="";
QString bodyAllSubdeviceStatusInformationResponse="";
QString bodyDeviceErrorMessagesResponse="";
QString bodyAllSubdeviceErrorMessagesResponse="";
QString bodyServiceStatusResponse="";
QString bodyRestartDeviceResponse="";
if (mVersion=="2.2")
{
QDomDocument xmlDocument;
bodyDeviceInformationResponse=xmlGenerator.DeviceInformationResponse1_0(xmlDocument,mDeviceName,mDeviceManufacturer,mDeviceSerialNumber,mDeviceClass,mSwVersion);
bodyDeviceConfigurationResponse=xmlGenerator.DeviceConfigurationResponseStructure1_0(xmlDocument,mDeviceId);
bodyDeviceStatusInformationResponse=xmlGenerator.DeviceStatusResponse1_0(xmlDocument,deviceStates[mDeviceStatus] );
}
else
{
QDomDocument xmlDocument;
bodyDeviceInformationResponse=xmlGenerator.DeviceInformationResponse1_0(xmlDocument,mDeviceName,mDeviceManufacturer,mDeviceSerialNumber,mDeviceClass,mSwVersion);
bodyDeviceConfigurationResponse=xmlGenerator.DeviceConfigurationResponseStructure1_0(xmlDocument,mDeviceId);
bodyDeviceStatusInformationResponse=xmlGenerator.DeviceStatusResponse1_0(xmlDocument,deviceStates[mDeviceStatus]);
}
this->setBodyContent("DeviceInformation",bodyDeviceInformationResponse);
this->setBodyContent("DeviceConfiguration",bodyDeviceConfigurationResponse);
this->setBodyContent("DeviceStatus",bodyDeviceStatusInformationResponse);
this->updateServerContent(structureContentMap);
for(int i=0;i<subscriberList.count();i++ )
{
postToSubscriber(subscriberList[i].address,structureContentMap.value(subscriberList[i].structure));
}
}
DeviceManagementService::DeviceStatus DeviceManagementService::deviceStatus() const
{
return mDeviceStatus;
}
void DeviceManagementService::setDeviceStatus(DeviceStatus newDeviceStatus)
{
mDeviceStatus = newDeviceStatus;
}
QString DeviceManagementService::swVersion() const
{
return mSwVersion;
}
void DeviceManagementService::setSwVersion(const QString &newSwVersion)
{
mSwVersion = StringToNmToken(newSwVersion);
}
QString DeviceManagementService::deviceId() const
{
return mDeviceId;
}
void DeviceManagementService::setDeviceId(const QString &newDeviceId)
{
mDeviceId = newDeviceId;
}
QString DeviceManagementService::deviceClass() const
{
return mDeviceClass;
}
void DeviceManagementService::setDeviceClass(const QString &newDeviceClass)
{
mDeviceClass = newDeviceClass;
}
QString DeviceManagementService::deviceSerialNumber() const
{
return mDeviceSerialNumber;
}
void DeviceManagementService::setDeviceSerialNumber(const QString &newDeviceSerialNumber)
{
mDeviceSerialNumber = newDeviceSerialNumber;
}
QString DeviceManagementService::deviceManufacturer() const
{
return mDeviceManufacturer;
}
void DeviceManagementService::setDeviceManufacturer(const QString &newDeviceManufacturer)
{
mDeviceManufacturer = newDeviceManufacturer;
}
QString DeviceManagementService::deviceName() const
{
return mDeviceName;
}
void DeviceManagementService::setDeviceName(const QString &newDeviceName)
{
mDeviceName = newDeviceName;
}
void DeviceManagementService::slotDataUpdate()
{
updateInternalVariables();
}
void DeviceManagementService::slotSetParameters(QMap<QString,QString> parameters)
{
qDebug()<<Q_FUNC_INFO;
qDebug()<<"list contains "<<parameters.count()<<" parameters";
if(parameters.contains("DeviceID"))
{
mDeviceId=parameters["DeviceID"];
qDebug()<<"setting ID: "<<mDeviceId;
}
updateInternalVariables();
emit signalParametersChanged();
}