Subversion Repositories Projects

Compare Revisions

Ignore whitespace Rev 399 → Rev 440

/QMK-Groundstation/branches/libMK/Forms/dlg_MotorMixer.cpp
77,6 → 77,8
// Motordaten übernehmen.
void dlg_MotorMixer::set_MotorConfig(sRxData RX)
{
//FIXME: put this in libMK/Handler.cpp and fill motor values in KopterData
/*
int Pos = 0;
 
MixerName = ToolBox::dataToQString(RX.decode, 1, 12);
93,69 → 95,37
}
 
set_MotorData();
*/
}
 
// Motordaten aus GUI übernehmen
void dlg_MotorMixer::get_MotorData()
{
MixerName = le_NAME->text();
//FIXME: add Function in handler to send data
char * mixerName = le_NAME->text().toAscii().data();
 
Motor[0][0] = sb_GAS_1->value();
Motor[1][0] = sb_GAS_2->value();
Motor[2][0] = sb_GAS_3->value();
Motor[3][0] = sb_GAS_4->value();
Motor[4][0] = sb_GAS_5->value();
Motor[5][0] = sb_GAS_6->value();
Motor[6][0] = sb_GAS_7->value();
Motor[7][0] = sb_GAS_8->value();
Motor[8][0] = sb_GAS_9->value();
Motor[9][0] = sb_GAS_10->value();
Motor[10][0] = sb_GAS_11->value();
Motor[11][0] = sb_GAS_12->value();
 
Motor[0][1] = sb_NICK_1->value();
Motor[1][1] = sb_NICK_2->value();
Motor[2][1] = sb_NICK_3->value();
Motor[3][1] = sb_NICK_4->value();
Motor[4][1] = sb_NICK_5->value();
Motor[5][1] = sb_NICK_6->value();
Motor[6][1] = sb_NICK_7->value();
Motor[7][1] = sb_NICK_8->value();
Motor[8][1] = sb_NICK_9->value();
Motor[9][1] = sb_NICK_10->value();
Motor[10][1] = sb_NICK_11->value();
Motor[11][1] = sb_NICK_12->value();
 
Motor[0][2] = sb_ROLL_1->value();
Motor[1][2] = sb_ROLL_2->value();
Motor[2][2] = sb_ROLL_3->value();
Motor[3][2] = sb_ROLL_4->value();
Motor[4][2] = sb_ROLL_5->value();
Motor[5][2] = sb_ROLL_6->value();
Motor[6][2] = sb_ROLL_7->value();
Motor[7][2] = sb_ROLL_8->value();
Motor[8][2] = sb_ROLL_9->value();
Motor[9][2] = sb_ROLL_10->value();
Motor[10][2] = sb_ROLL_11->value();
Motor[11][2] = sb_ROLL_12->value();
 
Motor[0][3] = sb_GIER_1->value();
Motor[1][3] = sb_GIER_2->value();
Motor[2][3] = sb_GIER_3->value();
Motor[3][3] = sb_GIER_4->value();
Motor[4][3] = sb_GIER_5->value();
Motor[5][3] = sb_GIER_6->value();
Motor[6][3] = sb_GIER_7->value();
Motor[7][3] = sb_GIER_8->value();
Motor[8][3] = sb_GIER_9->value();
Motor[9][3] = sb_GIER_10->value();
Motor[10][3] = sb_GIER_11->value();
Motor[11][3] = sb_GIER_12->value();
//TODO: use an array in Form
int motor[16][4] = {
sb_GAS_1->value(), sb_NICK_1->value(), sb_ROLL_1->value(), sb_GIER_1->value(),
sb_GAS_2->value(), sb_NICK_2->value(), sb_ROLL_2->value(), sb_GIER_2->value(),
sb_GAS_3->value(), sb_NICK_3->value(), sb_ROLL_3->value(), sb_GIER_3->value(),
sb_GAS_4->value(), sb_NICK_4->value(), sb_ROLL_4->value(), sb_GIER_4->value(),
sb_GAS_5->value(), sb_NICK_5->value(), sb_ROLL_5->value(), sb_GIER_5->value(),
sb_GAS_6->value(), sb_NICK_6->value(), sb_ROLL_6->value(), sb_GIER_6->value(),
sb_GAS_7->value(), sb_NICK_7->value(), sb_ROLL_7->value(), sb_GIER_7->value(),
sb_GAS_8->value(), sb_NICK_8->value(), sb_ROLL_8->value(), sb_GIER_8->value(),
sb_GAS_9->value(), sb_NICK_9->value(), sb_ROLL_9->value(), sb_GIER_9->value(),
sb_GAS_10->value(), sb_NICK_10->value(), sb_ROLL_10->value(), sb_GIER_10->value(),
sb_GAS_11->value(), sb_NICK_11->value(), sb_ROLL_11->value(), sb_GIER_11->value(),
sb_GAS_12->value(), sb_NICK_12->value(), sb_ROLL_12->value(), sb_GIER_12->value()
};
}
 
