Subversion Repositories Projects

Compare Revisions

Ignore whitespace Rev 395 → Rev 396

/QMK-Groundstation/branches/own_com_lib/Forms/mktool.cpp
36,7 → 36,6
#include "dlg_Preferences.h"
#include "../global.h"
#include "../Classes/ToolBox.h"
#include "../com/Parser.h"
 
#include <stdlib.h>
 
198,13 → 197,19
 
void MKTool::init_Objects()
{
//new QT-Communication object
com = new QTCommunication();
 
//create handler that handles incomming data
handler = new Handler(com);
 
// QTimer-Instanzen
Ticker = new QTimer(this);
 
// Verbindungsobject
o_Connection = new cConnection();
//o_Connection = new cConnection();
 
// neuer Logger
// Logger
logger = new Logger(Settings, &Mode);
 
// LCD-Dialog
238,13 → 243,14
connect(f_Map, SIGNAL(set_WayPoints(QList<sWayPoint>)), this , SLOT(slot_MAP_SetWayPoints(QList<sWayPoint>)));
 
// Daten Senden / Empfangen
connect(o_Connection, SIGNAL(newData(sRxData)), this, SLOT(slot_newData(sRxData)));
connect(o_Connection, SIGNAL(showTerminal(int, QString)), this, SLOT(slot_showTerminal(int, QString)));
//FIXME: put this in QTCommunication.cpp
// 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()));
 
// TCP-Connection verbinden / trennen
// TCP-Connection for other QMK-Groundstations
connect(ac_QMKServer, SIGNAL(triggered()), this, SLOT(slot_QMKS_Connect()));
 
// Buttons Settings lesen / schreiben
406,6 → 412,7
}
 
// Waypoint zur NC Senden.
//FIXME: put this in cpp/NaviCtrl.cpp
void MKTool::slot_pb_SendTarget()
{
if ((Navi.Current.Longitude == 0) && (Navi.Current.Latitude == 0))
453,7 → 460,8
abs((double)(Navi.Current.Longitude - desired_pos.Position.Longitude)) < max_radius &&
abs((double)(Navi.Current.Latitude - desired_pos.Position.Latitude)) < max_radius)
{
o_Connection->send_Cmd('s', ADDRESS_NC, (char *)&desired_pos, sizeof(desired_pos), false);
//FIXME: Put this in com/Handler.cpp
// o_Connection->send_Cmd('s', ADDRESS_NC, (char *)&desired_pos, sizeof(desired_pos), false);
}
else
{
488,10 → 496,11
// Hardware Auswahl und umschalten
void MKTool::slot_rb_Hardware()
{
//FIXME:put this in Handler.cpp
if ((rb_SelNC->isChecked() == false) && (Mode.ID != ADDRESS_NC))
{
lb_Status->setText(tr("Schalte um auf NaviCtrl."));
TX_Data[0] = 0x1B;
/*TX_Data[0] = 0x1B;
TX_Data[1] = 0x1B;
TX_Data[2] = 0x55;
TX_Data[3] = 0xAA;
498,38 → 507,38
TX_Data[4] = 0x00;
TX_Data[5] = '\r';
o_Connection->send_Cmd('#', ADDRESS_NC, TX_Data, 6, false);
ToolBox::wait(SLEEP);
ToolBox::wait(SLEEP);*/
}
 
if (rb_SelFC->isChecked())
{
lb_Status->setText(tr("Schalte um auf FlightCtrl."));
TX_Data[0] = 0;
o_Connection->send_Cmd('u', ADDRESS_NC, TX_Data, 1, false);
/*TX_Data[0] = 0;
o_Connection->send_Cmd('u', ADDRESS_NC, TX_Data, 1, false);*/
}
else
if (rb_SelMag->isChecked())
{
lb_Status->setText(tr("Schalte um auf MK3MAG."));
TX_Data[0] = 1;
o_Connection->send_Cmd('u', ADDRESS_NC, TX_Data, 1, false);
/*TX_Data[0] = 1;
o_Connection->send_Cmd('u', ADDRESS_NC, TX_Data, 1, false);*/
}
else
if (rb_SelNC->isChecked())
{
lb_Status->setText(tr("Schalte um auf NaviCtrl."));
TX_Data[0] = 0x1B;
/*TX_Data[0] = 0x1B;
TX_Data[1] = 0x1B;
TX_Data[2] = 0x55;
TX_Data[3] = 0xAA;
TX_Data[4] = 0x00;
TX_Data[5] = '\r';
o_Connection->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");
o_Connection->send_Cmd('v', ADDRESS_ALL, TX_Data, 0, true);
//o_Connection->send_Cmd('v', ADDRESS_ALL, TX_Data, 0, true);
}
 
// Ticker-Event
536,22 → 545,13
///////////////
void MKTool::slot_Ticker()
{
//FIXME: Put this somewhere in Handler.cpp
/*
if (TickerDiv)
TickerDiv = false;
else
TickerDiv = true;
/*
if (cb_ClipBoard->isChecked())
{
QString s_OLD = te_KML->toPlainText();
te_KML->clear();
te_KML->paste();
if (s_OLD != te_KML->toPlainText())
{
parse_TargetKML();
}
}
*/
 
for (int a = 0; a < MaxTickerEvents; a++)
{
if (TickerEvent[a] == true)
603,6 → 603,7
}
}
}
*/
}
 
