Subversion Repositories Projects

Compare Revisions

Ignore whitespace Rev 305 → Rev 306

/QMK-Groundstation/trunk/Classes/cServer.cpp
File deleted
/QMK-Groundstation/trunk/Classes/cServer.h
File deleted
/QMK-Groundstation/trunk/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/trunk/Classes/cKML_Server.h
0,0 → 1,57
/***************************************************************************
* 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 CKML_SERVER_H
#define CKML_SERVER_H
 
#include <QTcpServer>
#include <QTcpSocket>
 
//#include "../global.h"
#include "../Classes/cSettings.h"
 
class cKML_Server : public QObject
{
Q_OBJECT
 
public:
cKML_Server();
~cKML_Server();
 
void start_Server(int Port, cSettings *Set);
 
void stop_Server();
void store_NaviString(sNaviString Navi);
 
 
private:
QTcpServer *TcpServer;
QTcpSocket *TcpSocket;
 
cSettings *Settings;
 
QByteArray get_KML();
sNaviString Route[MaxNaviPos];
int NaviCount;
 
private slots:
void slot_NewConnection();
void slot_ReadData();
};
 
#endif // CSERVER_H
/QMK-Groundstation/trunk/Classes/cSettings.cpp
148,7 → 148,6
Setting.endGroup();
}
 
 
// Programmeinstellungen
void cSettings::read_Settings()
{
181,9 → 180,16
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();
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");
226,6 → 232,8
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");
240,6 → 248,11
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.endGroup();
 
Setting.beginGroup("MKData");
Setting.setValue("Plotter_Count", Data.Plotter_Count);
Setting.setValue("Debug_Fast", Data.Debug_Fast);
/QMK-Groundstation/trunk/Classes/cSettings.h
39,6 → 39,12
bool Term_Send;
};
 
struct set_Map
{
bool GotoPosition;
bool ShowTrack;
};
 
struct set_Data
{
int Plotter_Count;
54,6 → 60,8
{
QString Logging;
QString Parameter;
QString Cache;
QString AVRDUDE;
};
 
struct set_Server
90,6 → 98,7
set_Analog Analog1;
set_Data Data;
set_Server Server;
set_Map Map;
 
void read_Settings();
void read_SettingsID();