32,7 → 32,7 |
|
o_Settings = new cSettings(); |
|
o_Input = new Input(); |
wg_Connection->set_Client(ID_MAPS, QA_NAME + " " + QA_VERSION, DataFields); |
|
o_Map = new MapControl(QSize(25,25)); |
l_RouteWP = new LineString(); |
54,26 → 54,14 |
showMaximized(); |
} |
|
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]); |
} |
} |
wg_Connection->set_SelectVisible(false); |
|
cb_Server->setCurrentIndex(o_Settings->SERVER.IP_ID); |
|
le_Password->setText(o_Settings->SERVER.Password); |
|
sb_Intervall->setValue(o_Settings->DATA.Intervall); |
|
cb_CenterPos->setChecked(o_Settings->CONFIG.cb_CenterPos); |
cb_ShowRoute->setChecked(o_Settings->CONFIG.cb_ShowRoute); |
cb_ShowWPs->setChecked(o_Settings->CONFIG.cb_ShowWPs); |
cb_Goto->setChecked(o_Settings->CONFIG.cb_Goto); |
|
// tb_More->addWidget(cb_Maps); |
tb_More->addWidget(cb_Maps); |
cb_Maps->setVisible(false); |
|
ac_Toolbar->setChecked(o_Settings->GUI.Toolbar); |
80,7 → 68,7 |
|
if (ac_Toolbar->isChecked()) |
{ |
btn_Connect->setVisible(false); |
wg_Connection->set_ButtonVisible(false); |
} |
else |
{ |
92,11 → 80,9 |
// Signale mit Slots verbinden |
void dlg_Main::init_Connections() |
{ |
connect(ac_Connect, SIGNAL(triggered()), this, SLOT(slot_ac_Connect())); |
connect(ac_Connect, SIGNAL(triggered()), wg_Connection, SLOT(slot_btn_Connect())); |
connect(ac_Toolbar, SIGNAL(triggered()), this, SLOT(slot_ac_Toolbar())); |
|
connect(sb_Intervall, SIGNAL(valueChanged(int)), this, SLOT(slot_sb_Intervall(int))); |
|
connect(sl_Zoom, SIGNAL(valueChanged(int)), this, SLOT(slot_Zoom(int))); |
connect(cb_Maps, SIGNAL(currentIndexChanged(int)), this, SLOT(slot_ChangeMap(int))); |
|
116,6 → 102,11 |
// 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_NaviData(s_MK_NaviData)), this, SLOT(slot_MK_NaviData(s_MK_NaviData))); |
connect(wg_Connection, SIGNAL(sig_MK_WayPoint(int)), this, SLOT(slot_MK_WayPoint(int))); |
} |
|
void dlg_Main::init_Directorys() |
153,117 → 144,6 |
} |
} |
|
void dlg_Main::parse_IP_Data(QString t_Data) |
{ |
QStringList Data; |
Data = t_Data.split(":"); |
|
if (Data.count() > 1) |
{ |
int CMD = Data[2].toInt(); |
|
switch(CMD) |
{ |
case 101 : |
{ |
o_Input->send_Data(HandlerIP::make_Frame(ID_MAPS, 101, QA_NAME + " " + QA_VERSION)); |
} |
break; |
case 502 : |
{ |
switch (Data[3].toInt()) |
{ |
case 105 : |
{ |
QString s_MD5PW; |
QByteArray a_MD5PW; |
|
a_MD5PW = QCryptographicHash::hash(le_Password->text().toAscii(),QCryptographicHash::Md5); |
|
s_MD5PW = QString(a_MD5PW.toHex().data()); |
|
o_Input->send_Data(HandlerIP::make_Frame(ID_MAPS, 105, s_MD5PW)); |
} |
break; |
case 106 : |
{ |
o_Input->send_Data(HandlerIP::make_Frame(ID_MAPS, 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; |
} |
} |
} |
|
// Eingangsdaten verarbeiten |
void dlg_Main::parse_MK_Data(QString t_Data) |
{ |
unsigned char OutData[150]; |
char *InData = t_Data.toLatin1().data(); |
|
if (HandlerMK::Decode_64(InData, t_Data.length(), OutData) != 0) |
{ |
|
switch(InData[2]) |
{ |
case 'V' : // 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_NC) |
{ |
c_Data[0] = sb_Intervall->value() / 10; |
o_Input->send_Data(HandlerMK::make_Frame('o', ADDRESS_ALL, c_Data, 1).toLatin1().data()); |
} |
else // TODO: Befehl wenden zum Wechseln auf Navi. |
{ |
} |
} |
break; |
case 'O' : // Navi-OSD-Data |
{ |
if (InData[1] - 'a' == ADDRESS_NC) |
{ |
s_MK_NaviData MK_NaviData; |
|
memcpy((unsigned char *)&MK_NaviData, (unsigned char *)&OutData, sizeof(MK_NaviData)); |
if (MK_NaviData.Version == MK_VERSION_NAVI) |
{ |
show_Data(MK_NaviData); |
add_Position(MK_NaviData); |
} |
} |
} |
break; |
case 'W' : // WayPoints |
{ |
o_Input->stop_Resend(DATA_WRITE_WAYPOINT); |
|
if (OutData[0] < l_WayPoints.count()) |
{ |
send_WayPoints(l_WayPoints, OutData[0] + 1); |
} |
} |
break; |
} |
} |
} |
|
/////////////////////////////////////////////////////////////////// |
// QMK-Maps // |
/////////////////////////////////////////////////////////////////// |
482,25 → 362,6 |
f_MKW->close(); |
} |
|
void dlg_Main::show_Data(s_MK_NaviData t_NaviData) |
{ |
QString Mode = "NC-Flags : "; |
if (t_NaviData.NCFlags & 0x08) {le_Mode->setText(tr("Range Limit")); Mode += "R";} |
if (t_NaviData.NCFlags & 0x10) {le_Mode->setText(tr("Serial Error")); Mode += "S";} |
if (t_NaviData.NCFlags & 0x20) {le_Mode->setText(tr("Target reached")); Mode += "T";} |
if (t_NaviData.NCFlags & 0x40) {le_Mode->setText(tr("Manual Control")); Mode += "M";} |
if (t_NaviData.NCFlags & 0x01) {le_Mode->setText(tr("Free")); Mode += "F";} |
if (t_NaviData.NCFlags & 0x02) {le_Mode->setText(tr("Position Hold")); Mode += "P";} |
if (t_NaviData.NCFlags & 0x04) {le_Mode->setText(tr("Coming Home")); Mode += "C";} |
|
//qDebug(Mode.toLatin1().data()); |
|
le_WP->setText(QString("%1/").arg(t_NaviData.WaypointIndex) + QString("%1").arg(t_NaviData.WaypointNumber)); |
le_WPTime->setText(QString("%1:").arg(t_NaviData.TargetHoldTime / 60) + (QString("%1").arg(t_NaviData.TargetHoldTime % 60)).rightJustified(2, '0')); |
le_WPDist->setText(QString("%1m").arg(t_NaviData.TargetPositionDeviation.Distance / 10)); |
le_HomeDist->setText(QString("%1m").arg(t_NaviData.HomePositionDeviation.Distance / 10)); |
} |
|
// Aktuelle MK-Position hinzufügen |
void dlg_Main::add_Position(s_MK_NaviData t_NaviData) |
{ |
577,7 → 438,7 |
s_WayPoint.reserve[3] = 0; |
|
memcpy((unsigned char *)&c_Data, (unsigned char *)&s_WayPoint, sizeof(s_WayPoint)); |
o_Input->send_Data(HandlerMK::make_Frame('s', ADDRESS_NC, c_Data, sizeof(s_WayPoint)).toLatin1().data()); |
wg_Connection->send_Data(HandlerMK::make_Frame('s', ADDRESS_NC, c_Data, sizeof(s_WayPoint)).toLatin1().data()); |
} |
else |
{ |
596,7 → 457,7 |
s_WayPoint.Position.Status = INVALID; |
|
memcpy((unsigned char *)&c_Data, (unsigned char *)&s_WayPoint, sizeof(s_WayPoint)); |
o_Input->send_Data(HandlerMK::make_Frame('w', ADDRESS_NC, c_Data, sizeof(s_WayPoint)).toLatin1().data(), DATA_WRITE_WAYPOINT); |
wg_Connection->send_Data(HandlerMK::make_Frame('w', ADDRESS_NC, c_Data, sizeof(s_WayPoint)).toLatin1().data(), DATA_WRITE_WAYPOINT); |
} |
else |
{ |
625,7 → 486,7 |
s_WayPoint.reserve[3] = 0; // reserve |
|
memcpy((unsigned char *)&c_Data, (unsigned char *)&s_WayPoint, sizeof(s_WayPoint)); |
o_Input->send_Data(HandlerMK::make_Frame('w', ADDRESS_NC, c_Data, sizeof(s_WayPoint)).toLatin1().data(), DATA_WRITE_WAYPOINT); |
wg_Connection->send_Data(HandlerMK::make_Frame('w', ADDRESS_NC, c_Data, sizeof(s_WayPoint)).toLatin1().data(), DATA_WRITE_WAYPOINT); |
} |
} |
|
643,176 → 504,64 |
{ |
if (ac_Toolbar->isChecked()) |
{ |
btn_Connect->setVisible(false); |
wg_Connection->set_ButtonVisible(false); |
ToolBar->setVisible(true); |
tb_More->setVisible(true); |
} |
else |
{ |
btn_Connect->setVisible(true); |
wg_Connection->set_ButtonVisible(true); |
ToolBar->setVisible(false); |
tb_More->setVisible(false); |
} |
} |
|
|
// Datenintervall geändert. |
void dlg_Main::slot_sb_Intervall(int t_Intervall) |
void dlg_Main::slot_ConnectionStatus(int li_Status) |
{ |
if (t_Intervall == 0) |
if (li_Status) |
{ |
c_Data[0] = 0; |
ac_Connect->setChecked(true); |
ac_Connect->setText(tr("Trennen")); |
} |
else |
{ |
c_Data[0] = t_Intervall / 10; |
} |
o_Input->send_Data(HandlerMK::make_Frame('o', ADDRESS_ALL, c_Data, 1).toLatin1().data()); |
} |
|
// Verbindung zum Server auf f_Settings = new wdg_Settings( this );bauen |
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); |
|
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->setChecked(false); |
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) |
void dlg_Main::slot_MK_Version(s_Hardware ls_Version) |
{ |
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); |
} |
gs_Version = ls_Version; |
setWindowTitle(QA_NAME + " " + QA_VERSION + " - " + ls_Version.Hardware + " " + ls_Version.Version); |
} |
|
// Serververbindung beendet |
void dlg_Main::slot_Input_Disconnected(int Error) |
void dlg_Main::slot_MK_NaviData(s_MK_NaviData ps_MK_NaviData) |
{ |
cb_Server->setEnabled(true); |
le_Password->setEnabled(true); |
QString Mode = "NC-Flags : "; |
if (ps_MK_NaviData.NCFlags & 0x08) {le_Mode->setText(tr("Range Limit")); Mode += "R";} |
if (ps_MK_NaviData.NCFlags & 0x10) {le_Mode->setText(tr("Serial Error")); Mode += "S";} |
if (ps_MK_NaviData.NCFlags & 0x20) {le_Mode->setText(tr("Target reached")); Mode += "T";} |
if (ps_MK_NaviData.NCFlags & 0x40) {le_Mode->setText(tr("Manual Control")); Mode += "M";} |
if (ps_MK_NaviData.NCFlags & 0x01) {le_Mode->setText(tr("Free")); Mode += "F";} |
if (ps_MK_NaviData.NCFlags & 0x02) {le_Mode->setText(tr("Position Hold")); Mode += "P";} |
if (ps_MK_NaviData.NCFlags & 0x04) {le_Mode->setText(tr("Coming Home")); Mode += "C";} |
|
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); |
le_WP->setText(QString("%1/").arg(ps_MK_NaviData.WaypointIndex) + QString("%1").arg(ps_MK_NaviData.WaypointNumber)); |
le_WPTime->setText(QString("%1:").arg(ps_MK_NaviData.TargetHoldTime / 60) + (QString("%1").arg(ps_MK_NaviData.TargetHoldTime % 60)).rightJustified(2, '0')); |
le_WPDist->setText(QString("%1m").arg(ps_MK_NaviData.TargetPositionDeviation.Distance / 10)); |
le_HomeDist->setText(QString("%1m").arg(ps_MK_NaviData.HomePositionDeviation.Distance / 10)); |
|
ac_Connect->setChecked(false); |
ac_Connect->setText(tr("Verbinden")); |
btn_Connect->setChecked(false); |
add_Position(ps_MK_NaviData); |
} |
|
switch (Error) |
void dlg_Main::slot_MK_WayPoint(int pi_WayPointID) |
{ |
if (pi_WayPointID < l_WayPoints.count()) |
{ |
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; |
send_WayPoints(l_WayPoints, pi_WayPointID + 1); |
} |
|
} |
|
// Serververbindung hergestellt |
void dlg_Main::slot_Input_Connected() |
{ |
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); |
ac_Connect->setText(tr("Trennen")); |
} |
|
/////////////////////////////////////////////////////////////////// |
// QMK-Maps // |
/////////////////////////////////////////////////////////////////// |
1143,20 → 892,6 |
o_Settings->GUI.Point = pos(); |
o_Settings->GUI.Toolbar = ac_Toolbar->isChecked(); |
|
o_Settings->DATA.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->CONFIG.cb_CenterPos = cb_CenterPos->isChecked(); |
o_Settings->CONFIG.cb_ShowRoute = cb_ShowRoute->isChecked(); |
o_Settings->CONFIG.cb_ShowWPs = cb_ShowWPs->isChecked(); |