Removes dlbo onging qt5 development income folder
This commit is contained in:
16256 files changed
-3383918
No files matched your search
@@ -1,37 +0,0 @@
|
||||
#
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
#
|
||||
# CMakeLists.txt fuer egcuSimulator
|
||||
#
|
||||
|
||||
|
||||
SET(webserver_SRCS
|
||||
main.cpp
|
||||
egcu_simulator.cpp
|
||||
)
|
||||
|
||||
SET(webserver_HDRS
|
||||
egcu_simulator.h
|
||||
)
|
||||
|
||||
NGL_ADD_EXECUTABLE(WS egcuSimulator ${webserver_SRCS} ${webserver_HDRS})
|
||||
|
||||
|
||||
NGL_TARGET_COMPILE_DEFINITIONS(egcuSimulator
|
||||
PRIVATE
|
||||
${VLC_DEFINES}
|
||||
)
|
||||
|
||||
NGL_TARGET_LINK_LIBRARIES(egcuSimulator
|
||||
PUBLIC
|
||||
${VLC_LIBRARIES}
|
||||
NGLLogger
|
||||
LtsWidgets
|
||||
Qt5::Core
|
||||
Qt5::Network
|
||||
nglapplication
|
||||
)
|
||||
|
||||
NGL_INSTALL_TARGET(webserver_qt)
|
||||
@@ -1,143 +0,0 @@
|
||||
#include "egcu_simulator.h"
|
||||
|
||||
QVector<int> relayStates = {0,0,0,0,0,0,0,0};
|
||||
|
||||
QByteArray createHttpResponse(int statusCode, const QString &contentType, const QString &body)
|
||||
{
|
||||
QString statusText;
|
||||
switch (statusCode)
|
||||
{
|
||||
case 200: statusText = QStringLiteral("OK"); break;
|
||||
case 404: statusText = QStringLiteral("Not Found"); break;
|
||||
case 405: statusText = QStringLiteral("Method Not Allowed"); break;
|
||||
default: statusText = QStringLiteral("Error"); break;
|
||||
}
|
||||
|
||||
QString response;
|
||||
response.append(QString(QStringLiteral("HTTP/1.1 %1 %2\r\n")).arg(statusCode).arg(statusText));
|
||||
response.append(QString(QStringLiteral("Content-Type: %1\r\n")).arg(contentType));
|
||||
response.append(QString(QStringLiteral("Content-Length: %1\r\n")).arg(body.toUtf8().size()));
|
||||
response.append(QString(QStringLiteral("Connection: close\r\n\r\n")));
|
||||
QByteArray responseBa = response.toUtf8();
|
||||
responseBa.append(body.toUtf8());
|
||||
return responseBa;
|
||||
}
|
||||
|
||||
QString sendState()
|
||||
{
|
||||
int i = 0;
|
||||
QString stateString;
|
||||
for (int value : qAsConst(relayStates))
|
||||
{
|
||||
QString state = QStringLiteral("\"");
|
||||
state += QString::number(i);
|
||||
|
||||
if (value == 0)
|
||||
state +=QStringLiteral("\":\"off\",");
|
||||
else
|
||||
state +=QStringLiteral("\":\"on\",");
|
||||
i++;
|
||||
|
||||
stateString += state;
|
||||
}
|
||||
|
||||
stateString.chop(1);
|
||||
|
||||
//return createHttpResponse(200, "text/html", "{\"ID\":\"0x520\",\"Name\":\"Relay Report\",\"State\":{\"0\":\"on\",\"1\":\"off\",\"2\":\"off\",\"3\":\"off\",\"4\":\"off\",\"5\":\"off\",\"6\":\"off\",\"7\":\"off\"}}");
|
||||
QString resultString = QStringLiteral("{\"ID\":\"0x520\",\"Name\":\"Relay Report\",\"State\":{");
|
||||
resultString += stateString;
|
||||
resultString += QStringLiteral("}}");
|
||||
qDebug() << "resultString=" << resultString << "\n";
|
||||
return resultString;
|
||||
}
|
||||
|
||||
|
||||
QByteArray processRequest(const QByteArray &request)
|
||||
{
|
||||
qDebug() << "processRequest:\n" << request;
|
||||
QString requestStr = QString::fromUtf8( request);
|
||||
// Parsen der HTTP-Request-Zeile
|
||||
QStringList lines = requestStr.split(QStringLiteral("\r\n"));
|
||||
QStringList requestLine = lines.first().split(QStringLiteral(" "));
|
||||
QString method = requestLine.value(0);
|
||||
QString path = requestLine.value(1);
|
||||
|
||||
// GET-Anfrage verarbeiten
|
||||
if (method == QStringLiteral("GET"))
|
||||
{
|
||||
qDebug() << "GET path='" << path << "'\n";
|
||||
if (path == QStringLiteral("/"))
|
||||
return createHttpResponse(200, QStringLiteral("text/html"), QStringLiteral("<h1>EGCU-Simulator</h1>"));
|
||||
if (path == QStringLiteral("/relay.php?state=3"))
|
||||
{
|
||||
return createHttpResponse(200, QStringLiteral("text/html"), sendState());
|
||||
}
|
||||
else if (path.contains(QStringLiteral("relay.php"))&&path.contains(QStringLiteral("number")))
|
||||
{
|
||||
// number=0&state=1
|
||||
int startNumberStr= path.indexOf(QStringLiteral("number="));
|
||||
int startNumber = startNumberStr+7;
|
||||
QString numberStr = path.mid(startNumber,1);
|
||||
int number = numberStr.toInt();
|
||||
|
||||
int startStateStr= path.indexOf(QStringLiteral("state="));
|
||||
int startState = startStateStr+6;
|
||||
QString stateStr = path.mid(startState,1);
|
||||
int state = stateStr.toInt();
|
||||
|
||||
relayStates[number] = state;
|
||||
|
||||
qDebug() << "Relais wird geschaltet"
|
||||
<< " number=" << number
|
||||
<< " state=" << state << " \n";
|
||||
|
||||
return createHttpResponse(200, QStringLiteral("text/html"), sendState());
|
||||
}
|
||||
else if (path == QStringLiteral("/about"))
|
||||
return createHttpResponse(200, QStringLiteral("text/html"),QStringLiteral( "</h1>über uns: Qt Webserver</h1>"));
|
||||
else
|
||||
return createHttpResponse(404, QStringLiteral("text/html"), QStringLiteral("<h1>404 - Seite nicht gefunden</h1>"));
|
||||
}
|
||||
|
||||
// POST-Anfrage verarbeiten if (method == "POST") {
|
||||
QString postData = lines.last(); // POST-Daten befinden sich in der letzten Zeile qDebug() << "POST-Daten:" << postData;
|
||||
|
||||
QString responseStr = QStringLiteral("{\"status\": \"success\", \"data\": \"");
|
||||
responseStr += postData;
|
||||
responseStr += QStringLiteral("\"}");
|
||||
|
||||
// return createHttpResponse(200, QStringLiteral("application/json"),
|
||||
// QString("{\"status\": \"success\", \"data\": \"%1\"}").arg(postData));
|
||||
return createHttpResponse(200, QStringLiteral("application/json"),responseStr);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void SimpleWebServer::incomingConnection(qintptr socketDescriptor)
|
||||
{
|
||||
// Bei neuer Verbindung
|
||||
QTcpSocket *clientSocket = new QTcpSocket(this);
|
||||
clientSocket->setSocketDescriptor(socketDescriptor);
|
||||
|
||||
connect(clientSocket, &QTcpSocket::readyRead, [clientSocket]()
|
||||
{
|
||||
// HTTP-Anfrage lesen
|
||||
QByteArray request = clientSocket->readAll();
|
||||
qDebug() << "Anfrage erhalten:\n" << request;
|
||||
|
||||
// Verarbeite die Anfrage
|
||||
QByteArray response = processRequest(request);
|
||||
|
||||
// Antwort senden
|
||||
clientSocket->write(response);
|
||||
clientSocket->disconnectFromHost();
|
||||
|
||||
});
|
||||
|
||||
connect(clientSocket, &QTcpSocket::disconnected, clientSocket, &QTcpSocket::deleteLater);
|
||||
|
||||
qDebug() << "Neue Verbindung von:" << clientSocket->peerAddress().toString();
|
||||
}
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
#ifndef SIMPLEWEBSERVER_H
|
||||
#define SIMPLEWEBSERVER_H
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QTcpServer>
|
||||
#include <QTcpSocket>
|
||||
#include <QDebug>
|
||||
|
||||
|
||||
class SimpleWebServer : public QTcpServer
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
SimpleWebServer(QObject *parent = nullptr) : QTcpServer(parent) {}
|
||||
|
||||
protected:
|
||||
void incomingConnection(qintptr socketDescriptor) override;
|
||||
private:
|
||||
};
|
||||
|
||||
|
||||
#endif // SIMPLEWEBSERVER_H
|
||||
@@ -1,33 +0,0 @@
|
||||
#include <QCoreApplication>
|
||||
#include <QTcpServer>
|
||||
#include <QTcpSocket>
|
||||
#include <QDebug>
|
||||
#include "egcu_simulator.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QCoreApplication a(argc, argv);
|
||||
|
||||
int port = 8080;
|
||||
|
||||
if (argc < 2)
|
||||
{
|
||||
qDebug() << "Bitte Port als Parameter beim Aufruf mit angeben!";
|
||||
qDebug() << "egcuSimulator läuft per Default mit port 8080";
|
||||
}
|
||||
else
|
||||
{
|
||||
port = std::stoi(argv[1]);
|
||||
qDebug() << "Port=" << port;
|
||||
}
|
||||
|
||||
SimpleWebServer server;
|
||||
if (!server.listen(QHostAddress::Any, port))
|
||||
{
|
||||
qCritical() << "Server konnte nicht gestartet werden:" << server.errorString();
|
||||
return 1;
|
||||
}
|
||||
|
||||
qDebug() << "Server läuft auf Port" << port << "...";
|
||||
return a.exec();
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
ICD zur Gebäudeinstrumentierung:
|
||||
- GUEZRG50_ICD-0021_MASIE-Gebäudeinstrumentierung-Beschuss.doc
|
||||
|
||||
Effect Konfig File:
|
||||
- open effectConfigFile: /shd/CTC/TOOLS/TDS/TDS-build-3dWs/share/Lts/Buildings/effect_config.xml (s/BuildingControlUnit/ControlEffects/xmlreader.cpp:30)
|
||||
|
||||
------------------------------------------------
|
||||
--- Vorbereitungen und Start des EgcuSimulators:
|
||||
------------------------------------------------
|
||||
|
||||
EGCU mit Webtool infrastructure.html oder Justus-Tool mounten
|
||||
|
||||
Für einen einfachen Test in der hosttabelle einfach localhost für den Hostnamen der EGCU eintragen.
|
||||
|
||||
Auf meinem Entwicklungsrechner konnte ich nicht mit dem Port 80 arbeiten und habe ihn in der Konfig-Datei /shd/CTC/TOOLS/TDS/TDS-build-3dWs/share/Lts/Buildings/effect_config.xml im Eintrag port auf 8080 gesetzt.
|
||||
|
||||
EgcuSimulator starten:
|
||||
|
||||
cd bin
|
||||
./egcuSimulator (läuft per defaultmit dem Port 8080)
|
||||
|
||||
Im Güz wird der Port 80 genommen und man kann den egcuSimulator auch mit dem Port als Übergabeparameter starten
|
||||
|
||||
Im EGCU-Fenster Relais schalten, da sich der Simulator keine States merkt.
|
||||
|
||||
Zum Testen von Verbindungsabbrüchen egcuSimulator beenden und nach einem Timeout, wenn im EGCU-Info-Fenster der Relais-Status braun eingefärbt wird, neu starten
|
||||
Reference in new issue
Block a user