27,12 → 27,11 |
{ |
setupUi(this); |
|
|
o_Settings = new cSettings(); |
|
o_Settings->read_DebugLabels(0); |
|
wg_Connection->set_Client(ID_SCOPE, QA_NAME + " " + QA_VERSION, DataFields); |
o_Input = new Input(); |
|
init_GUI(); |
init_Connections(); |
52,9 → 51,20 |
showMaximized(); |
} |
|
wg_Connection->set_SelectVisible(false); |
wg_Connection->set_ButtonVisible(false); |
for(int z = 0; z < o_Settings->SERVER.IP_MAX; z++) |
{ |
if (cb_Server->findText(o_Settings->SERVER.IP[z]) == -1) |
{ |
cb_Server->addItem(o_Settings->SERVER.IP[z]); |
} |
} |
|
cb_Server->setCurrentIndex(o_Settings->SERVER.IP_ID); |
|
le_Password->setText(o_Settings->SERVER.Password); |
|
sb_Intervall->setValue(o_Settings->DATA.Debug_Intervall); |
|
btn_Start->setCheckable(true); |
|
ac_Plotter->setChecked(true); |
88,8 → 98,9 |
// Signale mit Slots verbinden |
void dlg_Main::init_Connections() |
{ |
connect(ac_Connect, SIGNAL(triggered()), wg_Connection, SLOT(slot_btn_Connect())); |
connect(sb_Intervall, SIGNAL(valueChanged(int)), this, SLOT(slot_sb_Intervall(int))); |
|
connect(ac_Connect, SIGNAL(triggered()), this, SLOT(slot_ac_Connect())); |
connect(ac_Plotter, SIGNAL(triggered()), this, SLOT(slot_ac_Plotter())); |
connect(ac_Debug, SIGNAL(triggered()), this, SLOT(slot_ac_Debug())); |
connect(ac_Chose, SIGNAL(triggered()), this, SLOT(slot_ac_Chose())); |
96,6 → 107,10 |
|
connect(ac_ReadLabels, SIGNAL(triggered()), this, SLOT(slot_ac_ReadLabels())); |
|
connect(rb_NC, SIGNAL(clicked()), this, SLOT(slot_rb_Hardware())); |
connect(rb_FC, SIGNAL(clicked()), this, SLOT(slot_rb_Hardware())); |
connect(rb_MK3MAG, SIGNAL(clicked()), this, SLOT(slot_rb_Hardware())); |
|
connect(Plotter_Scroll, SIGNAL(valueChanged(int)), this, SLOT(slot_Plotter_Scroll(int))); |
|
connect(btn_Start, SIGNAL(clicked()), this, SLOT(slot_Plotter_Start())); |
104,11 → 119,6 |
// About QMK-Kernel & About-QT Dialog einfügen |
connect(ac_About, SIGNAL(triggered()), this, SLOT(slot_ac_About())); |
menu_Help->addAction(trUtf8("Über &Qt"), qApp, SLOT(aboutQt())); |
|
connect(wg_Connection, SIGNAL(sig_Status(int)), this, SLOT(slot_ConnectionStatus(int))); |
connect(wg_Connection, SIGNAL(sig_MK_Version(s_Hardware)), this, SLOT(slot_MK_Version(s_Hardware))); |
connect(wg_Connection, SIGNAL(sig_MK_Debug(s_MK_Debug)), this, SLOT(slot_MK_Debug(s_MK_Debug))); |
connect(wg_Connection, SIGNAL(sig_MK_DebugLabels(s_MK_DebugLabels)), this, SLOT(slot_MK_DebugLabels(s_MK_DebugLabels))); |
} |
|
void dlg_Main::init_Plotter() |
188,95 → 198,171 |
qwt_Plotter->replot(); |
} |
|
/////////// |
// Slots // |
/////////// |
|
// About-Dialog |
void dlg_Main::slot_ac_About() |
// IP-Input-Daten verarbeiten. |
void dlg_Main::parse_IP_Data(QString t_Data) |
{ |
QMessageBox::about(this, trUtf8(("Über ")) + QA_NAME, QA_ABOUT); |
} |
QStringList Data; |
Data = t_Data.split(":"); |
|
void dlg_Main::slot_ConnectionStatus(int li_Status) |
{ |
if (li_Status) |
if (Data.count() > 1) |
{ |
ac_Connect->setChecked(true); |
ac_Connect->setText(tr("Trennen")); |
} |
else |
{ |
ac_Connect->setChecked(false); |
ac_Connect->setText(tr("Verbinden")); |
} |
} |
int CMD = Data[2].toInt(); |
|
void dlg_Main::slot_MK_Version(s_Hardware ls_Version) |
{ |
gs_Version = ls_Version; |
setWindowTitle(QA_NAME + " " + QA_VERSION + " - " + ls_Version.Hardware + " " + ls_Version.Version); |
switch(CMD) |
{ |
case 101 : |
{ |
o_Input->send_Data(HandlerIP::make_Frame(ID_SCOPE, 101, QA_NAME + " " + QA_VERSION)); |
} |
case 502 : |
{ |
switch (Data[3].toInt()) |
{ |
case 105 : |
{ |
QString s_MD5PW; |
QByteArray a_MD5PW; |
|
o_Settings->read_DebugLabels(gs_Version.ID); |
a_MD5PW = QCryptographicHash::hash(le_Password->text().toAscii(),QCryptographicHash::Md5); |
|
if (o_Settings->DebugData.Version != gs_Version.Version) |
{ |
qDebug(QString("Debug-Labels unterschiedlich. Neue anforden. " + o_Settings->DebugData.Version + " <> " + gs_Version.Version).toLatin1().data()); |
usleep(50000); |
s_MD5PW = QString(a_MD5PW.toHex().data()); |
|
slot_ac_ReadLabels(); |
} |
else |
{ |
for(int z = 0; z < MAX_DebugData; z++) |
{ |
lb_Debug[z]->setText(o_Settings->DebugData.Label[z]); |
cb_Debug[z]->setText(o_Settings->DebugData.Label[z]); |
cb_Debug[z]->setChecked(o_Settings->DebugData.Show_Plotter[z]); |
o_Input->send_Data(HandlerIP::make_Frame(ID_SCOPE, 105, s_MD5PW)); |
} |
break; |
case 106 : |
{ |
o_Input->send_Data(HandlerIP::make_Frame(ID_SCOPE, 106, DataFields)); |
} |
break; |
} |
} |
break; |
case 505 : |
{ |
if (Data[3] == "OK") |
{ |
} |
else |
{ |
QMessageBox::warning(this, QA_NAME, trUtf8("Authentifizierung fehlgeschlagen. <br />Daten senden zum Mikrokopter nicht möglich."), QMessageBox::Ok); |
} |
} |
break; |
} |
config_Plotter(); |
} |
} |
|
void dlg_Main::slot_MK_Debug(s_MK_Debug ls_Debug) |
// MK-Eingangsdaten verarbeiten |
void dlg_Main::parse_MK_Data(QString t_Data) |
{ |
gs_Debug = ls_Debug; |
unsigned char OutData[150]; |
char *InData = t_Data.toLatin1().data(); |
|
for (int z = 0; z < MAX_DebugData; z++) |
if (HandlerMK::Decode_64(InData, t_Data.length(), OutData) != 0) |
{ |
Debug_Data[z] = ls_Debug.Analog[z]; |
if (ac_Debug->isChecked()) |
switch(InData[2]) |
{ |
le_Debug[z]->setText(QString("%1").arg(Debug_Data[z])); |
} |
} |
if (btn_Start->isChecked()) |
{ |
update_Plotter(); |
} |
} |
case 'A' : // 0.76e - Debug-Labels |
{ |
o_Input->stop_Resend(DATA_READ_LABEL); |
int Position = OutData[0]; |
if (Position < 32) |
{ |
o_Settings->DebugData.Label[Position] = HandlerMK::Data2QString(OutData,1,17).trimmed(); |
if (o_Settings->DebugData.Label[Position] == "") |
{ |
o_Settings->DebugData.Label[Position] = "Debug-" + QString("%1").arg(Position); |
} |
lb_Debug[Position]->setText("" + o_Settings->DebugData.Label[Position]); |
cb_Debug[Position]->setText("" + o_Settings->DebugData.Label[Position]); |
|
void dlg_Main::slot_MK_DebugLabels(s_MK_DebugLabels MK_DebugLabels) |
{ |
if (MK_DebugLabels.Position < 32) |
{ |
o_Settings->DebugData.Label[MK_DebugLabels.Position] = MK_DebugLabels.Text; |
if (o_Settings->DebugData.Label[MK_DebugLabels.Position] == "") |
{ |
o_Settings->DebugData.Label[MK_DebugLabels.Position] = "Debug-" + QString("%1").arg(MK_DebugLabels.Position); |
Position ++; |
|
if ((Position < 32) && (get_Analoglabels == true)) |
{ |
c_Data[0] = Position; |
o_Input->send_Data(HandlerMK::make_Frame('a', ADDRESS_ALL, c_Data, 1).toLatin1().data(), DATA_READ_LABEL); |
} |
} |
if (Position == 32) |
{ |
o_Settings->DebugData.Version = VersionInfo.Version; |
o_Settings->write_DebugLabels(VersionInfo.ID); |
config_Plotter(); |
get_Analoglabels = false; |
} |
} |
break; |
|
case 'D' : // 0.75a - Debug-Daten |
{ |
for (int z = 0; z < MAX_DebugData; z++) |
{ |
Debug_Data[z] = HandlerMK::Data2Int(OutData, (z * 2) + 2); |
if (ac_Debug->isChecked()) |
{ |
le_Debug[z]->setText(QString("%1").arg(Debug_Data[z])); |
} |
} |
if (btn_Start->isChecked()) |
{ |
update_Plotter(); |
} |
} |
break; |
|
case 'V' : // 0.75a - Versions-Info |
{ |
o_Input->stop_Resend(DATA_VERSION); |
VersionInfo = HandlerMK::parse_Version(OutData, InData[1] - 'a'); |
setWindowTitle(QA_NAME + " " + QA_VERSION + " - " + VersionInfo.Hardware + " " + VersionInfo.Version); |
|
if (VersionInfo.ID == ADDRESS_FC) |
{ |
rb_FC->setChecked(true); |
} |
if (VersionInfo.ID == ADDRESS_NC) |
{ |
rb_NC->setChecked(true); |
} |
if (VersionInfo.ID == ADDRESS_MK3MAG) |
{ |
rb_MK3MAG->setChecked(true); |
} |
|
o_Settings->read_DebugLabels(VersionInfo.ID); |
|
if (o_Settings->DebugData.Version != VersionInfo.Version) |
{ |
// qDebug(QString("Debug-Labels unterschiedlich. Neue anforden. " + o_Settings->DebugData.Version + " <> " + VersionInfo.Version).toLatin1().data()); |
|
usleep(50000); |
|
slot_ac_ReadLabels(); |
// o_Input->send_Data(HandlerMK::make_Frame('a', ADDRESS_ALL, c_Data, 1).toLatin1().data()); |
} |
else |
{ |
for(int z = 0; z < MAX_DebugData; z++) |
{ |
lb_Debug[z]->setText(o_Settings->DebugData.Label[z]); |
cb_Debug[z]->setText(o_Settings->DebugData.Label[z]); |
cb_Debug[z]->setChecked(o_Settings->DebugData.Show_Plotter[z]); |
} |
config_Plotter(); |
} |
c_Data[0] = sb_Intervall->value() / 10; |
o_Input->send_Data(HandlerMK::make_Frame('d', ADDRESS_ALL, c_Data, 1).toLatin1().data()); |
} |
break; |
} |
lb_Debug[MK_DebugLabels.Position]->setText("" + o_Settings->DebugData.Label[MK_DebugLabels.Position]); |
cb_Debug[MK_DebugLabels.Position]->setText("" + o_Settings->DebugData.Label[MK_DebugLabels.Position]); |
|
} |
if (MK_DebugLabels.Position == 31) |
{ |
o_Settings->DebugData.Version = gs_Version.Version; |
o_Settings->write_DebugLabels(gs_Version.ID); |
config_Plotter(); |
} |
} |
|
/////////// |
// Slots // |
/////////// |
void dlg_Main::slot_Plotter_Start() |
{ |
if (btn_Start->isChecked()) |
296,11 → 382,12 |
o_Settings->DebugData.Show_Plotter[z] = cb_Debug[z]->isChecked(); |
} |
config_Plotter(); |
o_Settings->write_DebugLabels(gs_Version.ID); |
o_Settings->write_DebugLabels(VersionInfo.ID); |
} |
|
void dlg_Main::slot_ac_Chose() |
{ |
|
for(int z = 0; z < MAX_DebugData; z++) |
{ |
cb_Debug[z]->setChecked(o_Settings->DebugData.Show_Plotter[z]); |
330,10 → 417,199 |
|
void dlg_Main::slot_ac_ReadLabels() |
{ |
get_Analoglabels = true; |
c_Data[0] = 0; |
wg_Connection->send_Data(HandlerMK::make_Frame('a', ADDRESS_ALL, c_Data, 1).toLatin1().data(), DATA_READ_LABEL); |
o_Input->send_Data(HandlerMK::make_Frame('a', ADDRESS_ALL, c_Data, 1).toLatin1().data(), DATA_READ_LABEL); |
} |
|
// About-Dialog |
void dlg_Main::slot_ac_About() |
{ |
QMessageBox::about(this, trUtf8(("Über ")) + QA_NAME, QA_ABOUT); |
} |
|
// Datenintervall geändert. |
void dlg_Main::slot_sb_Intervall(int t_Intervall) |
{ |
if (t_Intervall == 0) |
{ |
c_Data[0] = 0; |
} |
else |
{ |
c_Data[0] = t_Intervall / 10; |
} |
o_Input->send_Data(HandlerMK::make_Frame('d', ADDRESS_ALL, c_Data, 1).toLatin1().data()); |
} |
|
// Hardware auswählen. |
void dlg_Main::slot_rb_Hardware() |
{ |
if ((rb_NC->isChecked() == false) && (VersionInfo.ID != ADDRESS_NC)) |
{ |
o_Input->send_Data(HandlerMK::get_SelectNC()); |
} |
|
if (rb_FC->isChecked()) |
{ |
o_Input->send_Data(HandlerMK::get_SelectFC()); |
} |
else |
if (rb_MK3MAG->isChecked()) |
{ |
o_Input->send_Data(HandlerMK::get_SelectMK3MAG()); |
} |
else |
if (rb_NC->isChecked()) |
{ |
o_Input->send_Data(HandlerMK::get_SelectNC()); |
} |
|
o_Input->send_Data(HandlerMK::make_Frame('v', 0, c_Data, 0).toLatin1().data(), DATA_VERSION); |
} |
|
// Verbindung zum Server aufbauen |
void dlg_Main::slot_ac_Connect() |
{ |
if (!o_Input->IsOpen()) |
{ |
if (cb_Server->findText(cb_Server->currentText()) == -1) |
{ |
cb_Server->addItem(cb_Server->currentText()); |
cb_Server->setCurrentIndex(cb_Server->findText(cb_Server->currentText())); |
} |
|
cb_Server->setEnabled(false); |
le_Password->setEnabled(false); |
|
// Connect über Device |
if (cb_Server->currentText().startsWith('/')) |
{ |
o_Input = new Input_TTY(); |
o_Input->Init(); |
|
set_Input s_Input; |
s_Input.Main = cb_Server->currentText(); |
|
if (o_Input->Open(s_Input) == true) |
{ |
ac_Connect->setText(tr("Trennen")); |
connect(o_Input, SIGNAL(sig_NewData(QString)), this, SLOT(slot_Input_Data(QString))); |
|
o_Input->send_Data(HandlerMK::make_Frame('v', 0, c_Data, 0).toLatin1().data(), DATA_VERSION); |
} |
else |
{ |
cb_Server->setEnabled(true); |
le_Password->setEnabled(true); |
} |
|
} |
else // Connect über TCPIP |
{ |
o_Input = new Input_TCP(); |
o_Input->Init(); |
|
set_Input s_Input; |
|
QStringList Server = cb_Server->currentText().split(":"); |
|
s_Input.Main = Server[0]; |
s_Input.Sub = Server[1]; |
|
if (o_Input->Open(s_Input) == true) |
{ |
connect(o_Input, SIGNAL(sig_Disconnected(int)), this, SLOT(slot_Input_Disconnected(int))); |
connect(o_Input, SIGNAL(sig_Connected()), this, SLOT(slot_Input_Connected())); |
} |
} |
} |
else |
{ |
cb_Server->setEnabled(true); |
le_Password->setEnabled(true); |
|
ac_Connect->setText(tr("Verbinden")); |
o_Input->Close(); |
disconnect(o_Input, SIGNAL(sig_NewData(QString)), 0, 0); |
if (o_Input->Mode() == TCP) |
{ |
disconnect(o_Input, SIGNAL(sig_Disconnected(int)), 0, 0); |
disconnect(o_Input, SIGNAL(sig_Connected()), 0, 0); |
} |
} |
} |
|
// Neue Daten empfangen. |
void dlg_Main::slot_Input_Data(QString t_Data) |
{ |
if ((t_Data[0] == '#')) |
{ |
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())))) |
{ |
parse_MK_Data(t_Data); |
} |
else |
{ |
qDebug(QString("CRC-Error - " + t_Data).toLatin1().data()); |
} |
} |
else if ((o_Input->Mode() == TCP) && (t_Data[0] == '$')) |
{ |
parse_IP_Data(t_Data); |
} |
} |
|
void dlg_Main::slot_Input_Disconnected(int Error) |
{ |
cb_Server->setEnabled(true); |
le_Password->setEnabled(true); |
|
disconnect(o_Input, SIGNAL(sig_NewData(QString)), 0, 0); |
disconnect(o_Input, SIGNAL(sig_Disconnected(int)), 0, 0); |
disconnect(o_Input, SIGNAL(sig_Connected()), 0, 0); |
|
ac_Connect->setChecked(false); |
ac_Connect->setText(tr("Verbinden")); |
|
switch (Error) |
{ |
case REMOTECLOSED : |
{ |
// lb_Status->setText(tr("Verbindung vom Server beendet.")); |
QMessageBox::warning(this, QA_NAME,tr("QMK-Datenserver: Verbindung wurde vom Server beendet."), QMessageBox::Ok); |
} |
break; |
case REFUSED : |
{ |
// lb_Status->setText(tr("Server nicht gefunden.")); |
QMessageBox::warning(this, QA_NAME,tr("QMK-Datenserver: Kann nicht zum Server verbinden."), QMessageBox::Ok); |
} |
break; |
case 3 : |
{ |
// lb_Status->setText(tr("Serververbindung getrennt. Logindaten falsch.")); |
QMessageBox::warning(this, QA_NAME,tr("QMK-Datenserver: Loginname oder Password falsch."), QMessageBox::Ok); |
} |
break; |
default : |
{ |
// lb_Status->setText(tr("Getrennt vom QMK-Datenserver.")); |
} |
break; |
} |
|
} |
|
void dlg_Main::slot_Input_Connected() |
{ |
connect(o_Input, SIGNAL(sig_NewData(QString)), this, SLOT(slot_Input_Data(QString))); |
|
// o_Input->send_Data(HandlerIP::make_Frame(ID_SCOPE, 101, QA_NAME + " " + QA_VERSION)); |
o_Input->send_Data(HandlerMK::make_Frame('v', 0, c_Data, 0).toLatin1().data(), DATA_VERSION); |
ac_Connect->setText(tr("Trennen")); |
} |
|
// Programm Ende |
dlg_Main::~dlg_Main() |
{ |
341,5 → 617,21 |
o_Settings->GUI.Size = size(); |
o_Settings->GUI.Point = pos(); |
|
o_Settings->DATA.Debug_Intervall = sb_Intervall->value(); |
|
o_Settings->SERVER.Password = le_Password->text(); |
o_Settings->SERVER.IP_MAX = cb_Server->count(); |
o_Settings->SERVER.IP_ID = cb_Server->currentIndex(); |
|
for (int z = 0; z < cb_Server->count(); z++) |
{ |
if (z < 10) |
{ |
o_Settings->SERVER.IP[z] = cb_Server->itemText(z); |
} |
} |
|
o_Settings->write_Settings(); |
|
// qDebug("Ende."); |
} |