0,0 → 1,1722 |
/*************************************************************************** |
* Copyright (C) 2008 by Manuel Schrape * |
* manuel.schrape@gmx.de * |
* * |
* This program is free software; you can redistribute it and/or modify * |
* it under the terms of the GNU General Public License as published by * |
* the Free Software Foundation; either version 2 of the License. * |
* * |
* This program is distributed in the hope that it will be useful, * |
* but WITHOUT ANY WARRANTY; without even the implied warranty of * |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
* GNU General Public License for more details. * |
* * |
* You should have received a copy of the GNU General Public License * |
* along with this program; if not, write to the * |
* Free Software Foundation, Inc., * |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
***************************************************************************/ |
|
#include <QtGui> |
|
#include <QLineEdit> |
#include <QString> |
#include <QTimer> |
#include <QIcon> |
#include <QToolButton> |
#include <QSpinBox> |
|
#include "mktool.h" |
#include "dlg_Config.h" |
#include "../global.h" |
|
#include <stdlib.h> |
|
MKTool::MKTool() |
{ |
setupUi(this); |
|
Settings = new cSettings; |
Settings->read_Settings(); |
|
init_Arrays(); |
init_Icons(); |
init_GUI(); |
|
init_Objects(); |
init_Connections(); |
|
init_Plot(); |
} |
|
void MKTool::init_GUI() |
{ |
setWindowTitle(QA_NAME + " v" + QA_VERSION); |
|
#ifdef _EEEPC_ |
toolBar->hide(); |
#endif |
|
resize(Settings->GUI.Size); |
move(Settings->GUI.Point); |
|
if (Settings->GUI.isMax) |
{ |
showMaximized(); |
} |
|
for (int a = 0; a < MaxAnalog; a++) |
{ |
lb_Analog[a]->setText(Settings->Analog[a].Name); |
} |
|
le_Port->setText(Settings->TTY.Port); |
} |
|
void MKTool::init_Objects() |
{ |
// QTimer-Instanzen |
timer = new QTimer(this); |
Poll = new QTimer(this); |
|
// Seriell-Port |
serialPort = new ManageSerialPort; |
// serialPort=serialPort = new ManageSerialPort; |
|
// QFile-Instanz (Log-Datei) |
CSVFile = new QFile(""); |
} |
|
void MKTool::init_Connections() |
{ |
// Seriel-Port Empfang |
connect(serialPort, SIGNAL(newDataReceived(const QByteArray &)), this, SLOT(slot_newDataReceived(const QByteArray &))); |
|
// Buttons und Menüpunkte / Toolbar |
|
connect(pb_Load, SIGNAL(clicked()), this, SLOT(slot_LoadParameter())); |
connect(pb_Save, SIGNAL(clicked()), this, SLOT(slot_SaveParameter())); |
connect(pb_Read, SIGNAL(clicked()), this, SLOT(slot_GetParameter())); |
connect(pb_Write, SIGNAL(clicked()), this, SLOT(slot_SetParameter())); |
|
connect(ac_Config, SIGNAL(triggered()), this, SLOT(slot_ac_Config())); |
connect(ac_StartPlotter, SIGNAL(triggered()), this, SLOT(slot_ac_StartPlotter())); |
|
connect(sl_Left, SIGNAL(valueChanged(int)), this, SLOT(slot_SliderMotorTest(int))); |
connect(sl_Right, SIGNAL(valueChanged(int)), this, SLOT(slot_SliderMotorTest(int))); |
connect(sl_Front, SIGNAL(valueChanged(int)), this, SLOT(slot_SliderMotorTest(int))); |
connect(sl_Back, SIGNAL(valueChanged(int)), this, SLOT(slot_SliderMotorTest(int))); |
connect(sl_All, SIGNAL(valueChanged(int)), this, SLOT(slot_SliderMotorTest(int))); |
|
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())); |
connect(ac_About, SIGNAL(triggered()), this, SLOT(slot_About())); |
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())); |
|
// Seitenwechsel :) |
connect(tab_Main, SIGNAL(currentChanged(int)), this, SLOT(slot_TabChanged(int))); |
connect(tab_Par, SIGNAL(currentChanged(int)), this, SLOT(slot_TabChanged(int))); |
|
// Parameterevents |
connect(tb_9_6, SIGNAL(clicked()), this, SLOT(slot_tbUp())); |
connect(tb_9_7, SIGNAL(clicked()), this, SLOT(slot_tbDown())); |
connect(tb_9_8, SIGNAL(clicked()), this, SLOT(slot_tbLeft())); |
connect(tb_9_9, SIGNAL(clicked()), this, SLOT(slot_tbRight())); |
|
connect(J16_0, SIGNAL(clicked()), this, SLOT(slot_LEDtoValue())); |
connect(J16_1, SIGNAL(clicked()), this, SLOT(slot_LEDtoValue())); |
connect(J16_2, SIGNAL(clicked()), this, SLOT(slot_LEDtoValue())); |
connect(J16_3, SIGNAL(clicked()), this, SLOT(slot_LEDtoValue())); |
connect(J16_4, SIGNAL(clicked()), this, SLOT(slot_LEDtoValue())); |
connect(J16_5, SIGNAL(clicked()), this, SLOT(slot_LEDtoValue())); |
connect(J16_6, SIGNAL(clicked()), this, SLOT(slot_LEDtoValue())); |
connect(J16_7, SIGNAL(clicked()), this, SLOT(slot_LEDtoValue())); |
|
connect(J17_0, SIGNAL(clicked()), this, SLOT(slot_LEDtoValue())); |
connect(J17_1, SIGNAL(clicked()), this, SLOT(slot_LEDtoValue())); |
connect(J17_2, SIGNAL(clicked()), this, SLOT(slot_LEDtoValue())); |
connect(J17_3, SIGNAL(clicked()), this, SLOT(slot_LEDtoValue())); |
connect(J17_4, SIGNAL(clicked()), this, SLOT(slot_LEDtoValue())); |
connect(J17_5, SIGNAL(clicked()), this, SLOT(slot_LEDtoValue())); |
connect(J17_6, SIGNAL(clicked()), this, SLOT(slot_LEDtoValue())); |
connect(J17_7, SIGNAL(clicked()), this, SLOT(slot_LEDtoValue())); |
|
connect(sb_11_1, SIGNAL(valueChanged(int)), this, SLOT(slot_ValuetoLED16(int))); |
connect(sb_11_3, SIGNAL(valueChanged(int)), this, SLOT(slot_ValuetoLED17(int))); |
|
// Plotter |
connect(scroll_plot, SIGNAL(valueChanged(int)), this, SLOT(slot_ScrollPlot(int))); |
|
// About-QT Dialog einfügen |
menu_Help->addAction(trUtf8("Über &Qt"), qApp, SLOT(aboutQt())); |
} |
|
void MKTool::init_Arrays() |
{ |
lb_Analog[0] = lb_A_0; |
lb_Analog[1] = lb_A_1; |
lb_Analog[2] = lb_A_2; |
lb_Analog[3] = lb_A_3; |
lb_Analog[4] = lb_A_4; |
lb_Analog[5] = lb_A_5; |
lb_Analog[6] = lb_A_6; |
lb_Analog[7] = lb_A_7; |
lb_Analog[8] = lb_A_8; |
lb_Analog[9] = lb_A_9; |
lb_Analog[10] = lb_A_10; |
lb_Analog[11] = lb_A_11; |
lb_Analog[12] = lb_A_12; |
lb_Analog[13] = lb_A_13; |
lb_Analog[14] = lb_A_14; |
lb_Analog[15] = lb_A_15; |
lb_Analog[16] = lb_A_16; |
lb_Analog[17] = lb_A_17; |
lb_Analog[18] = lb_A_18; |
lb_Analog[19] = lb_A_19; |
lb_Analog[20] = lb_A_20; |
lb_Analog[21] = lb_A_21; |
lb_Analog[22] = lb_A_22; |
lb_Analog[23] = lb_A_23; |
lb_Analog[24] = lb_A_24; |
lb_Analog[25] = lb_A_25; |
lb_Analog[26] = lb_A_26; |
lb_Analog[27] = lb_A_27; |
lb_Analog[28] = lb_A_28; |
lb_Analog[29] = lb_A_29; |
lb_Analog[30] = lb_A_30; |
lb_Analog[31] = lb_A_31; |
} |
|
void MKTool::init_Plot() |
{ |
NextPlot = 0; |
|
qwtPlot->setCanvasBackground(QColor(QRgb(0x00000000))); |
|
qwtPlot->insertLegend(new QwtLegend(), QwtPlot::RightLegend); |
|
QwtPlotGrid *Grid = new QwtPlotGrid(); |
Grid->setMajPen(QPen(Qt::gray, 0, Qt::DotLine)); |
|
|
Grid->attach(qwtPlot); |
|
qwtPlot->setAxisScale(QwtPlot::xBottom,0,PlotWide,0); |
|
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]->setRenderHint(QwtPlotItem::RenderAntialiased); |
|
if (Settings->Analog[a].Plot) |
Plot[a]->attach(qwtPlot); |
} |
qwtPlot->replot(); |
} |
|
void MKTool::init_Icons() |
{ |
Icons[0].addPixmap(QPixmap(QString::fromUtf8(":/LED/Images/16X16/ledred.png")), QIcon::Normal, QIcon::Off); |
Icons[1].addPixmap(QPixmap(QString::fromUtf8(":/LED/Images/16X16/ledyellow.png")), QIcon::Normal, QIcon::Off); |
Icons[3].addPixmap(QPixmap(QString::fromUtf8(":/LED/Images/16X16/ledyellow.png")), QIcon::Normal, QIcon::Off); |
Icons[4].addPixmap(QPixmap(QString::fromUtf8(":/LED/Images/16X16/ledoff.png")), QIcon::Normal, QIcon::Off); |
|
|
Icons[5].addPixmap(QPixmap(QString::fromUtf8(":/Actions/Images/22X22/application-exit.png")), QIcon::Normal, QIcon::Off); |
Icons[6].addPixmap(QPixmap(QString::fromUtf8(":/Actions/Images/22X22/media-playback-stop.png")), QIcon::Normal, QIcon::Off); |
Icons[7].addPixmap(QPixmap(QString::fromUtf8(":/Actions/Images/22X22/media-record.png")), QIcon::Normal, QIcon::Off); |
Icons[8].addPixmap(QPixmap(QString::fromUtf8(":/Actions/Images/22X22/network-connect.png")), QIcon::Normal, QIcon::Off); |
Icons[9].addPixmap(QPixmap(QString::fromUtf8(":/Actions/Images/22X22/network-disconnect.png")), QIcon::Normal, QIcon::Off); |
Icons[10].addPixmap(QPixmap(QString::fromUtf8(":/Actions/Images/22X22/utilities-system-monitor.png")), QIcon::Normal, QIcon::Off); |
|
Icons[20].addPixmap(QPixmap(QString::fromUtf8(":/Arrows/Images/32X32/arrow-up-double.png")), QIcon::Normal, QIcon::Off); |
Icons[21].addPixmap(QPixmap(QString::fromUtf8(":/Arrows/Images/32X32/arrow-up.png")), QIcon::Normal, QIcon::Off); |
Icons[22].addPixmap(QPixmap(QString::fromUtf8(":/Arrows/Images/32X32/arrow-down-double.png")), QIcon::Normal, QIcon::Off); |
Icons[23].addPixmap(QPixmap(QString::fromUtf8(":/Arrows/Images/32X32/arrow-down.png")), QIcon::Normal, QIcon::Off); |
Icons[24].addPixmap(QPixmap(QString::fromUtf8(":/Arrows/Images/32X32/arrow-left-double.png")), QIcon::Normal, QIcon::Off); |
Icons[25].addPixmap(QPixmap(QString::fromUtf8(":/Arrows/Images/32X32/arrow-left.png")), QIcon::Normal, QIcon::Off); |
Icons[26].addPixmap(QPixmap(QString::fromUtf8(":/Arrows/Images/32X32/arrow-right-double.png")), QIcon::Normal, QIcon::Off); |
Icons[27].addPixmap(QPixmap(QString::fromUtf8(":/Arrows/Images/32X32/arrow-right.png")), QIcon::Normal, QIcon::Off); |
} |
|
void MKTool::update_Plot() |
{ |
for (int a = 0; a < MaxAnalog; a++) |
{ |
Plot[a]->setData(aID,aData[a],NextPlot - 1); |
} |
|
if ((NextPlot > PlotWide)) |
{ |
scroll_plot->setMaximum(NextPlot - PlotWide); |
} |
|
if ((scroll_plot->value() == NextPlot - (PlotWide + 1))) |
{ |
qwtPlot->setAxisScale(QwtPlot::xBottom,NextPlot - PlotWide,NextPlot,0); |
scroll_plot->setValue(NextPlot - PlotWide); |
} |
|
qwtPlot->replot(); |
} |
|
void MKTool::config_Plot() |
{ |
for (int a = 0; a < MaxAnalog; a++) |
{ |
Plot[a]->detach(); |
Plot[a]->setPen(QPen(QColor(Settings->Analog[a].Color))); |
|
if (Settings->Analog[a].Plot) |
Plot[a]->attach(qwtPlot); |
} |
} |
|
void MKTool::slot_ac_Config() |
{ |
set_Analog Old_Analog[MaxAnalog]; |
memcpy(Old_Analog, Settings->Analog, sizeof(Settings->Analog)); |
|
dlg_Config *f_Config = new dlg_Config(this); |
f_Config->set_Settings(Settings); |
|
if (f_Config->exec()==QDialog::Accepted) |
{ |
Settings = f_Config->get_Settings(); |
Settings->write_Settings(); |
|
for (int a = 0; a < MaxAnalog; a++) |
{ |
if (Old_Analog[a].Plot == Settings->Analog[a].Plot) |
continue; |
else |
{ |
config_Plot(); |
break; |
} |
} |
|
if (CSVFile->isOpen()) |
{ |
for (int a = 0; a < MaxAnalog; a++) |
{ |
if (Old_Analog[a].Log == Settings->Analog[a].Log) |
continue; |
else |
{ |
slot_RecordCSV(); |
slot_RecordCSV(); |
break; |
} |
} |
} |
|
} |
} |
|
void MKTool::slot_ac_StartPlotter() |
{ |
if (ac_StartPlotter->isChecked()) |
{ |
ac_StartPlotter->setText("Stop Plotter"); |
pb_StartPlotter->setText("Stop Plotter"); |
} |
else |
{ |
ac_StartPlotter->setText("Start Plotter"); |
pb_StartPlotter->setText("Start Plotter"); |
} |
} |
|
|
|
void MKTool::slot_ScrollPlot(int Pos) |
{ |
qwtPlot->setAxisScale(QwtPlot::xBottom,Pos,Pos + PlotWide,0); |
qwtPlot->replot(); |
} |
|
void MKTool::slot_About() |
{ |
QMessageBox::about(this, trUtf8(("Über ")) + QA_NAME, QA_ABOUT); |
} |
|
void MKTool::slot_SetLogDir() |
{ |
QString directory = QFileDialog::getExistingDirectory(this, "Verzeichniss für CSV-Logdateien", Settings->DIR.Logging, QFileDialog::DontResolveSymlinks | QFileDialog::ShowDirsOnly); |
|
if ((!directory.isEmpty()) && (Settings->DIR.Logging != directory)) |
{ |
Settings->DIR.Logging = directory; |
Settings->write_Settings(); |
} |
} |
|
void MKTool::slot_SetParDir() |
{ |
QString directory = QFileDialog::getExistingDirectory(this, "Verzeichniss für Parameter-Dateien", Settings->DIR.Parameter, QFileDialog::DontResolveSymlinks | QFileDialog::ShowDirsOnly); |
|
if ((!directory.isEmpty()) && (Settings->DIR.Parameter != directory)) |
{ |
Settings->DIR.Parameter = directory; |
Settings->write_Settings(); |
} |
|
} |
|
void MKTool::slot_RecordCSV() |
{ |
if (!CSVFile->isOpen()) |
{ |
QString Filename = Settings->DIR.Logging + QDate::currentDate().toString(("yyyy-MM-dd")) + " -- " + QTime::currentTime().toString("hh-mm") + ".csv"; |
|
CSVFile = new QFile(Filename); |
if (!CSVFile->exists()) |
{ |
CSVFile->open(QIODevice::Append | QIODevice::Text); |
|
QTextStream Out(CSVFile); |
|
for (int a = 0; a < MaxAnalog; a++) |
{ |
if (Settings->Analog[a].Log) |
{ |
Out << Settings->Analog[a].Name; |
|
if (a < MaxAnalog - 1) |
Out << ';'; |
} |
} |
Out << "\n"; |
} |
else |
{ |
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]); |
ac_RecordCSV->setText("CSV Stop"); |
} |
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]); |
ac_RecordCSV->setText("CSV Aufzeichnen"); |
} |
} |
|
void MKTool::slot_LEDtoValue() |
{ |
QToolButton *ToolButton = (QToolButton*)sender(); |
if (ToolButton->text() == QString("0")) |
{ |
set_LED(ToolButton, true); |
sb_11_1->setValue(sb_11_1->value() + ToolButton->toolTip().toInt()); |
} |
else if (ToolButton->text() == QString("1")) |
{ |
set_LED(ToolButton); |
sb_11_1->setValue(sb_11_1->value() - ToolButton->toolTip().toInt()); |
} |
else if (ToolButton->text() == QString("00")) |
{ |
set_LED(ToolButton, true); |
sb_11_3->setValue(sb_11_3->value() + ToolButton->toolTip().toInt()); |
} |
else if (ToolButton->text() == QString("11")) |
{ |
set_LED(ToolButton); |
sb_11_3->setValue(sb_11_3->value() - ToolButton->toolTip().toInt()); |
} |
} |
|
void MKTool::slot_ValuetoLED16(int Wert) |
{ |
// QSpinBox *SpinBox = (QSpinBox*)sender(); |
|
// int Wert = SpinBox->value(); |
|
set_LED(J16_0); |
set_LED(J16_1); |
set_LED(J16_2); |
set_LED(J16_3); |
set_LED(J16_4); |
set_LED(J16_5); |
set_LED(J16_6); |
set_LED(J16_7); |
|
for (int a = 0; a < 8; a++) |
{ |
if (Wert > 127) |
{ |
set_LED(J16_0, true); |
Wert = Wert - 128; |
} |
if (Wert > 63) |
{ |
set_LED(J16_1, true); |
Wert = Wert - 64; |
} |
if (Wert > 31) |
{ |
set_LED(J16_2, true); |
Wert = Wert - 32; |
} |
if (Wert > 15) |
{ |
set_LED(J16_3, true); |
Wert = Wert - 16; |
} |
if (Wert > 7) |
{ |
set_LED(J16_4, true); |
Wert = Wert - 8; |
} |
if (Wert > 3) |
{ |
set_LED(J16_5, true); |
Wert = Wert - 4; |
} |
if (Wert > 1) |
{ |
set_LED(J16_6, true); |
Wert = Wert - 2; |
} |
if (Wert > 0) |
{ |
set_LED(J16_7, true); |
Wert = Wert - 1; |
} |
} |
} |
|
void MKTool::slot_ValuetoLED17(int Wert) |
{ |
// QSpinBox *SpinBox = (QSpinBox*)sender(); |
|
// int Wert = SpinBox->value(); |
|
set_LED(J17_0); |
set_LED(J17_1); |
set_LED(J17_2); |
set_LED(J17_3); |
set_LED(J17_4); |
set_LED(J17_5); |
set_LED(J17_6); |
set_LED(J17_7); |
|
for (int a = 0; a < 8; a++) |
{ |
if (Wert > 127) |
{ |
set_LED(J17_0, true); |
Wert = Wert - 128; |
} |
if (Wert > 63) |
{ |
set_LED(J17_1, true); |
Wert = Wert - 64; |
} |
if (Wert > 31) |
{ |
set_LED(J17_2, true); |
Wert = Wert - 32; |
} |
if (Wert > 15) |
{ |
set_LED(J17_3, true); |
Wert = Wert - 16; |
} |
if (Wert > 7) |
{ |
set_LED(J17_4, true); |
Wert = Wert - 8; |
} |
if (Wert > 3) |
{ |
set_LED(J17_5, true); |
Wert = Wert - 4; |
} |
if (Wert > 1) |
{ |
set_LED(J17_6, true); |
Wert = Wert - 2; |
} |
if (Wert > 0) |
{ |
set_LED(J17_7, true); |
Wert = Wert - 1; |
} |
} |
} |
|
void MKTool::set_LED(QToolButton *ToolButton, bool On) |
{ |
if (ToolButton->text() == QString("0") && On) |
{ |
// QIcon Icon; |
// Icon.addPixmap(QPixmap(QString::fromUtf8(":/LED/Images/ledred.png")), QIcon::Normal, QIcon::Off); |
ToolButton->setIcon(Icons[0]); |
ToolButton->setText("1"); |
} |
else if (ToolButton->text() == QString("1") && !On) |
{ |
// QIcon Icon; |
// Icon.addPixmap(QPixmap(QString::fromUtf8(":/LED/Images/ledoff.png")), QIcon::Normal, QIcon::Off); |
ToolButton->setIcon(Icons[4]); |
ToolButton->setText("0"); |
} |
else if (ToolButton->text() == QString("00") && On) |
{ |
// QIcon Icon; |
// Icon.addPixmap(QPixmap(QString::fromUtf8(":/LED/Images/ledred.png")), QIcon::Normal, QIcon::Off); |
ToolButton->setIcon(Icons[0]); |
ToolButton->setText("11"); |
} |
else if (ToolButton->text() == QString("11") && !On) |
{ |
// QIcon Icon; |
// Icon.addPixmap(QPixmap(QString::fromUtf8(":/LED/Images/ledoff.png")), QIcon::Normal, QIcon::Off); |
ToolButton->setIcon(Icons[4]); |
ToolButton->setText("00"); |
} |
} |
|
void MKTool::slot_tbUp() |
{ |
if (tb_9_6->text() == QString("0")) |
{ |
tb_9_6->setIcon(Icons[20]); |
tb_9_6->setText("1"); |
} |
else |
{ |
tb_9_6->setIcon(Icons[21]); |
tb_9_6->setText("0"); |
} |
} |
|
void MKTool::slot_tbDown() |
{ |
if (tb_9_7->text() == QString("0")) |
{ |
tb_9_7->setIcon(Icons[22]); |
tb_9_7->setText("1"); |
} |
else |
{ |
tb_9_7->setIcon(Icons[23]); |
tb_9_7->setText("0"); |
} |
} |
|
void MKTool::slot_tbLeft() |
{ |
if (tb_9_8->text() == QString("0")) |
{ |
tb_9_8->setIcon(Icons[24]); |
tb_9_8->setText("1"); |
} |
else |
{ |
tb_9_8->setIcon(Icons[25]); |
tb_9_8->setText("0"); |
} |
} |
|
void MKTool::slot_tbRight() |
{ |
if (tb_9_9->text() == QString("0")) |
{ |
tb_9_9->setIcon(Icons[26]); |
tb_9_9->setText("1"); |
} |
else |
{ |
tb_9_9->setIcon(Icons[27]); |
tb_9_9->setText("0"); |
} |
} |
|
void MKTool::write_Settings() |
{ |
QSettings Setting("KeyOz-Net", "QMK-Groundstation"); |
|
Setting.beginGroup("Port"); |
Setting.setValue("TTY", le_Port->text()); |
Setting.endGroup(); |
|
Setting.beginGroup("GUI"); |
Setting.setValue("IsMax", isMaximized()); |
Setting.setValue("Size", size()); |
Setting.setValue("Point", pos()); |
Setting.endGroup(); |
} |
|
bool MKTool::Decode64(char *RxdBuffer, int len, bool Long) |
{ |
unsigned char a,b,c,d; |
unsigned char ptr = 0; |
unsigned char x,y,z; |
int ptrOut[150]; |
|
int ptrIn = 3; |
int max = len; |
int DecLen = 0; |
|
if (RxdBuffer[ptrIn] == 0) |
{ |
qDebug("QString to Char ERROR...!!!!"); |
return false; |
} |
|
while(len != 0) |
{ |
a = RxdBuffer[ptrIn++] - '='; |
b = RxdBuffer[ptrIn++] - '='; |
c = RxdBuffer[ptrIn++] - '='; |
d = RxdBuffer[ptrIn++] - '='; |
|
if(ptrIn > max - 2) break; // nicht mehr Daten verarbeiten, als empfangen wurden |
|
x = (a << 2) | (b >> 4); |
y = ((b & 0x0f) << 4) | (c >> 2); |
z = ((c & 0x03) << 6) | d; |
|
if(len--) ptrOut[ptr++] = x; else break; |
if(len--) ptrOut[ptr++] = y; else break; |
if(len--) ptrOut[ptr++] = z; else break; |
} |
|
for (int a=0; a<ptr; a++) |
{ |
if (Long == false) |
{ |
int b1, b2, b3; |
|
b1 = ptrOut[a++]; |
b2 = ptrOut[a]; |
|
b3 = (b2 << 8) | b1; |
|
if (b3 > 32767) |
b3 = b3 - 65536; |
|
DecodeData[DecLen] = b3; |
DecLen++; |
} |
else |
{ |
DecodeData[DecLen] = ptrOut[a]; |
DecLen++; |
} |
} |
return true; |
} |
|
QString MKTool::Encode64(char Data[150],unsigned int Length) |
{ |
unsigned int pt = 0; |
unsigned char a,b,c; |
unsigned char ptr = 0; |
|
char TX_Buff[150]; |
|
while(Length > 0) |
{ |
if(Length) { a = Data[ptr++]; Length--;} else a = 0; |
if(Length) { b = Data[ptr++]; Length--;} else b = 0; |
if(Length) { c = Data[ptr++]; Length--;} else c = 0; |
|
TX_Buff[pt++] = '=' + (a >> 2); |
TX_Buff[pt++] = '=' + (((a & 0x03) << 4) | ((b & 0xf0) >> 4)); |
TX_Buff[pt++] = '=' + (((b & 0x0f) << 2) | ((c & 0xc0) >> 6)); |
TX_Buff[pt++] = '=' + ( c & 0x3f); |
} |
TX_Buff[pt] = 0; |
|
return QString(TX_Buff); |
} |
|
void MKTool::send_Data(char CMD, char Data[150],unsigned int Length, bool Resend) |
{ |
if (serialPort->isOpen()) |
{ |
QString TX_Data = Encode64(Data, Length); |
|
TX_Data = QString("#0") + QString(CMD) + TX_Data; |
|
// qDebug(TX_Data.toLatin1().data()); |
|
TX_Data = add_CRC(TX_Data) + '\r'; |
|
// qDebug(TX_Data.toLatin1().data()); |
|
QByteArray Temp(TX_Data.toUtf8()); |
LastSend = TX_Data; |
|
if (Resend) |
timer->start(1000); |
|
serialPort->sendData(Temp); |
} |
} |
|
void MKTool::write_CSV() |
{ |
QTextStream Out(CSVFile); |
for (int a=0; a<MaxAnalog; a++) |
{ |
if (Settings->Analog[a].Log) |
{ |
Out << AnalogData[a]; |
if (a < MaxAnalog - 1) |
Out << ';'; |
} |
} |
Out << "\n"; |
} |
|
void MKTool::show_DebugData() |
{ |
if (CSVFile->isOpen()) |
{ |
write_CSV(); |
} |
|
if (ac_StartPlotter->isChecked()) |
{ |
aID[NextPlot] = NextPlot; |
|
for (int a = 0; a < MaxAnalog; a++) |
{ |
aData[a][NextPlot] = AnalogData[a]; |
} |
NextPlot++; |
|
update_Plot(); |
} |
|
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])); |
le_A_3->setText(QString("%1").arg(AnalogData[3])); |
le_A_4->setText(QString("%1").arg(AnalogData[4])); |
le_A_5->setText(QString("%1").arg(AnalogData[5])); |
le_A_6->setText(QString("%1").arg(AnalogData[6])); |
le_A_7->setText(QString("%1").arg(AnalogData[7])); |
le_A_8->setText(QString("%1").arg(AnalogData[8])); |
le_A_9->setText(QString("%1").arg(AnalogData[9])); |
le_A_10->setText(QString("%1").arg(AnalogData[10])); |
le_A_11->setText(QString("%1").arg(AnalogData[11])); |
le_A_12->setText(QString("%1").arg(AnalogData[12])); |
le_A_13->setText(QString("%1").arg(AnalogData[13])); |
le_A_14->setText(QString("%1").arg(AnalogData[14])); |
le_A_15->setText(QString("%1").arg(AnalogData[15])); |
le_A_16->setText(QString("%1").arg(AnalogData[16])); |
le_A_17->setText(QString("%1").arg(AnalogData[17])); |
le_A_18->setText(QString("%1").arg(AnalogData[18])); |
le_A_19->setText(QString("%1").arg(AnalogData[19])); |
le_A_20->setText(QString("%1").arg(AnalogData[20])); |
le_A_21->setText(QString("%1").arg(AnalogData[21])); |
le_A_22->setText(QString("%1").arg(AnalogData[22])); |
le_A_23->setText(QString("%1").arg(AnalogData[23])); |
le_A_24->setText(QString("%1").arg(AnalogData[24])); |
le_A_25->setText(QString("%1").arg(AnalogData[25])); |
le_A_26->setText(QString("%1").arg(AnalogData[26])); |
le_A_27->setText(QString("%1").arg(AnalogData[27])); |
le_A_28->setText(QString("%1").arg(AnalogData[28])); |
le_A_29->setText(QString("%1").arg(AnalogData[29])); |
le_A_30->setText(QString("%1").arg(AnalogData[30])); |
le_A_31->setText(QString("%1").arg(AnalogData[31])); |
} |
|
QComboBox *MKTool::setCombo(QComboBox *Combo, int Set, int Wert) |
{ |
if (ParameterSet[Set][Wert] <= 250) |
{ |
Combo->setItemText(4, QString("%1").arg(ParameterSet[Set][Wert])); |
Combo->setCurrentIndex(4); |
} |
else |
{ |
Combo->setCurrentIndex(ParameterSet[Set][Wert] - 251); |
} |
return Combo; |
} |
|
int MKTool::get_Value(QComboBox *Combo) |
{ |
if (Combo->currentText() == QString("Poti 1")) |
return 251; |
if (Combo->currentText() == QString("Poti 2")) |
return 252; |
if (Combo->currentText() == QString("Poti 3")) |
return 253; |
if (Combo->currentText() == QString("Poti 4")) |
return 254; |
return Combo->currentText().toInt(); |
} |
|
void MKTool::store_ParameterSet(int Set) |
{ |
char *Name = le_SetName->text().toLatin1().data(); |
|
int a; |
|
for (a = 0; a < le_SetName->text().length(); a++) |
{ |
ParameterSet[Set][P_NAME+a] = Name[a]; |
} |
|
while(a < 12) |
{ |
ParameterSet[Set][P_NAME+a] = 0; |
a++; |
} |
|
// Seite 1 |
ParameterSet[Set][P_GLOBAL_CONF] = 0; |
|
if (cb_1_1->isChecked()) |
ParameterSet[Set][P_GLOBAL_CONF] = ParameterSet[Set][P_GLOBAL_CONF] | 0x01; |
if (cb_1_2->isChecked()) |
ParameterSet[Set][P_GLOBAL_CONF] = ParameterSet[Set][P_GLOBAL_CONF] | 0x02; |
if (cb_1_3->isChecked()) |
ParameterSet[Set][P_GLOBAL_CONF] = ParameterSet[Set][P_GLOBAL_CONF] | 0x04; |
if (cb_1_4->isChecked()) |
ParameterSet[Set][P_GLOBAL_CONF] = ParameterSet[Set][P_GLOBAL_CONF] | 0x08; |
if (cb_1_5->isChecked()) |
ParameterSet[Set][P_GLOBAL_CONF] = ParameterSet[Set][P_GLOBAL_CONF] | 0x10; |
if (cb_1_6->isChecked()) |
ParameterSet[Set][P_GLOBAL_CONF] = ParameterSet[Set][P_GLOBAL_CONF] | 0x20; |
if (cb_1_7->isChecked()) |
ParameterSet[Set][P_GLOBAL_CONF] = ParameterSet[Set][P_GLOBAL_CONF] | 0x40; |
if (cb_1_8->isChecked()) |
ParameterSet[Set][P_GLOBAL_CONF] = ParameterSet[Set][P_GLOBAL_CONF] | 0x80; |
|
// Seite 2 |
ParameterSet[Set][P_KANAL_NICK] = sb_2_1->value(); |
ParameterSet[Set][P_KANAL_ROLL] = sb_2_2->value(); |
ParameterSet[Set][P_KANAL_GAS] = sb_2_3->value(); |
ParameterSet[Set][P_KANAL_GIER] = sb_2_4->value(); |
ParameterSet[Set][P_KANAL_POTI1] = sb_2_5->value(); |
ParameterSet[Set][P_KANAL_POTI2] = sb_2_6->value(); |
ParameterSet[Set][P_KANAL_POTI3] = sb_2_7->value(); |
ParameterSet[Set][P_KANAL_POTI4] = sb_2_8->value(); |
|
// Seite 3 |
ParameterSet[Set][P_STICK_P] = sb_3_1->value(); |
ParameterSet[Set][P_STICK_D] = sb_3_2->value(); |
ParameterSet[Set][P_GIER_P] = get_Value(cb_3_3); |
ParameterSet[Set][P_EXTERNAL] = get_Value(cb_3_4); |
|
// Seite 4 |
ParameterSet[Set][P_MAXHOEHE] = get_Value(cb_4_1); |
ParameterSet[Set][P_MIN_GAS] = sb_4_2->value(); |
ParameterSet[Set][P_HOEHE_P] = get_Value(cb_4_3); |
ParameterSet[Set][P_DRUCK_D] = get_Value(cb_4_4); |
ParameterSet[Set][P_HOEHE_ACC] = get_Value(cb_4_5); |
ParameterSet[Set][P_HOEHE_GAIN] = sb_4_6->value(); |
|
// Seite 5 |
ParameterSet[Set][P_GYRO_P] = get_Value(cb_5_1); |
ParameterSet[Set][P_GYRO_I] = get_Value(cb_5_2); |
ParameterSet[Set][P_DYNAMIC_STAB] = get_Value(cb_5_3); |
ParameterSet[Set][P_GYRO_ACC_FAKTOR] = sb_5_4->value(); |
ParameterSet[Set][P_GYRO_ACC_ABGL] = sb_5_5->value(); |
ParameterSet[Set][P_FAKTOR_I] = get_Value(cb_5_6); |
ParameterSet[Set][P_DRIFT_KOMP] = sb_5_7->value(); |
|
// Seite 6 |
ParameterSet[Set][P_SERVO_NICK_CONT] = get_Value(cb_6_1); |
ParameterSet[Set][P_SERVO_NICK_COMP] = sb_6_2->value(); |
ParameterSet[Set][P_SERVO_NICK_MIN] = sb_6_3->value(); |
ParameterSet[Set][P_SERVO_NICK_MAX] = sb_6_4->value(); |
ParameterSet[Set][P_SERVO_NICK_REFR] = sb_6_5->value(); |
ParameterSet[Set][P_SERVO_NICK_COMPI] = cb_6_6->isChecked(); |
|
// Seite 7 |
ParameterSet[Set][P_GAS_MIN] = sb_7_1->value(); |
ParameterSet[Set][P_GAS_MAX] = sb_7_2->value(); |
ParameterSet[Set][P_KOMPASS_WIRKUNG] = get_Value(cb_7_3); |
ParameterSet[Set][P_UNTERSPANNUNG] = sb_7_4->value(); |
ParameterSet[Set][P_NOTGASZEIT] = sb_7_5->value(); |
ParameterSet[Set][P_NOTGAS] = sb_7_6->value(); |
|
// Seite 8 |
ParameterSet[Set][P_ACHS_KOPPLUNG] = get_Value(cb_8_1); |
ParameterSet[Set][P_ACHS_GKOPPLUNG] = get_Value(cb_8_2); |
|
// Seite 9 |
ParameterSet[Set][P_LOOP_CONFIG] = 0; |
if (tb_9_6->text() == QString("1")) |
ParameterSet[Set][P_LOOP_CONFIG] = ParameterSet[Set][P_LOOP_CONFIG] | 0x01; |
if (tb_9_7->text() == QString("1")) |
ParameterSet[Set][P_LOOP_CONFIG] = ParameterSet[Set][P_LOOP_CONFIG] | 0x02; |
if (tb_9_8->text() == QString("1")) |
ParameterSet[Set][P_LOOP_CONFIG] = ParameterSet[Set][P_LOOP_CONFIG] | 0x04; |
if (tb_9_9->text() == QString("1")) |
ParameterSet[Set][P_LOOP_CONFIG] = ParameterSet[Set][P_LOOP_CONFIG] | 0x08; |
|
ParameterSet[Set][P_LOOP_GAS_LIMIT] = get_Value(cb_9_1); |
ParameterSet[Set][P_LOOP_THRESHOLD] = sb_9_2->value(); |
ParameterSet[Set][P_WINKEL_NICK] = sb_9_3->value(); |
ParameterSet[Set][P_LOOP_HYSTERESE] = sb_9_4->value(); |
ParameterSet[Set][P_WINKEL_ROLL] = sb_9_5->value(); |
|
// Seite 10 |
ParameterSet[Set][P_USER_1] = get_Value(cb_10_1); |
ParameterSet[Set][P_USER_2] = get_Value(cb_10_2); |
ParameterSet[Set][P_USER_3] = get_Value(cb_10_3); |
ParameterSet[Set][P_USER_4] = get_Value(cb_10_4); |
ParameterSet[Set][P_USER_5] = get_Value(cb_10_5); |
ParameterSet[Set][P_USER_6] = get_Value(cb_10_6); |
ParameterSet[Set][P_USER_7] = get_Value(cb_10_7); |
ParameterSet[Set][P_USER_8] = get_Value(cb_10_8); |
|
// Seite 11 |
ParameterSet[Set][P_J16_BITMASK] = sb_11_1->value(); |
ParameterSet[Set][P_J16_TIMING] = get_Value(cb_11_2); |
ParameterSet[Set][P_J17_BITMASK] = sb_11_3->value(); |
ParameterSet[Set][P_J17_TIMING] = get_Value(cb_11_4); |
|
// Seite 12 |
ParameterSet[Set][P_NAV_GPS_MODE] = get_Value(cb_12_1); |
ParameterSet[Set][P_NAV_GPS_GAIN] = get_Value(cb_12_2); |
ParameterSet[Set][P_NAV_STICK_THRE] = sb_12_3->value(); |
ParameterSet[Set][P_NAV_GPS_MIN] = sb_12_4->value(); |
ParameterSet[Set][P_NAV_GPS_P] = get_Value(cb_12_5); |
ParameterSet[Set][P_NAV_GPS_I] = get_Value(cb_12_6); |
ParameterSet[Set][P_NAV_GPS_D] = get_Value(cb_12_7); |
ParameterSet[Set][P_NAV_GPS_ACC] = get_Value(cb_12_8); |
} |
|
void MKTool::slot_SaveParameter() |
{ |
int Set = sb_Set->value() + 5; |
|
QString Filename = QFileDialog::getSaveFileName(this, "Mikrokopter Parameter speichern", Settings->DIR.Parameter + le_SetName->text(), "Mikrokopter Parameter(*.mkp);;Alle Dateien (*)"); |
|
if (!Filename.isEmpty()) |
{ |
if (!(Filename.endsWith(".mkp", Qt::CaseInsensitive))) |
{ |
Filename = Filename + QString(".mkp"); |
} |
store_ParameterSet(Set); |
QSettings Setting(Filename, QSettings::IniFormat); |
|
Setting.beginGroup("Setup"); |
Setting.setValue("Name", le_SetName->text()); |
Setting.setValue("GlobalConfig", ParameterSet[Set][P_GLOBAL_CONF]); |
Setting.endGroup(); |
|
Setting.beginGroup("Channels"); |
Setting.setValue("Nick", ParameterSet[Set][P_KANAL_NICK]); |
Setting.setValue("Roll", ParameterSet[Set][P_KANAL_ROLL]); |
Setting.setValue("Gas", ParameterSet[Set][P_KANAL_GAS]); |
Setting.setValue("Gier", ParameterSet[Set][P_KANAL_GIER]); |
Setting.setValue("Poti_1", ParameterSet[Set][P_KANAL_POTI1]); |
Setting.setValue("Poti_2", ParameterSet[Set][P_KANAL_POTI2]); |
Setting.setValue("Poti_3", ParameterSet[Set][P_KANAL_POTI3]); |
Setting.setValue("Poti_4", ParameterSet[Set][P_KANAL_POTI4]); |
Setting.endGroup(); |
|
Setting.beginGroup("Stick"); |
Setting.setValue("Nick_Roll-P", ParameterSet[Set][P_STICK_P]); |
Setting.setValue("Nick_Roll-D", ParameterSet[Set][P_STICK_D]); |
Setting.setValue("Gier-P", ParameterSet[Set][P_GIER_P]); |
Setting.setValue("ExternalControl", ParameterSet[Set][P_EXTERNAL]); |
Setting.endGroup(); |
|
Setting.beginGroup("Altitude"); |
Setting.setValue("Setpoint", ParameterSet[Set][P_MAXHOEHE]); |
Setting.setValue("MinGas", ParameterSet[Set][P_MIN_GAS]); |
Setting.setValue("P", ParameterSet[Set][P_HOEHE_P]); |
Setting.setValue("Barometric-D", ParameterSet[Set][P_DRUCK_D]); |
Setting.setValue("Z-ACC-Effect", ParameterSet[Set][P_HOEHE_ACC]); |
Setting.setValue("Gain", ParameterSet[Set][P_HOEHE_GAIN]); |
Setting.endGroup(); |
|
Setting.beginGroup("Gyro"); |
Setting.setValue("P", ParameterSet[Set][P_GYRO_P]); |
Setting.setValue("I", ParameterSet[Set][P_GYRO_I]); |
Setting.setValue("DynamicStability", ParameterSet[Set][P_DYNAMIC_STAB]); |
Setting.setValue("ACC_Gyro-Factor", ParameterSet[Set][P_GYRO_ACC_FAKTOR]); |
Setting.setValue("ACC_Gyro-Compensation", ParameterSet[Set][P_GYRO_ACC_ABGL]); |
Setting.setValue("DriftCompensation", ParameterSet[Set][P_DRIFT_KOMP]); |
Setting.setValue("Main-I", ParameterSet[Set][P_FAKTOR_I]); |
Setting.endGroup(); |
|
Setting.beginGroup("Camera"); |
Setting.setValue("ServoNickControl", ParameterSet[Set][P_SERVO_NICK_CONT]); |
Setting.setValue("ServoNickCompensation", ParameterSet[Set][P_SERVO_NICK_COMP]); |
Setting.setValue("ServoNickInvert", ParameterSet[Set][P_SERVO_NICK_COMPI]); |
Setting.setValue("ServoNickMin", ParameterSet[Set][P_SERVO_NICK_MIN]); |
Setting.setValue("ServoNickMax", ParameterSet[Set][P_SERVO_NICK_MAX]); |
Setting.setValue("ServoNickRefreshRate", ParameterSet[Set][P_SERVO_NICK_REFR]); |
Setting.endGroup(); |
|
Setting.beginGroup("Others"); |
Setting.setValue("MinGas", ParameterSet[Set][P_GAS_MIN]); |
Setting.setValue("MaxGas", ParameterSet[Set][P_GAS_MAX]); |
Setting.setValue("Compass-Effect", ParameterSet[Set][P_KOMPASS_WIRKUNG]); |
Setting.setValue("UnderVoltage", ParameterSet[Set][P_UNTERSPANNUNG]); |
Setting.setValue("NotGas", ParameterSet[Set][P_NOTGAS]); |
Setting.setValue("NotGasTime", ParameterSet[Set][P_NOTGASZEIT]); |
Setting.endGroup(); |
|
Setting.beginGroup("Coupling"); |
Setting.setValue("YawPosFeedback", ParameterSet[Set][P_ACHS_KOPPLUNG]); |
Setting.setValue("YawNegFeedback", ParameterSet[Set][P_ACHS_GKOPPLUNG]); |
Setting.endGroup(); |
|
Setting.beginGroup("Loop"); |
Setting.setValue("Config", ParameterSet[Set][P_LOOP_CONFIG]); |
Setting.setValue("GasLimit", ParameterSet[Set][P_LOOP_GAS_LIMIT]); |
Setting.setValue("StickThreshold", ParameterSet[Set][P_LOOP_THRESHOLD]); |
Setting.setValue("LoopHysteresis", ParameterSet[Set][P_LOOP_HYSTERESE]); |
Setting.setValue("TurnOverNick", ParameterSet[Set][P_WINKEL_NICK]); |
Setting.setValue("TurnOverRoll", ParameterSet[Set][P_WINKEL_ROLL]); |
Setting.endGroup(); |
|
Setting.beginGroup("User"); |
Setting.setValue("Parameter_1", ParameterSet[Set][P_USER_1]); |
Setting.setValue("Parameter_2", ParameterSet[Set][P_USER_2]); |
Setting.setValue("Parameter_3", ParameterSet[Set][P_USER_3]); |
Setting.setValue("Parameter_4", ParameterSet[Set][P_USER_4]); |
Setting.setValue("Parameter_5", ParameterSet[Set][P_USER_5]); |
Setting.setValue("Parameter_6", ParameterSet[Set][P_USER_6]); |
Setting.setValue("Parameter_7", ParameterSet[Set][P_USER_7]); |
Setting.setValue("Parameter_8", ParameterSet[Set][P_USER_8]); |
Setting.endGroup(); |
|
Setting.beginGroup("Output"); |
Setting.setValue("J16_Bitmask", ParameterSet[Set][P_J16_BITMASK]); |
Setting.setValue("J16_Timing", ParameterSet[Set][P_J16_TIMING]); |
Setting.setValue("J17_Bitmask", ParameterSet[Set][P_J17_BITMASK]); |
Setting.setValue("J17_Timing", ParameterSet[Set][P_J17_TIMING]); |
Setting.endGroup(); |
|
Setting.beginGroup("NaviCtrl"); |
Setting.setValue("GPS_ModeControl", ParameterSet[Set][P_NAV_GPS_MODE]); |
Setting.setValue("GPS_Gain", ParameterSet[Set][P_NAV_GPS_GAIN]); |
Setting.setValue("GPS_P", ParameterSet[Set][P_NAV_GPS_P]); |
Setting.setValue("GPS_I", ParameterSet[Set][P_NAV_GPS_I]); |
Setting.setValue("GPS_D", ParameterSet[Set][P_NAV_GPS_D]); |
Setting.setValue("GPS_Acc", ParameterSet[Set][P_NAV_GPS_ACC]); |
Setting.setValue("GPS_MinSat", ParameterSet[Set][P_NAV_GPS_MIN]); |
Setting.setValue("GPS_StickThreshold", ParameterSet[Set][P_NAV_STICK_THRE]); |
Setting.endGroup(); |
} |
} |
|
void MKTool::slot_LoadParameter() |
{ |
QString Filename = QFileDialog::getOpenFileName(this, "Mikrokopter Parameter laden", Settings->DIR.Parameter, "Mikrokopter Parameter(*.mkp);;Alle Dateien (*)"); |
|
if (!Filename.isEmpty()) |
{ |
int Set = sb_Set->value(); |
QSettings Setting(Filename, QSettings::IniFormat); |
|
Setting.beginGroup("Setup"); |
QString Name = Setting.value("Name", QString("--noname--")).toString(); |
char *CName = Name.toLatin1().data(); |
int a; |
|
for (a=0; a < Name.length(); a++) |
{ |
ParameterSet[Set][P_NAME+a] = CName[a]; |
} |
while (a < 12) |
{ |
ParameterSet[Set][P_NAME+a] = 0; |
a++; |
} |
|
ParameterSet[Set][P_GLOBAL_CONF] = Setting.value("GlobalConfig", 0).toInt(); |
Setting.endGroup(); |
|
Setting.beginGroup("Channels"); |
ParameterSet[Set][P_KANAL_NICK] = Setting.value("Nick", 1).toInt(); |
ParameterSet[Set][P_KANAL_ROLL] = Setting.value("Roll", 2).toInt(); |
ParameterSet[Set][P_KANAL_GAS] = Setting.value("Gas", 3).toInt(); |
ParameterSet[Set][P_KANAL_GIER] = Setting.value("Gier", 4).toInt(); |
ParameterSet[Set][P_KANAL_POTI1] = Setting.value("Poti_1", 5).toInt(); |
ParameterSet[Set][P_KANAL_POTI2] = Setting.value("Poti_2", 6).toInt(); |
ParameterSet[Set][P_KANAL_POTI3] = Setting.value("Poti_3", 7).toInt(); |
ParameterSet[Set][P_KANAL_POTI4] = Setting.value("Poti_4", 8).toInt(); |
Setting.endGroup(); |
|
Setting.beginGroup("Stick"); |
ParameterSet[Set][P_STICK_P] = Setting.value("Nick_Roll-P", 4).toInt(); |
ParameterSet[Set][P_STICK_D] = Setting.value("Nick_Roll-D", 8).toInt(); |
ParameterSet[Set][P_GIER_P] = Setting.value("Gier-P", 1).toInt(); |
ParameterSet[Set][P_EXTERNAL] = Setting.value("ExternalControl", 1).toInt(); |
Setting.endGroup(); |
|
Setting.beginGroup("Altitude"); |
ParameterSet[Set][P_MAXHOEHE] = Setting.value("Setpoint", 251).toInt(); |
ParameterSet[Set][P_MIN_GAS] = Setting.value("MinGas", 30).toInt(); |
ParameterSet[Set][P_HOEHE_P] = Setting.value("P", 10).toInt(); |
ParameterSet[Set][P_DRUCK_D] = Setting.value("Barometric-D", 30).toInt(); |
ParameterSet[Set][P_HOEHE_ACC] = Setting.value("Z-ACC-Effect", 30).toInt(); |
ParameterSet[Set][P_HOEHE_GAIN] = Setting.value("Gain", 3).toInt(); |
Setting.endGroup(); |
|
Setting.beginGroup("Gyro"); |
ParameterSet[Set][P_GYRO_P] = Setting.value("P", 80).toInt(); |
ParameterSet[Set][P_GYRO_I] = Setting.value("I", 120).toInt(); |
ParameterSet[Set][P_DYNAMIC_STAB] = Setting.value("DynamicStability", 75).toInt(); |
ParameterSet[Set][P_GYRO_ACC_FAKTOR] = Setting.value("ACC_Gyro-Factor", 30).toInt(); |
ParameterSet[Set][P_GYRO_ACC_ABGL] = Setting.value("ACC_Gyro-Compensation", 32).toInt(); |
ParameterSet[Set][P_DRIFT_KOMP] = Setting.value("DriftCompensation", 4).toInt(); |
ParameterSet[Set][P_FAKTOR_I] = Setting.value("Main-I", 32).toInt(); |
Setting.endGroup(); |
|
Setting.beginGroup("Camera"); |
ParameterSet[Set][P_SERVO_NICK_CONT] = Setting.value("ServoNickControl", 100).toInt(); |
ParameterSet[Set][P_SERVO_NICK_COMP] = Setting.value("ServoNickCompensation", 40).toInt(); |
ParameterSet[Set][P_SERVO_NICK_COMPI] = Setting.value("ServoNickInvert", 0).toInt(); |
ParameterSet[Set][P_SERVO_NICK_MIN] = Setting.value("ServoNickMin", 50).toInt(); |
ParameterSet[Set][P_SERVO_NICK_MAX] = Setting.value("ServoNickMax", 150).toInt(); |
ParameterSet[Set][P_SERVO_NICK_REFR] = Setting.value("ServoNickRefreshRate", 5).toInt(); |
Setting.endGroup(); |
|
Setting.beginGroup("Others"); |
ParameterSet[Set][P_GAS_MIN] = Setting.value("MinGas", 8).toInt(); |
ParameterSet[Set][P_GAS_MAX] = Setting.value("MaxGas", 230).toInt(); |
ParameterSet[Set][P_KOMPASS_WIRKUNG] = Setting.value("Compass-Effect", 128).toInt(); |
ParameterSet[Set][P_UNTERSPANNUNG] = Setting.value("UnderVoltage", 94).toInt(); |
ParameterSet[Set][P_NOTGAS] = Setting.value("NotGas", 35).toInt(); |
ParameterSet[Set][P_NOTGASZEIT] = Setting.value("NotGasTime", 30).toInt(); |
Setting.endGroup(); |
|
Setting.beginGroup("Coupling"); |
ParameterSet[Set][P_ACHS_KOPPLUNG] = Setting.value("YawPosFeedback", 90).toInt(); |
ParameterSet[Set][P_ACHS_GKOPPLUNG] = Setting.value("YawNegFeedback", 5).toInt(); |
Setting.endGroup(); |
|
Setting.beginGroup("Loop"); |
ParameterSet[Set][P_LOOP_CONFIG] = Setting.value("Config", 0).toInt(); |
ParameterSet[Set][P_LOOP_GAS_LIMIT] = Setting.value("GasLimit", 50).toInt(); |
ParameterSet[Set][P_LOOP_THRESHOLD] = Setting.value("StickThreshold", 90).toInt(); |
ParameterSet[Set][P_LOOP_HYSTERESE] = Setting.value("LoopHysteresis", 50).toInt(); |
ParameterSet[Set][P_WINKEL_NICK] = Setting.value("TurnOverNick", 85).toInt(); |
ParameterSet[Set][P_WINKEL_ROLL] = Setting.value("TurnOverRoll", 85).toInt(); |
Setting.endGroup(); |
|
Setting.beginGroup("User"); |
ParameterSet[Set][P_USER_1] = Setting.value("Parameter_1", 0).toInt(); |
ParameterSet[Set][P_USER_2] = Setting.value("Parameter_2", 0).toInt(); |
ParameterSet[Set][P_USER_3] = Setting.value("Parameter_3", 0).toInt(); |
ParameterSet[Set][P_USER_4] = Setting.value("Parameter_4", 0).toInt(); |
ParameterSet[Set][P_USER_5] = Setting.value("Parameter_5", 0).toInt(); |
ParameterSet[Set][P_USER_6] = Setting.value("Parameter_6", 0).toInt(); |
ParameterSet[Set][P_USER_7] = Setting.value("Parameter_7", 0).toInt(); |
ParameterSet[Set][P_USER_8] = Setting.value("Parameter_8", 0).toInt(); |
Setting.endGroup(); |
|
Setting.beginGroup("Output"); |
ParameterSet[Set][P_J16_BITMASK] = Setting.value("J16_Bitmask", 255).toInt(); |
ParameterSet[Set][P_J16_TIMING] = Setting.value("J16_Timing", 251).toInt(); |
ParameterSet[Set][P_J17_BITMASK] = Setting.value("J17_Bitmask", 255).toInt(); |
ParameterSet[Set][P_J17_TIMING] = Setting.value("J17_Timing", 251).toInt(); |
Setting.endGroup(); |
|
Setting.beginGroup("NaviCtrl"); |
ParameterSet[Set][P_NAV_GPS_MODE] = Setting.value("GPS_ModeControl", 253).toInt(); |
ParameterSet[Set][P_NAV_GPS_GAIN] = Setting.value("GPS_Gain", 100).toInt(); |
ParameterSet[Set][P_NAV_GPS_P] = Setting.value("GPS_P", 90).toInt(); |
ParameterSet[Set][P_NAV_GPS_I] = Setting.value("GPS_I", 90).toInt(); |
ParameterSet[Set][P_NAV_GPS_D] = Setting.value("GPS_D", 90).toInt(); |
ParameterSet[Set][P_NAV_GPS_ACC] = Setting.value("GPS_Acc", 0).toInt(); |
ParameterSet[Set][P_NAV_GPS_MIN] = Setting.value("GPS_MinSat", 6).toInt(); |
ParameterSet[Set][P_NAV_STICK_THRE] = Setting.value("GPS_StickThreshold", 8).toInt(); |
Setting.endGroup(); |
|
show_ParameterSet(Set); |
} |
} |
|
void MKTool::show_ParameterSet(int Set) |
{ |
char Name[12]; |
for (int a = 0; a < 12; a++) |
{ |
Name[a] = ParameterSet[Set][P_NAME+a]; |
} |
le_SetName->setText(QString(Name)); |
|
// Seite 1 |
{ |
cb_1_1->setChecked(ParameterSet[Set][P_GLOBAL_CONF] & 0x01); |
cb_1_2->setChecked(ParameterSet[Set][P_GLOBAL_CONF] & 0x02); |
cb_1_3->setChecked(ParameterSet[Set][P_GLOBAL_CONF] & 0x04); |
cb_1_4->setChecked(ParameterSet[Set][P_GLOBAL_CONF] & 0x08); |
cb_1_5->setChecked(ParameterSet[Set][P_GLOBAL_CONF] & 0x10); |
cb_1_6->setChecked(ParameterSet[Set][P_GLOBAL_CONF] & 0x20); |
cb_1_7->setChecked(ParameterSet[Set][P_GLOBAL_CONF] & 0x40); |
cb_1_8->setChecked(ParameterSet[Set][P_GLOBAL_CONF] & 0x80); |
} |
// Seite 2 |
{ |
sb_2_1->setValue(ParameterSet[Set][P_KANAL_NICK]); |
sb_2_2->setValue(ParameterSet[Set][P_KANAL_ROLL]); |
sb_2_3->setValue(ParameterSet[Set][P_KANAL_GAS]); |
sb_2_4->setValue(ParameterSet[Set][P_KANAL_GIER]); |
sb_2_5->setValue(ParameterSet[Set][P_KANAL_POTI1]); |
sb_2_6->setValue(ParameterSet[Set][P_KANAL_POTI2]); |
sb_2_7->setValue(ParameterSet[Set][P_KANAL_POTI3]); |
sb_2_8->setValue(ParameterSet[Set][P_KANAL_POTI4]); |
} |
// Seite 3 |
{ |
sb_3_1->setValue(ParameterSet[Set][P_STICK_P]); |
sb_3_2->setValue(ParameterSet[Set][P_STICK_D]); |
cb_3_3 = setCombo(cb_3_3, Set, P_GIER_P); |
cb_3_4 = setCombo(cb_3_4, Set, P_EXTERNAL); |
} |
// Seite 4 |
{ |
cb_4_1 = setCombo(cb_4_1, Set, P_MAXHOEHE); |
sb_4_2->setValue(ParameterSet[Set][P_MIN_GAS]); |
cb_4_3 = setCombo(cb_4_3, Set, P_HOEHE_P); |
cb_4_4 = setCombo(cb_4_4, Set, P_DRUCK_D); |
cb_4_5 = setCombo(cb_4_5, Set, P_HOEHE_ACC); |
sb_4_6->setValue(ParameterSet[Set][P_HOEHE_GAIN]); |
} |
// Seite 5 |
{ |
cb_5_1 = setCombo(cb_5_1, Set, P_GYRO_P); |
cb_5_2 = setCombo(cb_5_2, Set, P_GYRO_I); |
cb_5_3 = setCombo(cb_5_3, Set, P_DYNAMIC_STAB); |
sb_5_4->setValue(ParameterSet[Set][P_GYRO_ACC_FAKTOR]); |
sb_5_5->setValue(ParameterSet[Set][P_GYRO_ACC_ABGL]); |
cb_5_6 = setCombo(cb_5_6, Set, P_FAKTOR_I); |
sb_5_7->setValue(ParameterSet[Set][P_DRIFT_KOMP]); |
} |
// Seite 6 |
{ |
cb_6_1 = setCombo(cb_6_1, Set, P_SERVO_NICK_CONT); |
sb_6_2->setValue(ParameterSet[Set][P_SERVO_NICK_COMP]); |
sb_6_3->setValue(ParameterSet[Set][P_SERVO_NICK_MIN]); |
sb_6_4->setValue(ParameterSet[Set][P_SERVO_NICK_MAX]); |
sb_6_5->setValue(ParameterSet[Set][P_SERVO_NICK_REFR]); |
cb_6_6->setChecked(ParameterSet[Set][P_SERVO_NICK_COMPI]); |
} |
// Seite 7 |
{ |
sb_7_1->setValue(ParameterSet[Set][P_GAS_MIN]); |
sb_7_2->setValue(ParameterSet[Set][P_GAS_MAX]); |
cb_7_3 = setCombo(cb_7_3, Set, P_KOMPASS_WIRKUNG); |
sb_7_4->setValue(ParameterSet[Set][P_UNTERSPANNUNG]); |
sb_7_5->setValue(ParameterSet[Set][P_NOTGASZEIT]); |
sb_7_6->setValue(ParameterSet[Set][P_NOTGAS]); |
} |
// Seite 8 |
{ |
cb_8_1 = setCombo(cb_8_1, Set, P_ACHS_KOPPLUNG); |
cb_8_2 = setCombo(cb_8_2, Set, P_ACHS_GKOPPLUNG); |
} |
// Seite 9 |
{ |
if (ParameterSet[Set][P_LOOP_CONFIG] & 0x01) |
{ |
tb_9_6->setIcon(Icons[20]); |
tb_9_6->setText("1"); |
} |
else |
{ |
tb_9_6->setIcon(Icons[21]); |
tb_9_6->setText("0"); |
} |
|
if (ParameterSet[Set][P_LOOP_CONFIG] & 0x02) |
{ |
tb_9_7->setIcon(Icons[22]); |
tb_9_7->setText("1"); |
} |
else |
{ |
tb_9_7->setIcon(Icons[23]); |
tb_9_7->setText("0"); |
} |
|
if (ParameterSet[Set][P_LOOP_CONFIG] & 0x04) |
{ |
tb_9_8->setIcon(Icons[24]); |
tb_9_8->setText("1"); |
} |
else |
{ |
tb_9_8->setIcon(Icons[25]); |
tb_9_8->setText("0"); |
} |
|
if (ParameterSet[Set][P_LOOP_CONFIG] & 0x08) |
{ |
tb_9_9->setIcon(Icons[26]); |
tb_9_9->setText("1"); |
} |
else |
{ |
tb_9_9->setIcon(Icons[27]); |
tb_9_9->setText("0"); |
} |
|
cb_9_1 = setCombo(cb_9_1, Set, P_LOOP_GAS_LIMIT); |
sb_9_2->setValue(ParameterSet[Set][P_LOOP_THRESHOLD]); |
sb_9_3->setValue(ParameterSet[Set][P_WINKEL_NICK]); |
sb_9_4->setValue(ParameterSet[Set][P_LOOP_HYSTERESE]); |
sb_9_5->setValue(ParameterSet[Set][P_WINKEL_ROLL]); |
} |
// Seite 10 |
{ |
cb_10_1 = setCombo(cb_10_1, Set, P_USER_1); |
cb_10_2 = setCombo(cb_10_2, Set, P_USER_2); |
cb_10_3 = setCombo(cb_10_3, Set, P_USER_3); |
cb_10_4 = setCombo(cb_10_4, Set, P_USER_4); |
cb_10_5 = setCombo(cb_10_5, Set, P_USER_5); |
cb_10_6 = setCombo(cb_10_6, Set, P_USER_6); |
cb_10_7 = setCombo(cb_10_7, Set, P_USER_7); |
cb_10_8 = setCombo(cb_10_8, Set, P_USER_8); |
} |
// Seite 11 |
{ |
sb_11_1->setValue(ParameterSet[Set][P_J16_BITMASK]); |
cb_11_2 = setCombo(cb_11_2, Set, P_J16_TIMING); |
sb_11_3->setValue(ParameterSet[Set][P_J17_BITMASK]); |
cb_11_4 = setCombo(cb_11_4, Set, P_J17_TIMING); |
} |
// Seite 12 |
{ |
cb_12_1 = setCombo(cb_12_1, Set, P_NAV_GPS_MODE); |
cb_12_2 = setCombo(cb_12_2, Set, P_NAV_GPS_GAIN); |
sb_12_3->setValue(ParameterSet[Set][P_NAV_STICK_THRE]); |
sb_12_4->setValue(ParameterSet[Set][P_NAV_GPS_MIN]); |
cb_12_5 = setCombo(cb_12_5, Set, P_NAV_GPS_P); |
cb_12_6 = setCombo(cb_12_6, Set, P_NAV_GPS_I); |
cb_12_7 = setCombo(cb_12_7, Set, P_NAV_GPS_D); |
cb_12_8 = setCombo(cb_12_8, Set, P_NAV_GPS_ACC); |
|
} |
} |
|
void MKTool::new_RXData(QString RX_Data) |
{ |
char *RX = RX_Data.toLatin1().data(); |
|
if (LastSend.length() > 2) |
{ |
} |
|
switch(RX[2]) |
{ |
case '4' : |
if (Decode64(RX, RX_Data.length())) |
{ |
pb_K1->setValue(DecodeData[1]); |
pb_K2->setValue(DecodeData[2]); |
pb_K3->setValue(DecodeData[3]); |
pb_K4->setValue(DecodeData[4]); |
pb_K5->setValue(DecodeData[5]); |
pb_K6->setValue(DecodeData[6]); |
pb_K7->setValue(DecodeData[7]); |
pb_K8->setValue(DecodeData[8]); |
} |
break; |
case 'D' : |
if (Decode64(RX, RX_Data.length())) |
{ |
for (int i = 0; i < MaxAnalog; i++) |
{ |
AnalogData[i] = DecodeData[i + 1]; |
} |
show_DebugData(); |
|
if (ac_MehrDaten->isChecked()) |
{ |
send_Data('c', TX_Data, 0); |
} |
} |
break; |
case 'L' : |
case 'M' : |
case 'N' : |
case 'O' : |
case 'P' : |
timer->stop(); |
|
Decode64(RX, RX_Data.length(), true); |
memcpy(ParameterSet[sb_Set->value()],DecodeData, sizeof(DecodeData)); |
show_ParameterSet(sb_Set->value()); |
break; |
case 'V' : |
timer->stop(); |
|
Decode64(RX, RX_Data.length(), true); |
QString Version = QString("%1").arg(DecodeData[0]) + "." + QString("%1").arg(DecodeData[1]); |
setWindowTitle(QA_NAME + " v" + QA_VERSION + " - FC Version: " + Version); |
|
if (DecodeData[2] != FC_VERSION) |
{ |
pb_Read->setDisabled(true); |
pb_Write->setDisabled(true); |
|
QMessageBox::warning(this, QA_NAME, |
QA_NAME + " und Flight-Control inkompatibel.\nParameterbearbeitung nicht moeglich.", QMessageBox::Ok); |
} |
else |
{ |
TX_Data[0] = 1; |
TX_Data[1] = 0; |
send_Data('q', TX_Data, 1); |
} |
break; |
} |
} |
|
QString MKTool::add_CRC(QString TXString) |
{ |
unsigned int tmpCRC = 0; |
|
char *TXBuff; |
char CRC[2]; |
|
TXBuff = TXString.toLatin1().data(); |
|
for(int i = 0; i < TXString.length(); i++) |
{ |
tmpCRC += TXBuff[i]; |
} |
|
tmpCRC %= 4096; |
|
CRC[0] = '=' + tmpCRC / 64; |
CRC[1] = '=' + tmpCRC % 64; |
CRC[2] = '\0'; |
|
QString Return = TXString + QString(CRC); |
|
return Return; |
} |
|
bool MKTool::check_CRC(QString RXString) |
{ |
int CRC = 0; |
char *RX; |
|
int Length = RXString.length(); |
|
RX = RXString.toLatin1().data(); |
|
for(int i=0; i < Length-2; i++) |
{ |
CRC+=RX[i]; |
} |
|
CRC -= RX[1]; |
|
CRC = CRC % 4096; |
|
if(RX[Length - 2] != ('=' + (CRC / 64))) |
{ |
return false; |
} |
|
if(RX[Length - 1] != ('=' + CRC % 64)) |
{ |
return false; |
} |
|
return true; |
} |
|
void MKTool::slot_Timer() |
{ |
QByteArray Temp(LastSend.toUtf8()); |
serialPort->sendData(Temp); |
// qDebug("Re-Send"); |
} |
|
void MKTool::slot_Poll() |
{ |
TX_Data[0] = 255; |
TX_Data[1] = 255; |
send_Data('h', TX_Data, 2, false); |
} |
|
void MKTool::slot_SliderMotorTest(int Wert) |
{ |
TX_Data[0] = sl_Front->value(); |
TX_Data[1] = sl_Back->value(); |
TX_Data[2] = sl_Right->value(); |
TX_Data[3] = sl_Left->value(); |
send_Data('t', TX_Data, 4, false); |
} |
|
void MKTool::slot_TabChanged(int Tab) |
{ |
Tab = Tab; |
|
if ((tab_Main->currentIndex() == 1) && (tab_Par->currentIndex() == 1)) |
{ |
Poll->start(500); |
} |
else if (Poll->isActive()) |
{ |
Poll->stop(); |
} |
} |
|
void MKTool::slot_OpenPort() |
{ |
if (serialPort->isOpen()) |
{ |
TX_Data[0] = 0; |
TX_Data[1] = 0; |
TX_Data[2] = 0; |
TX_Data[3] = 0; |
send_Data('t', TX_Data, 4, false); |
|
timer->stop(); |
serialPort->close(); |
pb_Open->setText("Verbinden"); |
ac_ConnectTTY->setText("Verbinden"); |
pb_Open->setIcon(Icons[9]); |
ac_ConnectTTY->setIcon(Icons[9]); |
} |
else |
{ |
serialPort->setPort(le_Port->text()); //Port |
|
serialPort->setBaudRate(BAUD57600); //BaudRate |
serialPort->setDataBits(DATA_8); //DataBits |
serialPort->setParity(PAR_NONE); //Parity |
serialPort->setStopBits(STOP_1); //StopBits |
serialPort->setFlowControl(FLOW_OFF); //FlowControl |
|
serialPort->setTimeout(0, 10); |
serialPort->enableSending(); |
serialPort->enableReceiving(); |
|
serialPort->open(); |
if (serialPort->isOpen()) |
{ |
serialPort->receiveData(); |
|
send_Data('v', TX_Data, 0); |
pb_Open->setText("Trennen"); |
ac_ConnectTTY->setText("Trennen"); |
pb_Open->setIcon(Icons[8]); |
ac_ConnectTTY->setIcon(Icons[8]); |
} |
} |
} |
|
void MKTool::slot_newDataReceived(const QByteArray &dataReceived) |
{ |
allDataReceived += dataReceived; |
|
QTextStream in(dataReceived); |
|
QString decodedStr = in.readAll(); |
|
const char *RXt; |
RXt = dataReceived.data(); |
int a = 0; |
|
while (RXt[a] != '\0') |
{ |
if (RXt[a] == '\r') |
{ |
while ((RXS.length() > 1) && (RXS.at(1) == '#')) |
{ |
RXS.remove(0,1); |
} |
if (check_CRC(RXS)) |
{ |
te_RX->moveCursor(QTextCursor::End, QTextCursor::MoveAnchor); |
te_RX->insertPlainText(RXS + '\r'); |
new_RXData(RXS); |
} |
else |
{ |
// qDebug(RXS.toLatin1().data()); |
// te_RX->insertPlainText(RXS + '\r'); |
} |
|
RXS = QString(""); |
} |
else |
{ |
RXS = RXS + QString(RXt[a]); |
} |
a++; |
} |
} |
|
void MKTool::slot_GetParameter() |
{ |
TX_Data[0] = sb_Set->value(); |
TX_Data[1] = 0; |
send_Data('q', TX_Data, 1); |
} |
|
void MKTool::slot_SetParameter() |
{ |
store_ParameterSet(sb_Set->value()); |
|
for (int a = 0; a < 150; a++) |
{ |
TX_Data[a] = ParameterSet[sb_Set->value()][a]; |
} |
|
store_ParameterSet(sb_Set->value()); |
|
char Set = 'k' + sb_Set->value(); |
send_Data(Set, TX_Data, 83, false); |
} |
|
void MKTool::slot_Quit() |
{ |
if (serialPort->isOpen()) |
{ |
serialPort->close(); |
} |
|
write_Settings(); |
|
if (CSVFile->isOpen()) |
{ |
CSVFile->close(); |
} |
|
close(); |
} |
|
MKTool::~MKTool() |
{ |
write_Settings(); |
qDebug("Ende"); |
} |
|