/QMK-Groundstation/trunk/Classes/ToolBox.cpp |
---|
0,0 → 1,246 |
/*************************************************************************** |
* 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 "ToolBox.h" |
ToolBox::ToolBox() |
{ |
} |
void ToolBox::Wait(int Time) |
{ |
#ifndef _WIN32_ |
usleep(Time); |
#else |
// sleep(Time); |
#endif |
} |
QString ToolBox::get_Float(long Wert, long Count) |
{ |
QString Temp; |
if (Wert > 0) |
Temp = ""; |
else |
Temp = "-"; |
Temp = Temp + QString("%1").arg(Wert / Count) + "." + QString("%1").arg(Wert % Count); |
return Temp; |
} |
// Base64 Decoder |
bool ToolBox::Decode64(sRxData &RX, 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 = RX.String.length(); |
int len = RX.String.length(); |
int DecLen = 0; |
if (RX.Input[ptrIn] == 0) |
{ |
qDebug("QString to Char ERROR...!!!!"); |
return false; |
} |
while(len != 0) |
{ |
a = RX.Input[ptrIn++] - '='; |
b = RX.Input[ptrIn++] - '='; |
c = RX.Input[ptrIn++] - '='; |
d = RX.Input[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; |
RX.Decode[DecLen] = b3; |
DecLen++; |
} |
else |
{ |
RX.Decode[DecLen] = ptrOut[a]; |
DecLen++; |
} |
RX.DecLen = DecLen; |
} |
return true; |
} |
// Base64 Encoder |
QString ToolBox::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); |
} |
// Datensatz nach 16bit Integer |
int ToolBox::Data2Int(int *Data , int Start, bool is_signed) |
{ |
int Out = (Data[Start+1]<<8) | (Data[Start+0]); |
if ((Out > 32767) && (is_signed)) |
Out = Out - 65536; |
return Out; |
} |
// Datensatz nach 32bit Long |
long ToolBox::Data2Long(int *Data , int Start, bool is_signed) |
{ |
long Out = (Data[Start+3]<<24) | (Data[Start+2]<<16) | (Data[Start+1]<<8) | (Data[Start+0]); |
if ((Out > 32767) && (is_signed)) |
Out = Out; |
return Out; |
} |
// Datensatz nach QString |
QString ToolBox::Data2QString(int Data[150], int Start, int End) |
{ |
char String[150]; |
for (int a = Start; a < End; a++) |
{ |
String[a - Start] = Data[a]; |
} |
String[End - Start] = '\0'; |
return QString(String); |
} |
// Datensatz-CRC prüfen |
bool ToolBox::check_CRC(QString RXString) |
{ |
int CRC = 0; |
char *RX; |
int Length = RXString.length(); |
RX = RXString.toLatin1().data(); |
if (RX[1] == 127) |
{ |
RX[1] = 0; |
} |
for(int i=0; i < Length-2; i++) |
{ |
CRC+=RX[i]; |
} |
CRC = CRC % 4096; |
if(RX[Length - 2] != ('=' + (CRC / 64))) |
{ |
return false; |
} |
if(RX[Length - 1] != ('=' + CRC % 64)) |
{ |
return false; |
} |
return true; |
} |
// Datensatz-CRC hinzufügen |
QString ToolBox::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; |
} |
// Alle Icons |
QIcon ToolBox::Icon(int ID) |
{ |
QIcon Icons[5] ; |
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); |
return Icons[ID]; |
} |
/QMK-Groundstation/trunk/Classes/ToolBox.h |
---|
0,0 → 1,42 |
/*************************************************************************** |
* 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 TOOLBOX_H |
#define TOOLBOX_H |
#include <QString> |
#include <QIcon> |
#include "../global.h" |
class ToolBox |
{ |
public : |
ToolBox(); |
static bool Decode64(sRxData &RX, bool Long = true); |
static QString Encode64(char Data[150],unsigned int Length); |
static bool check_CRC(QString RXString); |
static QString add_CRC(QString TXString); |
static int Data2Int(int *Data , int Start, bool is_signed = true); |
static long Data2Long(int *Data , int Start, bool is_signed = true); |
static QString Data2QString(int Data[150], int Start = 0, int End = 150); |
static QIcon Icon(int ID); |
static QString get_Float(long Wert, long Count); |
static void Wait(int Time); |
}; |
#endif // TOOLBOX_H |
/QMK-Groundstation/trunk/Classes/cAttitude.cpp |
---|
0,0 → 1,136 |
#include <qevent.h> |
#include <qpainter.h> |
#include <qwt_math.h> |
#include <qwt_polygon.h> |
#include "cAttitude.h" |
AttitudeIndicatorNeedle::AttitudeIndicatorNeedle(const QColor &c) |
{ |
QPalette palette; |
for ( int i = 0; i < QPalette::NColorGroups; i++ ) |
{ |
palette.setColor((QPalette::ColorGroup)i, QPalette::Text, c); |
} |
setPalette(palette); |
} |
void AttitudeIndicatorNeedle::draw(QPainter *painter, const QPoint ¢er, int length, double direction, QPalette::ColorGroup cg) const |
{ |
direction *= M_PI / 180.0; |
int triangleSize = qRound(length * 0.1); |
painter->save(); |
// Verschiebung von Pfeil und Linie |
const QPoint p0(QPoint(center.x() + 1, center.y() + 1)); |
const QPoint p01(QPoint(center.x() + 1, center.y() + 10)); |
const QPoint p02(QPoint(center.x() + 1, center.y() - 11)); |
const QPoint p03(QPoint(center.x() + 1, center.y() + 20)); |
const QPoint p04(QPoint(center.x() + 1, center.y() - 21)); |
// Der kleine Pfeil |
const QPoint p1 = qwtPolar2Pos(p0, length - 2 * triangleSize - 2, direction); |
QwtPolygon pa(3); |
pa.setPoint(0, qwtPolar2Pos(p1, 2 * triangleSize, direction)); |
pa.setPoint(1, qwtPolar2Pos(p1, triangleSize, direction + M_PI_2)); |
pa.setPoint(2, qwtPolar2Pos(p1, triangleSize, direction - M_PI_2)); |
const QColor color = palette().color(cg, QPalette::Text); |
painter->setBrush(color); |
painter->drawPolygon(pa); |
painter->setPen(QPen(color, 3)); |
painter->drawLine(qwtPolar2Pos(p0, length - 2, direction + M_PI_2), qwtPolar2Pos(p0, length - 2, direction - M_PI_2)); |
painter->setPen(QPen(QColor(255,255,255), 1)); |
painter->drawLine(qwtPolar2Pos(p01, length - 40, direction + M_PI_2), qwtPolar2Pos(p01, length - 40, direction - M_PI_2)); |
painter->drawLine(qwtPolar2Pos(p02, length - 40, direction + M_PI_2), qwtPolar2Pos(p02, length - 40, direction - M_PI_2)); |
painter->drawLine(qwtPolar2Pos(p03, length - 30, direction + M_PI_2), qwtPolar2Pos(p03, length - 30, direction - M_PI_2)); |
painter->drawLine(qwtPolar2Pos(p04, length - 30, direction + M_PI_2), qwtPolar2Pos(p04, length - 30, direction - M_PI_2)); |
painter->restore(); |
} |
AttitudeIndicator::AttitudeIndicator(QWidget *parent): QwtDial(parent), d_gradient(0.0) |
{ |
setMode(RotateScale); |
setWrapping(true); |
setOrigin(270.0); |
setScaleOptions(ScaleTicks); |
setScale(0, 0, 30.0); |
const QColor color = palette().color(QPalette::Text); |
setNeedle(new AttitudeIndicatorNeedle(color)); |
} |
void AttitudeIndicator::setGradient(double gradient) |
{ |
if ( gradient < -1.0 ) |
gradient = -1.0; |
else if ( gradient > 1.0 ) |
gradient = 1.0; |
if ( d_gradient != gradient ) |
{ |
d_gradient = gradient; |
update(); |
} |
} |
void AttitudeIndicator::drawScale(QPainter *painter, const QPoint ¢er, int radius, double origin, double minArc, double maxArc) const |
{ |
double dir = (360.0 - origin) * M_PI / 180.0; // counter clockwise, radian |
int offset = 4; |
const QPoint p0 = qwtPolar2Pos(center, offset, dir + M_PI); |
const int w = contentsRect().width(); |
QwtPolygon pa(4); |
pa.setPoint(0, qwtPolar2Pos(p0, w, dir - M_PI_2)); |
pa.setPoint(1, qwtPolar2Pos(pa.point(0), 2 * w, dir + M_PI_2)); |
pa.setPoint(2, qwtPolar2Pos(pa.point(1), w, dir)); |
pa.setPoint(3, qwtPolar2Pos(pa.point(2), 2 * w, dir - M_PI_2)); |
painter->save(); |
painter->setClipRegion(pa); // swallow 180 - 360 degrees |
QwtDial::drawScale(painter, center, radius, origin, minArc, maxArc); |
painter->restore(); |
} |
void AttitudeIndicator::drawScaleContents(QPainter *painter, const QPoint &, int) const |
{ |
int dir = 360 - qRound(origin() - value()); // counter clockwise |
int arc = 90 + qRound(gradient() * 90); |
const QColor skyColor(38, 151, 221); |
painter->save(); |
painter->setBrush(skyColor); |
painter->drawChord(scaleContentsRect(), (dir - arc) * 16, 2 * arc * 16 ); |
painter->restore(); |
} |
void AttitudeIndicator::keyPressEvent(QKeyEvent *e) |
{ |
switch(e->key()) |
{ |
case Qt::Key_Plus: |
setGradient(gradient() + 0.05); |
break; |
case Qt::Key_Minus: |
setGradient(gradient() - 0.05); |
break; |
default: |
QwtDial::keyPressEvent(e); |
} |
} |
/QMK-Groundstation/trunk/Classes/cAttitude.h |
---|
0,0 → 1,37 |
#include <QObject> |
#include <qwt_dial.h> |
#include <qwt_dial_needle.h> |
class AttitudeIndicatorNeedle: public QwtDialNeedle |
{ |
public: |
AttitudeIndicatorNeedle(const QColor &); |
virtual void draw(QPainter *, const QPoint &, int length, |
double direction, QPalette::ColorGroup) const; |
}; |
class AttitudeIndicator: public QwtDial |
{ |
Q_OBJECT |
public: |
AttitudeIndicator(QWidget *parent = NULL); |
double angle() const { return value(); } |
double gradient() const { return d_gradient; } |
public slots: |
void setGradient(double); |
void setAngle(double angle) { setValue(angle); } |
protected: |
virtual void keyPressEvent(QKeyEvent *); |
virtual void drawScale(QPainter *, const QPoint ¢er, int radius, double origin, double arcMin, double arcMax) const; |
virtual void drawScaleContents(QPainter *painter, const QPoint ¢er, int radius) const; |
private: |
double d_gradient; |
}; |
/QMK-Groundstation/trunk/Classes/cQMK_Server.cpp |
---|
0,0 → 1,137 |
/*************************************************************************** |
* Copyright (C) 2008-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 "cQMK_Server.h" |
cQMK_Server::cQMK_Server() |
{ |
} |
void cQMK_Server::Connect(QString IP, int Port, QString User, QString Pass) |
{ |
Username = User; |
Password = Pass; |
TcpSocket = new(QTcpSocket); |
TcpSocket->connectToHost (IP, Port); |
connect(TcpSocket, SIGNAL(connected()), this, SLOT(slot_Connected()) ); |
connect(TcpSocket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(slot_Error(QAbstractSocket::SocketError))); |
} |
void cQMK_Server::Disconnect() |
{ |
TcpSocket->disconnectFromHost(); |
disconnect(TcpSocket, SIGNAL(connected()), 0, 0); |
disconnect(TcpSocket, SIGNAL(readyRead()), 0, 0); |
disconnect(TcpSocket, SIGNAL(disconnected()), 0, 0); |
} |
void cQMK_Server::SendData(int CMD, QString Data) |
{ |
QString SendString = QString(QString("%1").arg(CMD) + ":" + Data + ":"); |
int CRC = qChecksum(SendString.toLatin1().data(), SendString.length()); |
QString sCRC = QString("%1").arg(CRC); |
SendString = SendString + sCRC + "\n"; |
QByteArray SendText = SendString.toAscii(); |
TcpSocket->write(SendText); |
} |
void cQMK_Server::NewPosition(sNaviString Pos) |
{ |
if (1==1) |
{ |
SendData(100, QString(Pos.Longitude + ":" + Pos.Latitude + ":" + Pos.Altitude)); |
} |
} |
void cQMK_Server::slot_Connected() |
{ |
// qDebug("Verbunden"); |
connect(TcpSocket, SIGNAL(readyRead()), SLOT(slot_ReadLine())); |
connect(TcpSocket, SIGNAL(disconnected()),TcpSocket, SLOT(deleteLater())); |
connect(TcpSocket, SIGNAL(disconnected()),this, SLOT(slot_Disconnect())); |
emit sig_Connected(); |
} |
void cQMK_Server::slot_Disconnect() |
{ |
// qDebug("Verbindung getrennt "); |
disconnect(TcpSocket, SIGNAL(disconnected()), 0, 0); |
emit sig_Disconnected(1); |
} |
void cQMK_Server::slot_Error(QAbstractSocket::SocketError Error) |
{ |
switch (Error) |
{ |
case QAbstractSocket::ConnectionRefusedError: |
emit sig_Disconnected(2); |
break; |
case QAbstractSocket::RemoteHostClosedError: |
emit sig_Disconnected(1); |
break; |
default: |
emit sig_Disconnected(0); |
break; |
} |
disconnect(TcpSocket, SIGNAL(disconnected()), 0, 0); |
emit sig_Disconnected(2); |
// qDebug("Error..!!"); |
} |
void cQMK_Server::slot_ReadLine() |
{ |
QString Input = QString(TcpSocket->readLine(TcpSocket->bytesAvailable())).remove(QChar('\n')); |
QStringList Data = Input.split(":"); |
if (Data.count() > 1) |
{ |
int CMD = Data[0].toInt(); |
switch(CMD) |
{ |
case 1 : |
{ |
SendData(1, QString(QA_NAME + " " + QA_VERSION + ":" + Username + ":" + Password + ":")); |
} |
break; |
case 2 : |
{ |
// qDebug("Login OK"); |
} |
break; |
case 3 : |
{ |
emit sig_Disconnected(3); |
} |
break; |
} |
} |
} |
/QMK-Groundstation/trunk/Classes/cQMK_Server.h |
---|
0,0 → 1,57 |
/*************************************************************************** |
* Copyright (C) 2008-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 CQMK_SERVER_H |
#define CQMK_SERVER_H |
#include <QString> |
#include <QTcpSocket> |
#include <QStringList> |
#include "../global.h" |
class cQMK_Server : public QObject |
{ |
Q_OBJECT |
public: |
cQMK_Server(); |
void Connect(QString IP, int Port, QString User, QString Pass); |
void Disconnect(); |
void NewPosition(sNaviString Pos); |
private: |
//TCP-Socket |
QTcpSocket *TcpSocket; |
QString Username; |
QString Password; |
void SendData(int CMD, QString Data); |
private slots: |
void slot_Connected(); |
void slot_Disconnect(); |
void slot_ReadLine(); |
void slot_Error(QAbstractSocket::SocketError Error); |
signals: |
void sig_Connected(); |
void sig_Disconnected(int Error); |
}; |
#endif // CQMK_SERVER_H |
/QMK-Groundstation/trunk/Classes/cServer.h |
---|
22,8 → 22,8 |
#include <QTcpServer> |
#include <QTcpSocket> |
#include "../global.h" |
#include "../cSettings.h" |
//#include "../global.h" |
#include "../Classes/cSettings.h" |
class cServer : public QObject |
{ |
/QMK-Groundstation/trunk/Classes/cSettings.cpp |
---|
0,0 → 1,267 |
/*************************************************************************** |
* 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(); |
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("Dirs"); |
DIR.Logging = Setting.value("LogDir", HomeDir).toString(); |
DIR.Parameter = Setting.value("ParDir", HomeDir).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(); |
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.endGroup(); |
Setting.beginGroup("Dirs"); |
Setting.setValue("LogDir", DIR.Logging); |
Setting.setValue("ParDir", DIR.Parameter); |
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("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.endGroup(); |
} |
cSettings::~cSettings() |
{ |
} |
/QMK-Groundstation/trunk/Classes/cSettings.h |
---|
0,0 → 1,101 |
/*************************************************************************** |
* 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; |
}; |
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_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; |
}; |
struct set_Server |
{ |
QString Port; |
bool StartServer; |
bool ToGround; |
QString QMKS_Login; |
QString QMKS_Password; |
}; |
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; |
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/trunk/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/trunk/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; |
}; |