// Zum QMK-Datenserver verbinden
708,6 → 709,8
 
void MKTool::slot_Motortest(sMotor p_Motor)
{
//FIXME: put this in com/Handler.cpp
/*
Motor = p_Motor;
 
for (int z = 0; z<12; z++)
715,13 → 718,14
TX_Data[z] = Motor.Speed[z];
}
o_Connection->send_Cmd('t', ADDRESS_FC, TX_Data, 12, false);
*/
}
 
// Motormixer-Einstellungen anzeigen
void MKTool::slot_ac_MotorMixer()
{
f_MotorMixer->set_Objects(o_Connection, Settings);
f_MotorMixer->read_Mixer();
f_MotorMixer->set_Objects(handler, Settings);
handler->read_mixer();
 
if (f_MotorMixer->exec()==QDialog::Accepted)
{
739,12 → 743,13
// LCD auf / ab
connect(f_LCD->pb_LCDup, SIGNAL(clicked()), this, SLOT(slot_LCD_UP()));
connect(f_LCD->pb_LCDdown, SIGNAL(clicked()), this, SLOT(slot_LCD_DOWN()));
 
//FIXME: put this in com/Handler.cpp
f_LCD->show();
TX_Data[0] = 0;
/*TX_Data[0] = 0;
TX_Data[1] = 0;
o_Connection->send_Cmd('l', ADDRESS_ALL, TX_Data, 1, true);
 
*/
//FIXME: replace ticker with something else
Ticker->setInterval(500);
TickerEvent[2] = true;
}
761,6 → 766,8
 
void MKTool::slot_MAP_SetWayPoints(QList<sWayPoint> l_WayPoints)
{
//FIXME: Put this in com/Handler.cpp or com/NaviCtrlHandler.cpp
/*
Waypoint_t WayPoint;
double Longitude, Latitude;
 
797,7 → 804,7
o_Connection->send_Cmd('w', ADDRESS_NC, (char *)&WayPoint, sizeof(WayPoint), false);
// ToolBox::Wait(SLEEP);
}
 
*/
}
 
void MKTool::slot_MAP_SetTarget(sWayPoint Target)
954,14 → 961,15
if (ac_FastNavi->isChecked())
{
lb_Status->setText(tr("Fordere schnelle NaviDaten an."));
TX_Data[0] = Settings->Data.Navi_Fast / 10;
//TX_Data[0] = Settings->Data.Navi_Fast / 10;
}
else
{
lb_Status->setText(tr("Fordere langsame NaviDaten an."));
TX_Data[0] = Settings->Data.Navi_Slow / 10;
//TX_Data[0] = Settings->Data.Navi_Slow / 10;
}
o_Connection->send_Cmd('o', ADDRESS_NC, TX_Data, 1, false);
//FIXME: put this in com/Handler.cpp / com/NaviCtrl.cpp
//o_Connection->send_Cmd('o', ADDRESS_NC, TX_Data, 1, false);
}
}
 
970,7 → 978,7
if (ac_NoNavi->isChecked())
{
lb_Status->setText(tr("NaviDaten abstellen."));
TX_Data[0] = 0;
// TX_Data[0] = 0;
}
else
{
977,15 → 985,16
if (ac_FastNavi->isChecked())
{
lb_Status->setText(tr("Fordere schnelle NaviDaten an."));
TX_Data[0] = Settings->Data.Navi_Fast / 10;
// TX_Data[0] = Settings->Data.Navi_Fast / 10;
}
else
{
lb_Status->setText(tr("Fordere langsame NaviDaten an."));
TX_Data[0] = Settings->Data.Navi_Slow / 10;
// TX_Data[0] = Settings->Data.Navi_Slow / 10;
}
}
o_Connection->send_Cmd('o', ADDRESS_NC, TX_Data, 1, false);
//FIXME: Put this in com/Handler.cpp
// o_Connection->send_Cmd('o', ADDRESS_NC, TX_Data, 1, false);
}
 
void MKTool::slot_ac_FastDebug() // DONE 0.71g
995,14 → 1004,15
if (ac_FastDebug->isChecked())
{
lb_Status->setText(tr("Fordere schnelle DebugDaten an."));
TX_Data[0] = Settings->Data.Debug_Fast / 10;
//TX_Data[0] = Settings->Data.Debug_Fast / 10;
}
else
{
lb_Status->setText(tr("Fordere langsame DebugDaten an."));
TX_Data[0] = Settings->Data.Debug_Slow / 10;
//TX_Data[0] = Settings->Data.Debug_Slow / 10;
}
o_Connection->send_Cmd('d', ADDRESS_ALL, TX_Data, 1, false);
//FIXME: Put this in com/Handler.cpp
// o_Connection->send_Cmd('d', ADDRESS_ALL, TX_Data, 1, false);
}
}
 
