Subversion Repositories Projects

Compare Revisions

Ignore whitespace Rev 161 → Rev 162

/QMK-Groundstation/trunk/Forms/mktool.cpp
40,8 → 40,8
setupUi(this);
 
Settings = new cSettings;
Settings->read_Settings();
Settings->read_Settings_FC();
// Settings->read_Settings();
// Settings->read_Settings_FC();
 
init_Arrays();
init_Icons();
73,7 → 73,7
 
for (int a = 0; a < MaxAnalog; a++)
{
lb_Analog[a]->setText(Settings->Analog[a].Name);
lb_Analog[a]->setText(Settings->Analog1.Label[a]);
}
 
for (int b = 0; b < 6; b++)
105,6 → 105,10
ac_View5->setChecked(Settings->GUI.TabViews[5]);
 
le_Port->setText(Settings->TTY.Port);
 
cb_ShowMSG->setChecked(Settings->GUI.Term_Info);
cb_ShowData->setChecked(Settings->GUI.Term_Data);
cb_ShowAlways->setChecked(Settings->GUI.Term_Always);
}
 
void MKTool::init_Objects()
153,10 → 157,9
connect(ac_View4, SIGNAL(triggered()), this, SLOT(slot_ac_View()));
connect(ac_View5, SIGNAL(triggered()), this, SLOT(slot_ac_View()));
 
connect(pb_Update, SIGNAL(clicked()), this, SLOT(slot_pb_Update()));
// connect(pb_Update, SIGNAL(clicked()), this, SLOT(slot_pb_Update()));
 
connect(ac_ConnectTTY, SIGNAL(triggered()), this, SLOT(slot_OpenPort()));
connect(ac_Quit, SIGNAL(triggered()), this, SLOT(slot_Quit()));
connect(ac_RecordCSV, SIGNAL(triggered()), this, SLOT(slot_RecordCSV()));
 
connect(ac_LogDir, SIGNAL(triggered()), this, SLOT(slot_SetLogDir()));
163,8 → 166,6
connect(ac_ParameterDir, SIGNAL(triggered()), this, SLOT(slot_SetParDir()));
 
// Timer-Events
// connect(timer, SIGNAL(timeout()), SLOT(slot_Timer()));
// connect(Poll, SIGNAL(timeout()), SLOT(slot_Poll()));
connect(Ticker, SIGNAL(timeout()), SLOT(slot_Ticker()));
 
// Seitenwechsel :)
259,11 → 260,11
 
for (int a = 0; a < MaxAnalog; a++)
{
Plot[a] = new QwtPlotCurve(Settings->Analog[a].Name);
Plot[a]->setPen(QPen(QColor(Settings->Analog[a].Color)));
Plot[a] = new QwtPlotCurve(Settings->Analog1.Label[a]);
Plot[a]->setPen(QPen(QColor(Def_Colors[a])));
// Plot[a]->setRenderHint(QwtPlotItem::RenderAntialiased);
 
if (Settings->Analog[a].Plot)
if (Settings->Analog1.PlotView[a])
Plot[a]->attach(qwtPlot);
}
qwtPlot->replot();
358,20 → 359,21
 