// Motordaten anzeigen
void dlg_MotorMixer::set_MotorData()
{
//FIXME: create special struct for mixer - KopterData
/*
le_NAME->setText(MixerName);
 
sb_GAS_1->setValue(Motor[0][0]);
209,6 → 179,7
sb_GIER_10->setValue(Motor[9][3]);
sb_GIER_11->setValue(Motor[10][3]);
sb_GIER_12->setValue(Motor[11][3]);
*/
}
 
// Prüfen auf vollstaändigkeit
253,7 → 224,7
}
}
 
//FIXME: put this in com/Handler.cpp
//FIXME: put this in libMK/Handler.cpp
/*
int dlg_MotorMixer::get_MotorConfig()
{
289,26 → 260,22
 
return Pos - 1;
}
*/
 
void dlg_MotorMixer::read_Mixer()
{
//See Handler::read_mixer in com/Handler.cpp
}*/
 
// read motor values
void dlg_MotorMixer::slot_pb_READ()
{
//send command to get mixer values
handler->read_mixer();
handler->read_motor_mixer();
}
 
//write motor values
//FIXME: put this in com/Handler.cpp
 
//FIXME: put this in libMK/Handler.cpp
void dlg_MotorMixer::slot_pb_WRITE()
{
/* int Length = handler->get_motor_config();
handler->write_mixer(TX_Data, Length);*/
char tx_data[150];
int length = handler->get_motor_config(tx_data);
handler->write_motor_mixer(tx_data, length);
}
 
void dlg_MotorMixer::slot_pb_LOAD()
320,10 → 287,13
QSettings Setting(Filename, QSettings::IniFormat);
 
Setting.beginGroup("Info");
MixerName = Setting.value("Name", QString("--noname--")).toString();
MixerVersion = Setting.value("Version", 0).toInt();
//FIXME: Add mixer-struct in kopter.h for kopterdata
// MixerName = Setting.value("Name", QString("--noname--")).toString();
// MixerVersion = Setting.value("Version", 0).toInt();
Setting.endGroup();
 
//FIXME: Add mixer-struct in kopter.h for kopterdata
/*
Setting.beginGroup("Gas");
for (int z = 0; z < MAXMOTOR; z++)
{
351,11 → 321,11
Motor[z][3] = Setting.value(QString("Motor%1").arg(z+1), 0).toInt();
}
Setting.endGroup();
 
if (MixerVersion == VERSION_MIXER)
{
set_MotorData();
}
*/
}
}
 
375,6 → 345,8
QSettings Setting(Filename, QSettings::IniFormat);
 
Setting.beginGroup("Info");
//FIXME: Add mixer-struct in kopter.h for kopterdata - doppelter Code!!!
/*
Setting.setValue("Name", MixerName);
Setting.setValue("Version", VERSION_MIXER);
Setting.endGroup();
406,5 → 378,6
Setting.setValue(QString("Motor%1").arg(z+1), Motor[z][3]);
}
Setting.endGroup();
*/
}
}
/QMK-Groundstation/branches/libMK/Forms/dlg_MotorMixer.h
29,7 → 29,7
#include "../typedefs.h"
//#include "../Classes/ToolBox.h"
#include "../global.h"
#include "../com/Handler.h"
#include "../libMK/Handler.h"
 