1012,7 → 1022,7
{
lb_Status->setText(tr("DebugDaten abstellen."));
TickerEvent[3] = false;
TX_Data[0] = 0;
//TX_Data[0] = 0;
}
else
{
1023,15 → 1033,16
if (ac_FastDebug->isChecked())
{
lb_Status->setText(tr("Fordere schnelle DebugDaten an."));
TX_Data[0] = Settings->Data.Debug_Fast / 10;
//TX_Data[0] = Settings->Data.Debug_Fast / 10;
}
else
{
lb_Status->setText(tr("Fordere langsame DebugDaten an."));
TX_Data[0] = Settings->Data.Debug_Slow / 10;
//TX_Data[0] = Settings->Data.Debug_Slow / 10;
}
}
o_Connection->send_Cmd('d', ADDRESS_ALL, TX_Data, 1, false);
//FIXME: Put this in com/Handler.cpp
// o_Connection->send_Cmd('d', ADDRESS_ALL, TX_Data, 1, false);
}
 
void MKTool::slot_ac_About()
1042,8 → 1053,9
void MKTool::slot_ac_GetLabels() // DONE 0.71g
{
lb_Status->setText(tr("Analoglabels auslesen."));
TX_Data[0] = 0;
o_Connection->send_Cmd('a', ADDRESS_ALL, TX_Data, 1, true);
//FIXME: Put this in com/Handler.cpp
// TX_Data[0] = 0;
// o_Connection->send_Cmd('a', ADDRESS_ALL, TX_Data, 1, true);
}
 
void MKTool::slot_ac_StartServer()
1149,11 → 1161,12
 
Update = new QProcess();
 
if (o_Connection->isOpen())
//FIXME: put this in QTCommunication.cpp
/* if (o_Connection->isOpen())
{
slot_OpenPort();
}
 
*/
Argumente << "-P";
Argumente << le_Port->text();
Argumente << "-p";
1208,8 → 1221,9
{
if ((tab_Main->currentWidget()->objectName() == QString("Tab_2")) && (f_Settings->listWidget->currentRow() == 1))
{
TX_Data[0] = 0;
o_Connection->send_Cmd('p', ADDRESS_FC, TX_Data, 0, false);
// TX_Data[0] = 0;
//FIXME: Put this in com/Handler.cpp
// o_Connection->send_Cmd('p', ADDRESS_FC, TX_Data, 0, false);
 
Ticker->setInterval(500);
TickerEvent[1] = true;
1225,7 → 1239,8
// LCD-Seiten weiterschalten
void MKTool::slot_LCD_UP() // DONE 0.71g
{
if (LCD_Page == LCD_MAX_Page)
//FIXME: Put this in com/Handler.cpp
/* if (LCD_Page == LCD_MAX_Page)
TX_Data[0] = 0;
else
TX_Data[0] = LCD_Page + 1;
1232,10 → 1247,13
 
TX_Data[1] = 0;
o_Connection->send_Cmd('l', ADDRESS_ALL, TX_Data, 1, true);
*/
}
 
void MKTool::slot_LCD_DOWN() // DONE 0.71g
{
//FIXME: Put this in com/Handler.cpp
/*
if (LCD_Page == 0)
TX_Data[0] = LCD_MAX_Page;
else
1243,6 → 1261,7
 
TX_Data[1] = 0;
o_Connection->send_Cmd('l', ADDRESS_ALL, TX_Data, 1, true);
*/
}
 
// Settings aus MK lesen / in MK schreiben
1249,18 → 1268,24
void MKTool::slot_GetFCSettings() // DONE 0.71g
{
lb_Status->setText(tr("Lese FlightCtrl-Settings aus."));
//FIXME: Put this in com/Handler.cpp
/*
TX_Data[0] = f_Settings->sb_Set->value();
TX_Data[1] = 0;
o_Connection->send_Cmd('q', ADDRESS_FC, TX_Data, 1, true);
*/
}
 
void MKTool::slot_SetFCSettings() // DONE 0.71g
{
//FIXME: Put this in com/Handler.cpp
/*
char *TX_Data2 = f_Settings->GetFCSettings();
 
lb_Status->setText(tr("Schreibe FlightCtrl-Settings."));
 
o_Connection->send_Cmd('s', ADDRESS_FC, TX_Data2, MaxParameter + 2, true);
*/
}
 
 
1510,6 → 1535,8
// Verbindung zum Kopter herstellen / Trennen
void MKTool::slot_OpenPort()
{
//FIXME: Put this in com/QTCommunication.cpp
/*
if (o_Connection->isOpen())
{
TX_Data[0] = Settings->Data.Debug_Off / 10;
1562,6 → 1589,7
Ticker->start(2000);
}
}
*/
}
 
// Programm beenden
1569,11 → 1597,13
 
MKTool::~MKTool()
{
//FIXME: Put this in com/QTCommunication.cpp
/*
if (o_Connection->isOpen())
{
o_Connection->Close();
}
 
*/
set_Preferences();
Settings->write_Settings();