void MKTool::slot_ac_Config()
{
set_Analog Old_Analog[MaxAnalog];
memcpy(Old_Analog, Settings->Analog, sizeof(Settings->Analog));
set_Analog Old_Analog1;
 
Old_Analog1 = Settings->Analog1;
 
dlg_Config *f_Config = new dlg_Config(this);
f_Config->set_Settings(Settings);
f_Config->set_Settings(Settings, Mode.ID);
 
if (f_Config->exec()==QDialog::Accepted)
{
Settings = f_Config->get_Settings();
Settings->write_Settings_FC();
Settings->write_Settings_Analog(Mode.ID);
 
for (int a = 0; a < MaxAnalog; a++)
{
if (Old_Analog[a].Plot == Settings->Analog[a].Plot)
if (Old_Analog1.PlotView[a] == Settings->Analog1.PlotView[a])
continue;
else
{
384,7 → 386,7
{
for (int a = 0; a < MaxAnalog; a++)
{
if (Old_Analog[a].Log == Settings->Analog[a].Log)
if (Old_Analog1.LogView[a] == Settings->Analog1.LogView[a])
continue;
else
{
514,10 → 516,13
for (int a = 0; a < MaxAnalog; a++)
{
Plot[a]->detach();
Plot[a]->setPen(QPen(QColor(Settings->Analog[a].Color)));
Plot[a]->setPen(QPen(QColor(Def_Colors[a])));
 
if (Settings->Analog[a].Plot)
if (Settings->Analog1.PlotView[a])
{
Plot[a]->setTitle(Settings->Analog1.Label[a]);
Plot[a]->attach(qwtPlot);
}
}
}
 
532,32 → 537,38
///////////////////
void MKTool::slot_pb_Update()
{
diskfree = new QProcess();
QByteArray ausgabe;
const QString programm = "find";
const QStringList argumente = (QStringList() << "/home/Manuel/");
qDebug("Update");
 
te_Shell->setText(""); // Ausgabefenster säubern
diskfree->start(programm, argumente); // Programmaufruf
// diskfree.waitForFinished(); // auf Rückmeldung warten
// diskfree.close(); // Kanal schließen
connect(diskfree, SIGNAL(readyReadStandardOutput()), this, SLOT(slot_UpdateShell()) );
if (serialPort->isOpen())
{
slot_OpenPort();
}
 
Update = new QProcess();
 
const QString Programm = "avrdude -p m644 -P /dev/ttyS0 -c butterfly -b 57600 -U flash:w:Flight-Ctrl_MEGA644_V0_71f.hex";
const QStringList Argumente = (QStringList() << "-?");
 
te_Shell->setText(""); // Ausgabefenster säubern
Update->start(Programm); // Programmaufruf
// Update.waitForFinished(); // auf Rückmeldung warten
// Update.close(); // Kanal schließen
connect(Update, SIGNAL(readyReadStandardOutput()), this, SLOT(slot_UpdateShell()) );
}
 
void MKTool::slot_UpdateShell()
{
QByteArray ausgabe;
QByteArray Output;
// te_Shell->setText(""); // Ausgabefenster säubern
// ausgabe = diskfree->readAllStandardOutput(); // Shellausgabe an Variable
Output = Update->readAllStandardOutput(); // Shellausgabe an Variable
 
te_Shell->moveCursor(QTextCursor::End, QTextCursor::MoveAnchor);
te_Shell->insertPlainText(QString::fromUtf8(ausgabe));
te_Shell->moveCursor(QTextCursor::End, QTextCursor::MoveAnchor);
te_Shell->insertPlainText(QString::fromUtf8(Output));
 
// te_Shell->setText(QString::fromUtf8(ausgabe)); // ...und endlich: Ausgabe im QLabel
// qDebug("Shell");
te_Shell->setText(QString::fromUtf8(Output)); // ...und endlich: Ausgabe im QLabel
qDebug("Shell");
}
 
 
// Configuration -> Verzeichnisse
/////////////////////////////////
void MKTool::slot_SetLogDir()
1411,36 → 1422,37
void MKTool::slot_TabChanged(int Tab) // DONE 0.71g
{
Tab = Tab;
 
if ((tab_Main->currentWidget()->objectName() == QString("Tab_2")) && (tab_Par->currentIndex() == 1))
if (tab_Main->count() != 0)
{
TX_Data[0] = 0;
send_Data('p', ADDRESS_FC, TX_Data, 0, true);
if ((tab_Main->currentWidget()->objectName() == QString("Tab_2")) && (tab_Par->currentIndex() == 1))
{
TX_Data[0] = 0;
send_Data('p', ADDRESS_FC, TX_Data, 0, true);
 
Ticker->setInterval(500);
TickerEvent[1] = true;
}
else
{
Ticker->setInterval(2000);
TickerEvent[1] = false;
}
Ticker->setInterval(500);
TickerEvent[1] = true;
}
else
{
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);
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;
Ticker->setInterval(500);
TickerEvent[2] = true;
}
else
{
Ticker->setInterval(2000);
TickerEvent[2] = false;
}
}
else
{
Ticker->setInterval(2000);
TickerEvent[2] = false;
}
 
}
 
void MKTool::slot_LCD_UP() // DONE 0.71g
1502,6 → 1514,10
TabViews.setBit(4, ac_View4->isChecked());
TabViews.setBit(5, ac_View5->isChecked());
 
Settings->GUI.Term_Info = cb_ShowMSG->isChecked();
Settings->GUI.Term_Data = cb_ShowData->isChecked();
Settings->GUI.Term_Always = cb_ShowAlways->isChecked();
 
QSettings Setting("KeyOz-Net", "QMK-Groundstation");
 
Setting.beginGroup("Port");
1524,7 → 1540,7
QTextStream Out(CSVFile);
for (int a=0; a<MaxAnalog; a++)
{
if (Settings->Analog[a].Log)
if (Settings->Analog1.LogView[a])
{
Out << AnalogData[a];
if (a < MaxAnalog - 1)
1549,9 → 1565,9
 
for (int a = 0; a < MaxAnalog; a++)
{
if (Settings->Analog[a].Log)
if (Settings->Analog1.LogView[a])
{
Out << Settings->Analog[a].Name;
Out << Settings->Analog1.Label[a];
 
if (a < MaxAnalog - 1)
Out << ';';
1564,8 → 1580,6
CSVFile->open(QIODevice::Append | QIODevice::Text);
}
 
// QIcon icon;
// icon.addPixmap(QPixmap(QString::fromUtf8(":/Actions/Images/media-playback-stop.png")), QIcon::Normal, QIcon::Off);
pb_Record->setIcon(Icons[6]);
pb_Record->setText("CSV Stop");
ac_RecordCSV->setIcon(Icons[6]);
1574,8 → 1588,6
else
{
CSVFile->close();
// QIcon icon;
// icon.addPixmap(QPixmap(QString::fromUtf8(":/Actions/Images/media-record.png")), QIcon::Normal, QIcon::Off);
pb_Record->setIcon(Icons[7]);
pb_Record->setText("CSV Aufzeichnen");
ac_RecordCSV->setIcon(Icons[7]);
1650,6 → 1662,8
{
}
 
int HardwareID = RX.Input[1] - 'a';
 
switch(RX.Input[2])
{
case 'L' : // DONE 0.71g
1688,7 → 1702,7
int Position = RX.Decode[0];
if (Position < 32)
{
Settings->Analog[Position].Name = ToolBox::Data2QString(RX.Decode,1,17).trimmed();
Settings->Analog1.Label[Position] = ToolBox::Data2QString(RX.Decode,1,17).trimmed();
Position ++;
TX_Data[0] = Position;
send_Data('a', ADDRESS_ALL, TX_Data, 1, false);
1697,9 → 1711,9
{
for (int a = 0; a < MaxAnalog; a++)
{
lb_Analog[a]->setText(Settings->Analog[a].Name);
lb_Analog[a]->setText(Settings->Analog1.Label[a]);
}
Settings->write_Settings_FC();
Settings->write_Settings_AnalogLabels(HardwareID);
config_Plot();
}
}
1786,6 → 1800,15
// QMessageBox::warning(this, QA_NAME,
// "Keine Verbindung zur FlightCtrl. \nParameterbearbeitung nicht moeglich.", QMessageBox::Ok);
}
 
Settings->read_Settings_AnalogLabels(HardwareID);
Settings->read_Settings_Analog(HardwareID);
for (int a = 0; a < MaxAnalog; a++)
{
lb_Analog[a]->setText(Settings->Analog1.Label[a]);
}
config_Plot();
 
break;
}
}
1811,7 → 1834,7
RxData.Input = RxData.String.toLatin1().data();
new_RXData(RxData);
 
if ((cb_ShowData->isChecked()) && (tab_Main->currentWidget()->objectName() == QString("Tab_3")))
if ((cb_ShowData->isChecked()) && ((tab_Main->currentWidget()->objectName() == QString("Tab_3")) || (cb_ShowAlways->isChecked())))
{
te_RX->moveCursor(QTextCursor::End, QTextCursor::MoveAnchor);
te_RX->insertPlainText(RxData.String + '\r');
1819,7 → 1842,7
}
else
{
if ((cb_ShowMSG->isChecked()) && (tab_Main->currentWidget()->objectName() == QString("Tab_3")))
if ((cb_ShowMSG->isChecked()) && ((tab_Main->currentWidget()->objectName() == QString("Tab_3")) || (cb_ShowAlways->isChecked())))
{
te_RX->moveCursor(QTextCursor::End, QTextCursor::MoveAnchor);
te_RX->insertPlainText(RxData.String + '\r');
1912,8 → 1935,10
 
// Programm beenden
///////////////////
void MKTool::slot_Quit()
 
MKTool::~MKTool()
{
qDebug(" Programm Ende ..!! ");
if (serialPort->isOpen())
{
serialPort->close();
1920,6 → 1945,7
}
 
write_Settings();
Settings->write_Settings();
 
if (CSVFile->isOpen())
{
1926,12 → 1952,6
CSVFile->close();
}
 
close();
// close();
}
 
MKTool::~MKTool()
{
write_Settings();
qDebug("Ende");
}