-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindicatorcontrol.cpp
More file actions
175 lines (159 loc) · 5 KB
/
indicatorcontrol.cpp
File metadata and controls
175 lines (159 loc) · 5 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
//******************************************************************************
#include "indicatorcontrol.h"
//******************************************************************************
IndicatorControl::IndicatorControl()
{
this->setWindowTitle("Telnet client");
setMinimumSize(200,200);
flagConnected = 0;
GridLayout_Form = new QGridLayout(this);
}
//******************************************************************************
void IndicatorControl::ReceiveMessage(QString message)
{
if(message.size() == 0) return;
message.replace("\r", "");
outSplitMassiv = message.split('\n');
if(outSplitMassiv.size() == 1)
{
qDebug() << "Конец строки не найден, ожидание новой информации";
allMassiv.append(outSplitMassiv[0]);
}else
{
if(allMassiv.size() != 0)
{
allMassiv.append(outSplitMassiv[0]);
outSplitMassiv[0] = allMassiv;
allMassiv.clear();
}
outSplitMassiv.removeOne("");
for(int i = 0; i < outSplitMassiv.size(); i++)
{
int a = outSplitMassiv[i].indexOf("\"");
if (a < 0)
{
inSplitMassiv = outSplitMassiv[i].split(' ');
}else
{
QStringList textSplit = outSplitMassiv[i].split(("\""));
textSplit.removeLast();
inSplitMassiv = textSplit[0].split(' ');
inSplitMassiv.removeLast();
inSplitMassiv.append(textSplit[1]);
}
if(flagConnected == 0)
{
if (inSplitMassiv[0] == "INFORMATION_DISPLAY_SERVER")
{
qDebug()<<"<***Server is connected!***>";
flagConnected = 1;
}else
{
qDebug() << "Error! Server is not connected!";
}
}else
{
// qDebug() << "inSplitMassiv" << inSplitMassiv;
MSGselector(inSplitMassiv);
}
}
inSplitMassiv.clear();
outSplitMassiv.clear();
return;
}
}
void IndicatorControl::MSGPlace(QStringList message)
{
this->show();
bool flagPozition;
int row, column,rowSpan, columnSpan;
bool ok;
if(message.size() == 4)
{
flagPozition = true;
row = message[2].toUInt(&ok);
if(!ok) return;
column = message[3].toUInt(&ok);
if(!ok) return;
}else if (message.size() == 6)
{
flagPozition = false;
row = message[2].toUInt(&ok);
if(!ok) return;
column = message[3].toUInt(&ok);
if(!ok) return;
rowSpan = message[4].toUInt(&ok);
if(!ok) return;
columnSpan = message[5].toUInt(&ok);
if(!ok) return;
}else return;
if(message[1] == "STRING")
{
if (BIObjectName.indexOf(message[0]) != -1) return;
else BIObjectName.append(message[0]);
BIString *Obj = new BIString;
BIObjects.append(Obj);
if(flagPozition) GridLayout_Form->addWidget(Obj, row, column);
else GridLayout_Form->addWidget(Obj, row, column, rowSpan, columnSpan);
}else if(message[1] == "DIOD")
{
if (BIObjectName.indexOf(message[0]) != -1) return;
else BIObjectName.append(message[0]);
BIDiod *Obj = new BIDiod;
BIObjects.append(Obj);
if(flagPozition) GridLayout_Form->addWidget(Obj, row, column);
else GridLayout_Form->addWidget(Obj, row, column, rowSpan, columnSpan);
}
}
void IndicatorControl::MSGColor(QStringList message)
{
this->show();
if(message.size() != 4) return;
int ind = BIObjectName.indexOf(message[0]);
if (ind < 0) return;
int r, g, b;
bool ok;
r = message[1].toUInt(&ok);
if(!ok) return;
g = message[2].toUInt(&ok);
if(!ok) return;
b = message[3].toUInt(&ok);
if(!ok) return;
BIObjects[ind]->Color(r, g, b);
}
void IndicatorControl::MSGText(QStringList message)
{
this->show();
if(message.size() != 2) return;
int ind = BIObjectName.indexOf(message[0]);
if (ind < 0) return;
BIObjects[ind]->Text(message[1]);
}
void IndicatorControl::MSGDiod(QStringList message)
{
this->show();
qDebug() << "message -" << message;
if(message.size() != 1) return;
int ind = BIObjectName.indexOf(message[0]);
if (ind < 0) return;
BIObjects[ind]->Diod();
}
//******************************************************************************
void IndicatorControl::MSGselector(QStringList message)
{
if(message.size() == 0) return;
QString CMD = message[0];
message.removeAt(0);
if(CMD == "PLACE")
{
MSGPlace(message);
}
else if (CMD == "COLOR")
{
MSGColor(message);
}
else if (CMD == "TEXT")
{
MSGText(message);
}
}