class dlg_MotorMixer : public QDialog, public Ui::dlg_MotorMixer_UI
{
47,12 → 47,6
 
cSettings *o_Settings;
 
char TX_Data[150];
 
int Motor[16][4]; //vgl. typedefs.h
QString MixerName;
int MixerVersion;
 
void set_MotorData();
void get_MotorData();
 
/QMK-Groundstation/branches/libMK/Forms/mktool.cpp
197,11 → 197,14
 
void MKTool::init_Objects()
{
//new KopterData object that contains all data from MK
data = new KopterData();
 
//new QT-Communication object
com = new QTCommunication();
 
//create handler that handles incomming data
handler = new Handler(com);
handler = new Handler(com, data);
 
// QTimer-Instanzen
Ticker = new QTimer(this);
210,7 → 213,7
//o_Connection = new cConnection();
 
// Logger
logger = new Logger(Settings, &Mode);
logger = new Logger(Settings, data);
 
// LCD-Dialog
f_LCD = new dlg_LCD(this);
417,7 → 420,8
//FIXME: put this in cpp/NaviCtrl.cpp?
void MKTool::slot_pb_SendTarget()
{
if ((Navi.Current.Longitude == 0) && (Navi.Current.Latitude == 0))
sNaviData navi = data->navi;
if ((navi.Current.Longitude == 0) && (navi.Current.Latitude == 0))
{
QMessageBox msgB;
QString msg;
459,8 → 463,8
//...und sende ihn an die NaviCtrl
int max_radius = 10000;
if (ok_lat && ok_lon &&
abs((double)(Navi.Current.Longitude - desired_pos.Position.Longitude)) < max_radius &&
abs((double)(Navi.Current.Latitude - desired_pos.Position.Latitude)) < max_radius)
abs((double)(navi.Current.Longitude - desired_pos.Position.Longitude)) < max_radius &&
abs((double)(navi.Current.Latitude - desired_pos.Position.Latitude)) < max_radius)
{
handler->send_waypoint(desired_pos);
}
471,10 → 475,10
msg += tr("Bitte die Eingabe ueberpruefen!\n");
msg += tr("Die Werte muessen sich in der Naehe der aktuellen Koordinaten befinden\n");
msg += "(Lon: ";
msg += QString::number(Navi.Current.Longitude);
msg += QString::number(navi.Current.Longitude);
msg += ", ";
msg += "Lat: ";
msg += QString::number(Navi.Current.Latitude);
msg += QString::number(navi.Current.Latitude);
msg += ")";
msgB.setText(msg);
msgB.exec();
497,7 → 501,7
// Hardware Auswahl und umschalten
void MKTool::slot_rb_Hardware()
{
if ((rb_SelNC->isChecked() == false) && (Mode.ID != ADDRESS_NC))
if ((rb_SelNC->isChecked() == false) && (data->mode.ID != ADDRESS_NC))
{
lb_Status->setText(tr("Schalte um auf NaviCtrl."));
handler->switch_navictrl();
532,7 → 536,7
///////////////
void MKTool::slot_Ticker()
{
//FIXME: Put this somewhere in Handler.cpp
//FIXME: Put this somewhere in libMK/QTCommunication.cpp
/*
if (TickerDiv)
TickerDiv = false;
683,13 → 687,8
 
disconnect(f_Motortest, 0,0,0);
 
for (int z = 0; z<12; z++)
{
Motor.Speed[z] = 0;
}
handler->reset_motor();
 
slot_Motortest(Motor);
 
Ticker->setInterval(2000);
TickerEvent[4] = false;
}
703,7 → 702,7
void MKTool::slot_ac_MotorMixer()
{
f_MotorMixer->set_Objects(handler, Settings);
handler->read_mixer();
handler->read_motor_mixer();
 
if (f_MotorMixer->exec()==QDialog::Accepted)
{
721,10 → 720,10
// 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
//FIXME: put this in libMK/Handler.cpp
f_LCD->show();
handler->show_lcd();
//FIXME: replace ticker with something else
//FIXME: replace ticker with something else???
Ticker->setInterval(500);
TickerEvent[2] = true;
}
741,7 → 740,7
 
void MKTool::slot_MAP_SetWayPoints(QList<sWayPoint> l_WayPoints)
{
//FIXME: Put this in com/Handler.cpp or com/NaviCtrl.cpp
//FIXME: Put this in libMK/Handler.cpp or libMK/NaviCtrl.cpp
 
double Longitude, Latitude;
 
806,12 → 805,12
Old_Analog1 = Settings->Analog1;
 
dlg_Config *f_Config = new dlg_Config(this);
f_Config->set_Settings(Settings, Mode.ID);
f_Config->set_Settings(Settings, data->mode.ID);
 
if (f_Config->exec()==QDialog::Accepted)
{
Settings = f_Config->get_Settings();
Settings->write_Settings_Analog(Mode.ID);
Settings->write_Settings_Analog(data->mode.ID);
 
// Plotter neu einrichten
if (Old_Analog1.PlotView != Settings->Analog1.PlotView)
994,8 → 993,9
else
{
// Wenn MK3MAG dann andauernd Daten neu anfragen.
if (Mode.ID == ADDRESS_MK3MAG)
TickerEvent[3] = true;
//FIXME: TickerEvent in Communication oder so
/* if (Mode.ID == ADDRESS_MK3MAG)
TickerEvent[3] = true;*/
 
if (ac_FastDebug->isChecked())
{
1257,17 → 1257,19
 
void MKTool::show_DebugData()
{
if (logger->is_active())
logger->write(AnalogData);
//FIXME: log analogdata in Communication
/* if (logger->is_active())
logger->write(AnalogData);*/
 
if (ac_StartPlotter->isChecked())
{
aID[NextPlot] = NextPlot;
 
//FIXME: get analogData from handler
/*
for (int a = 0; a < MaxAnalog; a++)
{
aData[a][NextPlot] = AnalogData[a];
}
}*/
NextPlot++;
 
if ((tab_Main->currentWidget()->objectName() == QString("Tab_1")))
1274,6 → 1276,8
update_Plot();
}
 
//FIXME: get analogdata from handler
/*
le_A_0->setText(QString("%1").arg(AnalogData[0]));
le_A_1->setText(QString("%1").arg(AnalogData[1]));
le_A_2->setText(QString("%1").arg(AnalogData[2]));
1326,12 → 1330,13
Attitude->setAngle(Roll);
Attitude->setGradient(double(double(Nick) / 100.0));
}
*/
}
 
void MKTool::new_NaviData(sRxData RX)
{
// qDebug("Navi-Data");
 
sNaviData navi = data->navi;
switch(RX.decode[N_NC_FLAGS])
{
case 0x01 : lb_Mode->setText(tr("Free")); break;
1343,12 → 1348,12
case 0x40 : lb_Mode->setText(tr("Manual Control")); break;
}
 
Navi.Current.Longitude = Parser::dataToLong(RX.decode, N_CUR_LONGITUDE, true);
Navi.Current.Latitude = Parser::dataToLong(RX.decode, N_CUR_LATITUDE, true);
Navi.Current.Altitude = Parser::dataToLong(RX.decode, N_CUR_ALTITUDE, true);
Navi.Target.Longitude = Parser::dataToLong(RX.decode, N_TAR_LONGITUDE, true);
Navi.Target.Latitude = Parser::dataToLong(RX.decode, N_TAR_LATITUDE, true);
Navi.Target.Altitude = Parser::dataToLong(RX.decode, N_TAR_ALTITUDE, true);
navi.Current.Longitude = Parser::dataToLong(RX.decode, N_CUR_LONGITUDE, true);
navi.Current.Latitude = Parser::dataToLong(RX.decode, N_CUR_LATITUDE, true);
navi.Current.Altitude = Parser::dataToLong(RX.decode, N_CUR_ALTITUDE, true);
navi.Target.Longitude = Parser::dataToLong(RX.decode, N_TAR_LONGITUDE, true);
navi.Target.Latitude = Parser::dataToLong(RX.decode, N_TAR_LATITUDE, true);
navi.Target.Altitude = Parser::dataToLong(RX.decode, N_TAR_ALTITUDE, true);
 
le_CDistance->setText(QString("%1 cm").arg(Parser::dataToInt(RX.decode, N_HOME_DISTANCE)));
le_CWPA->setText(QString("%1").arg(RX.decode[N_WP_INDEX]));
1395,23 → 1400,23
Attitude->setAngle(Roll);
Attitude->setGradient(double(0.0 - (double(Nick) / 100.0)));
 
sNaviString NaviString;
sNaviData naviData;
naviData.Longitude = Parser::getFloat(navi.Current.Longitude,7);
naviData.Latitude = Parser::getFloat(navi.Current.Latitude,7);
naviData.Altitude = Parser::getFloat(navi.Current.Altitude,3);
 
NaviString.Longitude = Parser::getFloat(Navi.Current.Longitude,7);
NaviString.Latitude = Parser::getFloat(Navi.Current.Latitude,7);
NaviString.Altitude = Parser::getFloat(Navi.Current.Altitude,3);
le_CurLong->setText(QString::number(naviData.Longitude));
le_CurLat->setText(QString::number(naviData.Latitude));
 
le_CurLong->setText(QString::number(NaviString.Longitude));
le_CurLat->setText(QString::number(NaviString.Latitude));
KML_Server->store_NaviString(naviData);
 
KML_Server->store_NaviString(NaviString);
f_Map->add_Position(naviData.Longitude, naviData.Latitude);
 
f_Map->add_Position(NaviString.Longitude, NaviString.Latitude);
 
if ((QMK_Server->property("Connect")) == true)
{
// qDebug("Send Data to Server..!!");
QMK_Server->NewPosition(NaviString);
// qDebug("Send Data to Server...");
QMK_Server->NewPosition(naviData);
}
}
 
1472,7 → 1477,7
// Verbindung zum Kopter herstellen / Trennen
void MKTool::slot_OpenPort()
{
//FIXME: Put this in com/QTCommunication.cpp
//FIXME: Put this in libMK/QTCommunication.cpp
/*
if (o_Connection->isOpen())
{
1534,7 → 1539,7
 
MKTool::~MKTool()
{
//FIXME: Put this in com/QTCommunication.cpp
//FIXME: Put this in libMK/QTCommunication.cpp
/*
if (o_Connection->isOpen())
{
/QMK-Groundstation/branches/libMK/Forms/mktool.h
53,9 → 53,9
#include "../typedefs.h"
 
//quadcopter lib stuff
#include "../com/Handler.h"
#include "../com/Communication.h"
#include "../com/QTCommunication.h"
#include "../libMK/Handler.h"
#include "../libMK/Communication.h"
#include "../libMK/QTCommunication.h"
 
class QextSerialPort;
 
70,6 → 70,7
private:
// Object für Kopter-Verbindung
//cConnection *o_Connection;
KopterData * data;
 
Handler *handler;
 
108,9 → 109,6
// Analogwert-Beschreibungen
QLabel *lb_Analog[MaxAnalog];
 
// Analogwerte
int AnalogData[MaxAnalog];
 
// Plots für die Analogwerte
QwtPlotCurve *Plot[MaxAnalog];
 
129,13 → 127,6
//Logger für CVS und andere
Logger * logger;
 
sMode Mode;
sRxData RxData;
sNaviData Navi;
sMotor Motor;
 
QString RXS;
 
// Softwareupdate
QProcess *Update;