/QMK-Groundstation/tags/V1.0.1/Classes/cConnection.cpp |
---|
0,0 → 1,264 |
/*************************************************************************** |
* Copyright (C) 2009 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 "cConnection.h" |
cConnection::cConnection() |
{ |
i_Type = 0; |
TTY = new ManageSerialPort(); |
o_Timer = new QTimer(this); |
connect(o_Timer, SIGNAL(timeout()), SLOT(slot_Timer())); |
TTY->setBaudRate(BAUD57600); //BaudRate |
TTY->setDataBits(DATA_8); //DataBits |
TTY->setParity(PAR_NONE); //Parity |
TTY->setStopBits(STOP_1); //StopBits |
TTY->setFlowControl(FLOW_OFF); //FlowControl |
TTY->setTimeout(0, 10); |
TTY->enableSending(); |
TTY->enableReceiving(); |
b_isOpen = false; |
} |
void cConnection::new_Data(QString Data) |
{ |
Data = Data; |
while ((RxData.String.length() > 1) && (RxData.String.at(1) == '#')) |
{ |
RxData.String.remove(0,1); |
} |
if (ToolBox::check_CRC(RxData.String)) |
{ |
RxData.Input = RxData.String.toLatin1().data(); |
emit(newData(RxData)); |
} |
else |
{ |
emit(showTerminal(2, RxData.String)); |
} |
} |
void cConnection::slot_newDataReceived(const QByteArray &dataReceived) |
{ |
const char *RXt; |
RXt = dataReceived.data(); |
int a = 0; |
while (RXt[a] != '\0') |
{ |
if (RXt[a] == '\r') |
{ |
new_Data(QString("")); |
RxData.String = QString(""); |
} |
else |
{ |
RxData.String = RxData.String + QString(RXt[a]); |
} |
a++; |
} |
} |
bool cConnection::isOpen() |
{ |
return b_isOpen; |
} |
bool cConnection::Close() |
{ |
switch(i_Type) |
{ |
case C_TTY : |
{ |
TTY->close(); |
disconnect(TTY, SIGNAL(newDataReceived(const QByteArray &)), this, 0); |
b_isOpen = false; |
} |
break; |
case C_IP : |
{ |
TcpSocket->disconnectFromHost(); |
disconnect(TcpSocket, SIGNAL(connected()), 0, 0); |
disconnect(TcpSocket, SIGNAL(readyRead()), 0, 0); |
disconnect(TcpSocket, SIGNAL(disconnected()), 0, 0); |
b_isOpen = false; |
} |
break; |
} |
return b_isOpen; |
} |
bool cConnection::Open(int Typ, QString Address) |
{ |
switch(Typ) |
{ |
case C_TTY : |
{ |
TTY->setPort(Address); //Port |
TTY->open(); |
ToolBox::Wait(1000); |
if (TTY->isOpen()) |
{ |
connect(TTY, SIGNAL(newDataReceived(const QByteArray &)), this, SLOT(slot_newDataReceived(const QByteArray &))); |
TTY->receiveData(); |
b_isOpen = true; |
i_Type = C_TTY; |
} |
} |
break; |
case C_IP : |
{ |
QStringList Host = Address.split(":"); |
TcpSocket = new(QTcpSocket); |
TcpSocket->connectToHost (Host[1], Host[2].toInt()); |
connect(TcpSocket, SIGNAL(connected()), this, SLOT(slot_IP_Connected()) ); |
// connect(TcpSocket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(slot_Error(QAbstractSocket::SocketError))); |
b_isOpen = true; |
i_Type = C_IP; |
} |
break; |
} |
return b_isOpen; |
} |
void cConnection::slot_IP_Connected() |
{ |
connect(TcpSocket, SIGNAL(readyRead()), SLOT(slot_IP_ReadLine())); |
connect(TcpSocket, SIGNAL(disconnected()),TcpSocket, SLOT(deleteLater())); |
connect(TcpSocket, SIGNAL(disconnected()),this, SLOT(slot_IP_Disconnect())); |
// emit sig_Connected(); |
} |
void cConnection::slot_IP_Disconnect() |
{ |
disconnect(TcpSocket, SIGNAL(disconnected()), 0, 0); |
disconnect(TcpSocket, SIGNAL(readyRead()), 0, 0); |
// emit sig_Disconnected(1); |
} |
void cConnection::slot_IP_ReadLine() |
{ |
QString Input = QString(TcpSocket->readLine(TcpSocket->bytesAvailable())).remove(QChar(' ')); |
int Len = Input.length(); |
for (int z = 0; z < Len; z++) |
{ |
if (Input[z] == '\r') |
{ |
new_Data(QString("")); |
RxData.String = QString(""); |
} |
else |
{ |
RxData.String = RxData.String + Input[z]; |
} |
} |
} |
bool cConnection::send_Cmd(char CMD, int Address, char Data[150],unsigned int Length, bool Resend) |
{ |
if (b_isOpen) |
{ |
QByteArray Temp; |
QString TX_Data; |
if (CMD != '#') |
{ |
TX_Data = ToolBox::Encode64(Data, Length); |
TX_Data = QString("#") + (QString('a' + Address)) + QString(CMD) + TX_Data; |
TX_Data = ToolBox::add_CRC(TX_Data) + '\r'; |
Temp = QByteArray(TX_Data.toUtf8()); |
if (Resend) |
{ |
o_Timer->start(TICKER); |
s_ReSend = Temp; |
} |
} |
else |
{ |
for (unsigned int a = 0; a < Length; a++) |
{ |
Temp[a] = Data[a]; |
} |
} |
switch(i_Type) |
{ |
case C_TTY : |
{ |
TTY->sendData(Temp); |
} |
break; |
case C_IP : |
{ |
TcpSocket->write(Temp); |
} |
break; |
} |
emit(showTerminal(3, TX_Data)); |
} |
return true; |
} |
void cConnection::stop_ReSend() |
{ |
o_Timer->stop(); |
} |
void cConnection::slot_Timer() |
{ |
switch(i_Type) |
{ |
case C_TTY : |
{ |
TTY->sendData(s_ReSend); |
} |
break; |
case C_IP : |
{ |
TcpSocket->write(s_ReSend); |
} |
break; |
} |
emit(showTerminal(3, QString(s_ReSend))); |
} |
/QMK-Groundstation/tags/V1.0.1/Classes/cConnection.h |
---|
0,0 → 1,72 |
/*************************************************************************** |
* Copyright (C) 2009 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. * |
***************************************************************************/ |
#ifndef CCONNECTION_H |
#define CCONNECTION_H |
#include <QObject> |
#include <QTcpSocket> |
#include <QTimer> |
#include "ToolBox.h" |
#include "../global.h" |
#include "../SerialPort/ManageSerialPort.h" |
#define C_TTY 1 |
#define C_IP 2 |
class cConnection : public QObject |
{ |
Q_OBJECT |
public: |
cConnection(); |
bool isOpen(); |
bool Open(int Typ, QString Address); |
bool Close(); |
bool send_Cmd(char CMD, int Address, char Data[150],unsigned int Length, bool Resend = true); |
void stop_ReSend(); |
private: |
ManageSerialPort *TTY; |
QTcpSocket *TcpSocket; |
QTimer *o_Timer; |
QByteArray s_ReSend; |
bool b_isOpen; |
int i_Type; |
sRxData RxData; |
void new_Data(QString Data); |
private slots: |
void slot_newDataReceived(const QByteArray &dataReceived); |
void slot_IP_Connected(); |
void slot_IP_Disconnect(); |
void slot_IP_ReadLine(); |
void slot_Timer(); |
// void slot_Error(QAbstractSocket::SocketError Error); |
signals: |
void newData(sRxData RxData); |
void showTerminal(int Typ, QString Text); |
}; |
#endif // CCONNECTION_H |
/QMK-Groundstation/tags/V1.0.1/Classes/cKML_Server.cpp |
---|
0,0 → 1,136 |
/*************************************************************************** |
* 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 <QStringList> |
#include "cKML_Server.h" |
cKML_Server::cKML_Server() |
{ |
NaviCount = 0; |
} |
void cKML_Server::start_Server(int Port, cSettings *Set) |
{ |
Settings = Set; |
TcpServer = new QTcpServer(); |
if (!TcpServer->listen(QHostAddress::Any, qint16(Port))) |
{ |
qDebug("Kann Serversocket nicht Einrichten..!!"); |
} |
else |
{ |
connect(TcpServer, SIGNAL(newConnection()), this, SLOT(slot_NewConnection())); |
} |
} |
void cKML_Server::stop_Server() |
{ |
delete TcpServer; |
} |
void cKML_Server::store_NaviString(sNaviString Navi) |
{ |
Route[NaviCount] = Navi; |
NaviCount++; |
} |
void cKML_Server::slot_ReadData() |
{ |
if (TcpSocket->canReadLine()) |
{ |
QStringList tokens = QString(TcpSocket->readLine()).split(QRegExp("[ \r\n][ \r\n]*")); |
qDebug() << "QStringList ---------"; |
for (QList<QString>::iterator i = tokens.begin(); i != tokens.end(); ++i) |
qDebug() << (*i); |
} |
TcpSocket->close(); |
} |
void cKML_Server::slot_NewConnection() |
{ |
TcpSocket = TcpServer->nextPendingConnection(); |
connect(TcpSocket, SIGNAL(readyRead ()),this, SLOT(slot_ReadData())); |
QByteArray block; |
block = "HTTP/1.0 200 OK\nContent-Type: application/vnd.google-earth.kml+xml; charset=iso-8859-1\nConnection: close\n\n"; |
// block = "HTTP/1.0 200 OK\nContent-Type: text/xml; charset=utf-8\nConnection: close\n\n"; |
TcpSocket->write(block); |
TcpSocket->write(get_KML()); |
TcpSocket->close(); |
} |
QByteArray cKML_Server::get_KML() |
{ |
QByteArray block; |
block = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" |
"<kml xmlns=\"http://earth.google.com/kml/2.2\">\n" |
" <Document>\n" |
" <name>Online Mikrokopter GPS Position</name>\n" |
" <Style id=\"MK_gps-style\">\n" |
" <LineStyle>\n" |
" <color>ff0000ff</color>\n" |
" <width>2</width>\n" |
" </LineStyle>\n" |
" </Style>\n" |
" <Placemark>\n" |
" <LookAt>\n" |
" <range>400</range>\n" |
" <tilt>45</tilt>\n" |
" </LookAt>\n" |
" <name>Flight</name>\n" |
" <styleUrl>#MK_gps-style</styleUrl>\n" |
" <LineString>\n"; |
if (Settings->Server.ToGround) |
{ |
block = block + " <extrude>1</extrude>\n"; |
} |
block = block + |
" <tessellate>1</tessellate>\n" |
" <altitudeMode>relativeToGround</altitudeMode>\n" |
" <coordinates>\n"; |
for (int a = 0; a < NaviCount; a++) |
{ |
block = block + Route[a].Longitude.toLatin1() + "," + Route[a].Latitude.toLatin1() + "," + Route[a].Altitude.toLatin1() + " " ; |
block = block + "\n"; |
} |
block = block + |
" </coordinates>\n" |
" </LineString>\n" |
" </Placemark>\n" |
" </Document>\n" |
" </kml>\n"; |
return block; |
} |
cKML_Server::~cKML_Server() |
{ |
} |
/QMK-Groundstation/tags/V1.0.1/Classes/cSettings.cpp |
---|
0,0 → 1,303 |
/*************************************************************************** |
* 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 <QCoreApplication> |
#include <QSettings> |
#include <QDir> |
#include "cSettings.h" |
cSettings::cSettings() |
{ |
read_SettingsID(); |
if (Settings_ID < 3) |
{ |
QBitArray Def_TabViews; |
Def_TabViews.fill(true, 6); |
qDebug("Konvertiere Einstellungen Version 1+2 -> 3"); |
QSettings Setting("KeyOz-Net", "QMK-Groundstation"); |
Setting.beginGroup("GUI"); |
GUI.TabViews = Setting.value("TabViews", QBitArray(Def_TabViews)).value<QBitArray>(); |
GUI.TabViews.resize(10); |
GUI.TabViews[6] = true; |
Setting.setValue("TabViews", QBitArray(GUI.TabViews)); |
Setting.endGroup(); |
} |
read_Settings(); |
Analog1.LogView.resize(MaxAnalog); |
Analog1.PlotView.resize(MaxAnalog); |
// Alte Settingsstruktur Löschen. |
if (Settings_ID < 2) |
{ |
qDebug("Konvertiere Einstellungen Version 1 -> 2"); |
QSettings Setting("KeyOz-Net", "QMK-Groundstation"); |
Setting.beginGroup("AnalogWerte"); |
for (int a = 0; a < MaxAnalog; a++) |
{ |
Analog1.LogView.setBit(a, Setting.value(("Analog_" + QString("%1").arg(a) + "_Log"), Def_Log[a]).toBool()); |
Analog1.PlotView.setBit(a, Setting.value(("Analog_" + QString("%1").arg(a) + "_Plot"), Def_Plot_Show[a]).toBool()); |
Analog1.Label[a] = Setting.value(("Analog_" + QString("%1").arg(a)), Def_AnalogNames[a]).toString(); |
} |
Setting.endGroup(); |
Setting.remove("AnalogWerte-FC"); |
Setting.remove("AnalogWerte"); |
write_Settings_Analog(); |
write_Settings_AnalogLabels(); |
} |
else |
{ |
read_Settings_Analog(); |
read_Settings_AnalogLabels(); |
} |
Settings_ID = 3; |
} |
// Config der Analogwert-Anzeige (Plotter / CVS) |
void cSettings::write_Settings_Analog(int ID) |
{ |
QString Hardware = HardwareType[ID]; |
QSettings Setting("KeyOz-Net", "QMK-Groundstation"); |
Setting.beginGroup("Analog-Werte"); |
Setting.setValue(Hardware + "-LogView", QBitArray(Analog1.LogView)); |
Setting.setValue(Hardware + "-PlotView", QBitArray(Analog1.PlotView)); |
Setting.endGroup(); |
} |
void cSettings::read_Settings_Analog(int ID) |
{ |
QBitArray Def_View; |
Def_View.fill(true,MaxAnalog); |
QString Hardware = HardwareType[ID]; |
QSettings Setting("KeyOz-Net", "QMK-Groundstation"); |
Setting.beginGroup("Analog-Werte"); |
Analog1.LogView = Setting.value(Hardware + "-LogView", QBitArray(Def_View)).value<QBitArray>(); |
Analog1.PlotView = Setting.value(Hardware + "-PlotView", QBitArray(Def_View)).value<QBitArray>(); |
Setting.endGroup(); |
} |
// Labels der Analogwerte. |
void cSettings::write_Settings_AnalogLabels(int ID) |
{ |
QString Hardware = HardwareType[ID]; |
QSettings Setting("KeyOz-Net", "QMK-Groundstation-Labels"); |
Setting.beginGroup("Analog-Labels-" + Hardware); |
Setting.setValue("Version", Analog1.Version); |
for (int a=0; a<MaxAnalog; a++) |
{ |
Setting.setValue("Label_" + QString("%1").arg(a), Analog1.Label[a]); |
} |
Setting.endGroup(); |
} |
void cSettings::read_Settings_AnalogLabels(int ID) |
{ |
QString Hardware = HardwareType[ID]; |
QSettings Setting("KeyOz-Net", "QMK-Groundstation-Labels"); |
Setting.beginGroup("Analog-Labels-" + Hardware); |
Analog1.Version = Setting.value(("Version"), "0").toString(); |
for (int a=0; a<MaxAnalog; a++) |
{ |
Analog1.Label[a] = Setting.value(("Label_" + QString("%1").arg(a)), Def_AnalogNames[a]).toString(); |
} |
Setting.endGroup(); |
} |
// Programmeinstellungen |
void cSettings::read_SettingsID() |
{ |
QSettings Setting("KeyOz-Net", "QMK-Groundstation"); |
Setting.beginGroup("Global"); |
Settings_ID = Setting.value("Settings ID", 1).toInt(); |
Setting.endGroup(); |
} |
// Programmeinstellungen |
void cSettings::read_Settings() |
{ |
QBitArray Def_BitArray; |
Def_BitArray.fill(true, 10); |
QDir Dir; |
QString HomeDir = (QString(Dir.homePath() + "/")); |
QSettings Setting("KeyOz-Net", "QMK-Groundstation"); |
Setting.beginGroup("Global"); |
Settings_ID = Setting.value("Settings ID", 1).toInt(); |
Setting.endGroup(); |
Setting.beginGroup("Port"); |
TTY.Port = Setting.value("TTY", QString(OS_PORT)).toString(); |
TTY.MaxPorts = Setting.value("TTY_MAX", 1).toInt(); |
TTY.PortID = Setting.value("TTY_ID", 0).toInt(); |
for (int z = 0; z < TTY.MaxPorts; z++) |
{ |
TTY.Ports[z] = Setting.value("TTY_" + QString("%1").arg(z), QString(OS_PORT)).toString(); |
} |
Setting.endGroup(); |
Setting.beginGroup("GUI"); |
GUI.isMax = Setting.value("IsMax",false).toBool(); |
GUI.Size = Setting.value("Size", QSize(700, 300)).toSize(); |
GUI.Point = Setting.value("Point",QPoint(1,1)).toPoint(); |
GUI.TabViews = Setting.value("TabViews", QBitArray(Def_BitArray)).value<QBitArray>(); |
GUI.ToolViews = Setting.value("ToolViews", QBitArray(Def_BitArray)).value<QBitArray>(); |
GUI.Term_Info = Setting.value("Terminal_Info",false).toBool(); |
GUI.Term_Data = Setting.value("Terminal_Data",true).toBool(); |
GUI.Term_Always = Setting.value("Terminal_Always",false).toBool(); |
GUI.Term_Send = Setting.value("Terminal_Send",true).toBool(); |
Setting.endGroup(); |
Setting.beginGroup("Map"); |
Map.GotoPosition = Setting.value("Goto_Position",true).toBool(); |
Map.ShowTrack = Setting.value("Show_Track",true).toBool(); |
Map.LastLatitude = Setting.value("Last_Latitude",13.5).toDouble(); |
Map.LastLongitude = Setting.value("Last_Longitude",52.5).toDouble(); |
Setting.endGroup(); |
Setting.beginGroup("Dirs"); |
DIR.Logging = Setting.value("LogDir", HomeDir).toString(); |
DIR.Parameter = Setting.value("ParDir", HomeDir).toString(); |
DIR.Cache = Setting.value("Dir_MapCache", HomeDir + ".QMK-Cache").toString(); |
DIR.AVRDUDE = Setting.value("Path_AVRDUDE", "avrdude").toString(); |
Setting.endGroup(); |
Setting.beginGroup("MKData"); |
Data.Plotter_Count = Setting.value("Plotter_Count", 100).toInt(); |
Data.Debug_Fast = Setting.value("Debug_Fast", 100).toInt(); |
Data.Debug_Slow = Setting.value("Debug_Slow", 500).toInt(); |
Data.Debug_Off = Setting.value("Debug_Off", 1000).toInt(); |
Data.Navi_Fast = Setting.value("Navi_Fast", 100).toInt(); |
Data.Navi_Slow = Setting.value("Navi_Slow", 500).toInt(); |
Data.Navi_Off = Setting.value("Navi_Off", 1000).toInt(); |
Setting.endGroup(); |
Setting.beginGroup("GoogleEarth-Server"); |
Server.Port = Setting.value("Port", 10664).toString(); |
Server.StartServer = Setting.value("StartServer", false).toBool(); |
Server.ToGround = Setting.value("ToGround", false).toBool(); |
Setting.endGroup(); |
Setting.beginGroup("QMK-Server"); |
Server.QMKS_Login = Setting.value("Login", "").toString(); |
Server.QMKS_Password = Setting.value("Password", "").toString(); |
Server.QMKS_Host = Setting.value("Host", "nimari.de").toString(); |
Server.QMKS_Port = Setting.value("Port", "16441").toString(); |
Setting.endGroup(); |
} |
void cSettings::write_Settings() |
{ |
QSettings Setting("KeyOz-Net", "QMK-Groundstation"); |
Setting.beginGroup("Global"); |
Setting.setValue("Settings ID", Settings_ID); |
Setting.endGroup(); |
Setting.beginGroup("Port"); |
Setting.setValue("TTY", TTY.Port); |
Setting.setValue("TTY_MAX", TTY.MaxPorts); |
Setting.setValue("TTY_ID", TTY.PortID); |
for (int z = 0; z < TTY.MaxPorts; z++) |
{ |
Setting.setValue("TTY_" + QString("%1").arg(z), TTY.Ports[z]); |
} |
Setting.endGroup(); |
Setting.beginGroup("Dirs"); |
Setting.setValue("LogDir", DIR.Logging); |
Setting.setValue("ParDir", DIR.Parameter); |
Setting.setValue("Dir_MapCache", DIR.Cache); |
Setting.setValue("Path_AVRDUDE", DIR.AVRDUDE); |
Setting.endGroup(); |
Setting.beginGroup("GUI"); |
Setting.setValue("IsMax", GUI.isMax); |
Setting.setValue("Size", GUI.Size); |
Setting.setValue("Point", GUI.Point); |
Setting.setValue("TabViews", QBitArray(GUI.TabViews)); |
Setting.setValue("ToolViews", QBitArray(GUI.ToolViews)); |
Setting.setValue("Terminal_Info", GUI.Term_Info); |
Setting.setValue("Terminal_Data", GUI.Term_Data); |
Setting.setValue("Terminal_Always", GUI.Term_Always); |
Setting.setValue("Terminal_Send", GUI.Term_Send); |
Setting.endGroup(); |
Setting.beginGroup("Map"); |
Setting.setValue("Goto_Position", Map.GotoPosition); |
Setting.setValue("Show_Track", Map.ShowTrack); |
Setting.setValue("Last_Latitude", Map.LastLatitude); |
Setting.setValue("Last_Longitude", Map.LastLongitude); |
Setting.endGroup(); |
Setting.beginGroup("MKData"); |
Setting.setValue("Plotter_Count", Data.Plotter_Count); |
Setting.setValue("Debug_Fast", Data.Debug_Fast); |
Setting.setValue("Debug_Slow", Data.Debug_Slow); |
Setting.setValue("Debug_Off", Data.Debug_Off); |
Setting.setValue("Navi_Fast", Data.Navi_Fast); |
Setting.setValue("Navi_Slow", Data.Navi_Slow); |
Setting.setValue("Navi_Off", Data.Navi_Off); |
Setting.endGroup(); |
Setting.beginGroup("GoogleEarth-Server"); |
Setting.setValue("Port", Server.Port); |
Setting.setValue("StartServer", Server.StartServer); |
Setting.setValue("ToGround", Server.ToGround); |
Setting.endGroup(); |
Setting.beginGroup("QMK-Server"); |
Setting.setValue("Login", Server.QMKS_Login); |
Setting.setValue("Password", Server.QMKS_Password); |
Setting.setValue("Host", Server.QMKS_Host); |
Setting.setValue("Port", Server.QMKS_Port); |
Setting.endGroup(); |
} |
cSettings::~cSettings() |
{ |
} |
/QMK-Groundstation/tags/V1.0.1/Classes/cSettings.h |
---|
0,0 → 1,117 |
/*************************************************************************** |
* 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. * |
***************************************************************************/ |
#ifndef CSETTINGS_H |
#define CSETTINGS_H |
#include "../global.h" |
struct set_TTY |
{ |
QString Port; |
int MaxPorts; |
int PortID; |
QString Ports[10]; |
}; |
struct set_GUI |
{ |
bool isMax; |
QSize Size; |
QPoint Point; |
QBitArray TabViews; |
QBitArray ToolViews; |
bool Term_Info; |
bool Term_Data; |
bool Term_Always; |
bool Term_Send; |
}; |
struct set_Map |
{ |
bool GotoPosition; |
bool ShowTrack; |
double LastLatitude; |
double LastLongitude; |
}; |
struct set_Data |
{ |
int Plotter_Count; |
int Debug_Fast; |
int Debug_Slow; |
int Debug_Off; |
int Navi_Fast; |
int Navi_Slow; |
int Navi_Off; |
}; |
struct set_DIR |
{ |
QString Logging; |
QString Parameter; |
QString Cache; |
QString AVRDUDE; |
}; |
struct set_Server |
{ |
QString Port; |
bool StartServer; |
bool ToGround; |
QString QMKS_Login; |
QString QMKS_Password; |
QString QMKS_Host; |
QString QMKS_Port; |
}; |
struct set_Analog |
{ |
QString Version; |
QString Label[MaxAnalog]; |
QBitArray PlotView; |
QBitArray LogView; |
}; |
class cSettings |
{ |
public: |
cSettings(); |
~cSettings(); |
int Settings_ID; |
set_GUI GUI; |
set_DIR DIR; |
set_TTY TTY; |
set_Analog Analog1; |
set_Data Data; |
set_Server Server; |
set_Map Map; |
void read_Settings(); |
void read_SettingsID(); |
void write_Settings(); |
void write_Settings_Analog(int ID = 0); |
void read_Settings_Analog(int ID = 0); |
void write_Settings_AnalogLabels(int ID = 0); |
void read_Settings_AnalogLabels(int ID = 0); |
}; |
#endif |
/QMK-Groundstation/tags/V1.0.1/Classes/cSpeedMeter.cpp |
---|
0,0 → 1,44 |
#include <qpainter.h> |
#include <qwt_dial_needle.h> |
#include "cSpeedMeter.h" |
cSpeedMeter::cSpeedMeter(QWidget *parent): QwtDial(parent), d_label("m/s") |
{ |
setWrapping(false); |
setReadOnly(true); |
setOrigin(125.0); |
setScaleArc(0.0, 270.0); |
scaleDraw()->setSpacing(8); |
QwtDialSimpleNeedle *needle = new QwtDialSimpleNeedle(QwtDialSimpleNeedle::Arrow, true, Qt::red, QColor(Qt::gray).light(130)); |
setNeedle(needle); |
setScaleOptions(ScaleTicks | ScaleLabel); |
setScaleTicks(0, 4, 8); |
} |
void cSpeedMeter::setLabel(const QString &label) |
{ |
d_label = label; |
update(); |
} |
QString cSpeedMeter::label() const |
{ |
return d_label; |
} |
void cSpeedMeter::drawScaleContents(QPainter *painter, const QPoint ¢er, int radius) const |
{ |
QRect rect(0, 0, 2 * radius, 2 * radius - 10); |
rect.moveCenter(center); |
const QColor color = |
palette().color(QPalette::Text); |
painter->setPen(color); |
const int flags = Qt::AlignBottom | Qt::AlignHCenter; |
painter->drawText(rect, flags, d_label); |
} |
/QMK-Groundstation/tags/V1.0.1/Classes/cSpeedMeter.h |
---|
0,0 → 1,17 |
#include <qstring.h> |
#include <qwt_dial.h> |
class cSpeedMeter: public QwtDial |
{ |
public: |
cSpeedMeter(QWidget *parent = NULL); |
void setLabel(const QString &); |
QString label() const; |
protected: |
virtual void drawScaleContents(QPainter *painter, const QPoint ¢er, int radius) const; |
private: |
QString d_label; |
}; |