47,6 → 47,7 |
|
init_Arrays(); |
init_GUI(); |
init_Cockpit(); |
|
init_Objects(); |
init_Connections(); |
95,49 → 96,6 |
|
lb_Status->setText(tr("Hallo bei QMK-Groundstation...!!!")); |
|
// Cockpit-Elemente |
QPalette newPalette; |
|
newPalette.setColor(QPalette::Base, Qt::darkBlue); |
newPalette.setColor(QPalette::Foreground, QColor(Qt::darkBlue).dark(120)); |
newPalette.setColor(QPalette::Text, Qt::white); |
|
Compass->setScaleOptions(QwtDial::ScaleTicks | QwtDial::ScaleLabel); |
Compass->setScaleTicks(0, 0, 3); |
Compass->setScale(36, 5, 0); |
|
Compass->setNeedle(new QwtDialSimpleNeedle(QwtDialSimpleNeedle::Arrow, true, Qt::red, QColor(Qt::gray).light(130))); |
Compass->setPalette(newPalette); |
Compass->setMaximumSize(QSize(MeterSize, MeterSize)); |
Compass->setMinimumSize(QSize(MeterSize, MeterSize)); |
|
QPalette newPalette1; |
|
newPalette1.setColor(QPalette::Base, Qt::darkBlue); |
newPalette1.setColor(QPalette::Foreground, QColor(255,128,0).dark(120)); |
newPalette1.setColor(QPalette::Text, Qt::white); |
|
Attitude = new AttitudeIndicator(this); |
Attitude->setMaximumSize(QSize(MeterSize, MeterSize)); |
Attitude->setMinimumSize(QSize(MeterSize, MeterSize)); |
Attitude->setPalette(newPalette1); |
|
verticalLayout->addWidget(Attitude); |
|
qwt_Rate->setRange(-10.0, 10.0, 0.1, 0); |
|
newPalette1.setColor(QPalette::Foreground, QColor(Qt::darkBlue).dark(120)); |
|
SpeedMeter = new cSpeedMeter(this); |
SpeedMeter->setMaximumSize(QSize(MeterSize, MeterSize)); |
SpeedMeter->setMinimumSize(QSize(MeterSize, MeterSize)); |
SpeedMeter->setPalette(newPalette1); |
SpeedMeter->setRange(0.0, 5.0); |
SpeedMeter->setScale(1, 2, 0.5); |
SpeedMeter->setProperty("END", 5); |
|
LayOut_Speed->addWidget(SpeedMeter); |
|
resize(Settings->GUI.Size); |
move(Settings->GUI.Point); |
|
190,12 → 148,59 |
cb_ShowAlways->setChecked(Settings->GUI.Term_Always); |
} |
|
void MKTool::init_Cockpit() |
{ |
// Cockpit-Elemente |
QPalette newPalette; |
|
newPalette.setColor(QPalette::Base, Qt::darkBlue); |
newPalette.setColor(QPalette::Foreground, QColor(Qt::darkBlue).dark(120)); |
newPalette.setColor(QPalette::Text, Qt::white); |
|
Compass->setScaleOptions(QwtDial::ScaleTicks | QwtDial::ScaleLabel); |
Compass->setScaleTicks(0, 0, 3); |
Compass->setScale(36, 5, 0); |
|
Compass->setNeedle(new QwtDialSimpleNeedle(QwtDialSimpleNeedle::Arrow, true, Qt::red, QColor(Qt::gray).light(130))); |
Compass->setPalette(newPalette); |
Compass->setMaximumSize(QSize(MeterSize, MeterSize)); |
Compass->setMinimumSize(QSize(MeterSize, MeterSize)); |
|
QPalette newPalette1; |
|
newPalette1.setColor(QPalette::Base, Qt::darkBlue); |
newPalette1.setColor(QPalette::Foreground, QColor(255,128,0).dark(120)); |
newPalette1.setColor(QPalette::Text, Qt::white); |
|
Attitude = new AttitudeIndicator(this); |
Attitude->setMaximumSize(QSize(MeterSize, MeterSize)); |
Attitude->setMinimumSize(QSize(MeterSize, MeterSize)); |
Attitude->setPalette(newPalette1); |
|
verticalLayout->addWidget(Attitude); |
|
qwt_Rate->setRange(-10.0, 10.0, 0.1, 0); |
|
newPalette1.setColor(QPalette::Foreground, QColor(Qt::darkBlue).dark(120)); |
|
SpeedMeter = new cSpeedMeter(this); |
SpeedMeter->setMaximumSize(QSize(MeterSize, MeterSize)); |
SpeedMeter->setMinimumSize(QSize(MeterSize, MeterSize)); |
SpeedMeter->setPalette(newPalette1); |
SpeedMeter->setRange(0.0, 5.0); |
SpeedMeter->setScale(1, 2, 0.5); |
SpeedMeter->setProperty("END", 5); |
|
LayOut_Speed->addWidget(SpeedMeter); |
} |
|
void MKTool::init_Objects() |
{ |
// QTimer-Instanzen |
Ticker = new QTimer(this); |
|
Conn = new cConnection(); |
// Verbindungsobject |
o_Connection = new cConnection(); |
|
// neuer Logger |
logger = new Logger(Settings, &Mode); |
205,8 → 210,9 |
|
// LCD-Dialog |
f_Map = new dlg_Map(this); |
f_Map->create_Map(Settings); |
|
GE_Server = new cServer(); |
KML_Server = new cKML_Server(); |
|
QMK_Server = new cQMK_Server(); |
QMK_Server->setProperty("Connect", false); |
214,7 → 220,7 |
if (Settings->Server.StartServer) |
{ |
ac_StartServer->setChecked(true); |
GE_Server->start_Server(Settings->Server.Port.toInt(), Settings); |
KML_Server->start_Server(Settings->Server.Port.toInt(), Settings); |
} |
} |
|
222,9 → 228,12 |
{ |
connect(Dec, SIGNAL(clicked()), this, SLOT(slot_Test())); |
|
// Waypoints übergeben |
connect(f_Map, SIGNAL(set_Target(sWayPoint)), this , SLOT(slot_MAP_SetTarget(sWayPoint))); |
|
// Daten Senden / Empfangen |
connect(Conn, SIGNAL(newData(sRxData)), this, SLOT(slot_newData(sRxData))); |
connect(Conn, SIGNAL(showTerminal(int, QString)), this, SLOT(slot_showTerminal(int, QString))); |
connect(o_Connection, SIGNAL(newData(sRxData)), this, SLOT(slot_newData(sRxData))); |
connect(o_Connection, SIGNAL(showTerminal(int, QString)), this, SLOT(slot_showTerminal(int, QString))); |
|
// Serielle Verbundung öffnen / schließen |
connect(ac_ConnectTTY, SIGNAL(triggered()), this, SLOT(slot_OpenPort())); |
285,7 → 294,8 |
|
// Seitenwechsel |
connect(tab_Main, SIGNAL(currentChanged(int)), this, SLOT(slot_TabChanged(int))); |
connect(f_Settings->tab_Par, SIGNAL(currentChanged(int)), this, SLOT(slot_TabChanged(int))); |
// connect(f_Settings->tab_Par, SIGNAL(currentChanged(int)), this, SLOT(slot_TabChanged(int))); |
connect(f_Settings->listWidget, SIGNAL(currentRowChanged(int)), this, SLOT(slot_TabChanged(int))); |
|
// About QMK & About-QT Dialog einfügen |
connect(ac_About, SIGNAL(triggered()), this, SLOT(slot_ac_About())); |
355,6 → 365,11 |
qwtPlot->replot(); |
} |
|
void MKTool::slot_set_Settings(cSettings *t_Settings) |
{ |
Settings = t_Settings; |
} |
|
void MKTool::slot_Test() |
{ |
// qDebug("Decode Data"); |
440,7 → 455,7 |
abs(Navi.Current.Longitude - desired_pos.Position.Longitude) < max_radius && |
abs(Navi.Current.Latitude - desired_pos.Position.Latitude) < max_radius) |
{ |
Conn->send_Cmd('s', ADDRESS_NC, (char *)&desired_pos, sizeof(desired_pos), false); |
o_Connection->send_Cmd('s', ADDRESS_NC, (char *)&desired_pos, sizeof(desired_pos), false); |
} |
else |
{ |
482,7 → 497,7 |
TX_Data[3] = 0xAA; |
TX_Data[4] = 0x00; |
TX_Data[5] = '\r'; |
Conn->send_Cmd('#', ADDRESS_NC, TX_Data, 6, false); |
o_Connection->send_Cmd('#', ADDRESS_NC, TX_Data, 6, false); |
ToolBox::Wait(SLEEP); |
} |
|
490,7 → 505,7 |
{ |
lb_Status->setText(tr("Schalte um auf FlightCtrl.")); |
TX_Data[0] = 0; |
Conn->send_Cmd('u', ADDRESS_NC, TX_Data, 1, false); |
o_Connection->send_Cmd('u', ADDRESS_NC, TX_Data, 1, false); |
} |
else |
if (rb_SelMag->isChecked()) |
497,7 → 512,7 |
{ |
lb_Status->setText(tr("Schalte um auf MK3MAG.")); |
TX_Data[0] = 1; |
Conn->send_Cmd('u', ADDRESS_NC, TX_Data, 1, false); |
o_Connection->send_Cmd('u', ADDRESS_NC, TX_Data, 1, false); |
} |
else |
if (rb_SelNC->isChecked()) |
509,12 → 524,12 |
TX_Data[3] = 0xAA; |
TX_Data[4] = 0x00; |
TX_Data[5] = '\r'; |
Conn->send_Cmd('#', ADDRESS_NC, TX_Data, 6, false); |
o_Connection->send_Cmd('#', ADDRESS_NC, TX_Data, 6, false); |
} |
ToolBox::Wait(SLEEP); |
|
// qDebug("Select RB Hardware"); |
Conn->send_Cmd('v', ADDRESS_ALL, TX_Data, 0, true); |
o_Connection->send_Cmd('v', ADDRESS_ALL, TX_Data, 0, true); |
} |
|
// Ticker-Event |
552,7 → 567,7 |
break; |
case 1 : |
TX_Data[0] = 0; |
Conn->send_Cmd('p', ADDRESS_FC, TX_Data, 0, false); |
o_Connection->send_Cmd('p', ADDRESS_FC, TX_Data, 0, false); |
break; |
case 2 : |
if (f_LCD->cb_LCD->isChecked()) |
564,7 → 579,7 |
} |
TX_Data[0] = LCD_Page; |
TX_Data[1] = 0; |
Conn->send_Cmd('l', ADDRESS_ALL, TX_Data, 1, true); |
o_Connection->send_Cmd('l', ADDRESS_ALL, TX_Data, 1, true); |
} |
break; |
case 3 : |
571,12 → 586,12 |
if (ac_FastDebug->isChecked()) |
{ |
TX_Data[0] = Settings->Data.Debug_Fast / 10; |
Conn->send_Cmd('d', ADDRESS_ALL, TX_Data, 1, false); |
o_Connection->send_Cmd('d', ADDRESS_ALL, TX_Data, 1, false); |
} |
else |
{ |
TX_Data[0] = Settings->Data.Debug_Slow / 10; |
Conn->send_Cmd('d', ADDRESS_ALL, TX_Data, 1, false); |
o_Connection->send_Cmd('d', ADDRESS_ALL, TX_Data, 1, false); |
} |
break; |
} |
672,6 → 687,7 |
{ |
if (!f_LCD->isVisible()) |
{ |
delete f_LCD; |
f_LCD = new dlg_LCD(this); |
|
// LCD auf / ab |
681,7 → 697,7 |
f_LCD->show(); |
TX_Data[0] = 0; |
TX_Data[1] = 0; |
Conn->send_Cmd('l', ADDRESS_ALL, TX_Data, 1, true); |
o_Connection->send_Cmd('l', ADDRESS_ALL, TX_Data, 1, true); |
|
Ticker->setInterval(500); |
TickerEvent[2] = true; |
692,13 → 708,23 |
{ |
if (!f_Map->isVisible()) |
{ |
f_Map = new dlg_Map(this); |
// delete f_Map; |
// f_Map = new dlg_Map(this); |
// f_Map->create_Map(Settings); |
|
f_Map->show(); |
} |
} |
|
void MKTool::slot_MAP_SetTarget(sWayPoint Target) |
{ |
le_TarLong->setText(QString("%1").arg(Target.Longitude)); |
le_TarLat->setText(QString("%1").arg(Target.Latitude)); |
sb_TarTime->setValue(Target.Time); |
|
slot_pb_SendWaypoint(); |
} |
|
void MKTool::slot_Motortest(int Motor1, int Motor2, int Motor3, int Motor4) |
{ |
TX_Data[0] = Motor1; |
705,7 → 731,7 |
TX_Data[1] = Motor2; |
TX_Data[2] = Motor3; |
TX_Data[3] = Motor4; |
Conn->send_Cmd('t', ADDRESS_FC, TX_Data, 4, false); |
o_Connection->send_Cmd('t', ADDRESS_FC, TX_Data, 4, false); |
} |
|
void MKTool::slot_ac_Config() |
850,7 → 876,7 |
lb_Status->setText(tr("Fordere langsame NaviDaten an.")); |
TX_Data[0] = Settings->Data.Navi_Slow / 10; |
} |
Conn->send_Cmd('o', ADDRESS_NC, TX_Data, 1, false); |
o_Connection->send_Cmd('o', ADDRESS_NC, TX_Data, 1, false); |
} |
} |
|
874,7 → 900,7 |
TX_Data[0] = Settings->Data.Navi_Slow / 10; |
} |
} |
Conn->send_Cmd('o', ADDRESS_NC, TX_Data, 1, false); |
o_Connection->send_Cmd('o', ADDRESS_NC, TX_Data, 1, false); |
} |
|
void MKTool::slot_ac_FastDebug() // DONE 0.71g |
891,7 → 917,7 |
lb_Status->setText(tr("Fordere langsame DebugDaten an.")); |
TX_Data[0] = Settings->Data.Debug_Slow / 10; |
} |
Conn->send_Cmd('d', ADDRESS_ALL, TX_Data, 1, false); |
o_Connection->send_Cmd('d', ADDRESS_ALL, TX_Data, 1, false); |
} |
} |
|
920,7 → 946,7 |
TX_Data[0] = Settings->Data.Debug_Slow / 10; |
} |
} |
Conn->send_Cmd('d', ADDRESS_ALL, TX_Data, 1, false); |
o_Connection->send_Cmd('d', ADDRESS_ALL, TX_Data, 1, false); |
} |
|
void MKTool::slot_ac_About() |
932,7 → 958,7 |
{ |
lb_Status->setText(tr("Analoglabels auslesen.")); |
TX_Data[0] = 0; |
Conn->send_Cmd('a', ADDRESS_ALL, TX_Data, 1, true); |
o_Connection->send_Cmd('a', ADDRESS_ALL, TX_Data, 1, true); |
} |
|
void MKTool::slot_ac_StartServer() |
939,13 → 965,13 |
{ |
if (ac_StartServer->isChecked()) |
{ |
lb_Status->setText(tr("GoogleEarth-Server gestartet.")); |
GE_Server->start_Server(Settings->Server.Port.toInt(), Settings); |
lb_Status->setText(tr("KML-Server gestartet.")); |
KML_Server->start_Server(Settings->Server.Port.toInt(), Settings); |
} |
else |
{ |
lb_Status->setText(tr("GoogleEarth-Server gestopt.")); |
GE_Server->stop_Server(); |
lb_Status->setText(tr("KML-Server gestopt.")); |
KML_Server->stop_Server(); |
} |
} |
|
1032,13 → 1058,13 |
} |
else if (QMessageBox::warning(this, QA_NAME, Message, QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) |
{ |
QString Programm = "avrdude" ; |
QString Programm = Settings->DIR.AVRDUDE; |
|
QStringList Argumente; |
|
Update = new QProcess(); |
|
if (Conn->isOpen()) |
if (o_Connection->isOpen()) |
{ |
slot_OpenPort(); |
} |
1095,10 → 1121,10 |
Tab = Tab; |
if (tab_Main->count() != 0) |
{ |
if ((tab_Main->currentWidget()->objectName() == QString("Tab_2")) && (f_Settings->tab_Par->currentIndex() == 1)) |
if ((tab_Main->currentWidget()->objectName() == QString("Tab_2")) && (f_Settings->listWidget->currentRow() == 1)) |
{ |
TX_Data[0] = 0; |
Conn->send_Cmd('p', ADDRESS_FC, TX_Data, 0, true); |
o_Connection->send_Cmd('p', ADDRESS_FC, TX_Data, 0, true); |
|
Ticker->setInterval(500); |
TickerEvent[1] = true; |
1108,22 → 1134,6 |
Ticker->setInterval(2000); |
TickerEvent[1] = false; |
} |
/* |
if ((tab_Main->currentWidget()->objectName() == QString("Tab_4"))) |
{ |
TX_Data[0] = 0; |
TX_Data[1] = 0; |
send_Data('l', ADDRESS_ALL, TX_Data, 1, true); |
|
Ticker->setInterval(500); |
TickerEvent[2] = true; |
} |
else |
{ |
Ticker->setInterval(2000); |
TickerEvent[2] = false; |
} |
*/ |
} |
} |
|
1136,7 → 1146,7 |
TX_Data[0] = LCD_Page + 1; |
|
TX_Data[1] = 0; |
Conn->send_Cmd('l', ADDRESS_ALL, TX_Data, 1, true); |
o_Connection->send_Cmd('l', ADDRESS_ALL, TX_Data, 1, true); |
} |
|
void MKTool::slot_LCD_DOWN() // DONE 0.71g |
1147,7 → 1157,7 |
TX_Data[0] = LCD_Page - 1; |
|
TX_Data[1] = 0; |
Conn->send_Cmd('l', ADDRESS_ALL, TX_Data, 1, true); |
o_Connection->send_Cmd('l', ADDRESS_ALL, TX_Data, 1, true); |
} |
|
// Settings aus MK lesen / in MK schreiben |
1156,7 → 1166,7 |
lb_Status->setText(tr("Lese FlightCtrl-Settings aus.")); |
TX_Data[0] = f_Settings->sb_Set->value(); |
TX_Data[1] = 0; |
Conn->send_Cmd('q', ADDRESS_FC, TX_Data, 1); |
o_Connection->send_Cmd('q', ADDRESS_FC, TX_Data, 1); |
} |
|
void MKTool::slot_SetFCSettings() // DONE 0.71g |
1165,7 → 1175,7 |
|
lb_Status->setText(tr("Schreibe FlightCtrl-Settings.")); |
|
Conn->send_Cmd('s', ADDRESS_FC, TX_Data2, MaxParameter + 2, false); |
o_Connection->send_Cmd('s', ADDRESS_FC, TX_Data2, MaxParameter + 2, false); |
} |
|
|
1273,6 → 1283,16 |
|
void MKTool::new_NaviData(sRxData RX) |
{ |
// qDebug("Navi-Data"); |
|
switch(RX.Decode[N_NC_FLAGS]) |
{ |
case 1 : lb_Mode->setText("Free"); break; |
case 2 : lb_Mode->setText("Position Hold"); break; |
case 4 : lb_Mode->setText("Coming Home"); break; |
case 8 : lb_Mode->setText("Range Limit"); break; |
} |
|
Navi.Current.Longitude = ToolBox::Data2Long(RX.Decode, N_CUR_LONGITUDE, true); |
Navi.Current.Latitude = ToolBox::Data2Long(RX.Decode, N_CUR_LATITUDE, true); |
Navi.Current.Altitude = ToolBox::Data2Long(RX.Decode, N_CUR_ALTITUDE, true); |
1331,8 → 1351,11 |
NaviString.Latitude = ToolBox::get_Float(Navi.Current.Latitude,10000000); |
NaviString.Altitude = ToolBox::get_Float(Navi.Current.Altitude,1000); |
|
GE_Server->store_NaviString(NaviString); |
le_CurLong->setText(NaviString.Longitude); |
le_CurLat->setText(NaviString.Latitude); |
|
KML_Server->store_NaviString(NaviString); |
|
f_Map->add_Position(NaviString.Longitude.toDouble(), NaviString.Latitude.toDouble()); |
|
if ((QMK_Server->property("Connect")) == true) |
1451,7 → 1474,7 |
} |
Position ++; |
TX_Data[0] = Position; |
Conn->send_Cmd('a', ADDRESS_ALL, TX_Data, 1, true); |
o_Connection->send_Cmd('a', ADDRESS_ALL, TX_Data, 1, true); |
} |
if (Position == 31) |
{ |
1515,7 → 1538,7 |
TX_Data[0] = Settings->Data.Debug_Slow / 10; |
} |
|
Conn->send_Cmd('d', ADDRESS_ALL, TX_Data, 1, false); |
o_Connection->send_Cmd('d', ADDRESS_ALL, TX_Data, 1, false); |
|
// Wenn MK3MAG dann andauernd Daten neu anfragen. |
if (Mode.ID == ADDRESS_MK3MAG) |
1543,7 → 1566,7 |
TX_Data[0] = Settings->Data.Navi_Slow / 10; |
} |
|
Conn->send_Cmd('o', ADDRESS_NC, TX_Data, 1, false); |
o_Connection->send_Cmd('o', ADDRESS_NC, TX_Data, 1, false); |
} |
|
|
1557,7 → 1580,7 |
|
// DEP: Raus wenn Resend implementiert. |
ToolBox::Wait(SLEEP); |
Conn->send_Cmd('q', ADDRESS_FC, TX_Data, 1, true); |
o_Connection->send_Cmd('q', ADDRESS_FC, TX_Data, 1, true); |
qDebug("FC - Get Settings"); |
} |
} |
1633,16 → 1656,16 |
// Verbindung zum Kopter herstellen / Trennen |
void MKTool::slot_OpenPort() |
{ |
if (Conn->isOpen()) |
if (o_Connection->isOpen()) |
{ |
TX_Data[0] = Settings->Data.Debug_Off / 10; |
Conn->send_Cmd('d', ADDRESS_ALL, TX_Data, 1, false); |
o_Connection->send_Cmd('d', ADDRESS_ALL, TX_Data, 1, false); |
ToolBox::Wait(SLEEP); |
|
if (Mode.ID == ADDRESS_NC) |
{ |
TX_Data[0] = Settings->Data.Navi_Off / 10; |
Conn->send_Cmd('o', ADDRESS_NC, TX_Data, 1, false); |
o_Connection->send_Cmd('o', ADDRESS_NC, TX_Data, 1, false); |
ToolBox::Wait(SLEEP); |
} |
|
1652,11 → 1675,11 |
TX_Data[1] = 0; |
TX_Data[2] = 0; |
TX_Data[3] = 0; |
Conn->send_Cmd('t', ADDRESS_FC, TX_Data, 4, false); |
o_Connection->send_Cmd('t', ADDRESS_FC, TX_Data, 4, false); |
ToolBox::Wait(SLEEP); |
} |
|
Conn->Close(); |
o_Connection->Close(); |
|
ac_ConnectTTY->setText("Kopter Verbinden"); |
le_Port->setEnabled(true); |
1675,12 → 1698,12 |
i_Type = C_TTY; |
} |
|
if (Conn->Open(i_Type, le_Port->text())) |
if (o_Connection->Open(i_Type, le_Port->text())) |
{ |
ac_ConnectTTY->setText("Kopter Trennen"); |
le_Port->setEnabled(false); |
|
Conn->send_Cmd('v', ADDRESS_ALL, TX_Data, 0, true); |
o_Connection->send_Cmd('v', ADDRESS_ALL, TX_Data, 0, true); |
|
Ticker->start(2000); |
} |
1692,9 → 1715,9 |
|
MKTool::~MKTool() |
{ |
if (Conn->isOpen()) |
if (o_Connection->isOpen()) |
{ |
Conn->Close(); |
o_Connection->Close(); |
} |
|
set_Preferences(); |