Rev 711 | Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
674 | KeyOz | 1 | /*************************************************************************** |
2 | * Copyright (C) 2009 by Manuel Schrape * |
||
3 | * manuel.schrape@gmx.de * |
||
4 | * * |
||
5 | * This program is free software; you can redistribute it and/or modify * |
||
6 | * it under the terms of the GNU General Public License as published by * |
||
7 | * the Free Software Foundation; either version 2 of the License. * |
||
8 | * * |
||
9 | * This program is distributed in the hope that it will be useful, * |
||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
||
12 | * GNU General Public License for more details. * |
||
13 | * * |
||
14 | * You should have received a copy of the GNU General Public License * |
||
15 | * along with this program; if not, write to the * |
||
16 | * Free Software Foundation, Inc., * |
||
17 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
||
18 | ***************************************************************************/ |
||
19 | |||
20 | #include <QMessageBox> |
||
21 | |||
22 | #include "dlg_Main.h" |
||
23 | |||
24 | // Konstruktor Main-Form |
||
25 | dlg_Main::dlg_Main() |
||
26 | { |
||
27 | setupUi(this); |
||
28 | |||
29 | o_Settings = new cSettings(); |
||
30 | |||
31 | o_Settings->read_DebugLabels(0); |
||
32 | |||
33 | o_Input = new Input(); |
||
34 | |||
35 | init_GUI(); |
||
36 | init_Connections(); |
||
37 | init_Plotter(); |
||
38 | } |
||
39 | |||
40 | // Grafische Oberfläche initialisieren |
||
41 | void dlg_Main::init_GUI() |
||
42 | { |
||
43 | setWindowTitle(QA_NAME + " " + QA_VERSION); |
||
44 | |||
45 | resize(o_Settings->GUI.Size); |
||
46 | move(o_Settings->GUI.Point); |
||
47 | |||
48 | if (o_Settings->GUI.isMax) |
||
49 | { |
||
50 | showMaximized(); |
||
51 | } |
||
52 | |||
53 | for(int z = 0; z < o_Settings->SERVER.IP_MAX; z++) |
||
54 | { |
||
55 | if (cb_Server->findText(o_Settings->SERVER.IP[z]) == -1) |
||
56 | { |
||
57 | cb_Server->addItem(o_Settings->SERVER.IP[z]); |
||
58 | } |
||
59 | } |
||
60 | |||
61 | cb_Server->setCurrentIndex(o_Settings->SERVER.IP_ID); |
||
62 | |||
63 | le_Password->setText(o_Settings->SERVER.Password); |
||
64 | |||
65 | sb_Intervall->setValue(o_Settings->DATA.Debug_Intervall); |
||
66 | |||
67 | btn_Start->setCheckable(true); |
||
68 | |||
69 | ac_Plotter->setChecked(true); |
||
70 | |||
71 | Font_1.setFamily(QString::fromUtf8("Adobe Courier")); |
||
72 | Font_1.setBold(true); |
||
73 | Font_1.setWeight(75); |
||
74 | |||
75 | for(int z = 0; z < MAX_DebugData; z++) |
||
76 | { |
||
77 | |||
78 | lb_Debug[z] = new QLabel(wg_Debug); |
||
79 | le_Debug[z] = new QLineEdit(wg_Debug); |
||
80 | cb_Debug[z] = new QCheckBox(wg_Config); |
||
81 | le_Debug[z]->setFont(Font_1); |
||
82 | le_Debug[z]->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); |
||
83 | le_Debug[z]->setReadOnly(true); |
||
84 | |||
85 | wg_Grid->addWidget(lb_Debug[z], (z % 8), z / 8 * 2, 0); |
||
86 | wg_Grid->addWidget(le_Debug[z], (z % 8), z / 8 * 2 + 1 , 0); |
||
87 | |||
88 | wg_Grid_2->addWidget(cb_Debug[z], (z % 8), z / 8, 0); |
||
89 | |||
90 | lb_Debug[z]->setText(o_Settings->DebugData.Label[z]); |
||
91 | cb_Debug[z]->setText(o_Settings->DebugData.Label[z]); |
||
92 | |||
93 | cb_Debug[z]->setChecked(o_Settings->DebugData.Show_Plotter[z]); |
||
94 | } |
||
95 | } |
||
96 | |||
97 | // Signale mit Slots verbinden |
||
98 | void dlg_Main::init_Connections() |
||
99 | { |
||
100 | connect(sb_Intervall, SIGNAL(valueChanged(int)), this, SLOT(slot_sb_Intervall(int))); |
||
101 | |||
102 | connect(ac_Connect, SIGNAL(triggered()), this, SLOT(slot_ac_Connect())); |
||
103 | connect(ac_Plotter, SIGNAL(triggered()), this, SLOT(slot_ac_Plotter())); |
||
104 | connect(ac_Debug, SIGNAL(triggered()), this, SLOT(slot_ac_Debug())); |
||
105 | connect(ac_Chose, SIGNAL(triggered()), this, SLOT(slot_ac_Chose())); |
||
106 | |||
107 | connect(ac_ReadLabels, SIGNAL(triggered()), this, SLOT(slot_ac_ReadLabels())); |
||
108 | |||
109 | connect(rb_NC, SIGNAL(clicked()), this, SLOT(slot_rb_Hardware())); |
||
110 | connect(rb_FC, SIGNAL(clicked()), this, SLOT(slot_rb_Hardware())); |
||
111 | connect(rb_MK3MAG, SIGNAL(clicked()), this, SLOT(slot_rb_Hardware())); |
||
112 | |||
113 | connect(Plotter_Scroll, SIGNAL(valueChanged(int)), this, SLOT(slot_Plotter_Scroll(int))); |
||
114 | |||
115 | connect(btn_Start, SIGNAL(clicked()), this, SLOT(slot_Plotter_Start())); |
||
116 | connect(btn_ChoseOK, SIGNAL(clicked()), this, SLOT(slot_btn_ChoseOK())); |
||
117 | |||
118 | // About QMK-Kernel & About-QT Dialog einfügen |
||
119 | connect(ac_About, SIGNAL(triggered()), this, SLOT(slot_ac_About())); |
||
120 | menu_Help->addAction(trUtf8("Über &Qt"), qApp, SLOT(aboutQt())); |
||
121 | } |
||
122 | |||
123 | void dlg_Main::init_Plotter() |
||
124 | { |
||
125 | NextPlot = 0; |
||
126 | |||
127 | qwt_Plotter->setCanvasBackground(QColor(QRgb(0x00000000))); |
||
128 | |||
129 | qwt_Plotter->insertLegend(new QwtLegend(), QwtPlot::RightLegend); |
||
130 | |||
131 | QwtPlotGrid *Grid = new QwtPlotGrid(); |
||
132 | Grid->setMajPen(QPen(Qt::gray, 0, Qt::DotLine)); |
||
133 | |||
134 | Grid->attach(qwt_Plotter); |
||
135 | |||
136 | qwt_Plotter->setAxisScale(QwtPlot::xBottom,0,o_Settings->DATA.Plotter_Count,0); |
||
137 | |||
138 | for (int a = 0; a < MAX_DebugData; a++) |
||
139 | { |
||
140 | Plot[a] = new QwtPlotCurve(o_Settings->DebugData.Label[a]); |
||
141 | Plot[a]->setPen(QPen(QColor(DEF_DebugColors[a]))); |
||
142 | Plot[a]->setRenderHint(QwtPlotItem::RenderAntialiased); |
||
143 | |||
144 | if (o_Settings->DebugData.Show_Plotter[a]) |
||
145 | Plot[a]->attach(qwt_Plotter); |
||
146 | } |
||
147 | qwt_Plotter->replot(); |
||
148 | } |
||
149 | |||
150 | void dlg_Main::update_Plotter() |
||
151 | { |
||
152 | pl_ID[NextPlot] = NextPlot; |
||
153 | |||
154 | for (int a = 0; a < MAX_DebugData; a++) |
||
155 | { |
||
156 | pl_Data[a][NextPlot] = Debug_Data[a]; |
||
157 | Plot[a]->setData(pl_ID,pl_Data[a],NextPlot); |
||
158 | } |
||
159 | |||
160 | NextPlot++; |
||
161 | |||
162 | if ((NextPlot > o_Settings->DATA.Plotter_Count)) |
||
163 | { |
||
164 | Plotter_Scroll->setMaximum(NextPlot - o_Settings->DATA.Plotter_Count); |
||
165 | } |
||
166 | |||
167 | if ((Plotter_Scroll->value() == NextPlot - (o_Settings->DATA.Plotter_Count + 1))) |
||
168 | { |
||
169 | qwt_Plotter->setAxisScale(QwtPlot::xBottom,NextPlot - o_Settings->DATA.Plotter_Count,NextPlot,0); |
||
170 | Plotter_Scroll->setValue(NextPlot - o_Settings->DATA.Plotter_Count); |
||
171 | } |
||
172 | |||
173 | qwt_Plotter->replot(); |
||
174 | } |
||
175 | |||
176 | void dlg_Main::config_Plotter() |
||
177 | { |
||
178 | qwt_Plotter->setAxisScale(QwtPlot::xBottom,0,o_Settings->DATA.Plotter_Count,0); |
||
179 | |||
180 | for (int a = 0; a < MAX_DebugData; a++) |
||
181 | { |
||
182 | Plot[a]->detach(); |
||
183 | Plot[a]->setPen(QPen(QColor(DEF_DebugColors[a]))); |
||
184 | |||
185 | if (o_Settings->DebugData.Show_Plotter[a]) |
||
186 | { |
||
187 | Plot[a]->setTitle(o_Settings->DebugData.Label[a]); |
||
188 | Plot[a]->attach(qwt_Plotter); |
||
189 | } |
||
190 | } |
||
191 | qwt_Plotter->replot(); |
||
192 | } |
||
193 | |||
194 | void dlg_Main::slot_Plotter_Scroll(int Position) |
||
195 | { |
||
196 | qwt_Plotter->setAxisScale(QwtPlot::xBottom,Position,Position + o_Settings->DATA.Plotter_Count,0); |
||
197 | qwt_Plotter->replot(); |
||
198 | } |
||
199 | |||
200 | void dlg_Main::parse_IP_Data(QString t_Data) |
||
201 | { |
||
202 | QStringList Data; |
||
203 | Data = t_Data.split(":"); |
||
204 | |||
205 | if (Data.count() > 1) |
||
206 | { |
||
207 | int CMD = Data[2].toInt(); |
||
208 | |||
209 | switch(CMD) |
||
210 | { |
||
211 | case 501 : |
||
212 | { |
||
213 | o_Input->send_Data(HandlerIP::make_Frame(ID_SCOPE, 105, le_Password->text())); |
||
214 | } |
||
215 | break; |
||
216 | case 505 : |
||
217 | { |
||
218 | if (Data[3] == "OK") |
||
219 | { |
||
220 | } |
||
221 | else |
||
222 | { |
||
223 | QMessageBox::warning(this, QA_NAME, trUtf8("Authentifizierung fehlgeschlagen. <br />Daten senden zum Mikrokopter nicht möglich."), QMessageBox::Ok); |
||
224 | } |
||
225 | } |
||
226 | break; |
||
227 | } |
||
228 | } |
||
229 | } |
||
230 | |||
231 | // Eingangsdaten verarbeiten |
||
232 | void dlg_Main::parse_MK_Data(QString t_Data) |
||
233 | { |
||
234 | unsigned char OutData[150]; |
||
235 | char *InData = t_Data.toLatin1().data(); |
||
236 | |||
237 | if (HandlerMK::Decode_64(InData, t_Data.length(), OutData) != 0) |
||
238 | { |
||
239 | switch(InData[2]) |
||
240 | { |
||
241 | case 'A' : // 0.76e - Debug-Labels |
||
242 | { |
||
243 | o_Input->stop_Resend(DATA_READ_LABEL); |
||
244 | int Position = OutData[0]; |
||
245 | if (Position < 32) |
||
246 | { |
||
247 | o_Settings->DebugData.Label[Position] = HandlerMK::Data2QString(OutData,1,17).trimmed(); |
||
248 | if (o_Settings->DebugData.Label[Position] == "") |
||
249 | { |
||
250 | o_Settings->DebugData.Label[Position] = "Debug-" + QString("%1").arg(Position); |
||
251 | } |
||
252 | lb_Debug[Position]->setText("" + o_Settings->DebugData.Label[Position]); |
||
253 | cb_Debug[Position]->setText("" + o_Settings->DebugData.Label[Position]); |
||
254 | |||
255 | Position ++; |
||
256 | |||
257 | if ((Position < 32) && (get_Analoglabels == true)) |
||
258 | { |
||
259 | c_Data[0] = Position; |
||
260 | o_Input->send_Data(HandlerMK::make_Frame('a', ADDRESS_ALL, c_Data, 1).toLatin1().data(), DATA_READ_LABEL); |
||
261 | } |
||
262 | } |
||
263 | if (Position == 32) |
||
264 | { |
||
265 | o_Settings->DebugData.Version = VersionInfo.Version; |
||
266 | o_Settings->write_DebugLabels(VersionInfo.ID); |
||
267 | config_Plotter(); |
||
268 | get_Analoglabels = false; |
||
269 | } |
||
270 | } |
||
271 | break; |
||
272 | |||
273 | case 'D' : // 0.75a - Debug-Daten |
||
274 | { |
||
275 | for (int z = 0; z < MAX_DebugData; z++) |
||
276 | { |
||
277 | Debug_Data[z] = HandlerMK::Data2Int(OutData, (z * 2) + 2); |
||
278 | if (ac_Debug->isChecked()) |
||
279 | { |
||
280 | le_Debug[z]->setText(QString("%1").arg(Debug_Data[z])); |
||
281 | } |
||
282 | } |
||
283 | if (btn_Start->isChecked()) |
||
284 | { |
||
285 | update_Plotter(); |
||
286 | } |
||
287 | } |
||
288 | break; |
||
289 | |||
290 | case 'V' : // 0.75a - Versions-Info |
||
291 | { |
||
292 | o_Input->stop_Resend(DATA_VERSION); |
||
293 | VersionInfo = HandlerMK::parse_Version(OutData, InData[1] - 'a'); |
||
294 | setWindowTitle(QA_NAME + " " + QA_VERSION + " - " + VersionInfo.Hardware + " " + VersionInfo.Version); |
||
295 | |||
296 | if (VersionInfo.ID == ADDRESS_FC) |
||
297 | { |
||
298 | rb_FC->setChecked(true); |
||
299 | } |
||
300 | if (VersionInfo.ID == ADDRESS_NC) |
||
301 | { |
||
302 | rb_NC->setChecked(true); |
||
303 | } |
||
304 | if (VersionInfo.ID == ADDRESS_MK3MAG) |
||
305 | { |
||
306 | rb_MK3MAG->setChecked(true); |
||
307 | } |
||
308 | |||
309 | o_Settings->read_DebugLabels(VersionInfo.ID); |
||
310 | |||
311 | if (o_Settings->DebugData.Version != VersionInfo.Version) |
||
312 | { |
||
313 | // qDebug(QString("Debug-Labels unterschiedlich. Neue anforden. " + o_Settings->DebugData.Version + " <> " + VersionInfo.Version).toLatin1().data()); |
||
314 | |||
315 | usleep(50000); |
||
316 | |||
317 | slot_ac_ReadLabels(); |
||
318 | // o_Input->send_Data(HandlerMK::make_Frame('a', ADDRESS_ALL, c_Data, 1).toLatin1().data()); |
||
319 | } |
||
320 | else |
||
321 | { |
||
322 | for(int z = 0; z < MAX_DebugData; z++) |
||
323 | { |
||
324 | lb_Debug[z]->setText(o_Settings->DebugData.Label[z]); |
||
325 | cb_Debug[z]->setText(o_Settings->DebugData.Label[z]); |
||
326 | cb_Debug[z]->setChecked(o_Settings->DebugData.Show_Plotter[z]); |
||
327 | } |
||
328 | config_Plotter(); |
||
329 | } |
||
330 | c_Data[0] = sb_Intervall->value() / 10; |
||
331 | o_Input->send_Data(HandlerMK::make_Frame('d', ADDRESS_ALL, c_Data, 1).toLatin1().data()); |
||
332 | } |
||
333 | break; |
||
334 | } |
||
335 | } |
||
336 | } |
||
337 | |||
338 | /////////// |
||
339 | // Slots // |
||
340 | /////////// |
||
341 | void dlg_Main::slot_Plotter_Start() |
||
342 | { |
||
343 | if (btn_Start->isChecked()) |
||
344 | { |
||
345 | btn_Start->setText(tr("Plotter stoppen")); |
||
346 | } |
||
347 | else |
||
348 | { |
||
349 | btn_Start->setText(tr("Plotter starten")); |
||
350 | } |
||
351 | } |
||
352 | |||
353 | void dlg_Main::slot_btn_ChoseOK() |
||
354 | { |
||
355 | for(int z = 0; z < MAX_DebugData; z++) |
||
356 | { |
||
357 | o_Settings->DebugData.Show_Plotter[z] = cb_Debug[z]->isChecked(); |
||
358 | } |
||
359 | config_Plotter(); |
||
360 | o_Settings->write_DebugLabels(VersionInfo.ID); |
||
361 | } |
||
362 | |||
363 | void dlg_Main::slot_ac_Chose() |
||
364 | { |
||
365 | |||
366 | for(int z = 0; z < MAX_DebugData; z++) |
||
367 | { |
||
368 | cb_Debug[z]->setChecked(o_Settings->DebugData.Show_Plotter[z]); |
||
369 | } |
||
370 | |||
371 | ac_Chose->setChecked(true); |
||
372 | ac_Debug->setChecked(false); |
||
373 | ac_Plotter->setChecked(false); |
||
374 | wg_Pages->setCurrentIndex(2); |
||
375 | } |
||
376 | |||
377 | void dlg_Main::slot_ac_Debug() |
||
378 | { |
||
379 | ac_Debug->setChecked(true); |
||
380 | ac_Chose->setChecked(false); |
||
381 | ac_Plotter->setChecked(false); |
||
382 | wg_Pages->setCurrentIndex(1); |
||
383 | } |
||
384 | |||
385 | void dlg_Main::slot_ac_Plotter() |
||
386 | { |
||
387 | ac_Plotter->setChecked(true); |
||
388 | ac_Debug->setChecked(false); |
||
389 | ac_Chose->setChecked(false); |
||
390 | wg_Pages->setCurrentIndex(0); |
||
391 | } |
||
392 | |||
393 | void dlg_Main::slot_ac_ReadLabels() |
||
394 | { |
||
395 | get_Analoglabels = true; |
||
396 | c_Data[0] = 0; |
||
397 | o_Input->send_Data(HandlerMK::make_Frame('a', ADDRESS_ALL, c_Data, 1).toLatin1().data(), DATA_READ_LABEL); |
||
398 | } |
||
399 | |||
400 | // About-Dialog |
||
401 | void dlg_Main::slot_ac_About() |
||
402 | { |
||
403 | QMessageBox::about(this, trUtf8(("Über ")) + QA_NAME, QA_ABOUT); |
||
404 | } |
||
405 | |||
406 | // Datenintervall geändert. |
||
407 | void dlg_Main::slot_sb_Intervall(int t_Intervall) |
||
408 | { |
||
409 | if (t_Intervall == 0) |
||
410 | { |
||
411 | c_Data[0] = 0; |
||
412 | } |
||
413 | else |
||
414 | { |
||
415 | c_Data[0] = t_Intervall / 10; |
||
416 | } |
||
417 | o_Input->send_Data(HandlerMK::make_Frame('d', ADDRESS_ALL, c_Data, 1).toLatin1().data()); |
||
418 | } |
||
419 | |||
420 | // Hardware auswählen. |
||
421 | void dlg_Main::slot_rb_Hardware() |
||
422 | { |
||
423 | if ((rb_NC->isChecked() == false) && (VersionInfo.ID != ADDRESS_NC)) |
||
424 | { |
||
425 | o_Input->send_Data(HandlerMK::get_SelectNC()); |
||
426 | } |
||
427 | |||
428 | if (rb_FC->isChecked()) |
||
429 | { |
||
430 | o_Input->send_Data(HandlerMK::get_SelectFC()); |
||
431 | } |
||
432 | else |
||
433 | if (rb_MK3MAG->isChecked()) |
||
434 | { |
||
435 | o_Input->send_Data(HandlerMK::get_SelectMK3MAG()); |
||
436 | } |
||
437 | else |
||
438 | if (rb_NC->isChecked()) |
||
439 | { |
||
440 | o_Input->send_Data(HandlerMK::get_SelectNC()); |
||
441 | } |
||
442 | |||
443 | o_Input->send_Data(HandlerMK::make_Frame('v', 0, c_Data, 0).toLatin1().data(), DATA_VERSION); |
||
444 | } |
||
445 | |||
446 | // Verbindung zum Server aufbauen |
||
447 | void dlg_Main::slot_ac_Connect() |
||
448 | { |
||
449 | if (!o_Input->IsOpen()) |
||
450 | { |
||
451 | if (cb_Server->findText(cb_Server->currentText()) == -1) |
||
452 | { |
||
453 | cb_Server->addItem(cb_Server->currentText()); |
||
454 | cb_Server->setCurrentIndex(cb_Server->findText(cb_Server->currentText())); |
||
455 | } |
||
456 | |||
457 | cb_Server->setEnabled(false); |
||
458 | le_Password->setEnabled(false); |
||
459 | |||
460 | if (cb_Server->currentText().startsWith('/')) |
||
461 | { |
||
462 | o_Input = new Input_TTY(); |
||
463 | o_Input->Init(); |
||
464 | |||
465 | set_Input s_Input; |
||
466 | s_Input.Main = cb_Server->currentText(); |
||
467 | |||
468 | if (o_Input->Open(s_Input) == true) |
||
469 | { |
||
470 | ac_Connect->setText(tr("Trennen")); |
||
471 | connect(o_Input, SIGNAL(sig_NewData(QString)), this, SLOT(slot_Input_Data(QString))); |
||
472 | |||
473 | o_Input->send_Data(HandlerMK::make_Frame('v', 0, c_Data, 0).toLatin1().data(), DATA_VERSION); |
||
474 | } |
||
475 | else |
||
476 | { |
||
477 | cb_Server->setEnabled(true); |
||
478 | le_Password->setEnabled(true); |
||
479 | } |
||
480 | |||
481 | } |
||
482 | else |
||
483 | { |
||
484 | o_Input = new Input_TCP(); |
||
485 | o_Input->Init(); |
||
486 | |||
487 | set_Input s_Input; |
||
488 | |||
489 | QStringList Server = cb_Server->currentText().split(":"); |
||
490 | |||
491 | s_Input.Main = Server[0]; |
||
492 | s_Input.Sub = Server[1]; |
||
493 | |||
494 | if (o_Input->Open(s_Input) == true) |
||
495 | { |
||
496 | connect(o_Input, SIGNAL(sig_Disconnected(int)), this, SLOT(slot_Input_Disconnected(int))); |
||
497 | connect(o_Input, SIGNAL(sig_Connected()), this, SLOT(slot_Input_Connected())); |
||
498 | } |
||
499 | } |
||
500 | } |
||
501 | else |
||
502 | { |
||
503 | cb_Server->setEnabled(true); |
||
504 | le_Password->setEnabled(true); |
||
505 | |||
506 | ac_Connect->setText(tr("Verbinden")); |
||
507 | o_Input->Close(); |
||
508 | disconnect(o_Input, SIGNAL(sig_NewData(QString)), 0, 0); |
||
509 | if (o_Input->Mode() == TCP) |
||
510 | { |
||
511 | disconnect(o_Input, SIGNAL(sig_Disconnected(int)), 0, 0); |
||
512 | disconnect(o_Input, SIGNAL(sig_Connected()), 0, 0); |
||
513 | } |
||
514 | } |
||
515 | } |
||
516 | |||
517 | // Neue Daten empfangen. |
||
518 | void dlg_Main::slot_Input_Data(QString t_Data) |
||
519 | { |
||
520 | if ((t_Data[0] == '#')) |
||
521 | { |
||
522 | if ((HandlerMK::Check_CRC(t_Data.toLatin1().data(), t_Data.length() - 1)) || ((o_Input->Mode() == TTY) && (HandlerMK::Check_CRC(t_Data.toLatin1().data(), t_Data.length())))) |
||
523 | { |
||
524 | parse_MK_Data(t_Data); |
||
525 | } |
||
526 | else |
||
527 | { |
||
528 | // qDebug(QString("CRC-Error - " + t_Data).toLatin1().data()); |
||
529 | } |
||
530 | } |
||
531 | else if (o_Input->Mode() == TCP) |
||
532 | { |
||
533 | parse_IP_Data(t_Data); |
||
534 | } |
||
535 | } |
||
536 | |||
537 | void dlg_Main::slot_Input_Disconnected(int Error) |
||
538 | { |
||
539 | cb_Server->setEnabled(true); |
||
540 | le_Password->setEnabled(true); |
||
541 | |||
542 | // qDebug("Close"); |
||
543 | disconnect(o_Input, SIGNAL(sig_NewData(QString)), 0, 0); |
||
544 | if (o_Input->Mode() == TCP) |
||
545 | { |
||
546 | disconnect(o_Input, SIGNAL(sig_Disconnected(int)), 0, 0); |
||
547 | disconnect(o_Input, SIGNAL(sig_Connected()), 0, 0); |
||
548 | } |
||
549 | ac_Connect->setChecked(false); |
||
550 | ac_Connect->setText(tr("Verbinden")); |
||
551 | |||
552 | switch (Error) |
||
553 | { |
||
554 | case REMOTECLOSED : |
||
555 | { |
||
556 | // lb_Status->setText(tr("Verbindung vom Server beendet.")); |
||
557 | QMessageBox::warning(this, QA_NAME,tr("QMK-Datenserver: Verbindung wurde vom Server beendet."), QMessageBox::Ok); |
||
558 | } |
||
559 | break; |
||
560 | case REFUSED : |
||
561 | { |
||
562 | // lb_Status->setText(tr("Server nicht gefunden.")); |
||
563 | QMessageBox::warning(this, QA_NAME,tr("QMK-Datenserver: Kann nicht zum Server verbinden."), QMessageBox::Ok); |
||
564 | } |
||
565 | break; |
||
566 | case 3 : |
||
567 | { |
||
568 | // lb_Status->setText(tr("Serververbindung getrennt. Logindaten falsch.")); |
||
569 | QMessageBox::warning(this, QA_NAME,tr("QMK-Datenserver: Loginname oder Password falsch."), QMessageBox::Ok); |
||
570 | } |
||
571 | break; |
||
572 | default : |
||
573 | { |
||
574 | // lb_Status->setText(tr("Getrennt vom QMK-Datenserver.")); |
||
575 | } |
||
576 | break; |
||
577 | } |
||
578 | |||
579 | } |
||
580 | |||
581 | void dlg_Main::slot_Input_Connected() |
||
582 | { |
||
583 | connect(o_Input, SIGNAL(sig_NewData(QString)), this, SLOT(slot_Input_Data(QString))); |
||
584 | |||
585 | o_Input->send_Data(HandlerIP::make_Frame(ID_SCOPE, 101, QA_NAME + " " + QA_VERSION)); |
||
586 | o_Input->send_Data(HandlerMK::make_Frame('v', 0, c_Data, 0).toLatin1().data(), DATA_VERSION); |
||
587 | ac_Connect->setText(tr("Trennen")); |
||
588 | } |
||
589 | |||
590 | // Programm Ende |
||
591 | dlg_Main::~dlg_Main() |
||
592 | { |
||
593 | o_Settings->GUI.isMax = isMaximized(); |
||
594 | o_Settings->GUI.Size = size(); |
||
595 | o_Settings->GUI.Point = pos(); |
||
596 | |||
597 | o_Settings->DATA.Debug_Intervall = sb_Intervall->value(); |
||
598 | |||
599 | o_Settings->SERVER.Password = le_Password->text(); |
||
600 | o_Settings->SERVER.IP_MAX = cb_Server->count(); |
||
601 | o_Settings->SERVER.IP_ID = cb_Server->currentIndex(); |
||
602 | |||
603 | for (int z = 0; z < cb_Server->count(); z++) |
||
604 | { |
||
605 | if (z < 10) |
||
606 | { |
||
607 | o_Settings->SERVER.IP[z] = cb_Server->itemText(z); |
||
608 | } |
||
609 | } |
||
610 | |||
611 | o_Settings->write_Settings(); |
||
612 | |||
613 | // qDebug("Ende."); |
||
614 | } |