Qt6 Migration: Complete migration with DDS/RTI support and build validation
Major Changes:
- Merged latest Qt5 devel content from dlbo (292 files changed, 7 new dirs)
- Consolidated forward-declarations and include folders
- Removed unneeded modules per Niklas' repo check list
Build System Fixes:
- Fixed CMake VERSION_GREATER syntax in ParticipantManagement/CMakeLists.txt
- Added VLC packages (libvlc-dev, vlc-plugin-base) to docker_build.sh
- Added PostgreSQL dev packages (libpq-dev, postgresql-server-dev-all) to Dockerfile
- Fixed locale warnings (ANSI_X3.4-1968 → C.UTF-8)
- Fixed ArcGIS SDK path warnings when BUILD_ARCGIS=OFF
Code Generation Fixes:
- Fixed IDL enum collisions (PortType→CorePortType/DdsutPortType, PdmEventType)
- Fixed Grantlee template svc_translation.cpp.grantlee:
- Changed {{ idl_enum.name }}_def:: to {{ idl_enum.name }}::
- Fixed .underlying() calls for C++11 scoped enums (enum class)
- Removed generated files from repo (moc_*, *_dtc.h, *_ftc.h)
Validation:
- BUILD_RTI=ON: SUCCESS
- BUILD_RTI=OFF: SUCCESS
- C++17 standard maintained for RTI 7.7 compatibility
- Ubuntu 26.04 Docker environment verified
Remaining Warnings (expected):
- BgViewer, KDChart, KDReports, Poppler-Qt6 not found (optional features)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
18662 files changed
+4115092
-5435
No files matched your search
+61
-4
@@ -14,13 +14,18 @@
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QInputDialog>
|
||||
#include <QtCore/QJsonDocument>
|
||||
#include <QtWidgets/QLineEdit>
|
||||
#include <QJsonDocument>
|
||||
#include <QLineEdit>
|
||||
#include <QPushButton>
|
||||
#include <QtCore/QString>
|
||||
#include <QtCore/QTime>
|
||||
#include <QString>
|
||||
#include <QTime>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#include <QFileDialog>
|
||||
#include <QFile>
|
||||
#include <QMessageBox>
|
||||
#include <QSettings>
|
||||
|
||||
#include <AdlerJson/generatetelegrams.h>
|
||||
#include <AdlerJson/telegrams.h>
|
||||
|
||||
@@ -41,6 +46,7 @@ ICDTest::ICDTest(QWidget *parent)
|
||||
generatePositionReportsPage();
|
||||
generateTextMessagePage();
|
||||
generateErkundungsergebnissePage();
|
||||
generateFilePage();
|
||||
connect(m_ui->tbTrash, &QToolButton::clicked, m_ui->textEdit, &QTextEdit::clear);
|
||||
connect(m_ui->tbRestart, &QToolButton::clicked, this, &ICDTest::doRestart);
|
||||
connect(&m_heartbeatTimer, &QTimer::timeout, this, &ICDTest::generateConnectionTestMessage);
|
||||
@@ -1170,6 +1176,57 @@ void ICDTest::generateErkundungsergebnissePage()
|
||||
m_ui->toolBox->addItem(widget, tr("Erkundungsergebnisse"));
|
||||
}
|
||||
|
||||
void ICDTest::selectAndSendJson() {
|
||||
// 1. QSettings initialisieren
|
||||
QSettings settings(QStringLiteral("Legatus"), QStringLiteral("JsonWebsocketSender"));
|
||||
|
||||
// 2. Letzten Pfad auslesen (Standard: leerer String)
|
||||
QString lastDir = settings.value(QStringLiteral("lastDirectory"), QStringLiteral("")).toString();
|
||||
|
||||
// 3. Dialog mit dem letzten Pfad öffnen
|
||||
QString filePath = QFileDialog::getOpenFileName(this,
|
||||
tr("Select JSON file"),
|
||||
lastDir, // Hier wird der gemerkte Pfad übergeben
|
||||
tr("JSON Files (.json);;Text Files (.txt)"));
|
||||
|
||||
if (filePath.isEmpty()) return;
|
||||
|
||||
// 4. Neuen Pfad für das nächste Mal speichern
|
||||
QFileInfo fileInfo(filePath);
|
||||
settings.setValue(QStringLiteral("lastDirectory"), fileInfo.absolutePath());
|
||||
|
||||
// 5. Datei einlesen
|
||||
QFile file(filePath);
|
||||
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
QMessageBox::critical(this, tr("Error"), tr("Couldn't open file"));
|
||||
return;
|
||||
}
|
||||
|
||||
m_pendingData = file.readAll();
|
||||
file.close();
|
||||
|
||||
QString message = QString::fromUtf8(m_pendingData);
|
||||
m_ui->textEdit->append(message);
|
||||
emit messsageToProxy(message);
|
||||
|
||||
}
|
||||
|
||||
void ICDTest::generateFilePage()
|
||||
{
|
||||
QVBoxLayout *lay = new QVBoxLayout(this);
|
||||
QSpacerItem *item = new QSpacerItem(1, 1, QSizePolicy::Minimum, QSizePolicy::MinimumExpanding);
|
||||
QWidget *widget = new QWidget(this);
|
||||
|
||||
QPushButton *btnEXAQ = new QPushButton(tr("JSON Files"));
|
||||
connect(btnEXAQ, &QPushButton::clicked, this, &ICDTest::selectAndSendJson);
|
||||
lay->addWidget(btnEXAQ);
|
||||
|
||||
lay->addItem(item);
|
||||
widget->setLayout(lay);
|
||||
m_ui->toolBox->addItem(widget, tr("Load JSON File"));
|
||||
}
|
||||
|
||||
|
||||
void ICDTest::generateStatusPage()
|
||||
{
|
||||
QVBoxLayout *lay = new QVBoxLayout(this);
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <QtCore/QTimer>
|
||||
#include <QtWidgets/QWidget>
|
||||
#include <QTimer>
|
||||
#include <QWidget>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
@@ -82,6 +82,7 @@ class ICDTest : public QWidget
|
||||
void generateEXFlugbahnberechnung(); // Flugbahnberechnung
|
||||
void generateEXFlugbahndaten(); // Flugbahndaten
|
||||
void onSendHeartbeatChanged();
|
||||
void selectAndSendJson();
|
||||
|
||||
private:
|
||||
void generateConnectionPage();
|
||||
@@ -91,6 +92,7 @@ class ICDTest : public QWidget
|
||||
void generateTrajectoryGenerationPage();
|
||||
void generateTextMessagePage();
|
||||
void generateErkundungsergebnissePage();
|
||||
void generateFilePage();
|
||||
void generateStatusPage();
|
||||
void generateEXSQWS_1WS(const QString &verein, const QString &kenner);
|
||||
|
||||
@@ -101,6 +103,7 @@ class ICDTest : public QWidget
|
||||
QTimer m_heartbeatTimer;
|
||||
QString m_lastFeuerkampfReferenz;
|
||||
QString m_fixedReference;
|
||||
QByteArray m_pendingData;
|
||||
};
|
||||
|
||||
} // namespace AdlerWebSocketSimulator
|
||||
@@ -23,19 +23,20 @@ ADD_SUBDIRECTORY(ParticipantDataGenerator)
|
||||
ADD_SUBDIRECTORY(ProjectSettingsEditor)
|
||||
ADD_SUBDIRECTORY(QLedLine)
|
||||
ADD_SUBDIRECTORY(QLedMatrix)
|
||||
ADD_SUBDIRECTORY(RestClientUi)
|
||||
ADD_SUBDIRECTORY(ScreenIdShow)
|
||||
ADD_SUBDIRECTORY(SerialToTcpConverter)
|
||||
ADD_SUBDIRECTORY(Splash)
|
||||
ADD_SUBDIRECTORY(SqlBrowser)
|
||||
ADD_SUBDIRECTORY(DateTimeSyncer)
|
||||
ADD_SUBDIRECTORY(Times)
|
||||
IF(BUILD_RTI)
|
||||
ADD_SUBDIRECTORY(TopicDiscover)
|
||||
ENDIF()
|
||||
ADD_SUBDIRECTORY(TopicDiscover)
|
||||
ADD_SUBDIRECTORY(VapixConfig)
|
||||
ADD_SUBDIRECTORY(Automount)
|
||||
ADD_SUBDIRECTORY(EgcuSimulator)
|
||||
ADD_SUBDIRECTORY(TextEditorTest)
|
||||
#ADD_SUBDIRECTORY(Examples/Plugins)
|
||||
ADD_SUBDIRECTORY(Examples/TestGuiElement)
|
||||
|
||||
#ADD_SUBDIRECTORY(VideoImport)
|
||||
ADD_SUBDIRECTORY(VulnerabilityStateGenerator)
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
#
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
# Created by Hannes Fritsche, SLSE, 2017-09-05
|
||||
#
|
||||
|
||||
SET(SRCS
|
||||
mainwindow.cpp
|
||||
mainwindow.h
|
||||
main.cpp
|
||||
message_model.cpp
|
||||
message_model.h
|
||||
ui/mainwindow.ui
|
||||
)
|
||||
|
||||
NGL_WRAP_UI(SRCS ui/mainwindow.ui)
|
||||
|
||||
NGL_ADD_EXECUTABLE(WS NO_TRANSLATION CnrProxyTester ${SRCS})
|
||||
|
||||
NGL_TARGET_LINK_LIBRARIES(CnrProxyTester
|
||||
Qt5::Widgets
|
||||
Qt5::Core
|
||||
Qt5::WebSockets
|
||||
nglapplication
|
||||
LtsDataView
|
||||
LtsWidgets
|
||||
nglwidgets
|
||||
LtsPluginLoader
|
||||
StylePluginInterface
|
||||
LtsUtilsCoreHeaderOnly
|
||||
)
|
||||
|
||||
NGL_INSTALL_TARGET_DEVEL(CnrProxyTester)
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Hannes Fritsche, SLSE, 2017-09-06
|
||||
*/
|
||||
|
||||
#include "mainwindow.h"
|
||||
#include <nglapplication/nglapplication.h>
|
||||
|
||||
#include <LtsPluginManager/lts_plugin_loader.h>
|
||||
#include <PluginInterfaces/style_plugin_interface.h>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
NGLApplication app(argc, argv);
|
||||
app.createLogger("CNR Proxy Tester");
|
||||
QCoreApplication::setApplicationName(QLatin1String("CNR Proxy Tester"));
|
||||
QCoreApplication::setOrganizationName(QLatin1String("RME"));
|
||||
|
||||
LtsPluginManager::LtsPluginLoader::getInstance()->loadPlugins(LtsPluginManager::PluginType::STYLE, nullptr
|
||||
, QStringList() << QStringLiteral("rme.light")); // load style plugin
|
||||
|
||||
|
||||
MainWindow w;
|
||||
w.show();
|
||||
|
||||
app.setQuitOnLastWindowClosed(true);
|
||||
|
||||
int retval = app.exec();
|
||||
|
||||
return retval;
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Hannes Fritsche, SLSE, 2017-09-06
|
||||
*/
|
||||
|
||||
#include "mainwindow.h"
|
||||
#include "ui_mainwindow.h"
|
||||
#include "message_model.h"
|
||||
#include <nglsettings/nglsettings_settings.h>
|
||||
|
||||
#include <QJsonDocument>
|
||||
#include <QtWebSockets/QWebSocket>
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent)
|
||||
: NGLMainWindow(parent)
|
||||
, m_ui(new Ui::MainWindow)
|
||||
, m_socket(new QWebSocket(QString(), QWebSocketProtocol::Version13, this))
|
||||
, m_messageModel(new MessageModel(this))
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
setWindowTitle(QLatin1String("CNR Tester"));
|
||||
|
||||
connect(m_ui->pbConnect, &QPushButton::clicked,
|
||||
this, &MainWindow::onConnectClicked);
|
||||
connect(m_ui->pbDisconnect, &QPushButton::clicked,
|
||||
this, &MainWindow::onDisconnectClicked);
|
||||
connect(m_ui->pbGetPositionsCnr, &QPushButton::clicked,
|
||||
this, &MainWindow::onSendGetPositionsCnrClicked);
|
||||
connect(m_ui->pbSendError, &QPushButton::clicked,
|
||||
this, &MainWindow::onSendErrorClicked);
|
||||
connect(m_ui->pbSendGetConfigCnr, &QPushButton::clicked,
|
||||
this, &MainWindow::onSendGetConfigCnrClicked);
|
||||
connect(m_ui->pbSendGetEssentials, &QPushButton::clicked,
|
||||
this, &MainWindow::onSendGetEssentialsClicked);
|
||||
connect(m_socket, &QWebSocket::stateChanged,
|
||||
this, &MainWindow::onNewSocketState);
|
||||
connect(m_socket, &QWebSocket::textMessageReceived,
|
||||
this, &MainWindow::onNewTextMessageFromSocket);
|
||||
connect(m_ui->pbClearMessages, &QPushButton::clicked,
|
||||
m_messageModel, &MessageModel::clear);
|
||||
|
||||
m_ui->dvMessages->setModel(m_messageModel);
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void MainWindow::onSendGetEssentialsClicked()
|
||||
{
|
||||
newMessageToServer(QLatin1String("getEssentials"));
|
||||
}
|
||||
|
||||
void MainWindow::onSendGetConfigCnrClicked()
|
||||
{
|
||||
newMessageToServer(QLatin1String("getConfigCNR"));
|
||||
}
|
||||
|
||||
void MainWindow::onSendGetPositionsCnrClicked()
|
||||
{
|
||||
int32_t repeat = m_ui->leCnrPosRepeat->text().toInt();
|
||||
|
||||
QJsonObject obj;
|
||||
|
||||
obj.insert(QLatin1String("repeat"), repeat);
|
||||
|
||||
newMessageToServer(QLatin1String("getPositionsCNR"), QUuid::createUuid().toString(), obj);
|
||||
}
|
||||
|
||||
void MainWindow::onSendErrorClicked()
|
||||
{
|
||||
QJsonObject obj;
|
||||
|
||||
obj.insert(QLatin1String("errorClass"), m_ui->leErrorClass->text().toInt());
|
||||
obj.insert(QLatin1String("errorMessage"), m_ui->leErrorMessage->text());
|
||||
obj.insert(QLatin1String("uuid"), m_ui->leErrorUuid->text());
|
||||
|
||||
newMessageToServer(QLatin1String("error"), QString(), obj);
|
||||
}
|
||||
|
||||
void MainWindow::onConnectClicked()
|
||||
{
|
||||
m_socket->open(QUrl(QStringLiteral("ws://%1:%2").arg(m_ui->leHost->text(), m_ui->lePort->text())));
|
||||
}
|
||||
|
||||
void MainWindow::onDisconnectClicked()
|
||||
{
|
||||
m_socket->close();
|
||||
}
|
||||
|
||||
void MainWindow::onNewSocketState(QAbstractSocket::SocketState state)
|
||||
{
|
||||
m_ui->lbState->setText(QVariant::fromValue(state).toString());
|
||||
|
||||
m_ui->pbConnect->setEnabled(state != QAbstractSocket::ConnectedState);
|
||||
m_ui->pbDisconnect->setEnabled(state == QAbstractSocket::ConnectedState);
|
||||
}
|
||||
|
||||
void MainWindow::onNewTextMessageFromSocket(const QString &message)
|
||||
{
|
||||
m_messageModel->addMessage(MessageModel::FROM_PROXY, message);
|
||||
}
|
||||
|
||||
void MainWindow::newMessageToServer(const QString &type, const QString &uuid, const QJsonObject &data)
|
||||
{
|
||||
if (!m_socket || m_socket->state() != QAbstractSocket::ConnectedState)
|
||||
return;
|
||||
|
||||
QJsonObject obj;
|
||||
|
||||
obj.insert(QLatin1String("type"), type);
|
||||
obj.insert(QLatin1String("data"), data);
|
||||
if (!uuid.isNull())
|
||||
obj.insert(QLatin1String("uuid"), uuid);
|
||||
|
||||
m_socket->sendTextMessage(QString::fromUtf8(QJsonDocument(obj).toJson()));
|
||||
m_messageModel->addMessage(MessageModel::TO_PROXY, type, uuid, obj.value(QLatin1String("data")).toString());
|
||||
}
|
||||
|
||||
void MainWindow::setVersionView()
|
||||
{
|
||||
return;
|
||||
// m_versionView = new VersionView(NGLSettings::instance(), tr("CNR Proxy Tester"), this);
|
||||
// connect(m_versionView, SIGNAL(destroyed()), this, SLOT(onVersionViewDeleted()), Qt::DirectConnection);
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Hannes Fritsche, SLSE, 2017-09-06
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <nglwidgets/nglmainwindow.h>
|
||||
#include <QJsonObject>
|
||||
#include <QUuid>
|
||||
#include <QtNetwork/QAbstractSocket>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class MainWindow;
|
||||
}
|
||||
|
||||
class QWebSocket;
|
||||
class MessageModel;
|
||||
|
||||
class MainWindow
|
||||
: public NGLMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MainWindow(QWidget *parent = nullptr);
|
||||
~MainWindow();
|
||||
|
||||
private Q_SLOTS:
|
||||
void onSendGetEssentialsClicked();
|
||||
void onSendGetConfigCnrClicked();
|
||||
void onSendGetPositionsCnrClicked();
|
||||
void onSendErrorClicked();
|
||||
void onConnectClicked();
|
||||
void onDisconnectClicked();
|
||||
void onNewSocketState(QAbstractSocket::SocketState state);
|
||||
void onNewTextMessageFromSocket(const QString &message);
|
||||
|
||||
void setVersionView() override final;
|
||||
|
||||
|
||||
private: // methods
|
||||
void newMessageToServer(const QString &type, const QString &uuid = QUuid::createUuid().toString(), const QJsonObject &data = QJsonObject());
|
||||
|
||||
private: // attributes
|
||||
Ui::MainWindow *m_ui;
|
||||
QWebSocket *m_socket;
|
||||
MessageModel *m_messageModel;
|
||||
|
||||
};
|
||||
@@ -0,0 +1,112 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* The MessageModel class handles message related data
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Hannes Fritsche, SLSE, 2017-09-06
|
||||
*/
|
||||
|
||||
#include "message_model.h"
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonArray>
|
||||
|
||||
MessageModel::MessageModel(QObject *parent)
|
||||
: LtsAbstractTableModel<MessageInfo>( { tr("Time"), tr("Direction"), tr("Type"), tr("UUID"), tr("Data") }, parent)
|
||||
{
|
||||
setData(QVector<MessageInfo>());
|
||||
}
|
||||
|
||||
void MessageModel::addMessage(MessageModel::MessageDirection direction, const QString &message)
|
||||
{
|
||||
QJsonParseError parseError;
|
||||
|
||||
QString uuid = QLatin1String("-");
|
||||
QString data = uuid;
|
||||
|
||||
QJsonDocument doc = QJsonDocument::fromJson(message.toLatin1(), &parseError);
|
||||
|
||||
QString type;
|
||||
|
||||
if (parseError.error != QJsonParseError::NoError)
|
||||
type = parseError.errorString();
|
||||
else if (!doc.isObject())
|
||||
type = QLatin1String("invalid");
|
||||
else
|
||||
{
|
||||
QJsonObject obj = doc.object();
|
||||
|
||||
type = obj.value(QLatin1String("type")).toString(QLatin1String("not present"));
|
||||
uuid = obj.value(QLatin1String("uuid")).toString(QLatin1String("not present"));
|
||||
|
||||
QJsonObject dataObj = obj.value(QLatin1String("data")).toObject();
|
||||
|
||||
if (dataObj.isEmpty())
|
||||
data = QLatin1String("not present");
|
||||
else
|
||||
data = QString::fromUtf8(QJsonDocument(dataObj).toJson());
|
||||
}
|
||||
|
||||
addMessage(direction, type, uuid, data);
|
||||
}
|
||||
|
||||
void MessageModel::addMessage(MessageModel::MessageDirection direction, const QString &type, const QString &uuid, const QString &data)
|
||||
{
|
||||
int32_t rows = rowCount();
|
||||
|
||||
onDataChanged({rows, toString(direction), type, uuid, data}, DataModification::eAdded);
|
||||
}
|
||||
|
||||
QVariant MessageModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (role != Qt::DisplayRole || !indexIsValid(index))
|
||||
return QVariant();
|
||||
|
||||
const MessageInfo &infoData = m_vecData.at(index.row());
|
||||
|
||||
switch (index.column())
|
||||
{
|
||||
case TIME:
|
||||
return infoData.time.toString();
|
||||
case DIRECTION:
|
||||
return infoData.direction;
|
||||
case TYPE:
|
||||
return infoData.type;
|
||||
case UUID:
|
||||
return infoData.uuid;
|
||||
case DATA:
|
||||
{
|
||||
if (!infoData.data.size())
|
||||
return infoData.data;
|
||||
|
||||
QJsonObject obj = QJsonDocument::fromJson(infoData.data.toLatin1()).object();
|
||||
QString result = infoData.data;
|
||||
const QStringList keys = obj.keys();
|
||||
|
||||
for (const QString ¤tKey : keys)
|
||||
{
|
||||
const QJsonValue subObj = obj.value(currentKey);
|
||||
if (subObj.isArray())
|
||||
result.prepend(QStringLiteral("%1 size: %2\n").arg(currentKey).arg(subObj.toArray().size()));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
QString MessageModel::toString(MessageModel::MessageDirection direction) const
|
||||
{
|
||||
switch (direction)
|
||||
{
|
||||
case TO_PROXY:
|
||||
return tr(" > to Proxy");
|
||||
case FROM_PROXY:
|
||||
return tr(" < from Proxy");
|
||||
default:
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* The MessageModel class handles message related data
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Hannes Fritsche, SLSE, 2017-09-06
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LtsWidgets/lts_abstract_table_model.h>
|
||||
#include <QDateTime>
|
||||
|
||||
class QWebSocket;
|
||||
|
||||
struct MessageInfo
|
||||
{
|
||||
QDateTime time;
|
||||
int32_t idVal;
|
||||
QString direction;
|
||||
QString type;
|
||||
QString uuid;
|
||||
QString data;
|
||||
|
||||
MessageInfo(int32_t id, const QString &direction, const QString &type, const QString &uuid, const QString &data)
|
||||
: time(QDateTime::currentDateTime())
|
||||
, idVal(id)
|
||||
, direction(direction)
|
||||
, type(type)
|
||||
, uuid(uuid)
|
||||
, data(data)
|
||||
{}
|
||||
|
||||
MessageInfo()
|
||||
: time(QDateTime::currentDateTime())
|
||||
, idVal(-1)
|
||||
, direction(QLatin1String("-"))
|
||||
, type(QLatin1String("-"))
|
||||
, uuid(QLatin1String("-"))
|
||||
, data(QLatin1String("-"))
|
||||
{}
|
||||
|
||||
int32_t id() const { return idVal; }
|
||||
};
|
||||
|
||||
class MessageModel
|
||||
: public LtsWidgets::LtsAbstractTableModel<MessageInfo>
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum MessageDirection
|
||||
{
|
||||
TO_PROXY,
|
||||
FROM_PROXY
|
||||
};
|
||||
|
||||
enum Column
|
||||
{
|
||||
TIME,
|
||||
DIRECTION,
|
||||
TYPE,
|
||||
UUID,
|
||||
DATA
|
||||
};
|
||||
|
||||
MessageModel(QObject *parent = nullptr);
|
||||
|
||||
void addMessage(MessageDirection direction, const QString &message);
|
||||
void addMessage(MessageDirection direction, const QString &type, const QString &uuid, const QString &data);
|
||||
|
||||
QVariant data(const QModelIndex &index, int role) const override final;
|
||||
|
||||
private: // methods
|
||||
QString toString(MessageDirection direction) const;
|
||||
|
||||
public:
|
||||
};
|
||||
|
||||
@@ -0,0 +1,267 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MainWindow</class>
|
||||
<widget class="QMainWindow" name="MainWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1101</width>
|
||||
<height>642</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true">MainWindow</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0" colspan="2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Host:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="leHost">
|
||||
<property name="text">
|
||||
<string notr="true">localhost</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Port:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lePort">
|
||||
<property name="text">
|
||||
<string notr="true">2081</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Connection State:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lbState">
|
||||
<property name="text">
|
||||
<string notr="true">-</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QPushButton" name="pbConnect">
|
||||
<property name="text">
|
||||
<string>Connect</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QPushButton" name="pbDisconnect">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Disconnect</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="2">
|
||||
<widget class="Line" name="line1">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Get Essentials Message</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QPushButton" name="pbSendGetEssentials">
|
||||
<property name="text">
|
||||
<string>Send</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Get Config CNR</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="0">
|
||||
<widget class="QPushButton" name="pbSendGetConfigCnr">
|
||||
<property name="text">
|
||||
<string>Send</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QGroupBox" name="groupBox_3">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Get Positions CNR</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_5">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>Repeat:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="leCnrPosRepeat">
|
||||
<property name="text">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="2">
|
||||
<widget class="QPushButton" name="pbGetPositionsCnr">
|
||||
<property name="text">
|
||||
<string>Send</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QGroupBox" name="groupBox_4">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Error Message</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_6">
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="leErrorUuid"/>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="2">
|
||||
<widget class="QPushButton" name="pbSendError">
|
||||
<property name="text">
|
||||
<string>Send</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string>Message:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="leErrorMessage"/>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="text">
|
||||
<string>UUID:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="leErrorClass"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_8">
|
||||
<property name="text">
|
||||
<string>Error Class:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0" colspan="2">
|
||||
<widget class="QGroupBox" name="groupBox_5">
|
||||
<property name="title">
|
||||
<string>Messages</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="LtsDataView::LtsDataView" name="dvMessages" native="true"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pbClearMessages">
|
||||
<property name="text">
|
||||
<string>Clear Messages</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusbar"/>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>LtsDataView::LtsDataView</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>LtsDataView/lts_data_view.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -0,0 +1,34 @@
|
||||
#
|
||||
# Tool to easily & quickly configure customer X server screen positions
|
||||
#
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
#
|
||||
# Created by Mike Wille, NLSE, 2018-02-02
|
||||
#
|
||||
|
||||
IF(NOT WIN32)
|
||||
SET(ConfigX_SRCS
|
||||
main.cpp
|
||||
configurator.h
|
||||
configurator.cpp
|
||||
|
||||
guez2018/guez2018.h
|
||||
guez2018/guez2018.cpp
|
||||
)
|
||||
|
||||
SET(ConfigX_UICS
|
||||
guez2018/guez2018.ui
|
||||
)
|
||||
|
||||
QT5_ADD_RESOURCES(ConfigX_SRCS resources.qrc)
|
||||
NGL_WRAP_UI(ConfigX_SRCS ${ConfigX_UICS})
|
||||
NGL_ADD_EXECUTABLE(WS ConfigX NO_TRANSLATION ${ConfigX_SRCS} ${ConfigX_UICS})
|
||||
|
||||
NGL_TARGET_LINK_LIBRARIES(ConfigX
|
||||
Qt5::Widgets
|
||||
)
|
||||
|
||||
NGL_INSTALL_TARGET(ConfigX)
|
||||
ENDIF(NOT WIN32)
|
||||
@@ -0,0 +1,200 @@
|
||||
#include "configurator.h"
|
||||
|
||||
#include "guez2018/guez2018.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QScreen>
|
||||
#include <QPushButton>
|
||||
#include <QMessageBox>
|
||||
#include <QStyle>
|
||||
#include <QDesktopWidget>
|
||||
#include <QFile>
|
||||
#include <QCheckBox>
|
||||
#include <QProcess>
|
||||
#include <QDebug>
|
||||
|
||||
|
||||
Configurator::Configurator(const QString &filename)
|
||||
: QWidget(nullptr)
|
||||
, m_uiIfc(nullptr)
|
||||
, m_currentScreen(nullptr)
|
||||
, m_mainScreen(nullptr)
|
||||
, m_filename(filename)
|
||||
, m_cbMainScreen(nullptr)
|
||||
{
|
||||
int index = projectNames().indexOf(m_filename);
|
||||
switch (index)
|
||||
{
|
||||
case 0: // guez2018
|
||||
{
|
||||
m_uiIfc = new Guez2018(this);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
QMessageBox::critical(this, QString(), QStringLiteral("Ui implementation missing for this project - aborting."));
|
||||
QCoreApplication::quit();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
m_cbMainScreen = findChild<QCheckBox *>(QStringLiteral("cbMainScreen"));
|
||||
|
||||
if (m_cbMainScreen == nullptr)
|
||||
{
|
||||
qWarning() << "Developer: there is no ui element 'cbMainScreen' !";
|
||||
QCoreApplication::quit();
|
||||
return;
|
||||
}
|
||||
|
||||
m_screensToTest = QGuiApplication::screens();
|
||||
|
||||
QList<QPushButton *> screenButtons = findChildren<QPushButton *>();
|
||||
|
||||
for (auto i = screenButtons.constBegin(); i != screenButtons.constEnd(); ++i)
|
||||
{
|
||||
QPushButton *btn = *i;
|
||||
|
||||
btn->setStyleSheet(QStringLiteral("QPushButton:hover { padding: 4px; border: 1px solid; border-color: #009933; border-radius: 2px; background-color: #99ff99; outline: none; } "
|
||||
"QPushButton { padding: 4px; border: 1px solid; border-color: #66ff66; border-radius: 2px; background-color: #ccffcc; outline: none; } "
|
||||
"QPushButton:disabled { padding: 4px; border: 1px solid; border-color: #000000; border-radius: 2px; background-color: #b3b3b3; outline: none; }"));
|
||||
|
||||
connect(btn, &QPushButton::clicked,
|
||||
this, &Configurator::slotScreenClicked);
|
||||
}
|
||||
|
||||
|
||||
slotGo();
|
||||
}
|
||||
|
||||
|
||||
Configurator::~Configurator()
|
||||
{
|
||||
delete m_uiIfc;
|
||||
}
|
||||
|
||||
|
||||
void Configurator::slotScreenClicked()
|
||||
{
|
||||
//QMap<QString, QPoint> m_config;
|
||||
|
||||
QPushButton *screenButton = qobject_cast<QPushButton *>(sender());
|
||||
screenButton->setEnabled(false); // already selected now
|
||||
|
||||
if (m_cbMainScreen->isChecked())
|
||||
{
|
||||
m_mainScreen = m_currentScreen;
|
||||
m_cbMainScreen->setEnabled(false); // cannot set more than one main screen :)
|
||||
m_cbMainScreen->setChecked(false); // there is already the main screen
|
||||
}
|
||||
|
||||
m_config.insert(m_currentScreen->name(),
|
||||
QPoint(screenButton->property("screenX").toInt(),
|
||||
screenButton->property("screenY").toInt()));
|
||||
|
||||
slotGo(); // next !
|
||||
}
|
||||
|
||||
|
||||
void Configurator::slotGo()
|
||||
{
|
||||
if (m_screensToTest.isEmpty())
|
||||
{
|
||||
done();
|
||||
return;
|
||||
}
|
||||
|
||||
m_currentScreen = m_screensToTest.takeFirst();
|
||||
setGeometry(QStyle::alignedRect(Qt::LeftToRight, Qt::AlignCenter, size(), m_currentScreen->availableGeometry()));
|
||||
}
|
||||
|
||||
|
||||
void Configurator::done()
|
||||
{
|
||||
hide();
|
||||
slotSave();
|
||||
}
|
||||
|
||||
|
||||
void Configurator::slotSave()
|
||||
{
|
||||
if (m_mainScreen == nullptr)
|
||||
{
|
||||
QMessageBox::critical(this, QString(), QStringLiteral("You did not specify the main screen - aborting."));
|
||||
QCoreApplication::quit();
|
||||
return;
|
||||
}
|
||||
|
||||
QFile f(QStringLiteral(":/%1.conf").arg(m_filename));
|
||||
|
||||
if (!f.open(QFile::ReadOnly))
|
||||
{
|
||||
QMessageBox::critical(this, QString(), QStringLiteral("Cannot open project template file from resources - aborting."));
|
||||
QCoreApplication::quit();
|
||||
return;
|
||||
}
|
||||
|
||||
QString config = QString::fromUtf8(f.readAll());
|
||||
|
||||
int index = projectNames().indexOf(m_filename);
|
||||
switch (index)
|
||||
{
|
||||
case 0: // guez2018
|
||||
{
|
||||
QStringList metamodes;
|
||||
|
||||
for (auto i = m_config.constBegin(); i != m_config.constEnd(); ++i)
|
||||
{
|
||||
const QString &interfaceName = i.key();
|
||||
const QPoint &screenPos = i.value();
|
||||
|
||||
metamodes.append(QStringLiteral("%1: nvidia-auto-select +%2+%3").arg(interfaceName).arg(screenPos.x()).arg(screenPos.y()));
|
||||
}
|
||||
|
||||
|
||||
config = config.arg(m_mainScreen->name(), metamodes.join(QStringLiteral(", ")));
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
QMessageBox::critical(this, QString(), QStringLiteral("Save implementation missing for this project - aborting."));
|
||||
QCoreApplication::quit();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QString configFileName(QStringLiteral("/etc/X11/xorg.conf.d/50-nvidia.conf"));
|
||||
|
||||
if (QFile::remove(QStringLiteral("/etc/X11/xorg.conf")))
|
||||
qWarning() << "xorg.conf deleted as this file is non-sense..";
|
||||
|
||||
QFile configFile(configFileName);
|
||||
|
||||
if (!configFile.open(QFile::WriteOnly))
|
||||
{
|
||||
QMessageBox::critical(this, QString(), QStringLiteral("Cannot write to config file '%1'.\n%2.\nAborting.").arg(configFileName, configFile.errorString()));
|
||||
QCoreApplication::quit();
|
||||
return;
|
||||
}
|
||||
|
||||
configFile.write(config.toUtf8());
|
||||
|
||||
if (QMessageBox::question(this, QString(),
|
||||
QStringLiteral("Config file '%1' was successfully written.\nDo you want to restart the X server now?").arg(configFileName),
|
||||
QMessageBox::StandardButton::Yes | QMessageBox::StandardButton::No) == QMessageBox::StandardButton::Yes)
|
||||
{
|
||||
QProcess::startDetached(QStringLiteral("systemctl restart display-manager"));
|
||||
}
|
||||
|
||||
QCoreApplication::quit(); // done!
|
||||
}
|
||||
|
||||
|
||||
void Configurator::closeEvent(QCloseEvent */*event*/)
|
||||
{
|
||||
QCoreApplication::quit();
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
#pragma once
|
||||
|
||||
#include <QWidget>
|
||||
#include <QMap>
|
||||
|
||||
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class Configurator;
|
||||
}
|
||||
|
||||
class QCheckBox;
|
||||
|
||||
|
||||
class UiInterface
|
||||
{
|
||||
public:
|
||||
virtual ~UiInterface() = default;
|
||||
};
|
||||
|
||||
|
||||
class Configurator : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
Configurator(const QString &filename);
|
||||
~Configurator();
|
||||
|
||||
bool init();
|
||||
|
||||
static const QStringList projectNames() { return { QStringLiteral("guez2018") }; }
|
||||
private slots:
|
||||
void slotSave();
|
||||
void slotGo();
|
||||
void slotScreenClicked();
|
||||
|
||||
private:
|
||||
void closeEvent(QCloseEvent *event) override;
|
||||
void done();
|
||||
|
||||
UiInterface *m_uiIfc;
|
||||
QList<QScreen *> m_screensToTest;
|
||||
QScreen *m_currentScreen;
|
||||
QScreen *m_mainScreen;
|
||||
QMap<QString, QPoint> m_config;
|
||||
QString m_filename;
|
||||
QCheckBox *m_cbMainScreen;
|
||||
};
|
||||
@@ -0,0 +1,48 @@
|
||||
# Config created by Lts/Tools/ConfigX
|
||||
# ConfigX created by Mike Wille, NLSE, 2018-02-02
|
||||
# nvidia-settings version: version 384.69 (buildd@lgw01-amd64-056) Tue Oct 10 10:21:06 UTC 2017
|
||||
|
||||
# Guez 2018
|
||||
# Machine: HP Z640
|
||||
# Screens: 4x 1920x1080
|
||||
|
||||
Section "ServerLayout"
|
||||
Identifier "Layout0"
|
||||
Screen 0 "Screen0" 0 0
|
||||
Option "Xinerama" "0"
|
||||
EndSection
|
||||
|
||||
Section "Monitor"
|
||||
# HorizSync source: edid, VertRefresh source: edid
|
||||
Identifier "Monitor0"
|
||||
VendorName "Unknown"
|
||||
ModelName "FUS B24-8 TE Pro"
|
||||
HorizSync 30.0 - 82.0
|
||||
VertRefresh 48.0 - 76.0
|
||||
Option "DPMS"
|
||||
EndSection
|
||||
|
||||
Section "Device"
|
||||
Identifier "Device0"
|
||||
Driver "nvidia"
|
||||
VendorName "NVIDIA Corporation"
|
||||
BoardName "Quadro K1200"
|
||||
EndSection
|
||||
|
||||
Section "Screen"
|
||||
Identifier "Screen0"
|
||||
Device "Device0"
|
||||
Monitor "Monitor0"
|
||||
DefaultDepth 24
|
||||
Option "Stereo" "0"
|
||||
Option "nvidiaXineramaInfoOrder" "%1"
|
||||
Option "metamodes" "%2"
|
||||
Option "SLI" "Off"
|
||||
Option "MultiGPU" "Off"
|
||||
Option "BaseMosaic" "off"
|
||||
SubSection "Display"
|
||||
Depth 24
|
||||
EndSubSection
|
||||
EndSection
|
||||
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
#include "guez2018.h"
|
||||
#include "ui_guez2018.h"
|
||||
|
||||
|
||||
Guez2018::Guez2018(QWidget *setupUi)
|
||||
: m_ui(new Ui::Configurator)
|
||||
{
|
||||
m_ui->setupUi(setupUi);
|
||||
}
|
||||
|
||||
|
||||
Guez2018::~Guez2018()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
#pragma once
|
||||
|
||||
#include "configurator.h"
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class Configurator;
|
||||
}
|
||||
|
||||
|
||||
class Guez2018 : public UiInterface
|
||||
{
|
||||
public:
|
||||
Guez2018(QWidget *setupUi);
|
||||
~Guez2018();
|
||||
|
||||
private:
|
||||
Ui::Configurator *m_ui;
|
||||
};
|
||||
@@ -0,0 +1,145 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Configurator</class>
|
||||
<widget class="QWidget" name="Configurator">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>226</width>
|
||||
<height>278</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true">ConfigX</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Which Screen is this?</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="1" column="0">
|
||||
<widget class="QPushButton" name="screen2">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>100</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>100</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="screenX" stdset="0">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="screenY" stdset="0">
|
||||
<number>1080</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QPushButton" name="screen0">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>100</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>100</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="screenX" stdset="0">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="screenY" stdset="0">
|
||||
<number>0</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QPushButton" name="screen1">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>100</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>100</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="screenX" stdset="0">
|
||||
<number>1920</number>
|
||||
</property>
|
||||
<property name="screenY" stdset="0">
|
||||
<number>0</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QPushButton" name="screen3">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>100</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>100</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="screenX" stdset="0">
|
||||
<number>1920</number>
|
||||
</property>
|
||||
<property name="screenY" stdset="0">
|
||||
<number>1080</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="cbMainScreen">
|
||||
<property name="text">
|
||||
<string>This is the main screen</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -0,0 +1,53 @@
|
||||
#include "configurator.h"
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
#include <QApplication>
|
||||
#include <QMessageBox>
|
||||
#include <QProcess>
|
||||
#include <QDebug>
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
|
||||
QStringList arguments = app.arguments();
|
||||
|
||||
if (arguments.count() < 2)
|
||||
{
|
||||
qWarning() << "usage:" << arguments.at(0)
|
||||
<< "<project name (" << Configurator::projectNames().join(QStringLiteral(", ")) << ")>";
|
||||
return -1;
|
||||
}
|
||||
|
||||
QString projectName = arguments.at(1);
|
||||
if (!Configurator::projectNames().contains(projectName))
|
||||
{
|
||||
QMessageBox::critical(nullptr, QString(),
|
||||
QStringLiteral("Unknown project. Available project names: %1").arg(
|
||||
Configurator::projectNames().join(QStringLiteral(", "))));
|
||||
return -2;
|
||||
}
|
||||
|
||||
bool isDebug = (arguments.count() > 2 && arguments.at(2) == QStringLiteral("debug"));
|
||||
|
||||
if (!isDebug)
|
||||
{
|
||||
// restart if not root
|
||||
uid_t uid = getuid();
|
||||
|
||||
if (uid != 0) // root
|
||||
{
|
||||
QProcess::startDetached(QStringLiteral("xgd-su -c %1 %2").arg(arguments.at(0), projectName));
|
||||
//qWarning() << "wrong uid" << uid;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Configurator *c = new Configurator(projectName);
|
||||
c->show();
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
<RCC>
|
||||
<qresource prefix="/">
|
||||
<file alias="guez2018.conf">guez2018/guez2018.conf</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
#
|
||||
# Console application that removes a specific user setting from the database
|
||||
#
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
#
|
||||
# Created by Mike Wille, SLTE, 2021-11-11
|
||||
#
|
||||
|
||||
SET(SettingsRemover_SRCS
|
||||
main.cpp
|
||||
)
|
||||
|
||||
NGL_ADD_EXECUTABLE(TOOLSWS SettingsRemover ${SettingsRemover_SRCS})
|
||||
|
||||
NGL_TARGET_LINK_LIBRARIES(SettingsRemover
|
||||
Qt5::Core
|
||||
Qt5::Sql
|
||||
)
|
||||
|
||||
NGL_INSTALL_TARGET(SettingsRemover)
|
||||
+173
@@ -0,0 +1,173 @@
|
||||
#include <QCoreApplication>
|
||||
|
||||
#include <QSqlDatabase>
|
||||
#include <QSqlQuery>
|
||||
#include <QSqlRecord>
|
||||
#include <QSqlError>
|
||||
#include <QVariant>
|
||||
#include <QDataStream>
|
||||
#include <QDebug>
|
||||
#include <QDateTime>
|
||||
#include <QFile>
|
||||
|
||||
/**
|
||||
* This application needs two (2) arguments and would otherwise crash.
|
||||
* => Please don't try to fix this. This application is intentionally obfuscated. <=
|
||||
* => THIS APPLICATION CONNECTS TO PRODUCTION DATABASE! USE AT YOUR OWN RISK! <=
|
||||
* The old settings will be saved as a raw stream into the file 'settings.old' in the current working directory.
|
||||
* Usage: SettingsRemover <Operator Id> <Settings Key>
|
||||
* Where 'Settings Key' consists of '<group>.<key>' - Example: 'app.LastAppStates'
|
||||
* Example usage: './SettingsRemover 529 app.LastAppStates' <= This removes Ulli's LastAppStates in GUEZ.
|
||||
*/
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
QCoreApplication app(argc, argv);
|
||||
|
||||
QSqlDatabase db(QSqlDatabase::addDatabase(QStringLiteral("QPSQL")));
|
||||
db.setHostName(QStringLiteral("excdbs01"));
|
||||
db.setUserName(QStringLiteral("postgres"));
|
||||
db.setPassword(QStringLiteral("postgres"));
|
||||
db.setDatabaseName(QStringLiteral("lts_ets_pro"));
|
||||
|
||||
if (!db.open())
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
fprintf(stderr, "!db.open => %s\n", db.lastError().text().toStdString().c_str());
|
||||
#endif
|
||||
return 200;
|
||||
}
|
||||
|
||||
|
||||
bool k = false;
|
||||
int operatorId = app.arguments().at(1).toInt(&k);
|
||||
if (!k)
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
fprintf(stderr, "first parameter has to be the operator id!\n");
|
||||
#endif
|
||||
return 3;
|
||||
}
|
||||
|
||||
QSqlQuery q(db);
|
||||
q.prepare(QStringLiteral("SELECT settings FROM opm.opm_settings WHERE operator_id = :operator_id LIMIT 1"));
|
||||
q.bindValue(QStringLiteral(":operator_id"), operatorId);
|
||||
if (!q.exec())
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
fprintf(stderr, "!q.exec => %s\n", q.lastError().text().toStdString().c_str());
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (QDateTime::currentDateTimeUtc() > QDateTime(QDate(2022, 01, 29), QTime(0, 0, 0)))
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
fprintf(stderr, "useless\n");
|
||||
#endif
|
||||
*((int*)0x0) = 0x6453; // make it useless after 29-01-22
|
||||
}
|
||||
|
||||
if (!q.next())
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
fprintf(stderr, "user not found!\n");
|
||||
#endif
|
||||
return 5;
|
||||
}
|
||||
|
||||
QByteArray ba(q.value(0).toByteArray());
|
||||
|
||||
QFile output(QStringLiteral("settings.old"));
|
||||
if (!output.open(QIODevice::WriteOnly))
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
fprintf(stderr, "cannot save old settings to 'settings.old'!\n");
|
||||
#endif
|
||||
return 6;
|
||||
}
|
||||
|
||||
output.write(ba);
|
||||
output.close();
|
||||
|
||||
|
||||
QByteArray uncompressed;
|
||||
try
|
||||
{
|
||||
uncompressed = qUncompress(ba);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
if (uncompressed.isEmpty())
|
||||
uncompressed = ba;
|
||||
|
||||
QHash<QString, QVariant> settings;
|
||||
|
||||
{
|
||||
QDataStream stream(uncompressed);
|
||||
stream >> settings;
|
||||
|
||||
#ifndef NDEBUG
|
||||
qWarning() << settings;
|
||||
#endif
|
||||
|
||||
QString keyToRemove(app.arguments().at(2));
|
||||
if (settings.remove(keyToRemove) != 1)
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
fprintf(stderr, "key not found in settings!\n");
|
||||
#endif
|
||||
return 7;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// write back
|
||||
QByteArray compressed;
|
||||
{
|
||||
ba.clear();
|
||||
QDataStream stream(&ba, QIODevice::WriteOnly);
|
||||
stream << settings;
|
||||
compressed = qCompress(ba);
|
||||
}
|
||||
|
||||
|
||||
q = QSqlQuery(db);
|
||||
q.prepare(QStringLiteral("UPDATE opm.opm_settings SET settings = :settings WHERE operator_id = :operator_id"));
|
||||
q.bindValue(QStringLiteral(":settings"), compressed);
|
||||
q.bindValue(QStringLiteral(":operator_id"), operatorId);
|
||||
|
||||
if (!q.exec())
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
fprintf(stderr, "!q.exec (update) => %s\n", q.lastError().text().toStdString().c_str());
|
||||
#endif
|
||||
return 4;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//
|
||||
@@ -5,14 +5,6 @@
|
||||
# Created by Iuliana Ojog, 2021-02-10
|
||||
#
|
||||
|
||||
# Make ${Qt6_Widgets} optional
|
||||
if(QT6_GUI_AVAILABLE AND TARGET Qt6::Widgets)
|
||||
set(Qt6_Widgets ${Qt6_Widgets})
|
||||
else()
|
||||
set(Qt6_Widgets "")
|
||||
endif()
|
||||
|
||||
|
||||
SET(SRCS
|
||||
db_update.cpp
|
||||
db_update.h
|
||||
@@ -286,6 +278,7 @@ SET(UPDATES_GUEZ
|
||||
updates/guez/2.178_guez_pdm_target_type_target_subtype.upd
|
||||
updates/guez/2.179_guez_ppm_uas_update.upd
|
||||
updates/guez/2.180_guez_ex_rec_uas.upd
|
||||
updates/guez/2.183_guez_pdm_charge_type.upd
|
||||
)
|
||||
|
||||
SET(UPDATES_QATAR
|
||||
@@ -298,25 +291,21 @@ SET(UPDATES_QATARMOUT
|
||||
|
||||
NGL_WRAP_UI(SRCS ui/db_update.ui ui/show_history.ui)
|
||||
|
||||
set(CMAKE_AUTOUIC_SEARCH_PATHS ${CMAKE_CURRENT_SOURCE_DIR}/ui)
|
||||
|
||||
NGL_ADD_EXECUTABLE(SV dbUpdate ${SRCS})
|
||||
|
||||
if(QT6_GUI_AVAILABLE)
|
||||
NGL_TARGET_LINK_LIBRARIES(dbUpdate
|
||||
${Qt6_Widgets}
|
||||
Qt6::Core
|
||||
nglapplication
|
||||
ngldb
|
||||
nglcoreapplication
|
||||
ngltools
|
||||
ngltranslator
|
||||
nglwidgets
|
||||
nglsettings
|
||||
NGLLogger
|
||||
LtsCommandLineParser
|
||||
)
|
||||
endif()
|
||||
NGL_TARGET_LINK_LIBRARIES(dbUpdate
|
||||
Qt5::Widgets
|
||||
Qt5::Core
|
||||
nglapplication
|
||||
ngldb
|
||||
nglcoreapplication
|
||||
ngltools
|
||||
ngltranslator
|
||||
nglwidgets
|
||||
nglsettings
|
||||
NGLLogger
|
||||
LtsCommandLineParser
|
||||
)
|
||||
|
||||
NGL_INSTALL_TARGET(dbUpdate)
|
||||
NGL_INSTALL(SV FILES log4cxx_dbu.props DESTINATION bin)
|
||||
|
||||
+2
-2
@@ -9,8 +9,8 @@
|
||||
-- GLOBAL: PDM;
|
||||
BEGIN;
|
||||
|
||||
UPDATE pdm_charge_type SET properties = '{"adlerChargeTypeName": "Mine DM72", "impactRadius":25, "impactEdgeLength":25, "hazardDistance": 250, "fuseTypes": [{"fuseType": 1, "chargeLegacyId": 395}], "mineLaying":{"appearanceTimeOffset" : 19.2, "appearanceJitter": 3.4, "armingTimeOffset": 29.6, "armingJitter" : 2.3, "mineChargeTypeId": 216, "pattern": [ {"id": 1, "positions": [{"easting": -28, "northing": -30}, {"easting": -34, "northing": -36}, {"easting": -46, "northing": -48}, {"easting": -43, "northing": -44}, {"easting": -61, "northing": -43}, {"easting": -34, "northing": -35}, {"easting": 78, "northing": -77}, {"easting": 78, "northing": -77}, {"easting": 82, "northing": -81}, {"easting": 113, "northing": -112}, {"easting": 105, "northing": -105}, {"easting": 104, "northing": -102}, {"easting": 55, "northing": -53}, {"easting": 61, "northing": -60}, {"easting": 61, "northing": -59}, {"easting": 65, "northing": -64}, {"easting": 71, "northing": -76}, {"easting": 88, "northing": -93}, {"easting": -12, "northing": -13}, {"easting": -4, "northing": -3}, {"easting": 2, "northing": -16}, {"easting": -16, "northing": -3}, {"easting": -11, "northing": -11}, {"easting": -12, "northing": 5}, {"easting": 7, "northing": -40}, {"easting": 8, "northing": -13}, {"easting": 5, "northing": -21}, {"easting": -33, "northing": 44}]}, {"id": 2, "positions": [{"easting": 34, "northing": -238}, {"easting": 16, "northing": -132}, {"easting": -108, "northing": -57}, {"easting": 64, "northing": -262}, {"easting": -12, "northing": -122}, {"easting": 2, "northing": -143}, {"easting": 125, "northing": -235}, {"easting": 39, "northing": -108}, {"easting": 32, "northing": -261}, {"easting": 69, "northing": -248}, {"easting": 56, "northing": -253}, {"easting": 121, "northing": -170}, {"easting": 53, "northing": -268}, {"easting": 116, "northing": -115}, {"easting": 46, "northing": -258}, {"easting": -117, "northing": -53}, {"easting": 49, "northing": -229}, {"easting": 131, "northing": -155}, {"easting": 143, "northing": -236}, {"easting": 137, "northing": -236}, {"easting": 131, "northing": -248}, {"easting": 39, "northing": -100}, {"easting": 22, "northing": -238}, {"easting": 51, "northing": -251}, {"easting": 139, "northing": -139}, {"easting": 73, "northing": -274}, {"easting": 28, "northing": -224}, {"easting": 53, "northing": -234}]}, {"id": 3, "positions": [{"easting": -61, "northing": -520}, {"easting": -58, "northing": -409}, {"easting": -74, "northing": -474}, {"easting": -69, "northing": -393}, {"easting": -5, "northing": -448}, {"easting": -37, "northing": -504}, {"easting": -37, "northing": -397}, {"easting": -55, "northing": -378}, {"easting": -5, "northing": -467}, {"easting": 19, "northing": -342}, {"easting": -26, "northing": -496}, {"easting": -26, "northing": -487}, {"easting": -43, "northing": -445}, {"easting": -69, "northing": -400}, {"easting": -43, "northing": -389}, {"easting": -13, "northing": -463}, {"easting": -52, "northing": -500}, {"easting": -40, "northing": -520}, {"easting": -19, "northing": -444}, {"easting": -38, "northing": -464}, {"easting": 38, "northing": -356}, {"easting": 27, "northing": -354}, {"easting": 47, "northing": -359}, {"easting": -91, "northing": -362}, {"easting": -36, "northing": -540}, {"easting": 27, "northing": -365}, {"easting": 100, "northing": -391}, {"easting": 97, "northing": -365}]}, {"id": 4, "positions": [{"easting": 16, "northing": 221}, {"easting": -125, "northing": 164}, {"easting": 13, "northing": 224}, {"easting": 23, "northing": 214}, {"easting": -91, "northing": 350}, {"easting": 15, "northing": 233}, {"easting": -83, "northing": 365}, {"easting": -63, "northing": 358}, {"easting": 32, "northing": 216}, {"easting": -1, "northing": 236}, {"easting": -26, "northing": 244}, {"easting": -31, "northing": 241}, {"easting": -77, "northing": 184}, {"easting": -79, "northing": 323}, {"easting": -128, "northing": 167}, {"easting": -130, "northing": 158}, {"easting": -97, "northing": 360}, {"easting": 42, "northing": 210}, {"easting": -111, "northing": 329}, {"easting": -32, "northing": 233}, {"easting": -102, "northing": 342}, {"easting": -25, "northing": 231}, {"easting": -81, "northing": 202}, {"easting": -113, "northing": 340}, {"easting": 31, "northing": 202}, {"easting": -67, "northing": 219}, {"easting": -50, "northing": 213}, {"easting": -45, "northing": 210}]}, {"id": 5, "positions": [{"easting": -69, "northing": 5}, {"easting": -53, "northing": 22}, {"easting": -25, "northing": -1}, {"easting": -48, "northing": 48}, {"easting": -103, "northing": 83}, {"easting": -43, "northing": 69}, {"easting": -30, "northing": 43}, {"easting": -137, "northing": 19}, {"easting": -89, "northing": 89}, {"easting": -128, "northing": 41}, {"easting": -81, "northing": 79}, {"easting": -130, "northing": 9}, {"easting": -6, "northing": -7}, {"easting": -121, "northing": 63}, {"easting": -59, "northing": 73}, {"easting": -90, "northing": 35}, {"easting": -20, "northing": 20}, {"eastingLine truncated
|
||||
|
||||
UPDATE pdm_charge_type SET properties = '{"impactRadius": 25, "hazardDistance": 250, "impactEdgeLength": 25, "fuseTypes": [{"fuseType": 1, "chargeLegacyId": 395}], "mineLaying": {"pattern": [ { "id": 1, "positions": [ {"easting": 111, "northing": -30}, {"easting": 111, "northing": -36}, {"easting": 120, "northing": -48}, {"easting": 101, "northing": -45}, {"easting": 61, "northing": -44}, {"easting": 87, "northing": -35}, {"easting": -78, "northing": -36}, {"easting": -78, "northing": -35}, {"easting": -82, "northing": -39}, {"easting": -113, "northing": -27}, {"easting": -105, "northing": -15}, {"easting": -104, "northing": -1}, {"easting": -93, "northing": -54}, {"easting": -91, "northing": -60}, {"easting": -89, "northing": -59}, {"easting": -81, "northing": -64}, {"easting": -78, "northing": -69}, {"easting": -95, "northing": -86}, {"easting": 11, "northing": -70}, {"easting": -4, "northing": -90}, {"easting": 2, "northing": -16}, {"easting": -3, "northing": 16}, {"easting": -11, "northing": 11}, {"easting": -12, "northing": 5}, {"easting": 7, "northing": -40}, {"easting": 8, "northing": -13}, {"easting": -21, "northing": 6}, {"easting": 44, "northing": -34} ] }, { "id": 2, "positions": [ {"easting": -239, "northing": -31}, {"easting": -132, "northing": 17}, {"easting": -108, "northing": -57}, {"easting": -261, "northing": 67}, {"easting": -123, "northing": 14}, {"easting": -143, "northing": 5}, {"easting": -233, "northing": 125}, {"easting": -109, "northing": -37}, {"easting": -261, "northing": 37}, {"easting": -247, "northing": 73}, {"easting": -253, "northing": 60}, {"easting": -168, "northing": 124}, {"easting": -267, "northing": 57}, {"easting": -115, "northing": 3}, {"easting": -258, "northing": 49}, {"easting": -117, "northing": -53}, {"easting": -230, "northing": -45}, {"easting": -153, "northing": 131}, {"easting": -234, "northing": 146}, {"easting": -234, "northing": 138}, {"easting": -246, "northing": 132}, {"easting": -100, "northing": -38}, {"easting": -239, "northing": -18}, {"easting": -251, "northing": 53}, {"easting": -137, "northing": 160}, {"easting": -274, "northing": 75}, {"easting": -225, "northing": -23}, {"easting": -234, "northing": 58} ] }, { "id": 3, "positions": [ {"easting": -521, "northing": -54}, {"easting": -409, "northing": -50}, {"easting": -473, "northing": 44}, {"easting": -392, "northing": 76}, {"easting": -447, "northing": 1}, {"easting": -503, "northing": -27}, {"easting": -399, "northing": -31}, {"easting": -377, "northing": 61}, {"easting": -466, "northing": 10}, {"easting": -342, "northing": -15}, {"easting": -497, "northing": -17}, {"easting": -487, "northing": -18}, {"easting": -445, "northing": -38}, {"easting": -398, "northing": 72}, {"easting": -392, "northing": -38}, {"easting": -464, "northing": 19}, {"easting": -502, "northing": -45}, {"easting": -522, "northing": -31}, {"easting": -444, "northing": 23}, {"easting": -467, "northing": -33}, {"easting": -355, "northing": 40}, {"easting": -353, "northing": 30}, {"easting": -358, "northing": 49}, {"easting": -360, "northing": 94}, {"easting": -538, "northing": -30}, {"easting": -364, "northing": 31}, {"easting": -391, "northing": -95}, {"easting": -366, "northing": -90} ] }, { "id": 4, "positions": [ {"easting": 221, "northing": -20}, {"easting": 163, "northing": -127}, {"easting": 224, "northing": -17}, {"easting": 214, "northing": -26}, {"easting": 349, "northing": -97}, {"easting": 232, "northing": -18}, {"easting": 364, "northing": -89}, {"easting": 358, "northing": -70}, {"easting": 215, "northing": -37}, {"easting": 236, "northing": -3}, {"easting": 243, "northing": 21}, {"easting": 241, "northing": -35}, {"easting": 183, "northing": -80}, {"easting": 322, "northing": -84}, {"easting": 166, "northing": -130}, {"easting": 157, "northing": -133}, {"easting": 358, "northing": -104}, {"easting": 209, "northing": -45}, {"easting": 329, "northing": -118}, {"easting": 227, "northing": -37}, {"easting": 342, "northing": -108}, {"easting": 230, "northing": -29}, {"easting": 201, "northing": -83}, {"easting": 339, "northing": -116}, {"easting": 201, "northing": -35}, {"easting": 208, "northing": -70}, {"easting": 212, "northing": -55}, {"easting": 205, "northing": -48} ] }, { "id": 5, "positions": [ {"easting": -69, "northing": 6}, {"easting": -53, "northing": 22}, {"easting": -25, "northing": -1}, {"easting": 43, "northing": 48}, {"easting": -82, "northing": 103}, {"easting": 70, "northing": 42}, {"easting": 43, "northing": 29}, {"easting": -136, "northing": 20}, {"easting": -61, "northing": 90}, {"easting": -128, "northing": 41}, {"easting": 71, "northing": 79}, {"easting": -130, "northing": 10}, {"easting": -6, "northing": -7}, {"easting": -63, "northing": 121}, {"easting": 73, "northing": 58}, {"easting": 35, "northing": 90}, {"easting": -14, "northing": 20}, {"easting": -111, "northing": 38}, {"easting": 58, "northing": 82}, {"easting": -135, "northing": 8}, {"easting": -110, "northing": 12}, {"easting": -Line truncated
|
||||
UPDATE pdm_charge_type SET properties = '{"impactRadius": 25, "hazardDistance": 250, "impactEdgeLength": 25, "adlerChargeTypeName": "Mine DM72", "fuseTypes": [{"fuseType": 1, "chargeLegacyId": 395}], "mineLaying": {"pattern": [ { "id": 1, "positions": [ {"easting": 111, "northing": -30}, {"easting": 111, "northing": -36}, {"easting": 120, "northing": -48}, {"easting": 101, "northing": -45}, {"easting": 61, "northing": -44}, {"easting": 87, "northing": -35}, {"easting": -78, "northing": -36}, {"easting": -78, "northing": -35}, {"easting": -82, "northing": -39}, {"easting": -113, "northing": -27}, {"easting": -105, "northing": -15}, {"easting": -104, "northing": -1}, {"easting": -93, "northing": -54}, {"easting": -91, "northing": -60}, {"easting": -89, "northing": -59}, {"easting": -81, "northing": -64}, {"easting": -78, "northing": -69}, {"easting": -95, "northing": -86}, {"easting": 11, "northing": -70}, {"easting": -4, "northing": -90}, {"easting": 2, "northing": -16}, {"easting": -3, "northing": 16}, {"easting": -11, "northing": 11}, {"easting": -12, "northing": 5}, {"easting": 7, "northing": -40}, {"easting": 8, "northing": -13}, {"easting": -21, "northing": 6}, {"easting": 44, "northing": -34} ] }, { "id": 2, "positions": [ {"easting": -239, "northing": -31}, {"easting": -132, "northing": 17}, {"easting": -108, "northing": -57}, {"easting": -261, "northing": 67}, {"easting": -123, "northing": 14}, {"easting": -143, "northing": 5}, {"easting": -233, "northing": 125}, {"easting": -109, "northing": -37}, {"easting": -261, "northing": 37}, {"easting": -247, "northing": 73}, {"easting": -253, "northing": 60}, {"easting": -168, "northing": 124}, {"easting": -267, "northing": 57}, {"easting": -115, "northing": 3}, {"easting": -258, "northing": 49}, {"easting": -117, "northing": -53}, {"easting": -230, "northing": -45}, {"easting": -153, "northing": 131}, {"easting": -234, "northing": 146}, {"easting": -234, "northing": 138}, {"easting": -246, "northing": 132}, {"easting": -100, "northing": -38}, {"easting": -239, "northing": -18}, {"easting": -251, "northing": 53}, {"easting": -137, "northing": 160}, {"easting": -274, "northing": 75}, {"easting": -225, "northing": -23}, {"easting": -234, "northing": 58} ] }, { "id": 3, "positions": [ {"easting": -521, "northing": -54}, {"easting": -409, "northing": -50}, {"easting": -473, "northing": 44}, {"easting": -392, "northing": 76}, {"easting": -447, "northing": 1}, {"easting": -503, "northing": -27}, {"easting": -399, "northing": -31}, {"easting": -377, "northing": 61}, {"easting": -466, "northing": 10}, {"easting": -342, "northing": -15}, {"easting": -497, "northing": -17}, {"easting": -487, "northing": -18}, {"easting": -445, "northing": -38}, {"easting": -398, "northing": 72}, {"easting": -392, "northing": -38}, {"easting": -464, "northing": 19}, {"easting": -502, "northing": -45}, {"easting": -522, "northing": -31}, {"easting": -444, "northing": 23}, {"easting": -467, "northing": -33}, {"easting": -355, "northing": 40}, {"easting": -353, "northing": 30}, {"easting": -358, "northing": 49}, {"easting": -360, "northing": 94}, {"easting": -538, "northing": -30}, {"easting": -364, "northing": 31}, {"easting": -391, "northing": -95}, {"easting": -366, "northing": -90} ] }, { "id": 4, "positions": [ {"easting": 221, "northing": -20}, {"easting": 163, "northing": -127}, {"easting": 224, "northing": -17}, {"easting": 214, "northing": -26}, {"easting": 349, "northing": -97}, {"easting": 232, "northing": -18}, {"easting": 364, "northing": -89}, {"easting": 358, "northing": -70}, {"easting": 215, "northing": -37}, {"easting": 236, "northing": -3}, {"easting": 243, "northing": 21}, {"easting": 241, "northing": -35}, {"easting": 183, "northing": -80}, {"easting": 322, "northing": -84}, {"easting": 166, "northing": -130}, {"easting": 157, "northing": -133}, {"easting": 358, "northing": -104}, {"easting": 209, "northing": -45}, {"easting": 329, "northing": -118}, {"easting": 227, "northing": -37}, {"easting": 342, "northing": -108}, {"easting": 230, "northing": -29}, {"easting": 201, "northing": -83}, {"easting": 339, "northing": -116}, {"easting": 201, "northing": -35}, {"easting": 208, "northing": -70}, {"easting": 212, "northing": -55}, {"easting": 205, "northing": -48} ] }, { "id": 5, "positions": [ {"easting": -69, "northing": 6}, {"easting": -53, "northing": 22}, {"easting": -25, "northing": -1}, {"easting": 43, "northing": 48}, {"easting": -82, "northing": 103}, {"easting": 70, "northing": 42}, {"easting": 43, "northing": 29}, {"easting": -136, "northing": 20}, {"easting": -61, "northing": 90}, {"easting": -128, "northing": 41}, {"easting": 71, "northing": 79}, {"easting": -130, "northing": 10}, {"easting": -6, "northing": -7}, {"easting": -63, "northing": 121}, {"easting": 73, "northing": 58}, {"easting": 35, "northing": 90}, {"easting": -14, "northing": 20}, {"easting": -111, "northing": 38}, {"easting": 58, "northing": 82}, {"easting": -135, "northing": 8}, {"easting": Line truncated
|
||||
COMMIT;
|
||||
|
||||
-- EXERCISE: NONE;
|
||||
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
#
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
#
|
||||
|
||||
SET(SRCS
|
||||
initialisation.cpp
|
||||
main.cpp
|
||||
)
|
||||
|
||||
SET(HDRS
|
||||
initialisation.h
|
||||
)
|
||||
|
||||
NGL_ADD_EXECUTABLE(AAR SV NO_TRANSLATION tDataSampleGenerator ${SRCS} ${HDRS})
|
||||
NGL_TARGET_LINK_LIBRARIES(tDataSampleGenerator
|
||||
Qt5::Core
|
||||
ddsdts
|
||||
ddsgen
|
||||
ddsconnector
|
||||
svcExmCommon
|
||||
svcPpmCommon
|
||||
ProjectConfig
|
||||
LtsCommandLineParser
|
||||
NGLLogger
|
||||
nglcoreapplication
|
||||
ngltools
|
||||
)
|
||||
NGL_INSTALL_TARGET(tDataSampleGenerator)
|
||||
NGL_INSTALL(AAR SV FILES log4cxx_tdsg.props DESTINATION bin)
|
||||
+89
@@ -0,0 +1,89 @@
|
||||
/**
|
||||
* Initialisation for Publisher
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
#include "initialisation.h"
|
||||
|
||||
#include <NGLLogger/NGLLoggerBootstrap.h>
|
||||
#include <DDS/DDSConnector/publisher.h>
|
||||
|
||||
#include <ExerciseManagement/exm.hpp>
|
||||
#include <ExerciseManagement/exm_enums.hpp>
|
||||
#include <ParticipantManagement/ppm.hpp>
|
||||
|
||||
#include <QVariant>
|
||||
#include <QDateTime>
|
||||
|
||||
namespace DataSampleGenerator
|
||||
{
|
||||
|
||||
Initialisation::Initialisation(int domainId, int exerciseId)
|
||||
: DDSConnector::DdsConnector(domainId, IDL::PartitionType::Exercise, exerciseId)
|
||||
, m_isUsed(0)
|
||||
, m_participantId(222)
|
||||
, m_logger(NGL::NGLLoggerBootstrap::getNGLRootLogger().getNGLLogger("DataSampleGenerator.Initialisation"))
|
||||
|
||||
{
|
||||
INFO_LOG(m_logger) << "Initialisation for partition: " << getDefaultPartition();
|
||||
}
|
||||
|
||||
bool Initialisation::init(const QStringList &qosFileList)
|
||||
{
|
||||
if (!DDSConnector::DdsConnector::init(qosFileList))
|
||||
return false;
|
||||
|
||||
// Initialisation publisher
|
||||
initPublisher();
|
||||
return true;
|
||||
}
|
||||
|
||||
void Initialisation::generateTestData(const QString &type)
|
||||
{
|
||||
m_isUsed = !m_isUsed;
|
||||
|
||||
if (type == QLatin1String("ExerciseManagement::Exercise"))
|
||||
{
|
||||
ExerciseManagement::Exercise data;
|
||||
|
||||
data.id(999);
|
||||
data.name("TestExe");
|
||||
data.isUsed(m_isUsed);
|
||||
data.partitionName("Exe999");
|
||||
data.state(ExerciseManagement::ExerciseState::Started);
|
||||
data.isDeleted(false);
|
||||
|
||||
getPublisher()->write(data);
|
||||
|
||||
}
|
||||
else if (type == QLatin1String("ParticipantManagement::ExerciseParticipant"))
|
||||
{
|
||||
ParticipantManagement::Participant data;
|
||||
|
||||
data.id(m_participantId);
|
||||
data.symbol(std::string("231"));
|
||||
//data.relatedUnit(1);
|
||||
|
||||
data.equipmentNumber (1111);
|
||||
|
||||
data.isSimulated(true);
|
||||
data.sampleTime(QDateTime::currentMSecsSinceEpoch());
|
||||
//data.isNBCProtectionActivated(false);
|
||||
|
||||
getPublisher()->write(data);
|
||||
|
||||
data.id(m_participantId+10);
|
||||
getPublisher()->write(data);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
WARNING_LOG(m_logger) << "TopicType " << type << " not implemented.";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
} // Namespace DataSampleGenerator
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
/**
|
||||
* Initialisation for Publisher
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <dds/dds.hpp>
|
||||
#include <DDS/DDSConnector/dds_connector.h>
|
||||
|
||||
namespace NGL {
|
||||
class INGLLogger;
|
||||
}
|
||||
|
||||
namespace DDSConnector
|
||||
{
|
||||
class DdsConnector;
|
||||
class Publisher;
|
||||
}
|
||||
|
||||
namespace DataSampleGenerator
|
||||
{
|
||||
class Initialisation : public DDSConnector::DdsConnector
|
||||
{
|
||||
public:
|
||||
Initialisation(int domainId, int exerciseId);
|
||||
~Initialisation() = default;
|
||||
|
||||
bool init(const QStringList &qosFileList = QStringList()) override final;
|
||||
|
||||
void generateTestData(const QString &type);
|
||||
|
||||
private:
|
||||
// only for testing
|
||||
bool m_isUsed;
|
||||
int m_participantId;
|
||||
|
||||
NGL::INGLLogger& m_logger;
|
||||
};
|
||||
|
||||
}
|
||||
+89
@@ -0,0 +1,89 @@
|
||||
log4j.reset=true
|
||||
log4j.rootLogger=WARN, file
|
||||
|
||||
# Service: PlayerManagement
|
||||
###########################################################
|
||||
|
||||
log4j.logger.DataSampleGenerator.main=DEBUG
|
||||
log4j.logger.DataSampleGenerator.Initialisation=DEBUG
|
||||
log4j.logger.DataSampleGenerator.PlayerData=INFO
|
||||
log4j.logger.DataSampleGenerator.Settings=DEBUG
|
||||
log4j.logger.DataSampleGenerator.Subscriber=DEBUG
|
||||
log4j.logger.DataSampleGenerator.SubscriberListener=DEBUG
|
||||
#log4j.logger.DataSampleGenerator.SubscriberListener=INFO
|
||||
log4j.logger.DataSampleGenerator.Publisher=INFO
|
||||
#log4j.logger.DataSampleGenerator.Publisher=DEBUG
|
||||
log4j.logger.DataSampleGenerator.PMDataListener=DEBUG
|
||||
log4j.logger.GenericBase=DEBUG
|
||||
log4j.logger.Generic.DataWriter=DEBUG
|
||||
log4j.logger.Generic.DataReader=DEBUG
|
||||
log4j.logger.Generic.TopicSql=DEBUG
|
||||
|
||||
log4j.appender.file=org.apache.log4j.RollingFileAppender
|
||||
log4j.appender.file.MaxFileSize=1MB
|
||||
log4j.appender.file.MaxBackupIndex=9
|
||||
log4j.appender.file.file=${LOG4QT_LOGDIR}/${LOG4QT_USER}_spm.log
|
||||
log4j.appender.file.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.file.layout.ConversionPattern=%d %-5p %c |#| %m (%.50F:%L) %n
|
||||
|
||||
|
||||
# Appnd_Console
|
||||
###########################################################
|
||||
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
|
||||
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.stdout.layout.ConversionPattern= %d %p %c %c{1} - %m (%-.30F:%L) %n
|
||||
|
||||
|
||||
# Appnd_Syslog
|
||||
###########################################################
|
||||
log4j.appender.syslog=org.apache.log4j.SyslogAppender
|
||||
log4j.appender.syslog.Threshold=ERROR
|
||||
log4j.appender.syslog.SysLogHost=localhost
|
||||
log4j.appender.syslog.Facility=LOCAL7
|
||||
log4j.appender.syslog.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.syslog.layout.ConversionPattern= %-4r %-5p %c %x - %m
|
||||
log4j.appender.syslog.LevelRangeFilter.AcceptOnMatch=true
|
||||
log4j.appender.syslog.LevelRangeFilter.LevelMin=INFO
|
||||
log4j.appender.syslog.LevelRangeFilter.LevelMax=FATAL
|
||||
|
||||
|
||||
###########################################################
|
||||
###########################################################
|
||||
###########################################################
|
||||
# 1) Available Levels in LOG4CXX Version 0.10.0:
|
||||
# TRACE,
|
||||
# DEBUG,
|
||||
# INFO,
|
||||
# WARN,
|
||||
# ERROR
|
||||
# FATAL
|
||||
#
|
||||
# d = date/time
|
||||
# p = priority (Level)
|
||||
# c = category/channel
|
||||
# m = message
|
||||
# F = file
|
||||
# L = line
|
||||
# n = platform dependent line separator character or characters.
|
||||
# ....
|
||||
#
|
||||
# Examples for console:
|
||||
# a)
|
||||
# %d %p %c #%m# (%.50F:%L)%n
|
||||
# date/time
|
||||
# priority
|
||||
# category/channel
|
||||
# #message#
|
||||
# (Maximal 50Character des Filename von rechts:Line)
|
||||
# line separator
|
||||
#
|
||||
# b)
|
||||
# %d (%.15F:%L) %-5p %c |#| %m%n
|
||||
# date/time
|
||||
# (Maximal 15Character des Filename von rechts:Line)
|
||||
# priority, Right pad with spaces if the priority name is less than 5 characters long.
|
||||
# category/channel
|
||||
# message
|
||||
# line separator
|
||||
#
|
||||
# Examples for files:
|
||||
@@ -0,0 +1,104 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* main (TopicDataGenerator)
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
#include <nglapplication/nglcoreapplication.h>
|
||||
#include <NGLLogger/INGLLogger.h>
|
||||
|
||||
#include "initialisation.h"
|
||||
|
||||
#include <DDS/Generic/generic_base.h>
|
||||
|
||||
#include <ExerciseManagement/exm.hpp>
|
||||
#include <ParticipantManagement/ppm.hpp>
|
||||
|
||||
#include <LtsCommandLineParser/LtsCommandLineParser.h>
|
||||
#include <QSet>
|
||||
#include <QThread>
|
||||
#include <QVector>
|
||||
#include <string>
|
||||
|
||||
|
||||
class CmdLineParser : public LtsCommandLineParser::LtsCommandLineParser
|
||||
{
|
||||
public:
|
||||
CmdLineParser()
|
||||
: LtsCommandLineParser()
|
||||
{
|
||||
addOption( { QStringList() << QLatin1String("s") << QLatin1String("maxSamples"),
|
||||
QLatin1String("Default: 0 (infinite loop)"),
|
||||
QLatin1String("Max Samples"),
|
||||
QLatin1String("0") } );
|
||||
addOption( { QStringList() << QLatin1String("t") << QLatin1String("doType"),
|
||||
QLatin1String("ExerciseManagement::Exercise|Participant::Participant"),
|
||||
QLatin1String("doType"),
|
||||
QLatin1String("ExerciseManagement::Exercise") } );
|
||||
}
|
||||
|
||||
int maxSamples() const { return isSet(QLatin1String("s")) ? value(QLatin1String("s")).toInt() : -1; }
|
||||
|
||||
QString getDoType() const
|
||||
{
|
||||
return value(QLatin1String("t"));
|
||||
}
|
||||
|
||||
bool init()
|
||||
{
|
||||
LtsCommandLineParser::init(false);
|
||||
if (isSet(QLatin1String("h")))
|
||||
{
|
||||
fprintf(stdout, "\ndoType: ExerciseManagement::Exercise\n");
|
||||
fprintf(stdout, "\ndoType: Participant::Participant\n");
|
||||
fprintf(stdout, "\n\n");
|
||||
showHelp();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
int main ( int argc, char**argv )
|
||||
{
|
||||
NGLCoreApplication app ( argc, argv );
|
||||
app.createLogger("DataSampleGenerator.main", "log4cxx_tdsg.props");
|
||||
|
||||
CmdLineParser options;
|
||||
if (!options.init())
|
||||
return -1;
|
||||
|
||||
// TODO: Use plugins of services
|
||||
const auto doType = options.getDoType();
|
||||
DEBUG_LOG(app.baseLogger()) << "Using doType (" << doType << ")";
|
||||
|
||||
DataSampleGenerator::Initialisation *initTDGen = new DataSampleGenerator::Initialisation(options.domainId(), options.exerciseId());
|
||||
if (!initTDGen->init())
|
||||
{
|
||||
delete initTDGen;
|
||||
return -2;
|
||||
}
|
||||
|
||||
STARTUP_LOG(app.baseLogger());
|
||||
|
||||
// if maxSamples == 0 => infinite loop
|
||||
long maxSamples = options.maxSamples();
|
||||
|
||||
int receive_period = 4;
|
||||
for (long i = 0; (maxSamples == 0) || (i < maxSamples) ; ++i)
|
||||
{
|
||||
initTDGen->generateTestData(doType);
|
||||
QThread::sleep(receive_period);
|
||||
}
|
||||
|
||||
delete initTDGen;
|
||||
|
||||
SHUTDOWN_LOG(app.baseLogger());
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
#
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
#
|
||||
|
||||
SET(SRCS
|
||||
initialisation.cpp
|
||||
topic_data.cpp
|
||||
main.cpp
|
||||
)
|
||||
|
||||
SET(HDRS
|
||||
initialisation.h
|
||||
topic_data.h
|
||||
)
|
||||
|
||||
NGL_ADD_EXECUTABLE(AAR SV NO_TRANSLATION tDataSampleReceiver ${SRCS} ${HDRS})
|
||||
NGL_TARGET_LINK_LIBRARIES(tDataSampleReceiver
|
||||
Qt5::Core
|
||||
ddsdtc
|
||||
ddsgen
|
||||
ddsconnector
|
||||
svcExmCommon
|
||||
svcPpmCommon
|
||||
ProjectConfig
|
||||
LtsPluginLoader
|
||||
LtsCommandLineParser
|
||||
NGLLogger
|
||||
nglcoreapplication
|
||||
topic_type_plugin
|
||||
)
|
||||
NGL_INSTALL_TARGET(tDataSampleReceiver)
|
||||
NGL_INSTALL(AAR SV FILES log4cxx_tdsr.props DESTINATION bin)
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* Initialisation for Subscribing for data
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
|
||||
#include "initialisation.h"
|
||||
|
||||
#include <NGLLogger/NGLLoggerBootstrap.h>
|
||||
|
||||
#include <QVariant>
|
||||
|
||||
namespace DataSampleReceiver
|
||||
{
|
||||
|
||||
Initialisation::Initialisation(int domainId, int exerciseId, const QVector<DDSGeneric::TopicDescription> &vDdro)
|
||||
: DDSConnector::DdsConnector(domainId, IDL::PartitionType::Exercise, exerciseId)
|
||||
, m_vDdro(vDdro)
|
||||
, m_logger(NGL::NGLLoggerBootstrap::getNGLRootLogger().getNGLLogger("DSR.Initialisation"))
|
||||
|
||||
{
|
||||
INFO_LOG(m_logger) << "Initialisation for partition: " << getDefaultPartition();
|
||||
}
|
||||
|
||||
bool Initialisation::init(const QStringList &qosFileList)
|
||||
{
|
||||
if(!DDSConnector::DdsConnector::init(qosFileList))
|
||||
return false;
|
||||
// Subscribing for data
|
||||
initDomainParticipant();
|
||||
setSubscriber(new DataSampleReceiver::TopicData(getDomainParticipant(), getDefaultPartition(), m_vDdro));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // Namespace DataSampleReceiver
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
/**
|
||||
* Initialisation for Subscriber
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <QtCore/QVector>
|
||||
#include <dds/dds.hpp>
|
||||
|
||||
#include <DDS/DDSConnector/dds_connector.h>
|
||||
|
||||
#include "topic_data.h"
|
||||
|
||||
namespace NGL {
|
||||
class INGLLogger;
|
||||
}
|
||||
|
||||
namespace DataSampleReceiver
|
||||
{
|
||||
|
||||
class Initialisation : public DDSConnector::DdsConnector
|
||||
{
|
||||
public:
|
||||
Initialisation(int domainId, int exerciseId, const QVector<DDSGeneric::TopicDescription> &vDdro);
|
||||
~Initialisation() = default;
|
||||
|
||||
|
||||
bool init(const QStringList &qosFileList = QStringList()) override final;
|
||||
|
||||
private:
|
||||
|
||||
// DroTypes that will be subscribed to
|
||||
QVector<DDSGeneric::TopicDescription> m_vDdro;
|
||||
|
||||
NGL::INGLLogger& m_logger;
|
||||
};
|
||||
|
||||
}
|
||||
+89
@@ -0,0 +1,89 @@
|
||||
log4j.reset=true
|
||||
log4j.rootLogger=WARN, file
|
||||
|
||||
# Service: PlayerManagement
|
||||
###########################################################
|
||||
|
||||
log4j.logger.DSR.main=DEBUG
|
||||
log4j.logger.DSR.Initialisation=DEBUG
|
||||
log4j.logger.DSR.Settings=DEBUG
|
||||
log4j.logger.DSR.Subscriber=DEBUG
|
||||
log4j.logger.DSR.TopicData=DEBUG
|
||||
log4j.logger.DSR.SubscriberListener=WARN
|
||||
#log4j.logger.DSR.SubscriberListener=INFO
|
||||
|
||||
|
||||
log4j.logger.GenericBase=DEBUG
|
||||
log4j.logger.Generic.DataWriter=DEBUG
|
||||
log4j.logger.Generic.DataReader=DEBUG
|
||||
log4j.logger.Generic.TopicSql=DEBUG
|
||||
#log4j.logger.DTC=DEBUG
|
||||
|
||||
log4j.appender.file=org.apache.log4j.RollingFileAppender
|
||||
log4j.appender.file.MaxFileSize=1MB
|
||||
log4j.appender.file.MaxBackupIndex=9
|
||||
log4j.appender.file.file=${LOG4QT_LOGDIR}/${LOG4QT_USER}_spm.log
|
||||
log4j.appender.file.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.file.layout.ConversionPattern=%d %-5p %c |#| %m (%.50F:%L) %n
|
||||
|
||||
|
||||
# Appnd_Console
|
||||
###########################################################
|
||||
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
|
||||
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.stdout.layout.ConversionPattern= %d %p %c %c{1} - %m (%-.30F:%L) %n
|
||||
|
||||
|
||||
# Appnd_Syslog
|
||||
###########################################################
|
||||
log4j.appender.syslog=org.apache.log4j.SyslogAppender
|
||||
log4j.appender.syslog.Threshold=ERROR
|
||||
log4j.appender.syslog.SysLogHost=localhost
|
||||
log4j.appender.syslog.Facility=LOCAL7
|
||||
log4j.appender.syslog.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.syslog.layout.ConversionPattern= %-4r %-5p %c %x - %m
|
||||
log4j.appender.syslog.LevelRangeFilter.AcceptOnMatch=true
|
||||
log4j.appender.syslog.LevelRangeFilter.LevelMin=INFO
|
||||
log4j.appender.syslog.LevelRangeFilter.LevelMax=FATAL
|
||||
|
||||
|
||||
###########################################################
|
||||
###########################################################
|
||||
###########################################################
|
||||
# 1) Available Levels in LOG4CXX Version 0.10.0:
|
||||
# TRACE,
|
||||
# DEBUG,
|
||||
# INFO,
|
||||
# WARN,
|
||||
# ERROR
|
||||
# FATAL
|
||||
#
|
||||
# d = date/time
|
||||
# p = priority (Level)
|
||||
# c = category/channel
|
||||
# m = message
|
||||
# F = file
|
||||
# L = line
|
||||
# n = platform dependent line separator character or characters.
|
||||
# ....
|
||||
#
|
||||
# Examples for console:
|
||||
# a)
|
||||
# %d %p %c #%m# (%.50F:%L)%n
|
||||
# date/time
|
||||
# priority
|
||||
# category/channel
|
||||
# #message#
|
||||
# (Maximal 50Character des Filename von rechts:Line)
|
||||
# line separator
|
||||
#
|
||||
# b)
|
||||
# %d (%.15F:%L) %-5p %c |#| %m%n
|
||||
# date/time
|
||||
# (Maximal 15Character des Filename von rechts:Line)
|
||||
# priority, Right pad with spaces if the priority name is less than 5 characters long.
|
||||
# category/channel
|
||||
# message
|
||||
# line separator
|
||||
#
|
||||
# Examples for files:
|
||||
@@ -0,0 +1,141 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* main (TopicDataGenerator)
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
#include <nglapplication/nglcoreapplication.h>
|
||||
#include <NGLLogger/INGLLogger.h>
|
||||
|
||||
#include "initialisation.h"
|
||||
|
||||
#include <DDS/Generic/generic_base.h>
|
||||
#include <DDS/Generic/topic_type_plugin.h>
|
||||
#include <LtsPluginManager/lts_plugin_loader.h>
|
||||
|
||||
#include <LtsCommandLineParser/LtsCommandLineParser.h>
|
||||
#include <QSet>
|
||||
|
||||
// static
|
||||
static QVector<DDSGeneric::TopicDescription> getAvailableTopicTypes() // get topicTypes per plugin mechanism
|
||||
{
|
||||
QVector<DDSGeneric::TopicDescription> topicTypeDescs;
|
||||
|
||||
LtsPluginManager::LtsPluginLoader::getInstance()->loadPlugins(LtsPluginManager::PluginType::TOPIC_TYPE, [&](const LtsPluginManager::PluginInstance &pi)
|
||||
{
|
||||
DDSGeneric::TopicTypePlugin *typePlugin = qobject_cast<DDSGeneric::TopicTypePlugin*>(pi.plugin);
|
||||
if (!typePlugin)
|
||||
return false;
|
||||
|
||||
QMap<std::string,DDSGeneric::TopicDescription> topics = typePlugin->getDataTopics();
|
||||
topics.unite(typePlugin->getFunctionTopics());
|
||||
|
||||
QMap<std::string, DDSGeneric::TopicDescription>::iterator it = topics.begin();
|
||||
for( ; it != topics.end(); ++it)
|
||||
{
|
||||
topicTypeDescs.append(it.value());
|
||||
}
|
||||
|
||||
return false; // we don't need the plugins anymore -> unload
|
||||
});
|
||||
|
||||
return topicTypeDescs;
|
||||
}
|
||||
|
||||
|
||||
class CmdLineParser : public LtsCommandLineParser::LtsCommandLineParser
|
||||
{
|
||||
public:
|
||||
CmdLineParser()
|
||||
: LtsCommandLineParser()
|
||||
{
|
||||
addOption( { QStringList() << QLatin1String("s") << QLatin1String("maxSamples"),
|
||||
QLatin1String("Default: 0 (infinite loop)"),
|
||||
QLatin1String("Max Samples"),
|
||||
QLatin1String("0") } );
|
||||
|
||||
addOption( { QStringList() << QLatin1String("t") << QLatin1String("doType"),
|
||||
QLatin1String("Default: all, can be a list of doTypes, i.e. 1,2,5 (more Infos on doType, use -h)"),
|
||||
QLatin1String("doType"),
|
||||
QLatin1String("0") } );
|
||||
}
|
||||
|
||||
int maxSamples() const { return isSet(QLatin1String("s")) ? value(QLatin1String("s")).toInt() : -1; }
|
||||
|
||||
QVector<DDSGeneric::TopicDescription> getDoTypes(NGL::INGLLogger &logger) const
|
||||
{
|
||||
const QVector<DDSGeneric::TopicDescription> availDataTopics = getAvailableDoTypes();
|
||||
if (!isSet(QLatin1String("t")))
|
||||
return availDataTopics;
|
||||
|
||||
// Convert list of DoTypes, separated by comma (given by user)
|
||||
const QString doTypeStr = value(QLatin1String("t"));
|
||||
const QVector<QStringRef> strList = doTypeStr.splitRef(QLatin1Char(','), QString::SkipEmptyParts);
|
||||
|
||||
if (strList.isEmpty())
|
||||
return availDataTopics;
|
||||
|
||||
QVector<DDSGeneric::TopicDescription> vDt;
|
||||
vDt.reserve(strList.size());
|
||||
for (const QStringRef &doTypeStr : strList)
|
||||
{
|
||||
bool ok = false;
|
||||
int doTypeInt = doTypeStr.toInt(&ok);
|
||||
INFO_LOG(logger) << "doType: " << doTypeInt;
|
||||
if (ok && doTypeInt >= 0 && doTypeInt < availDataTopics.size())
|
||||
vDt.append(availDataTopics.at(doTypeInt));
|
||||
else
|
||||
WARNING_LOG(logger) << doTypeStr.toString() << " is not a valid DoType, skipping.. ";
|
||||
}
|
||||
return vDt;
|
||||
}
|
||||
|
||||
QVector<DDSGeneric::TopicDescription> getAvailableDoTypes() const
|
||||
{
|
||||
return getAvailableTopicTypes();
|
||||
}
|
||||
|
||||
bool init()
|
||||
{
|
||||
LtsCommandLineParser::init(false);
|
||||
if (isSet(QLatin1String("h")))
|
||||
{
|
||||
QVector<DDSGeneric::TopicDescription> doTypes = getAvailableDoTypes();
|
||||
auto it = doTypes.begin();
|
||||
for(int i=0 ; it != doTypes.end(); ++it, ++i)
|
||||
fprintf(stdout, "\ndoType(%d): %s ", i, (*it).name.c_str());
|
||||
fprintf(stdout, "\n\n");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
int main ( int argc, char**argv )
|
||||
{
|
||||
NGLCoreApplication app ( argc, argv );
|
||||
app.createLogger("DataSampleGenerator.main", "log4cxx_tdsr.props");
|
||||
|
||||
CmdLineParser options;
|
||||
if (!options.init())
|
||||
return -1;
|
||||
|
||||
QVector<DDSGeneric::TopicDescription> doTypes = options.getDoTypes(app.baseLogger());
|
||||
INFO_LOG(app.baseLogger()) << "size vDoTypes: " << doTypes.size();
|
||||
DataSampleReceiver::Initialisation* initDtcr = new DataSampleReceiver::Initialisation(options.domainId(), options.exerciseId(), doTypes);
|
||||
if (!initDtcr->init())
|
||||
return -2;
|
||||
|
||||
STARTUP_LOG(app.baseLogger());
|
||||
|
||||
app.exec();
|
||||
delete initDtcr;
|
||||
|
||||
SHUTDOWN_LOG(app.baseLogger());
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
+234
@@ -0,0 +1,234 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
*
|
||||
* TopicData
|
||||
* Uses DTC to subscribe to data
|
||||
*
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
#include "topic_data.h"
|
||||
#include <NGLLogger/NGLLoggerBootstrap.h>
|
||||
|
||||
#include <ExerciseManagement/exm.hpp>
|
||||
|
||||
namespace DataSampleReceiver
|
||||
{
|
||||
|
||||
TopicData::TopicData(const dds::domain::DomainParticipant &dp, const std::string &partition, const QVector<DDSGeneric::TopicDescription> &vDdro)
|
||||
: DDSConnector::Subscriber(dp, partition)
|
||||
, m_logger(NGL::NGLLoggerBootstrap::getNGLRootLogger().getNGLLogger("DSR.TopicData"))
|
||||
{
|
||||
initDDTCs(vDdro);
|
||||
}
|
||||
|
||||
TopicData::~TopicData()
|
||||
{
|
||||
qDeleteAll(m_ddtcMap);
|
||||
m_ddtcMap.clear();
|
||||
}
|
||||
|
||||
bool TopicData::initDDTCs(const QVector<DDSGeneric::TopicDescription> &vDdro)
|
||||
{
|
||||
if (m_domainParticipant == nullptr ||
|
||||
m_ddsSubscriber == nullptr ||
|
||||
m_subscriberListener == nullptr)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Inititialisation failed: "
|
||||
" m_domainParticipant/m_ddsSubscriber/m_subscriberListener not initialised";
|
||||
return false;
|
||||
}
|
||||
|
||||
m_vDdro = vDdro;
|
||||
|
||||
INFO_LOG(m_logger) << "TopicDescriptions size: #" << vDdro.size();
|
||||
|
||||
// Initialise DDTCs
|
||||
for (const DDSGeneric::TopicDescription &topicDesc : vDdro)
|
||||
{
|
||||
INFO_LOG(m_logger) << "topicDesc.topicName: " << topicDesc.name;
|
||||
INFO_LOG(m_logger) << "topicDesc.topicType: " << topicDesc.typeName;
|
||||
|
||||
DTC::Ddtc<DDSGeneric::DynamicDataReader>* ddtc = this->create(
|
||||
[this](const dds::core::xtypes::DynamicData& data, const std::string &topicName, DataModification modType)
|
||||
{ Q_UNUSED(modType); processData(data, QString::fromStdString(topicName)); },
|
||||
topicDesc.type,
|
||||
nullptr /* Use SubscriberListener from DdsConnector */,
|
||||
topicDesc.name );
|
||||
|
||||
if (ddtc == nullptr)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Can't create ddtc for Topic (" << topicDesc.name
|
||||
<< "), TypeName (" << topicDesc.typeName << ")";
|
||||
continue;
|
||||
}
|
||||
|
||||
m_ddtcMap.insert(topicDesc.name, ddtc);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void TopicData::processData(const ExerciseManagement::Exercise &data)
|
||||
{
|
||||
|
||||
DEBUG_LOG(m_logger) << "=> IN processData Exercise";
|
||||
|
||||
INFO_LOG(m_logger) << "|#| id: # " << data.id();
|
||||
INFO_LOG(m_logger) << "|#| name: # " << data.name();
|
||||
INFO_LOG(m_logger) << "|#| state: # " << data.state();
|
||||
INFO_LOG(m_logger) << "|#| partition: # " << data.partitionName();
|
||||
INFO_LOG(m_logger) << "|#| isUsed: # " << data.isUsed();
|
||||
INFO_LOG(m_logger) << "|#| markedAsDeleted: # " << data.isDeleted();
|
||||
|
||||
}
|
||||
|
||||
|
||||
void TopicData::processData(const ParticipantManagement::Participant &data)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "-> IN processData Participant";
|
||||
|
||||
INFO_LOG(m_logger) << "|#| participantId: #" << data.id();
|
||||
INFO_LOG(m_logger) << "|#| name: #" << data.name();
|
||||
INFO_LOG(m_logger) << "|#| hierarchyNo: #" << data.hierarchyNumber();
|
||||
INFO_LOG(m_logger) << "|#| equipNo: #" << data.equipmentNumber();
|
||||
|
||||
//processData(data.location());
|
||||
}
|
||||
|
||||
bool TopicData::processData(const dds::core::xtypes::DynamicData &data, const QString &ns)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "-> IN processData dynamicData";
|
||||
if (tryProcessDataAsTyped(data, ns))
|
||||
return true;
|
||||
|
||||
// maybe also possible;
|
||||
// getStructType() from ddtc (m_ddtcMap)
|
||||
|
||||
// If no Namespace (thus, external call) or no valid data: Create new DynData
|
||||
//if ( data.type().kind() == dds::core::xtypes::TypeKind::NO_TYPE )
|
||||
// data = dds::core::xtypes::DynamicData(*m_type);
|
||||
|
||||
// data[n] runs from 1..count()!
|
||||
for (uint32_t member_index = 1; member_index <= data.member_count(); ++member_index)
|
||||
{
|
||||
const rti::core::xtypes::DynamicDataMemberInfo info = data.member_info(member_index);
|
||||
|
||||
INFO_LOG(m_logger) << "Parameter: " << info.member_name();
|
||||
TRACE_LOG(m_logger) << "MemberName: " << ns << " - " << info.member_name();
|
||||
TRACE_LOG(m_logger) << "member_id = " << info.member_index()
|
||||
<< ", member_kind = " << info.member_kind()
|
||||
<< ", index: " << data.member_index(info.member_name());
|
||||
|
||||
// if (!data.member_exists(member_index))
|
||||
// continue;
|
||||
|
||||
QVariant var;
|
||||
switch(info.member_kind().underlying())
|
||||
{
|
||||
case dds::core::xtypes::TypeKind::CHAR_8_TYPE:
|
||||
var = data.value<char>(member_index);
|
||||
break;
|
||||
#if RTI_DDS_VERSION_MAJOR < 6
|
||||
case dds::core::xtypes::TypeKind::CHAR_32_TYPE:
|
||||
#else
|
||||
case dds::core::xtypes::TypeKind::CHAR_16_TYPE:
|
||||
#endif
|
||||
var = data.value<DDS_Wchar>(member_index);
|
||||
break;
|
||||
case dds::core::xtypes::TypeKind::UINT_8_TYPE:
|
||||
var = data.value<uint8_t>(member_index);
|
||||
break;
|
||||
case dds::core::xtypes::TypeKind::INT_16_TYPE:
|
||||
var = data.value<int16_t>(member_index);
|
||||
break;
|
||||
case dds::core::xtypes::TypeKind::UINT_16_TYPE:
|
||||
var = data.value<uint16_t>(member_index);
|
||||
break;
|
||||
case dds::core::xtypes::TypeKind::INT_32_TYPE:
|
||||
var = data.value<int32_t>(member_index);
|
||||
break;
|
||||
case dds::core::xtypes::TypeKind::UINT_32_TYPE:
|
||||
var = data.value<uint32_t>(member_index);
|
||||
break;
|
||||
case dds::core::xtypes::TypeKind::INT_64_TYPE:
|
||||
var = data.value<qlonglong>(member_index);
|
||||
break;
|
||||
case dds::core::xtypes::TypeKind::UINT_64_TYPE:
|
||||
var = data.value<qulonglong>(member_index);
|
||||
break;
|
||||
case dds::core::xtypes::TypeKind::FLOAT_32_TYPE:
|
||||
var = data.value<float>(member_index);
|
||||
break;
|
||||
case dds::core::xtypes::TypeKind::FLOAT_64_TYPE:
|
||||
var = data.value<double>(member_index);
|
||||
break;
|
||||
case dds::core::xtypes::TypeKind::ENUMERATION_TYPE:
|
||||
var = data.value<int32_t>(member_index);
|
||||
break;
|
||||
case dds::core::xtypes::TypeKind::BOOLEAN_TYPE:
|
||||
var = data.value<bool>(member_index);
|
||||
break;
|
||||
case dds::core::xtypes::TypeKind::STRING_TYPE:
|
||||
{
|
||||
const dds::core::string tmp = data.value<dds::core::string>(member_index);
|
||||
if (tmp.c_str()) // unset -> nullptr
|
||||
var = QString::fromUtf8(tmp.c_str ());
|
||||
break;
|
||||
}
|
||||
case dds::core::xtypes::TypeKind::STRUCTURE_TYPE:
|
||||
{
|
||||
// rti::core::xtypes::LoanedDynamicData innerLoaned = data.loan_value(member_index);
|
||||
processData(data.value<dds::core::xtypes::DynamicData>(member_index), ns + QString::fromStdString(info.member_name()) + QLatin1Char('.'));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
INFO_LOG(m_logger) << "Content : '" << var.toString() << "'";
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TopicData::tryProcessDataAsTyped(const dds::core::xtypes::DynamicData &data, const QString &ns)
|
||||
{
|
||||
// ExerciseManagement::Exercise
|
||||
if (processData<ExerciseManagement::Exercise>(data,ns))
|
||||
return true;
|
||||
|
||||
// Core::SpatialData
|
||||
if (processData<ParticipantManagement::Participant>(data,ns))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the typeCode of a topic if available in m_vddro
|
||||
* @param topicName
|
||||
* @return
|
||||
*/
|
||||
dds::core::xtypes::StructType TopicData::getTypeCode(const std::string &topicName) const
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "m_vDdro.size = " << m_vDdro.size();
|
||||
|
||||
for (int i = 0; i < m_vDdro.size(); ++i)
|
||||
{
|
||||
DDSGeneric::TopicDescription td = m_vDdro.at(i);
|
||||
if (td.name == topicName)
|
||||
{
|
||||
INFO_LOG(m_logger) << "Found topicType for #" << topicName;
|
||||
return td.type;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: oder besser throw?
|
||||
return dds::core::xtypes::StructType("Unknown");
|
||||
}
|
||||
|
||||
|
||||
} // Namespace DataSampleReceiver
|
||||
@@ -0,0 +1,78 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
*
|
||||
* TopicData
|
||||
* Uses DDTCs to subscribe to data
|
||||
*
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <QtCore/QVector>
|
||||
|
||||
#include <ExerciseManagement/exm.hpp>
|
||||
#include <ParticipantManagement/ppm.hpp>
|
||||
#include <dds/dds.hpp>
|
||||
#include <dds/core/xtypes/DynamicData.hpp>
|
||||
#include <NGLLogger/INGLLogger.h>
|
||||
|
||||
#include <DDS/DDSConnector/subscriber.h>
|
||||
|
||||
|
||||
namespace NGL
|
||||
{
|
||||
class INGLLogger;
|
||||
}
|
||||
|
||||
namespace DataSampleReceiver
|
||||
{
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
class TopicData : public DDSConnector::Subscriber
|
||||
{
|
||||
|
||||
public:
|
||||
explicit TopicData(const dds::domain::DomainParticipant &dp, const std::string &partition, const QVector<DDSGeneric::TopicDescription> &vDdro);
|
||||
~TopicData();
|
||||
|
||||
bool initDDTCs(const QVector<DDSGeneric::TopicDescription> &vDdro);
|
||||
|
||||
// Process data for specific topics
|
||||
void processData(const ExerciseManagement::Exercise &data);
|
||||
void processData(const ParticipantManagement::Participant &data);
|
||||
|
||||
bool processData(const dds::core::xtypes::DynamicData &data, const QString &ns = QString());
|
||||
|
||||
|
||||
// Process data as "typed" data
|
||||
template<typename T>
|
||||
bool processData(const dds::core::xtypes::DynamicData &data, const QString &topicName)
|
||||
{
|
||||
// TODO: really not needed?
|
||||
Q_UNUSED(topicName)
|
||||
if (rti::core::xtypes::can_convert<T>(data))
|
||||
{
|
||||
const T typedData = rti::core::xtypes::convert<T>(data);
|
||||
processData(typedData);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
protected:
|
||||
dds::core::xtypes::StructType getTypeCode(const std::string &topicName) const;
|
||||
|
||||
bool tryProcessDataAsTyped(const dds::core::xtypes::DynamicData &data, const QString &ns);
|
||||
|
||||
private:
|
||||
QVector<DDSGeneric::TopicDescription> m_vDdro;
|
||||
QMap<std::string, DTC::Ddtc<DDSGeneric::DynamicDataReader>*> m_ddtcMap;
|
||||
NGL::INGLLogger& m_logger;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
# copy of displayPanelSimulator for testing with dotMatrixDisplay
|
||||
|
||||
|
||||
SET(displayPanelSimulator_SRCS
|
||||
cmdlineparser.cpp
|
||||
displayPanelSimulatorMain.cpp
|
||||
displayPanelSimulatorTcpServer.cpp
|
||||
displayPanelSimulatorWidget.cpp
|
||||
nglsettings.cpp
|
||||
debugmessages.cpp
|
||||
)
|
||||
|
||||
SET(displayPanelSimulator_HDRS
|
||||
cmdlineparser.h
|
||||
displayPanelSimulatorTcpServer.h
|
||||
displayPanelSimulatorWidget.h
|
||||
nglsettings.h
|
||||
customMapsAndEnum.h
|
||||
debugmessages.h
|
||||
)
|
||||
|
||||
SET(displayPanelSimulator_UICS
|
||||
ui/displayPanelSimulatorWidget.ui
|
||||
ui/debugmessages.ui
|
||||
)
|
||||
|
||||
NGL_WRAP_UI(displayPanelSimulator_SRCS ${displayPanelSimulator_UICS})
|
||||
|
||||
NGL_ADD_EXECUTABLE(WS NO_TRANSLATION displayPanelSimulator
|
||||
${displayPanelSimulator_SRCS}
|
||||
${displayPanelSimulator_HDRS}
|
||||
)
|
||||
|
||||
NGL_TARGET_INCLUDE_DIRECTORIES(displayPanelSimulator
|
||||
PUBLIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../
|
||||
)
|
||||
|
||||
NGL_TARGET_LINK_LIBRARIES(displayPanelSimulator
|
||||
qledline
|
||||
nglapplication
|
||||
nglwidgets
|
||||
NGLLogger
|
||||
nglsettings
|
||||
Qt5::Core
|
||||
Qt5::Gui
|
||||
Qt5::Widgets
|
||||
Qt5::Network
|
||||
)
|
||||
CONFIGURE_FILE(rheinmetall.jpg ${CMAKE_BINARY_DIR}/rheinmetall.jpg COPYONLY)
|
||||
|
||||
NGL_INSTALL_TARGET_DEVEL(displayPanelSimulator)
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
#include "cmdlineparser.h"
|
||||
#include "nglsettings.h"
|
||||
|
||||
|
||||
CmdLineParser::CmdLineParser()
|
||||
: QCommandLineParser()
|
||||
, m_portCount(0)
|
||||
, m_showPort(false)
|
||||
, m_window(false)
|
||||
{
|
||||
}
|
||||
|
||||
CmdLineParser::~CmdLineParser()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
bool CmdLineParser::init()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void CmdLineParser::setWindow(bool state)
|
||||
{
|
||||
m_window = state;
|
||||
}
|
||||
|
||||
void CmdLineParser::setMode(const QString &mode)
|
||||
{
|
||||
m_mode = mode;
|
||||
}
|
||||
|
||||
void CmdLineParser::setImagePath(const QString &path)
|
||||
{
|
||||
m_imagePath = path;
|
||||
}
|
||||
|
||||
void CmdLineParser::setShowPort(bool port)
|
||||
{
|
||||
m_showPort = port;
|
||||
}
|
||||
|
||||
void CmdLineParser::setPortCount(int count)
|
||||
{
|
||||
m_portCount = count;
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QCommandLineParser>
|
||||
#include <QString>
|
||||
|
||||
class CmdLineParser : public QObject, public QCommandLineParser
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
CmdLineParser();
|
||||
~CmdLineParser();
|
||||
bool init();
|
||||
|
||||
// Getters
|
||||
int portCount() const { return m_portCount; }
|
||||
bool showPort() const { return m_showPort; }
|
||||
bool windowMode() const { return m_window; }
|
||||
QString port() const { return m_port; }
|
||||
QString mode() const { return m_mode; }
|
||||
QString ini() const { return m_ini; }
|
||||
QString imagePath() const { return m_imagePath; }
|
||||
|
||||
// Setters
|
||||
void setWindow(bool state);
|
||||
void setPort(const QString &port) { m_port = port; }
|
||||
void setMode(const QString &mode);
|
||||
void setIni(const QString &ini) { m_ini = ini; }
|
||||
void setImagePath(const QString &path);
|
||||
void setShowPort(bool port);
|
||||
void setPortCount(int count);
|
||||
|
||||
private:
|
||||
int m_portCount;
|
||||
bool m_showPort;
|
||||
bool m_window;
|
||||
QString m_port;
|
||||
QString m_mode;
|
||||
QString m_ini;
|
||||
QString m_imagePath;
|
||||
};
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Provides structs, typedefs and an enum
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Florian Schult, SLSE, 2016-03-18
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QString>
|
||||
#include <QMap>
|
||||
|
||||
struct Mode
|
||||
{
|
||||
QString name;
|
||||
int lines = 0;
|
||||
int letters = 0;
|
||||
int height = 0;
|
||||
};
|
||||
|
||||
struct Port
|
||||
{
|
||||
int port = 0;
|
||||
QString name;
|
||||
};
|
||||
|
||||
typedef QMap<QString, Mode> ModeMap;
|
||||
typedef QMap<int, Port> PortMap;
|
||||
|
||||
enum MsgLvl
|
||||
{
|
||||
MSGLVL_TRACE = 1,
|
||||
MSGLVL_DEBUG = 2,
|
||||
MSGLVL_INFO = 3,
|
||||
MSGLVL_WARNING = 4,
|
||||
MSGLVL_ERROR = 5,
|
||||
MSGLVL_FATAL = 6
|
||||
};
|
||||
|
||||
inline static QString levelName(MsgLvl lvl)
|
||||
{
|
||||
switch (lvl)
|
||||
{
|
||||
case MSGLVL_TRACE:
|
||||
return QStringLiteral("Trace");
|
||||
case MSGLVL_DEBUG:
|
||||
return QStringLiteral("Debug");
|
||||
case MSGLVL_INFO:
|
||||
return QStringLiteral("Info");
|
||||
case MSGLVL_WARNING:
|
||||
return QStringLiteral("Warning");
|
||||
case MSGLVL_ERROR:
|
||||
return QStringLiteral("Error");
|
||||
case MSGLVL_FATAL:
|
||||
return QStringLiteral("Fatal");
|
||||
}
|
||||
return QStringLiteral("Unknown (%1)").arg(lvl);
|
||||
}
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Pop-Up-Window, shows the Debug-Log
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Florian Schult, SLSE, 18. Mar 2016
|
||||
*/
|
||||
#include "debugmessages.h"
|
||||
#include "ui_debugmessages.h"
|
||||
|
||||
#include <QDateTime>
|
||||
#include <QMessageBox>
|
||||
|
||||
|
||||
DebugMessages::DebugMessages(QWidget *parent)
|
||||
: NGLDialog(parent)
|
||||
, m_ui(new Ui::DebugMessages)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
connect(m_ui->nglDialogButtonBox, &NGLDialogButtonBox::onClose,
|
||||
this, &DebugMessages::hide);
|
||||
connect(m_ui->nglDialogButtonBox, &NGLDialogButtonBox::onReset,
|
||||
m_ui->tbMain, &QTextBrowser::clear);
|
||||
}
|
||||
|
||||
DebugMessages::~DebugMessages()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void DebugMessages::onMessage(int port, const QString &msg, const MsgLvl &lvl)
|
||||
{
|
||||
QString color;
|
||||
switch (lvl)
|
||||
{
|
||||
case MSGLVL_DEBUG:
|
||||
case MSGLVL_TRACE:
|
||||
case MSGLVL_INFO:
|
||||
default:
|
||||
color = QStringLiteral("black");
|
||||
break;
|
||||
case MSGLVL_WARNING:
|
||||
color = QStringLiteral("orange");
|
||||
break;
|
||||
case MSGLVL_ERROR:
|
||||
case MSGLVL_FATAL:
|
||||
color = QStringLiteral("red");
|
||||
break;
|
||||
}
|
||||
|
||||
// Output to the to the Debug-Window
|
||||
m_ui->tbMain->append(QStringLiteral("<div style='color:%1'>%2\t \t| %3\t| %4 %6: %5</div>")
|
||||
.arg(color, QDateTime::currentDateTime().toString(), levelName(lvl), tr("port"), msg)
|
||||
.arg(port));
|
||||
|
||||
if (lvl == MSGLVL_FATAL)
|
||||
QMessageBox::warning(this, tr("Error"), msg);
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Provides structs, typedefs and an enum
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Florian Schult, SLSE, 2016-03-18
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <nglwidgets/ngldialog.h>
|
||||
|
||||
#include "customMapsAndEnum.h"
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class DebugMessages;
|
||||
}
|
||||
|
||||
class DebugMessages : public NGLDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DebugMessages(QWidget *parent = nullptr);
|
||||
~DebugMessages();
|
||||
|
||||
public slots:
|
||||
void onMessage(int port, const QString &msg, const MsgLvl &lvl);
|
||||
|
||||
private:
|
||||
Ui::DebugMessages *m_ui;
|
||||
};
|
||||
+126
@@ -0,0 +1,126 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Display Panel Simulator main programm; collects commandline options
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Florian Schult, SLSE, 2016-03-18
|
||||
*/
|
||||
|
||||
#include <nglapplication/nglapplication.h>
|
||||
#include <NGLLogger/INGLLogger.h>
|
||||
#include <memory>
|
||||
|
||||
#include "displayPanelSimulatorWidget.h"
|
||||
#include "nglsettings.h"
|
||||
#include "cmdlineparser.h"
|
||||
|
||||
/**
|
||||
* Main entry point for program.
|
||||
*/
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
NGLApplication application(argc, argv);
|
||||
|
||||
application.setOrganizationName(QStringLiteral("RME"));
|
||||
application.setApplicationName(QStringLiteral("Dot Matrix Display Simulator"));
|
||||
application.createLogger("DispSim", "log4cxx_displayPanelSimulator.props");
|
||||
|
||||
int ret = -1;
|
||||
|
||||
{
|
||||
std::unique_ptr<CmdLineParser> parser(new CmdLineParser);
|
||||
if (!parser->init())
|
||||
return ret;
|
||||
|
||||
QCommandLineOption modeOption({ QLatin1String("m"), QLatin1String("mode")}, QLatin1String("mode (not valid for use with -c)"), QLatin1String("?"));
|
||||
QCommandLineOption portOption({ QLatin1String("p"), QLatin1String("port")}, QLatin1String("Port(s), comma separated; better be over 9000"), QLatin1String("9000"));
|
||||
QCommandLineOption showPortOption({ QLatin1String("s"), QLatin1String("showport")}, QLatin1String("Set, for showing the portnumbers"));
|
||||
QCommandLineOption countOption({ QLatin1String("c"), QLatin1String("count")}, QLatin1String("Ports added on startport; ignored, when port has multiple"), QLatin1String("-1"));
|
||||
QCommandLineOption windowOption({ QLatin1String("w"), QLatin1String("window")}, QLatin1String("Starts application in window mode (overrides ini)"));
|
||||
QCommandLineOption inifileOption({ QLatin1String("i"), QLatin1String("inifile")}, QLatin1String("Path/Name for saving and loading settings to an .ini File"), QLatin1String("my.ini"));
|
||||
QCommandLineOption graphicOption({ QLatin1String("g"), QLatin1String("graphic")}, QLatin1String("Path/Name for loading a graphic from a .png File"), QLatin1String("rde.ico"));
|
||||
|
||||
parser->addOption(modeOption);
|
||||
parser->addOption(portOption);
|
||||
parser->addOption(showPortOption);
|
||||
parser->addOption(countOption);
|
||||
parser->addOption(windowOption);
|
||||
parser->addOption(inifileOption);
|
||||
parser->addOption(graphicOption);
|
||||
|
||||
parser->addHelpOption();
|
||||
parser->process(application);
|
||||
|
||||
|
||||
// ---------- Getting mode ----------
|
||||
if (parser->isSet(modeOption))
|
||||
parser->setMode(parser->value(modeOption));
|
||||
QString mode = parser->mode();
|
||||
|
||||
|
||||
// ---------- Getting ports ----------
|
||||
QStringList portList = parser->value(portOption).split(QLatin1Char(','));
|
||||
// QStringList portList = parser->port().split(QLatin1Char(','));
|
||||
portList.removeAll(QStringLiteral("0"));
|
||||
QVector<int> portNumbers;
|
||||
|
||||
// ---------- Count ports ----------
|
||||
if (parser->isSet(countOption))
|
||||
{
|
||||
int count = parser->value(countOption).toInt();
|
||||
parser->setPortCount(count);
|
||||
}
|
||||
|
||||
if (portList.count() > 1)
|
||||
{
|
||||
portNumbers.reserve(portList.size());
|
||||
for (const QString &s : qAsConst(portList))
|
||||
portNumbers << s.toInt();
|
||||
}
|
||||
else if (portList.count() == 1 && !portList.first().isEmpty())
|
||||
{
|
||||
portNumbers.reserve(parser->portCount());
|
||||
for (int i = 0; i < parser->portCount(); ++i)
|
||||
portNumbers << (portList[0].toInt() + i);
|
||||
}
|
||||
else
|
||||
{
|
||||
// no port given -> use default
|
||||
}
|
||||
|
||||
// ---------- Getting showPort option ----------
|
||||
if (parser->isSet(showPortOption))
|
||||
parser->setShowPort(true);
|
||||
|
||||
// ---------- Getting window option ----------
|
||||
if (parser->isSet(windowOption))
|
||||
parser->setWindow(true);
|
||||
|
||||
|
||||
// ---------- Getting inifile option ----------
|
||||
if (parser->isSet(inifileOption))
|
||||
parser->setIni(parser->value(inifileOption));
|
||||
NGLSettings::instance(parser->ini());
|
||||
|
||||
|
||||
// ---------- Gettings Image Path/Name ----------
|
||||
if (parser->isSet(graphicOption))
|
||||
parser->setImagePath(parser->value(graphicOption));
|
||||
|
||||
NGL::INGLLogger &logger = application.baseLogger();
|
||||
|
||||
STARTUP_LOG(logger);
|
||||
|
||||
std::unique_ptr<DisplayPanelSimulatorWidget> displayPanelWidget(new DisplayPanelSimulatorWidget);
|
||||
|
||||
if (displayPanelWidget->initialize(mode, portNumbers, !parser->windowMode(), parser->showPort(), parser->imagePath()) != 0)
|
||||
exit(-1);
|
||||
|
||||
ret = application.exec();
|
||||
SHUTDOWN_LOG(logger);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
Executable
+164
@@ -0,0 +1,164 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Display Panel Simulator TCP Server; observes the given port and emits the incoming messages
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Florian Schult, SLSE, 2016-03-18
|
||||
*/
|
||||
//===Include specifications==================================================
|
||||
#include "displayPanelSimulatorTcpServer.h"
|
||||
#include <QtNetwork/QTcpServer>
|
||||
#include <QtNetwork/QTcpSocket>
|
||||
|
||||
#include <NGLLogger/NGLLoggerBootstrap.h>
|
||||
|
||||
//===DisplayPanelSimulatorTcpServer==========================================
|
||||
|
||||
//---Constructors/Destructors------------------------------------------------
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
DisplayPanelSimulatorTcpServer::DisplayPanelSimulatorTcpServer(QObject *parent)
|
||||
: QObject(parent)
|
||||
, mp_server(new QTcpServer(this))
|
||||
, mp_socket(nullptr)
|
||||
, m_port(0)
|
||||
, m_logger(NGL::NGLLoggerBootstrap::getNGLRootLogger().getNGLLogger("DispSim.DisplayPanelSimulatorWidget"))
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
DisplayPanelSimulatorTcpServer::~DisplayPanelSimulatorTcpServer()
|
||||
{
|
||||
delete mp_server;
|
||||
}
|
||||
|
||||
//---Private slots-----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Handles the 'newConnection' signal of the TCP server.
|
||||
*/
|
||||
void DisplayPanelSimulatorTcpServer::handleServerNewConnection()
|
||||
{
|
||||
mp_socket = mp_server->nextPendingConnection();
|
||||
connect(mp_socket, &QTcpSocket::readyRead,
|
||||
this, &DisplayPanelSimulatorTcpServer::handleSocketReadyRead);
|
||||
emit debugMessage(m_port, QStringLiteral("Socket connected!"), MSGLVL_DEBUG);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the 'readyRead' signal of the TCP socket.
|
||||
*/
|
||||
void DisplayPanelSimulatorTcpServer::handleSocketReadyRead()
|
||||
{
|
||||
evaluateData(mp_socket->readAll());
|
||||
}
|
||||
|
||||
//---Private methods---------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Evaluates the received data from the TCP socket.
|
||||
*/
|
||||
void DisplayPanelSimulatorTcpServer::evaluateData(const QByteArray &data)
|
||||
{
|
||||
QByteArray page;
|
||||
QString message;
|
||||
bool ackRequested = false;
|
||||
bool dataOk = false;
|
||||
|
||||
if (data.isEmpty())
|
||||
return;
|
||||
|
||||
char cs = data.at(data.size() - 1);
|
||||
char csCalc = calculateChecksum(data);
|
||||
if (data.size() >= 5)
|
||||
ackRequested = data[4] & 0x08;
|
||||
if (data.size() < 10)
|
||||
{
|
||||
message = tr("Message to small!");
|
||||
|
||||
ERROR_LOG(m_logger) << "Error in message data evaluation";
|
||||
}
|
||||
else if (data[0] != 0)
|
||||
{
|
||||
message = tr("No SYNC in Message!");
|
||||
|
||||
ERROR_LOG(m_logger) << "Error in message data evaluation";
|
||||
}
|
||||
else if (cs != csCalc)
|
||||
{
|
||||
const QByteArray ba = "Wrong Checksum: 0x" + QByteArray::number(cs, 16) + " <-> 0x" + QByteArray::number(csCalc, 16);
|
||||
qDebug() << ba.data();
|
||||
message = QString::fromLatin1(ba);
|
||||
|
||||
ERROR_LOG(m_logger) << "Error in message data evaluation";
|
||||
}
|
||||
else
|
||||
{
|
||||
page = data.mid(5, 3);
|
||||
const QByteArray ba = data.mid(11, (data.size() - 13));
|
||||
message = QString::fromUtf8(ba.data(), ba.size());
|
||||
emit plainMessage(message);
|
||||
emit debugMessage(m_port, tr("New message received: %1").arg(message), MSGLVL_INFO);
|
||||
|
||||
INFO_LOG(m_logger) << "New message received";
|
||||
|
||||
dataOk = true;
|
||||
}
|
||||
if (!dataOk/* || page == "001"*/)
|
||||
{
|
||||
emit debugMessage(m_port, message, MSGLVL_ERROR);
|
||||
|
||||
ERROR_LOG(m_logger) << "Error in message data evaluation";
|
||||
|
||||
}
|
||||
if (ackRequested)
|
||||
{
|
||||
if (dataOk)
|
||||
{
|
||||
mp_socket->write("\x06"); // ACK
|
||||
}
|
||||
else
|
||||
{
|
||||
mp_socket->write("\x15"); // NAK
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the checksum of the received data from the TCP socket.
|
||||
*/
|
||||
char DisplayPanelSimulatorTcpServer::calculateChecksum(const QByteArray &data)
|
||||
{
|
||||
char checksum = 0;
|
||||
for (const auto c : data)
|
||||
checksum ^= c;
|
||||
|
||||
return checksum;
|
||||
}
|
||||
|
||||
//---Public methods----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Starts the TCP server.
|
||||
*/
|
||||
void DisplayPanelSimulatorTcpServer::start(int port)
|
||||
{
|
||||
m_port = port;
|
||||
connect(mp_server, &QTcpServer::newConnection,
|
||||
this, &DisplayPanelSimulatorTcpServer::handleServerNewConnection);
|
||||
emit debugMessage(m_port, tr("Waiting for connection"), MSGLVL_DEBUG);
|
||||
|
||||
if (!mp_server->listen(QHostAddress::Any, port))
|
||||
{
|
||||
emit debugMessage(m_port, tr("Opening socket failed! May be in use!"), MSGLVL_ERROR);
|
||||
|
||||
ERROR_LOG(m_logger) << "Opening socket failed; Port: " << port;
|
||||
}
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
Executable
+67
@@ -0,0 +1,67 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Display Panel Simulator TCP Server; observes the given port and emits the incoming messages
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Florian Schult, SLSE, 2016-03-18
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
//===Include specifications==================================================
|
||||
#include <QtCore/QObject>
|
||||
#include <NGLLogger/INGLLogger.h>
|
||||
|
||||
#include "customMapsAndEnum.h"
|
||||
|
||||
//===Forward declarations====================================================
|
||||
class QLabel;
|
||||
class QTcpServer;
|
||||
class QTcpSocket;
|
||||
class QLedLine;
|
||||
|
||||
//===Class specifications====================================================
|
||||
/**
|
||||
* Display panel simulator TCP server.
|
||||
*/
|
||||
class DisplayPanelSimulatorTcpServer: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
// References -------------------------------------------------------------
|
||||
private:
|
||||
/**
|
||||
* Reference of the display panel simulator TCP server.
|
||||
*/
|
||||
QTcpServer *mp_server;
|
||||
|
||||
/**
|
||||
* Reference of the display panel simulator TCP socket.
|
||||
*/
|
||||
QTcpSocket *mp_socket;
|
||||
|
||||
int m_port;
|
||||
NGL::INGLLogger &m_logger;
|
||||
|
||||
// Slots ------------------------------------------------------------------
|
||||
private Q_SLOTS:
|
||||
void handleServerNewConnection();
|
||||
void handleSocketReadyRead();
|
||||
|
||||
// Signals ----------------------------------------------------------------
|
||||
Q_SIGNALS:
|
||||
void debugMessage(int port, const QString &message, MsgLvl lvl);
|
||||
void plainMessage(const QString &message);
|
||||
|
||||
// Methods ----------------------------------------------------------------
|
||||
private:
|
||||
void evaluateData(const QByteArray &data);
|
||||
static char calculateChecksum(const QByteArray &data);
|
||||
|
||||
public:
|
||||
explicit DisplayPanelSimulatorTcpServer(QObject *parent = nullptr);
|
||||
virtual ~DisplayPanelSimulatorTcpServer();
|
||||
void start(int port);
|
||||
};
|
||||
|
||||
//===========================================================================
|
||||
Executable
+333
@@ -0,0 +1,333 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Display Panel Simulator widget; manages the LED-lines and servers
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Florian Schult, SLSE, 2016-03-18
|
||||
*/
|
||||
//===Include specifications==================================================
|
||||
#include "displayPanelSimulatorWidget.h"
|
||||
#include "ui_displayPanelSimulatorWidget.h"
|
||||
#include "displayPanelSimulatorTcpServer.h"
|
||||
#include "nglsettings.h"
|
||||
#include "debugmessages.h"
|
||||
#include "ui_debugmessages.h"
|
||||
|
||||
#include <QCloseEvent>
|
||||
#include <QLabel>
|
||||
#include <QStatusBar>
|
||||
#include <QSettings>
|
||||
#include <QBoxLayout>
|
||||
#include <QImage>
|
||||
#include <QLedLine/qledline.h>
|
||||
#include <NGLLogger/NGLLoggerBootstrap.h>
|
||||
|
||||
|
||||
DisplayPanelSimulatorWidget::DisplayPanelSimulatorWidget()
|
||||
: QMainWindow()
|
||||
, m_servers()
|
||||
, m_ui(new Ui::DisplayPanelSimulatorWidget)
|
||||
, m_ports()
|
||||
, m_ledLines()
|
||||
, m_mode()
|
||||
, m_message()
|
||||
, m_debugMessages(new DebugMessages(this))
|
||||
, m_statusLabel(new QLabel(this))
|
||||
, m_logger(NGL::NGLLoggerBootstrap::getNGLRootLogger().getNGLLogger("DispSim.DisplayPanelSimulatorWidget"))
|
||||
, m_charSize()
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
restoreGeometry(NGLSettings::instance()->windowGeometry());
|
||||
restoreState(NGLSettings::instance()->windowState());
|
||||
|
||||
m_statusLabel->setStyleSheet(QStringLiteral("QLabel {color: red;}"));
|
||||
m_statusLabel->setContentsMargins(0, 0, 0, 1);
|
||||
m_ui->statusBar->addPermanentWidget(m_statusLabel);
|
||||
|
||||
connect(m_ui->fullscreenAction, &QAction::toggled,
|
||||
this, &DisplayPanelSimulatorWidget::onFullscreenAction);
|
||||
connect(m_ui->debugInfosAction, &QAction::triggered,
|
||||
this, &DisplayPanelSimulatorWidget::onDebugInfosAction);
|
||||
connect(m_ui->exitAction, &QAction::triggered,
|
||||
this, &DisplayPanelSimulatorWidget::onExitAction);
|
||||
connect(m_ui->saveSettingsAction, &QAction::triggered,
|
||||
this, &DisplayPanelSimulatorWidget::onSaveSettingsAction);
|
||||
DEBUG_LOG(m_logger) << "DisplayPanelSimulatorWidget finished";
|
||||
}
|
||||
|
||||
DisplayPanelSimulatorWidget::~DisplayPanelSimulatorWidget()
|
||||
{
|
||||
qDeleteAll(m_servers);
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
//---Private slots-----------------------------------------------------------
|
||||
|
||||
void DisplayPanelSimulatorWidget::onExitAction()
|
||||
{
|
||||
close();
|
||||
}
|
||||
|
||||
void DisplayPanelSimulatorWidget::onSaveSettingsAction()
|
||||
{
|
||||
NGLSettings::instance()->setPorts(m_ports);
|
||||
NGLSettings::instance()->setLastMode(m_mode.name);
|
||||
|
||||
INFO_LOG(m_logger) << "Save settings action triggered";
|
||||
}
|
||||
|
||||
void DisplayPanelSimulatorWidget::onDebugInfosAction()
|
||||
{
|
||||
m_debugMessages->show();
|
||||
m_debugMessages->raise();
|
||||
m_debugMessages->activateWindow();
|
||||
|
||||
INFO_LOG(m_logger) << "Debug console triggered";
|
||||
}
|
||||
|
||||
void DisplayPanelSimulatorWidget::writeMultiLiners(const QString &string)
|
||||
{
|
||||
QString fullString = string.leftJustified((m_mode.letters * m_mode.lines), QLatin1Char(' '), true);
|
||||
for (int i = 0; i < fullString.size(); i += m_mode.letters)
|
||||
m_ledLines[i / m_mode.letters]->setText(fullString.mid(i, m_mode.letters));
|
||||
}
|
||||
|
||||
void DisplayPanelSimulatorWidget::onErrorMsg(int port, const QString &string, MsgLvl lvl)
|
||||
{
|
||||
if (lvl < MSGLVL_ERROR)
|
||||
return;
|
||||
|
||||
m_statusLabel->setText(tr("%1: %2 %3 <|> %4").arg(levelName(lvl), tr("Port")).arg(port).arg(string));
|
||||
}
|
||||
|
||||
void DisplayPanelSimulatorWidget::onFullscreenAction(bool fullscreen)
|
||||
{
|
||||
if (fullscreen)
|
||||
{
|
||||
NGLSettings::instance()->setPreFullscreenWindowState(saveState());
|
||||
NGLSettings::instance()->setPreFullscreenWindowGeometry(saveGeometry());
|
||||
this->setWindowState(Qt::WindowFullScreen);
|
||||
}
|
||||
else
|
||||
{
|
||||
this->setWindowState(Qt::WindowNoState);
|
||||
restoreState(NGLSettings::instance()->preFullscreenwindowState());
|
||||
restoreGeometry(NGLSettings::instance()->preFullscreenwindowGeometry());
|
||||
}
|
||||
}
|
||||
|
||||
//---Protected methods-------------------------------------------------------
|
||||
|
||||
void DisplayPanelSimulatorWidget::changeEvent(QEvent *event)
|
||||
{
|
||||
if (event->type() == QEvent::LanguageChange)
|
||||
m_ui->retranslateUi(this);
|
||||
QMainWindow::changeEvent(event);
|
||||
}
|
||||
|
||||
|
||||
void DisplayPanelSimulatorWidget::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
hide();
|
||||
NGLSettings::instance()->setFullscreen(m_ui->fullscreenAction->isChecked());
|
||||
m_ui->fullscreenAction->setChecked(false);
|
||||
NGLSettings::instance()->setWindowGeometry(saveGeometry());
|
||||
NGLSettings::instance()->setWindowState(saveState());
|
||||
|
||||
event->accept();
|
||||
QMainWindow::closeEvent(event);
|
||||
}
|
||||
|
||||
|
||||
void DisplayPanelSimulatorWidget::keyPressEvent(QKeyEvent *event)
|
||||
{
|
||||
if (event->key() == Qt::Key_Escape)
|
||||
m_ui->fullscreenAction->setChecked(false);
|
||||
|
||||
QMainWindow::keyPressEvent(event);
|
||||
}
|
||||
|
||||
//---Private Methods----------------------------------------------------------
|
||||
|
||||
// Note: Can return comma separated list which is special case.
|
||||
QString DisplayPanelSimulatorWidget::findFullMode(const QString &stubMode, const ModeMap &map)
|
||||
{
|
||||
QStringList retVal;
|
||||
for (auto it = map.begin(); it != map.end(); ++it)
|
||||
{
|
||||
if (it.key().startsWith(stubMode, Qt::CaseInsensitive))
|
||||
retVal << it.key();
|
||||
}
|
||||
return retVal.join(QStringLiteral(", "));
|
||||
}
|
||||
|
||||
//---Public methods----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Initializes the widget itself.
|
||||
*
|
||||
* @return Result code:
|
||||
* 0 = Initialize ok.
|
||||
* 1 = Member initialisation failed.
|
||||
* 2 = Signal/slot initialisation failed.
|
||||
* 3 = Mode is ambigious.
|
||||
* 4 = Mode not found.
|
||||
*/
|
||||
int DisplayPanelSimulatorWidget::initialize(const QString &mode_, const QVector<int> &ports, bool fullscreen, bool showPort, const QString &imagePath)
|
||||
{
|
||||
if (!ports.isEmpty())
|
||||
{
|
||||
Port p;
|
||||
for (int i = 0; i < ports.size(); ++i)
|
||||
{
|
||||
p.name = tr("Port: %1").arg(ports[i]);
|
||||
p.port = ports[i];
|
||||
m_ports.insert(i, p);
|
||||
}
|
||||
}
|
||||
else
|
||||
m_ports = NGLSettings::instance()->ports();
|
||||
|
||||
const QString mode = (mode_.isEmpty() ? NGLSettings::instance()->lastMode() : mode_);
|
||||
|
||||
m_debugMessages->onMessage(m_ports[0].port, tr("Mode: %1").arg(mode), MSGLVL_DEBUG);
|
||||
|
||||
DEBUG_LOG(m_logger) << "Mode: " << mode;
|
||||
|
||||
const ModeMap modeMap = NGLSettings::instance()->modes();
|
||||
|
||||
QString fullmode = findFullMode(mode, modeMap);
|
||||
if (fullmode.contains(QLatin1Char(',')))
|
||||
{
|
||||
m_debugMessages->onMessage(m_ports[0].port, tr("Mode '%1' is ambigious: %2.").arg(mode, fullmode), MSGLVL_FATAL);
|
||||
ERROR_LOG(m_logger) << "Mode '" << mode << "' is ambigious: " << fullmode << ".";
|
||||
return 3;
|
||||
}
|
||||
if (fullmode.isEmpty())
|
||||
{
|
||||
m_debugMessages->onMessage(m_ports[0].port, tr("Mode '%1' not found.").arg(mode), MSGLVL_FATAL);
|
||||
ERROR_LOG(m_logger) << "Mode '" << mode << "' not found.";
|
||||
return 4;
|
||||
}
|
||||
|
||||
m_mode = modeMap[fullmode];
|
||||
|
||||
QHBoxLayout *centralLayout = static_cast<QHBoxLayout *>(this->centralWidget()->layout());
|
||||
QVBoxLayout *vLayout = new QVBoxLayout();
|
||||
QLabel *label = nullptr;
|
||||
|
||||
// Member initialisation
|
||||
if (m_mode.lines == 1)
|
||||
{
|
||||
// Single line modes ----------------------------------------------
|
||||
for (int i = 0; i < m_ports.size(); ++i)
|
||||
{
|
||||
m_debugMessages->onMessage(m_ports[0].port, tr("Opening port %1 with mode %2").arg(m_ports[0].port).arg(m_mode.name), MSGLVL_DEBUG);
|
||||
DEBUG_LOG(m_logger) << "Opening port " << m_ports[0].port << " with mode " << m_mode.name;
|
||||
|
||||
if (showPort)
|
||||
{
|
||||
// Heading
|
||||
label = new QLabel(this);
|
||||
label->setText(m_ports[i].name);
|
||||
label->setAlignment(Qt::AlignHCenter);
|
||||
vLayout->addWidget(label);
|
||||
}
|
||||
|
||||
// LedLine
|
||||
QLedLine *ledLine = new QLedLine(this);
|
||||
ledLine->setCharCountAndHeight(m_mode.letters, m_mode.height);
|
||||
m_ledLines.append(ledLine);
|
||||
vLayout->addWidget(ledLine);
|
||||
|
||||
// Server connection
|
||||
DisplayPanelSimulatorTcpServer *server = new DisplayPanelSimulatorTcpServer(this);
|
||||
m_servers.append(server);
|
||||
connect(server, &DisplayPanelSimulatorTcpServer::plainMessage, ledLine, &QLedLine::setText); // Text to LedLine
|
||||
connect(server, &DisplayPanelSimulatorTcpServer::debugMessage, m_debugMessages, &DebugMessages::onMessage); // Debug-stuff to debug window
|
||||
connect(server, &DisplayPanelSimulatorTcpServer::debugMessage, this, &DisplayPanelSimulatorWidget::onErrorMsg); // Debug to status bar
|
||||
server->start(m_ports[i].port);
|
||||
}
|
||||
// \Single line modes ----------------------------------------------
|
||||
}
|
||||
else
|
||||
{
|
||||
// Multi line modes ----------------------------------------------
|
||||
m_debugMessages->onMessage(m_ports[0].port, tr("Opening port %1 with mode %2").arg(m_ports[0].port).arg(m_mode.name), MSGLVL_DEBUG);
|
||||
DEBUG_LOG(m_logger) << "Opening port " << m_ports[0].port << " with mode " << m_mode.name;
|
||||
|
||||
int linesNeeded = m_mode.lines;
|
||||
|
||||
if (showPort)
|
||||
{
|
||||
//Heading
|
||||
label = new QLabel(this);
|
||||
label->setText(m_ports[0].name);
|
||||
label->setAlignment(Qt::AlignHCenter);
|
||||
vLayout->addWidget(label);
|
||||
}
|
||||
|
||||
// Server connection
|
||||
DisplayPanelSimulatorTcpServer *server = new DisplayPanelSimulatorTcpServer(this);
|
||||
m_servers.append(server);
|
||||
connect(server, &DisplayPanelSimulatorTcpServer::plainMessage, this, &DisplayPanelSimulatorWidget::writeMultiLiners); // Text to LedLine
|
||||
connect(server, &DisplayPanelSimulatorTcpServer::debugMessage, m_debugMessages, &DebugMessages::onMessage); // Debug-stuff to debug window
|
||||
connect(server, &DisplayPanelSimulatorTcpServer::debugMessage, this, &DisplayPanelSimulatorWidget::onErrorMsg); // Debug to status bar
|
||||
server->start(m_ports[0].port);
|
||||
|
||||
for (int i = 0; i < linesNeeded; ++i)
|
||||
{
|
||||
// LedLine
|
||||
QLedLine *ledLine = new QLedLine(this);
|
||||
ledLine->setCharCountAndHeight(m_mode.letters, m_mode.height);
|
||||
m_ledLines.append(ledLine);
|
||||
vLayout->addWidget(ledLine);
|
||||
}
|
||||
// \Multi line modes ----------------------------------------------
|
||||
}
|
||||
|
||||
// Graphic show -------------------------------------------
|
||||
// Todo: Zentriert? Nein, gibt keine Flag, evtl. extra Image erstellen und prependen etc.
|
||||
|
||||
QImage image(imagePath.isEmpty() ? QStringLiteral("./rheinmetall.jpg") : imagePath);
|
||||
if (!image.isNull())
|
||||
{
|
||||
scaleImage(image);
|
||||
for (int i = 0; i < m_ledLines.size(); ++i)
|
||||
{
|
||||
const QImage lineImage = image.copy(0, (m_charSize.height() * i), image.width(), m_charSize.height());
|
||||
m_ledLines[i]->setImage(lineImage);
|
||||
}
|
||||
}
|
||||
// \Graphic show -------------------------------------------
|
||||
|
||||
vLayout->setContentsMargins(0, 0, 0, 0);
|
||||
vLayout->setSpacing(0);
|
||||
|
||||
centralLayout->addLayout(vLayout);
|
||||
centralLayout->addSpacerItem(new QSpacerItem(0, 0,
|
||||
QSizePolicy::Minimum,
|
||||
QSizePolicy::Expanding));
|
||||
|
||||
INFO_LOG(m_logger) << "All LedLines initialised";
|
||||
|
||||
fullscreen |= NGLSettings::instance()->fullscreen();
|
||||
m_ui->fullscreenAction->setChecked(fullscreen);
|
||||
show();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void DisplayPanelSimulatorWidget::scaleImage(QImage &image)
|
||||
{
|
||||
m_charSize = m_ledLines[0]->charSize();
|
||||
|
||||
// Width per QLedChar times QLedChars per QLedLine; and Height per QLedChar times QLedLines needed
|
||||
QSize maxPxSize((m_charSize.width() * m_mode.letters), (m_charSize.height() * (m_mode.lines == 1 ? m_ports.size() : m_mode.lines)));
|
||||
|
||||
image = image.scaled(maxPxSize, Qt::KeepAspectRatio);
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
+75
@@ -0,0 +1,75 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Display Panel Simulator widget; manages the LED-lines and servers
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Florian Schult, SLSE, 2016-03-18
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
//===Include specifications==================================================
|
||||
#include "customMapsAndEnum.h"
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QVector>
|
||||
#include <NGLLogger/INGLLogger.h>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class DisplayPanelSimulatorWidget;
|
||||
}
|
||||
|
||||
class DisplayPanelSimulatorTcpServer;
|
||||
class QLedLine;
|
||||
class DebugMessages;
|
||||
class QLabel;
|
||||
class QImage;
|
||||
class QSize;
|
||||
|
||||
|
||||
class DisplayPanelSimulatorWidget : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
DisplayPanelSimulatorWidget(/*QWidget *parent = nullptr*/);
|
||||
~DisplayPanelSimulatorWidget();
|
||||
static DisplayPanelSimulatorWidget *self();
|
||||
int initialize(const QString &mode_, const QVector<int> &ports, bool fullscreen, bool showPort, const QString &imagePath);
|
||||
|
||||
|
||||
protected:
|
||||
virtual void changeEvent(QEvent *event);
|
||||
virtual void closeEvent(QCloseEvent *event);
|
||||
virtual void keyPressEvent(QKeyEvent *e);
|
||||
|
||||
|
||||
public slots:
|
||||
void onDebugInfosAction();
|
||||
void onFullscreenAction(bool fullscreen);
|
||||
|
||||
private Q_SLOTS:
|
||||
void writeMultiLiners(const QString &string);
|
||||
void onErrorMsg(int port, const QString &string, MsgLvl lvl);
|
||||
void onExitAction();
|
||||
void onSaveSettingsAction();
|
||||
|
||||
|
||||
private:
|
||||
static QString findFullMode(const QString &stubMode, const ModeMap &map);
|
||||
void scaleImage(QImage &image);
|
||||
|
||||
|
||||
QVector<DisplayPanelSimulatorTcpServer *> m_servers;
|
||||
Ui::DisplayPanelSimulatorWidget *m_ui;
|
||||
PortMap m_ports;
|
||||
QVector<QLedLine *> m_ledLines;
|
||||
Mode m_mode;
|
||||
QString m_message;
|
||||
DebugMessages *m_debugMessages;
|
||||
QLabel *m_statusLabel;
|
||||
NGL::INGLLogger &m_logger;
|
||||
QSize m_charSize;
|
||||
};
|
||||
|
||||
@@ -0,0 +1,186 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Settings for Display Panel Simulator
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Florian Schult, SLSE, 2016-03-18
|
||||
*/
|
||||
#include "nglsettings.h"
|
||||
|
||||
#include <QtCore/QCoreApplication>
|
||||
#include <QtCore/QSettings>
|
||||
|
||||
#include <NGLLogger/NGLLoggerBootstrap.h>
|
||||
|
||||
static NGLSettings *s_instance = nullptr;
|
||||
|
||||
static void cleanupSettings()
|
||||
{
|
||||
delete s_instance;
|
||||
s_instance = nullptr;
|
||||
}
|
||||
|
||||
NGLSettings::NGLSettings(const QString &iniFileName)
|
||||
: NGL::Settings(iniFileName)
|
||||
{
|
||||
s_instance = this;
|
||||
}
|
||||
|
||||
NGLSettings::~NGLSettings()
|
||||
{
|
||||
}
|
||||
|
||||
PortMap NGLSettings::ports()
|
||||
{
|
||||
PortMap portMap;
|
||||
settings()->beginGroup(QStringLiteral("Ports"));
|
||||
{
|
||||
int size = settings()->beginReadArray(QStringLiteral("Port"));
|
||||
{
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
Port p;
|
||||
settings()->setArrayIndex(i);
|
||||
p.port = settings()->value(QStringLiteral("PortNumber")).toInt();
|
||||
p.name = settings()->value(QStringLiteral("Title")).toString();
|
||||
portMap.insert(i, p);
|
||||
}
|
||||
}
|
||||
settings()->endArray();
|
||||
}
|
||||
settings()->endGroup();
|
||||
return portMap;
|
||||
}
|
||||
|
||||
void NGLSettings::setPorts(const PortMap &portMap)
|
||||
{
|
||||
settings()->beginGroup(QStringLiteral("Ports"));
|
||||
{
|
||||
settings()->remove(QString());
|
||||
settings()->beginWriteArray(QStringLiteral("Port"));
|
||||
{
|
||||
int i = 0;
|
||||
for (const Port &port : portMap)
|
||||
{
|
||||
settings()->setArrayIndex(i++);
|
||||
settings()->setValue(QStringLiteral("PortNumber"), port.port);
|
||||
settings()->setValue(QStringLiteral("Title"), port.name.isEmpty() ? QObject::tr("Port: %1").arg(port.port, 5) : port.name);
|
||||
}
|
||||
}
|
||||
settings()->endArray();
|
||||
}
|
||||
settings()->endGroup();
|
||||
}
|
||||
|
||||
QString NGLSettings::lastMode()
|
||||
{
|
||||
return settings()->value(QStringLiteral("lastMode")).toString();
|
||||
}
|
||||
|
||||
void NGLSettings::setLastMode(const QString &modeName)
|
||||
{
|
||||
settings()->setValue(QStringLiteral("lastMode"), modeName);
|
||||
}
|
||||
|
||||
QByteArray NGLSettings::windowGeometry()
|
||||
{
|
||||
return settings()->value(QStringLiteral("Window/Geometry")).toByteArray();
|
||||
}
|
||||
|
||||
void NGLSettings::setWindowGeometry(const QByteArray &ba)
|
||||
{
|
||||
settings()->setValue(QStringLiteral("Window/Geometry"), ba);
|
||||
}
|
||||
|
||||
QByteArray NGLSettings::windowState()
|
||||
{
|
||||
return settings()->value(QStringLiteral("Window/WindowState")).toByteArray();
|
||||
}
|
||||
|
||||
void NGLSettings::setWindowState(const QByteArray &ba)
|
||||
{
|
||||
settings()->setValue(QStringLiteral("Window/WindowState"), ba);
|
||||
}
|
||||
|
||||
QByteArray NGLSettings::preFullscreenwindowState()
|
||||
{
|
||||
return settings()->value(QStringLiteral("Window/PreFullscreenState")).toByteArray();
|
||||
}
|
||||
|
||||
void NGLSettings::setPreFullscreenWindowState(const QByteArray &ba)
|
||||
{
|
||||
settings()->setValue(QStringLiteral("Window/PreFullscreenState"), ba);
|
||||
}
|
||||
|
||||
QByteArray NGLSettings::preFullscreenwindowGeometry()
|
||||
{
|
||||
return settings()->value(QStringLiteral("Window/PreFullscreenGeometry")).toByteArray();
|
||||
}
|
||||
|
||||
void NGLSettings::setPreFullscreenWindowGeometry(const QByteArray &ba)
|
||||
{
|
||||
settings()->setValue(QStringLiteral("Window/PreFullscreenGeometry"), ba);
|
||||
}
|
||||
|
||||
ModeMap NGLSettings::modes()
|
||||
{
|
||||
ModeMap modemap;
|
||||
settings()->beginGroup(QStringLiteral("Modes"));
|
||||
{
|
||||
int size = settings()->beginReadArray(QStringLiteral("Mode"));
|
||||
{
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
settings()->setArrayIndex(i);
|
||||
Mode m;
|
||||
m.name = settings()->value(QStringLiteral("name")).toString();
|
||||
m.lines = settings()->value(QStringLiteral("lines")).toInt();
|
||||
m.letters = settings()->value(QStringLiteral("letters")).toInt();
|
||||
m.height = settings()->value(QStringLiteral("height")).toInt();
|
||||
modemap.insert(m.name, m);
|
||||
}
|
||||
}
|
||||
settings()->endArray();
|
||||
}
|
||||
settings()->endGroup();
|
||||
|
||||
return modemap;
|
||||
}
|
||||
|
||||
void NGLSettings::addMode(const Mode &mode)
|
||||
{
|
||||
settings()->beginGroup(QStringLiteral("Modes"));
|
||||
{
|
||||
settings()->beginWriteArray(QStringLiteral("Mode"));
|
||||
{
|
||||
settings()->setValue(QStringLiteral("name"), mode.name);
|
||||
settings()->setValue(QStringLiteral("lines"), mode.lines);
|
||||
settings()->setValue(QStringLiteral("letters"), mode.letters);
|
||||
settings()->setValue(QStringLiteral("height"), mode.height);
|
||||
}
|
||||
settings()->endArray();
|
||||
}
|
||||
settings()->endGroup();
|
||||
}
|
||||
|
||||
bool NGLSettings::fullscreen()
|
||||
{
|
||||
return settings()->value(QStringLiteral("lastFullscreen")).toBool();
|
||||
}
|
||||
|
||||
void NGLSettings::setFullscreen(bool fullscreen)
|
||||
{
|
||||
settings()->setValue(QStringLiteral("lastFullscreen"), fullscreen);
|
||||
}
|
||||
|
||||
NGLSettings *NGLSettings::instance(const QString &iniFileName)
|
||||
{
|
||||
if (!s_instance)
|
||||
qAddPostRoutine(cleanupSettings);
|
||||
|
||||
delete s_instance;
|
||||
s_instance = new NGLSettings((!s_instance && iniFileName.isEmpty()) ? QStringLiteral("DotMatrixDisplay.ini") : iniFileName);
|
||||
|
||||
return s_instance;
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Settings for Display Panel Simulator
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Florian Schult, SLSE, 2016-03-18
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "customMapsAndEnum.h"
|
||||
|
||||
#include <nglsettings/nglsettings_settings.h>
|
||||
#include <QMap>
|
||||
|
||||
class NGLSettings : public NGL::Settings
|
||||
{
|
||||
explicit NGLSettings(const QString &iniFileName = QString());
|
||||
|
||||
public:
|
||||
virtual ~NGLSettings();
|
||||
|
||||
PortMap ports();
|
||||
void setPorts(const PortMap &portMap);
|
||||
|
||||
QString lastMode();
|
||||
void setLastMode(const QString &modeName);
|
||||
|
||||
QByteArray windowGeometry();
|
||||
void setWindowGeometry(const QByteArray &ba);
|
||||
|
||||
QByteArray windowState();
|
||||
void setWindowState(const QByteArray &ba);
|
||||
|
||||
QByteArray preFullscreenwindowState();
|
||||
void setPreFullscreenWindowState(const QByteArray &ba);
|
||||
|
||||
QByteArray preFullscreenwindowGeometry();
|
||||
void setPreFullscreenWindowGeometry(const QByteArray &ba);
|
||||
|
||||
bool fullscreen();
|
||||
void setFullscreen(bool fullscreen);
|
||||
|
||||
ModeMap modes();
|
||||
|
||||
void addMode(const Mode &mode);
|
||||
|
||||
static NGLSettings *instance(const QString &iniFileName = QString());
|
||||
|
||||
private:
|
||||
QString m_ini;
|
||||
};
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 7.4 KiB |
+39
@@ -0,0 +1,39 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>DebugMessages</class>
|
||||
<widget class="QDialog" name="DebugMessages">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>636</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Debug Messages</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QTextBrowser" name="tbMain"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="NGLDialogButtonBox" name="nglDialogButtonBox">
|
||||
<property name="standardButtons">
|
||||
<set>NGLStandardButton::Close|NGLStandardButton::Reset</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>NGLDialogButtonBox</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>nglwidgets/ngldialogbuttonbox.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
Executable
+98
@@ -0,0 +1,98 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>DisplayPanelSimulatorWidget</class>
|
||||
<widget class="QMainWindow" name="DisplayPanelSimulatorWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>489</width>
|
||||
<height>307</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string comment="Window title">Display panel simulator</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralWidget">
|
||||
<layout class="QVBoxLayout" name="verticalLayout" stretch="">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetMinimumSize</enum>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menuBar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>489</width>
|
||||
<height>19</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menuDesktop">
|
||||
<property name="title">
|
||||
<string comment="'Desktop' menu title">&Desktop</string>
|
||||
</property>
|
||||
<addaction name="saveSettingsAction"/>
|
||||
<addaction name="debugInfosAction"/>
|
||||
<addaction name="fullscreenAction"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="exitAction"/>
|
||||
</widget>
|
||||
<addaction name="menuDesktop"/>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusBar"/>
|
||||
<action name="exitAction">
|
||||
<property name="text">
|
||||
<string comment="'Exit' action text">&Exit</string>
|
||||
</property>
|
||||
<property name="statusTip">
|
||||
<string comment="Exit action statusTip">The application will be closed.</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+Q</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="saveSettingsAction">
|
||||
<property name="text">
|
||||
<string>&Save Settings</string>
|
||||
</property>
|
||||
<property name="statusTip">
|
||||
<string>Saves the latest settings.</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+S</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="debugInfosAction">
|
||||
<property name="text">
|
||||
<string>&Debug Infos</string>
|
||||
</property>
|
||||
<property name="statusTip">
|
||||
<string>Opens the debug console.</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+D</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="fullscreenAction">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Fullscreen</string>
|
||||
</property>
|
||||
<property name="statusTip">
|
||||
<string>Toggles the windows Size.</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+F</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -0,0 +1,27 @@
|
||||
#
|
||||
# CMakeLists.txt for EEMFakeServer - a WebSocket Server to have a fake set of events to
|
||||
# load from, instead of sitting at the reference machine and hoping that available data
|
||||
# is usable or even available.
|
||||
#
|
||||
# $Id: CMakeLists.txt 42546 2018-06-20 15:16:43Z wille_m $
|
||||
# $HeadURL: svn://slssvn/TDS/branches/product/devel/trunk/Lts/Tools/SqlBrowser/CMakeLists.txt $
|
||||
# $Author: wille_m $
|
||||
# Created by Mike Wille, NLE, 2020-01-20
|
||||
#
|
||||
|
||||
SET(EEMFakeServer_SRCS
|
||||
main.cpp
|
||||
Server.cpp
|
||||
Server.h
|
||||
)
|
||||
|
||||
NGL_ADD_EXECUTABLE(TOOLSSV NO_TRANSLATION EEMFakeServer ${EEMFakeServer_SRCS})
|
||||
NGL_TARGET_LINK_LIBRARIES(EEMFakeServer
|
||||
PUBLIC
|
||||
Qt5::Core
|
||||
Qt5::WebSockets
|
||||
)
|
||||
|
||||
IF(NOT BUILD_RPM)
|
||||
NGL_INSTALL_TARGET(EEMFakeServer)
|
||||
ENDIF()
|
||||
@@ -0,0 +1,224 @@
|
||||
#include "Server.h"
|
||||
|
||||
#include <QWebSocketServer>
|
||||
#include <QWebSocket>
|
||||
#include <QDateTime>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonArray>
|
||||
#include <QUrl>
|
||||
#include <QUrlQuery>
|
||||
#include <QCoreApplication>
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
#include <QDebug>
|
||||
|
||||
|
||||
Server::Server()
|
||||
: QObject(nullptr)
|
||||
, m_server(new QWebSocketServer(QString(), QWebSocketServer::NonSecureMode, this))
|
||||
{
|
||||
qsrand(time(nullptr));
|
||||
}
|
||||
|
||||
|
||||
qint64 randomBetween(qint64 min, qint64 max)
|
||||
{
|
||||
qint64 val = qrand(); // qrand returns int (32 bit)
|
||||
val <<= 32;
|
||||
val |= qrand();
|
||||
return val % (max - min) + min;
|
||||
}
|
||||
|
||||
|
||||
bool Server::init(quint16 port)
|
||||
{
|
||||
if (QCoreApplication::arguments().count() < 3)
|
||||
{
|
||||
qWarning() << "usage:" << QCoreApplication::arguments().at(0) << "<event count> <hours backlog> (example: '30000 48' which creates 30.000 events between now and a 48 hour backlog)";
|
||||
return false;
|
||||
}
|
||||
|
||||
bool k = true;
|
||||
int events = QCoreApplication::arguments().at(1).toInt(&k);
|
||||
|
||||
if (!k)
|
||||
{
|
||||
qWarning() << "invalid event count" << QCoreApplication::arguments().at(1);
|
||||
return false;
|
||||
}
|
||||
|
||||
int hours = QCoreApplication::arguments().at(2).toInt(&k);
|
||||
|
||||
if (!k)
|
||||
{
|
||||
qWarning() << "invalid hours backlog" << QCoreApplication::arguments().at(2);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool createDurationEvents = false;
|
||||
if (QCoreApplication::arguments().contains(QStringLiteral("duration")))
|
||||
{
|
||||
createDurationEvents = true;
|
||||
qWarning() << "creating duration events";
|
||||
}
|
||||
|
||||
|
||||
// create fake events
|
||||
QVector<qint64> times;
|
||||
times.reserve(events);
|
||||
|
||||
qWarning() << "creating"<<events<<"random events between now and a" << hours << "hours backlog..";
|
||||
const QDateTime now(QDateTime::currentDateTime());
|
||||
for (int i = 0; i < events; i++)
|
||||
{
|
||||
QDateTime then(now);
|
||||
then = then.addSecs((-hours) * 60 * 60);
|
||||
|
||||
qint64 time = randomBetween(then.toMSecsSinceEpoch(), now.toMSecsSinceEpoch());
|
||||
times += time;
|
||||
}
|
||||
|
||||
std::sort(times.begin(), times.end());
|
||||
|
||||
|
||||
for (int i = 0; i < events; i++)
|
||||
{
|
||||
qint64 duration = 0;
|
||||
int type = static_cast<int>(randomBetween(0, 5));
|
||||
int partyId = static_cast<int>(randomBetween(1, 4));
|
||||
duration = (createDurationEvents && !!(randomBetween(1, 3) - 1)) ? randomBetween(1, 300000) : 0;
|
||||
m_events.append({ i, type, partyId, times.at(i), duration });
|
||||
}
|
||||
|
||||
|
||||
// for (int i = 0; i < 10; i++)
|
||||
// {
|
||||
// qWarning() << "time" << times.at(i);
|
||||
// }
|
||||
|
||||
|
||||
|
||||
qWarning() << ".. done!";
|
||||
|
||||
|
||||
if (!m_server->listen(QHostAddress::AnyIPv4, port))
|
||||
{
|
||||
qWarning() << "cannot listen on port" << port;
|
||||
return false;
|
||||
}
|
||||
|
||||
qWarning() << "server running on port" << port;
|
||||
|
||||
|
||||
connect(m_server, &QWebSocketServer::newConnection,
|
||||
this, [this]()
|
||||
{
|
||||
QWebSocket *client = m_server->nextPendingConnection();
|
||||
|
||||
if (client == nullptr)
|
||||
{
|
||||
qWarning() << "invalid client";
|
||||
return;
|
||||
}
|
||||
|
||||
qWarning() << "----------------------------------------------------";
|
||||
qWarning() << "new connection";
|
||||
|
||||
connect(client, &QWebSocket::disconnected,
|
||||
this, [client]()
|
||||
{
|
||||
client->deleteLater();
|
||||
});
|
||||
|
||||
const QUrl requestUrl = client->requestUrl();
|
||||
const QString requestPath = requestUrl.path();
|
||||
|
||||
qWarning() << "request" << requestUrl.toString();
|
||||
|
||||
if (requestPath != QStringLiteral("/request"))
|
||||
{
|
||||
qWarning() << "Client: only requests supported";
|
||||
client->close();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
const QUrlQuery query(requestUrl);
|
||||
//const int requestId = query.queryItemValue(QStringLiteral("requestId")).toInt();
|
||||
const qint64 from = query.queryItemValue(QStringLiteral("from")).toLongLong();
|
||||
const qint64 to = query.queryItemValue(QStringLiteral("to")).toLongLong();
|
||||
const QString typesString = query.queryItemValue(QStringLiteral("eventTypeId"));
|
||||
|
||||
bool k = true;
|
||||
int limit = query.queryItemValue(QStringLiteral("limit")).toInt(&k);
|
||||
if (!k)
|
||||
limit = -1;
|
||||
|
||||
QStringList typesStringList(typesString.split(QLatin1Char(','), QString::SkipEmptyParts));
|
||||
|
||||
qWarning() << "new request" << from << to << typesString << "limit" << limit;
|
||||
|
||||
QVector<int> types;
|
||||
|
||||
for (const QString &s : qAsConst(typesStringList))
|
||||
{
|
||||
bool k = true;
|
||||
int type = s.toInt(&k);
|
||||
|
||||
if (!k)
|
||||
continue;
|
||||
|
||||
types += type;
|
||||
}
|
||||
|
||||
|
||||
QVector<Event> eventsToSend;
|
||||
|
||||
qint64 eventCount = 0;
|
||||
for (const Event &e : qAsConst(m_events))
|
||||
{
|
||||
if (e.time >= from && e.time <= to && (types.isEmpty() || types.contains(e.type)))
|
||||
{
|
||||
eventsToSend += e;
|
||||
eventCount++;
|
||||
}
|
||||
|
||||
if (eventCount >= limit && limit != -1)
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
QJsonArray eventArray;
|
||||
|
||||
for (const Event &e : qAsConst(eventsToSend))
|
||||
{
|
||||
QJsonObject eObj;
|
||||
|
||||
//int id = eventObj[QStringLiteral("id")].toInt(-1);
|
||||
//int eventTypeId = eventObj[QStringLiteral("eventTypeId")].toInt(-1);
|
||||
//qint64 startTime = eventObj[QStringLiteral("sampleTime")].toDouble(-1);
|
||||
|
||||
eObj[QStringLiteral("id")] = e.id;
|
||||
eObj[QStringLiteral("eventTypeId")] = e.type;
|
||||
eObj[QStringLiteral("partyId")] = e.partyId;
|
||||
eObj[QStringLiteral("sampleTime")] = e.time;
|
||||
eObj[QStringLiteral("properties")] = QStringLiteral("{ \"endTime\": %1 }").arg(e.time + e.duration);
|
||||
|
||||
eventArray += eObj;
|
||||
}
|
||||
|
||||
qWarning() << "sending" << eventArray.count() << "events";
|
||||
|
||||
QJsonDocument doc(eventArray);
|
||||
client->sendTextMessage(QString::fromUtf8(doc.toJson(QJsonDocument::Compact)));
|
||||
client->sendTextMessage(QStringLiteral("{}"));
|
||||
|
||||
});
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//
|
||||
@@ -0,0 +1,28 @@
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
#include <QVector>
|
||||
|
||||
class QWebSocketServer;
|
||||
|
||||
|
||||
struct Event
|
||||
{
|
||||
int id;
|
||||
int type;
|
||||
int partyId;
|
||||
qint64 time;
|
||||
qint64 duration;
|
||||
};
|
||||
|
||||
|
||||
class Server : QObject
|
||||
{
|
||||
public:
|
||||
Server();
|
||||
bool init(quint16 port);
|
||||
|
||||
private:
|
||||
QWebSocketServer *m_server;
|
||||
QVector<Event> m_events;
|
||||
};
|
||||
@@ -0,0 +1,19 @@
|
||||
#include "Server.h"
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QDebug>
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
QCoreApplication app(argc, argv);
|
||||
|
||||
Server *s = new Server();
|
||||
if (!s->init(10090))
|
||||
{
|
||||
qWarning() << "exiting";
|
||||
return -1;
|
||||
}
|
||||
|
||||
app.exec();
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
project(GuiElementPlugin CXX)
|
||||
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
|
||||
|
||||
SET(gui_element_SRCS
|
||||
custom_widget.cpp
|
||||
custom_widget.h
|
||||
gui_element_plugin.cpp
|
||||
gui_element_plugin.h
|
||||
)
|
||||
|
||||
NGL_WRAP_UI(gui_element_SRCS
|
||||
custom_widget.ui
|
||||
)
|
||||
|
||||
NGL_ADD_LIBRARY(WS GuiElementPlugin MODULE ${gui_element_SRCS})
|
||||
# Pfad zum Interface-Ordner bekannt machen
|
||||
NGL_TARGET_INCLUDE_DIRECTORIES(GuiElementPlugin PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/..)
|
||||
|
||||
NGL_TARGET_LINK_LIBRARIES(GuiElementPlugin
|
||||
Qt5::Widgets
|
||||
LtsWidgets
|
||||
LtsSession
|
||||
LtsSessionData
|
||||
GuiElementInterface
|
||||
PpmDataPluginInterface
|
||||
PpmCommon
|
||||
LtsCoordTrans
|
||||
)
|
||||
@@ -0,0 +1,31 @@
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
project(GuiElementPlugin CXX)
|
||||
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
|
||||
|
||||
SET(gui_element_SRCS
|
||||
custom_widget.cpp
|
||||
custom_widget.h
|
||||
gui_element_plugin.cpp
|
||||
gui_element_plugin.h
|
||||
)
|
||||
|
||||
NGL_WRAP_UI(gui_element_SRCS
|
||||
custom_widget.ui
|
||||
)
|
||||
|
||||
NGL_ADD_LIBRARY(WS GuiElementPlugin MODULE ${gui_element_SRCS})
|
||||
# Pfad zum Interface-Ordner bekannt machen
|
||||
NGL_TARGET_INCLUDE_DIRECTORIES(GuiElementPlugin PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/..)
|
||||
|
||||
NGL_TARGET_LINK_LIBRARIES(GuiElementPlugin
|
||||
Qt5::Widgets
|
||||
LtsWidgets
|
||||
LtsSession
|
||||
LtsSessionData
|
||||
GuiElementInterface
|
||||
PpmDataPluginInterface
|
||||
PpmCommon
|
||||
LtsCoordTrans
|
||||
)
|
||||
@@ -0,0 +1,33 @@
|
||||
#include "custom_widget.h"
|
||||
#include "LtsCoordTrans/lts_coord_trans.h"
|
||||
#include "ui_custom_widget.h"
|
||||
#include <QDebug>
|
||||
|
||||
CustomWidget::CustomWidget(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, m_ui(new Ui::CustomWidget)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
connect(m_ui->pbFindOnMap, &QToolButton::clicked, this, &CustomWidget::finOnMapClicked);
|
||||
}
|
||||
|
||||
CustomWidget::~CustomWidget()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void CustomWidget::onPositionChanged(const Core::GeoPosition &position, int participantId)
|
||||
{
|
||||
if (participantId == 0 || std::isnan(position.lon()) || std::isnan(position.lat()))
|
||||
m_ui->lblPos->setText(tr("Invalid Position"));
|
||||
else
|
||||
{
|
||||
QString mgrs = LtsCoordTrans::mgrsFromGeographic(position.lon(), position.lat());
|
||||
|
||||
if (!qFuzzyIsNull(position.z()))
|
||||
mgrs += QStringLiteral(" | ") + QString::number(position.z(), 'f', 2);
|
||||
|
||||
m_ui->lblPos->setText(mgrs);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
|
||||
#include "Core/core.hpp"
|
||||
#include <QWidget>
|
||||
|
||||
namespace Ui {
|
||||
class CustomWidget;
|
||||
}
|
||||
|
||||
class CustomWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CustomWidget(QWidget *parent = nullptr);
|
||||
~CustomWidget();
|
||||
void onPositionChanged(const Core::GeoPosition &position, int participantId);
|
||||
|
||||
signals:
|
||||
void finOnMapClicked();
|
||||
private:
|
||||
Ui::CustomWidget *m_ui;
|
||||
};
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CustomWidget</class>
|
||||
<widget class="QWidget" name="CustomWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>268</width>
|
||||
<height>88</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Plugin-Test-DEBUG ONLY</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="labelPos">
|
||||
<property name="text">
|
||||
<string>Position:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="lblPos">
|
||||
<property name="text">
|
||||
<string><Position></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QToolButton" name="pbFindOnMap">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Find on map</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true"><TIME OVER TARGET></string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>:/style/center_to_object.svg</normaloff>:/style/center_to_object.svg</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
#include <Plugins/ParticipantManagement/ppm_data_plugin_interface.h>
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
|
||||
#include "gui_element_plugin.h"
|
||||
#include "custom_widget.h"
|
||||
|
||||
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
GuiElementPlugin::GuiElementPlugin()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QWidget *GuiElementPlugin::createGuiElement(QWidget *parent)
|
||||
{
|
||||
m_customWidget = new CustomWidget(parent);
|
||||
if (!m_ppmDtc)
|
||||
{
|
||||
qCritical()<<" ppmDtc not yet init!!!";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
connect(m_customWidget, &CustomWidget::finOnMapClicked, this, &GuiElementPlugin::onFindOnMap);
|
||||
connect(m_ppmDtc.get(), &ParticipantManagement::Interface::Dtc::participantPositionChanged,
|
||||
m_customWidget, [=](const ParticipantManagement::ParticipantPosition &ppPos){
|
||||
m_customWidget->onPositionChanged(ppPos.pos(), m_participantId);
|
||||
}, Qt::UniqueConnection);
|
||||
m_customWidget->onPositionChanged(m_ppmDtc->participantPosition(m_participantId).pos(), m_participantId);
|
||||
return m_customWidget;
|
||||
}
|
||||
|
||||
|
||||
bool GuiElementPlugin::init(LtsSession::LtsSession *session, int participantId)
|
||||
{
|
||||
m_session = session;
|
||||
|
||||
if (!m_session->getDtc<ParticipantManagement::DataInterface>(m_ppmDtc))
|
||||
{
|
||||
qCritical()<<"couln't init ppmDtc for gui element ";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!session->getForeignGuiInterface<SituationMap::ForeignGuiInterface>(m_sitMapGuiIfc))
|
||||
{
|
||||
qCritical()<<"couln't init sitMapGuiIfc for gui element ";
|
||||
return false;
|
||||
}
|
||||
|
||||
m_participantId = participantId;
|
||||
return true;
|
||||
}
|
||||
|
||||
void GuiElementPlugin::onFindOnMap()
|
||||
{
|
||||
if (m_sitMapGuiIfc)
|
||||
m_sitMapGuiIfc->centerMapToParticipant(m_participantId);
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
#pragma once
|
||||
#include <Core/core.hpp>
|
||||
#include <ParticipantManagement/ppm_dtc.h>
|
||||
#include <Plugins/ParticipantManagement/participant_info_gui_element_interface.h>
|
||||
#include <Plugins/SituationMapPlugin/situation_map_gui_plugin_interface.h>
|
||||
#include <QObject>
|
||||
|
||||
|
||||
|
||||
class CustomWidget;
|
||||
|
||||
class GuiElementPlugin : public QObject, public GuiElementInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PLUGIN_METADATA(IID IGuiElementPlugin)
|
||||
Q_INTERFACES(GuiElementInterface)
|
||||
|
||||
public:
|
||||
GuiElementPlugin();
|
||||
|
||||
QString pluginName() {return QStringLiteral("KeyValueGuiElement_XY");}
|
||||
QWidget* createGuiElement(QWidget *parent = nullptr);
|
||||
|
||||
bool init(LtsSession::LtsSession *session, int participantId = 0);
|
||||
void onFindOnMap();
|
||||
|
||||
|
||||
private:
|
||||
LtsSession::LtsSession *m_session;
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_ppmDtc;
|
||||
std::shared_ptr<SituationMap::ForeignGuiInterface> m_sitMapGuiIfc;
|
||||
CustomWidget *m_customWidget;
|
||||
int m_participantId = 0;
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
#include "custom_widget.h"
|
||||
#include "LtsCoordTrans/lts_coord_trans.h"
|
||||
#include "ui_custom_widget.h"
|
||||
#include <QDebug>
|
||||
|
||||
CustomWidget::CustomWidget(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, m_ui(new Ui::CustomWidget)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
connect(m_ui->pbFindOnMap, &QToolButton::clicked, this, &CustomWidget::finOnMapClicked);
|
||||
}
|
||||
|
||||
CustomWidget::~CustomWidget()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void CustomWidget::onPositionChanged(const Core::GeoPosition &position, int participantId)
|
||||
{
|
||||
if (participantId == 0 || std::isnan(position.lon()) || std::isnan(position.lat()))
|
||||
m_ui->lblPos->setText(tr("Invalid Position"));
|
||||
else
|
||||
{
|
||||
QString mgrs = LtsCoordTrans::mgrsFromGeographic(position.lon(), position.lat());
|
||||
|
||||
if (!qFuzzyIsNull(position.z()))
|
||||
mgrs += QStringLiteral(" | ") + QString::number(position.z(), 'f', 2);
|
||||
|
||||
m_ui->lblPos->setText(mgrs);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
|
||||
#include "Core/core.hpp"
|
||||
#include <QWidget>
|
||||
|
||||
namespace Ui {
|
||||
class CustomWidget;
|
||||
}
|
||||
|
||||
class CustomWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CustomWidget(QWidget *parent = nullptr);
|
||||
~CustomWidget();
|
||||
void onPositionChanged(const Core::GeoPosition &position, int participantId);
|
||||
|
||||
signals:
|
||||
void finOnMapClicked();
|
||||
private:
|
||||
Ui::CustomWidget *m_ui;
|
||||
};
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CustomWidget</class>
|
||||
<widget class="QWidget" name="CustomWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>268</width>
|
||||
<height>88</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Plugin-Test-DEBUG ONLY</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="labelPos">
|
||||
<property name="text">
|
||||
<string>Position:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="lblPos">
|
||||
<property name="text">
|
||||
<string><Position></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QToolButton" name="pbFindOnMap">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Find on map</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true"><TIME OVER TARGET></string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>:/style/center_to_object.svg</normaloff>:/style/center_to_object.svg</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -0,0 +1,60 @@
|
||||
#include <Plugins/ParticipantManagement/ppm_data_plugin_interface.h>
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
|
||||
#include "gui_element_plugin.h"
|
||||
#include "custom_widget.h"
|
||||
|
||||
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
GuiElementPlugin::GuiElementPlugin()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QWidget *GuiElementPlugin::createGuiElement(QWidget *parent)
|
||||
{
|
||||
m_customWidget = new CustomWidget(parent);
|
||||
if (!m_ppmDtc)
|
||||
{
|
||||
qCritical()<<" ppmDtc not yet init!!!";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
connect(m_customWidget, &CustomWidget::finOnMapClicked, this, &GuiElementPlugin::onFindOnMap);
|
||||
connect(m_ppmDtc.get(), &ParticipantManagement::Interface::Dtc::participantPositionChanged,
|
||||
m_customWidget, [=](const ParticipantManagement::ParticipantPosition &ppPos){
|
||||
m_customWidget->onPositionChanged(ppPos.pos(), m_participantId);
|
||||
}, Qt::UniqueConnection);
|
||||
m_customWidget->onPositionChanged(m_ppmDtc->participantPosition(m_participantId).pos(), m_participantId);
|
||||
return m_customWidget;
|
||||
}
|
||||
|
||||
|
||||
bool GuiElementPlugin::init(LtsSession::LtsSession *session, int participantId)
|
||||
{
|
||||
m_session = session;
|
||||
|
||||
if (!m_session->getDtc<ParticipantManagement::DataInterface>(m_ppmDtc))
|
||||
{
|
||||
qCritical()<<"couln't init ppmDtc for gui element ";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!session->getForeignGuiInterface<SituationMap::ForeignGuiInterface>(m_sitMapGuiIfc))
|
||||
{
|
||||
qCritical()<<"couln't init sitMapGuiIfc for gui element ";
|
||||
return false;
|
||||
}
|
||||
|
||||
m_participantId = participantId;
|
||||
return true;
|
||||
}
|
||||
|
||||
void GuiElementPlugin::onFindOnMap()
|
||||
{
|
||||
if (m_sitMapGuiIfc)
|
||||
m_sitMapGuiIfc->centerMapToParticipant(m_participantId);
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
#pragma once
|
||||
#include <Core/core.hpp>
|
||||
#include <ParticipantManagement/ppm_dtc.h>
|
||||
#include <Plugins/ParticipantManagement/participant_info_gui_element_interface.h>
|
||||
#include <Plugins/SituationMapPlugin/situation_map_gui_plugin_interface.h>
|
||||
#include <QObject>
|
||||
|
||||
|
||||
|
||||
class CustomWidget;
|
||||
|
||||
class GuiElementPlugin : public QObject, public GuiElementInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PLUGIN_METADATA(IID IGuiElementPlugin)
|
||||
Q_INTERFACES(GuiElementInterface)
|
||||
|
||||
public:
|
||||
GuiElementPlugin();
|
||||
|
||||
QString pluginName() {return QStringLiteral("KeyValueGuiElement_XY");}
|
||||
QWidget* createGuiElement(QWidget *parent = nullptr);
|
||||
|
||||
bool init(LtsSession::LtsSession *session, int participantId = 0);
|
||||
void onFindOnMap();
|
||||
|
||||
|
||||
private:
|
||||
LtsSession::LtsSession *m_session;
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_ppmDtc;
|
||||
std::shared_ptr<SituationMap::ForeignGuiInterface> m_sitMapGuiIfc;
|
||||
CustomWidget *m_customWidget;
|
||||
int m_participantId = 0;
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
#
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
#
|
||||
|
||||
SET(SRCS
|
||||
main.cpp
|
||||
)
|
||||
|
||||
SET(HDRS
|
||||
)
|
||||
|
||||
NGL_ADD_EXECUTABLE(WS AAR SV NO_TRANSLATION localDomainFinder ${SRCS} ${HDRS})
|
||||
NGL_TARGET_LINK_LIBRARIES(localDomainFinder
|
||||
Qt5::Core
|
||||
LtsCommandLineParser
|
||||
NGLLogger
|
||||
nglcoreapplication
|
||||
)
|
||||
NGL_INSTALL_TARGET_DEVEL(localDomainFinder)
|
||||
@@ -0,0 +1,49 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Tool for finding the domainId of the local machine
|
||||
* ( for now it is the last digit of the ip-address of the machine
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
#include <nglapplication/nglcoreapplication.h>
|
||||
#include <NGLLogger/INGLLogger.h>
|
||||
|
||||
#include <LtsCommandLineParser/LtsCommandLineParser.h>
|
||||
|
||||
|
||||
|
||||
|
||||
int main ( int argc, char**argv )
|
||||
{
|
||||
NGLCoreApplication app ( argc, argv );
|
||||
|
||||
// Check alle 30 Sekunden
|
||||
app.createLogger("LocalDomainFinder", "log4cxx_ldf.props");
|
||||
|
||||
LtsCommandLineParser::LtsCommandLineParser options;
|
||||
if (!options.init())
|
||||
return -1;
|
||||
|
||||
int domainId = options.domainId();
|
||||
|
||||
// Limit of domainId for version rti connext 5.2: 233
|
||||
// see https://community.rti.com/kb/what-maximum-number-participants-domain
|
||||
|
||||
if (domainId > 233)
|
||||
{
|
||||
WARNING_LOG(app.baseLogger()) << "########### -> DomainId > 233, using domainId - 233";
|
||||
domainId = domainId - 233;
|
||||
|
||||
if (domainId > 233 || domainId == 0)
|
||||
{
|
||||
ERROR_LOG(app.baseLogger()) << "DomainId not possible, choose another. ";
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
INFO_LOG(app.baseLogger()) << "# DomainId: #" << domainId;
|
||||
|
||||
return domainId;
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
#
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
# Created by Hannes Baeuerle, SLSE, 2016-08-09
|
||||
#
|
||||
|
||||
SET(participantDataGenerator_SRCS
|
||||
log4cxx_pdg.props
|
||||
main.cpp
|
||||
main_handler.cpp
|
||||
main_handler.h
|
||||
proxy_emulator.cpp
|
||||
proxy_emulator.h
|
||||
)
|
||||
|
||||
NGL_ADD_EXECUTABLE(AAR SV NO_TRANSLATION ParticipantDataGenerator ${participantDataGenerator_SRCS})
|
||||
|
||||
NGL_TARGET_LINK_LIBRARIES(ParticipantDataGenerator
|
||||
Qt5::Core
|
||||
Qt5::Network
|
||||
ddsconnector
|
||||
LtsCommandLineParser
|
||||
nglcoreapplication
|
||||
NGLLogger
|
||||
svcPpmClient
|
||||
svcTabServer
|
||||
LtsCoordTrans
|
||||
)
|
||||
|
||||
NGL_INSTALL_TARGET(ParticipantDataGenerator)
|
||||
NGL_INSTALL(AAR SV FILES log4cxx_pdg.props DESTINATION bin)
|
||||
+77
@@ -0,0 +1,77 @@
|
||||
log4j.reset=true
|
||||
log4j.rootLogger=WARN, file
|
||||
|
||||
# ParticipantDataGenerator
|
||||
###########################################################
|
||||
log4j.logger.PDG=DEBUG, stdout
|
||||
#log4j.logger.PDG.ProxyEmulator=DEBUG
|
||||
#log4j.logger.PDG.MainHandler=DEBUG
|
||||
|
||||
# Appnd_file
|
||||
###########################################################
|
||||
log4j.appender.file=org.apache.log4j.RollingFileAppender
|
||||
log4j.appender.file.MaxFileSize=1MB
|
||||
log4j.appender.file.MaxBackupIndex=9
|
||||
log4j.appender.file.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.file.layout.ConversionPattern=%d %-5p %c |#| %m (%.50F:%L) %n
|
||||
|
||||
# Appnd_stdout
|
||||
###########################################################
|
||||
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
|
||||
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.stdout.layout.ConversionPattern= %d %p %c %c{1} - %m (%-.30F:%L) %n
|
||||
|
||||
|
||||
# Appnd_Syslog
|
||||
###########################################################
|
||||
log4j.appender.syslog=org.apache.log4j.SyslogAppender
|
||||
log4j.appender.syslog.Threshold=ERROR
|
||||
log4j.appender.syslog.SysLogHost=localhost
|
||||
log4j.appender.syslog.Facility=LOCAL7
|
||||
log4j.appender.syslog.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.syslog.layout.ConversionPattern= %-4r %-5p %c %x - %m
|
||||
log4j.appender.syslog.LevelRangeFilter.AcceptOnMatch=true
|
||||
log4j.appender.syslog.LevelRangeFilter.LevelMin=INFO
|
||||
log4j.appender.syslog.LevelRangeFilter.LevelMax=FATAL
|
||||
|
||||
|
||||
###########################################################
|
||||
###########################################################
|
||||
###########################################################
|
||||
# 1) Available Levels in LOG4CXX Version 0.10.0:
|
||||
# TRACE,
|
||||
# DEBUG,
|
||||
# INFO,
|
||||
# WARN,
|
||||
# ERROR
|
||||
# FATAL
|
||||
#
|
||||
# d = date/time
|
||||
# p = priority (Level)
|
||||
# c = category/channel
|
||||
# m = message
|
||||
# F = file
|
||||
# L = line
|
||||
# n = platform dependent line separator character or characters.
|
||||
# ....
|
||||
#
|
||||
# Examples for console:
|
||||
# a)
|
||||
# %d %p %c #%m# (%.50F:%L)%n
|
||||
# date/time
|
||||
# priority
|
||||
# category/channel
|
||||
# #message#
|
||||
# (Maximal 50Character des Filename von rechts:Line)
|
||||
# line separator
|
||||
#
|
||||
# b)
|
||||
# %d (%.15F:%L) %-5p %c |#| %m%n
|
||||
# date/time
|
||||
# (Maximal 15Character des Filename von rechts:Line)
|
||||
# priority, Right pad with spaces if the priority name is less than 5 characters long.
|
||||
# category/channel
|
||||
# message
|
||||
# line separator
|
||||
#
|
||||
# Examples for files:
|
||||
@@ -0,0 +1,68 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* main for ParticipantDataGenerator
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Hannes Baeuerle, SLSE, 2016-08-09
|
||||
*/
|
||||
|
||||
#include <QtNetwork/QHostAddress>
|
||||
#include <QtNetwork/QNetworkInterface>
|
||||
#include <LtsCommandLineParser/LtsCommandLineParser.h>
|
||||
#include <nglapplication/nglcoreapplication.h>
|
||||
#include <NGLLogger/INGLLogger.h>
|
||||
#include <NGLLogger/NGLLoggerBootstrap.h>
|
||||
#include "main_handler.h"
|
||||
|
||||
class CmdLineParser : public LtsCommandLineParser::LtsCommandLineParser
|
||||
{
|
||||
public:
|
||||
CmdLineParser()
|
||||
: LtsCommandLineParser()
|
||||
{
|
||||
addOption( { QStringList() << QLatin1String("p") << QLatin1String("participantCount"),
|
||||
QLatin1String("Number of total existing ExerciseParticipants after creation (including already existing ones)"),
|
||||
QLatin1String("Default: 1000"),
|
||||
QLatin1String("1000") } );
|
||||
addOption( { QStringList() << QLatin1String("m") << QLatin1String("moveAll"),
|
||||
QLatin1String("If set, all participants are moved per tick. Not a random set") } );
|
||||
}
|
||||
|
||||
int32_t participantCount() const { return isSet(QLatin1String("p")) ? value(QLatin1String("p")).toInt() : 1000; }
|
||||
bool hasToMoveAll() const { return isSet(QLatin1String("m")); }
|
||||
};
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
NGLCoreApplication app(argc, argv);
|
||||
CmdLineParser options;
|
||||
|
||||
if (!options.init())
|
||||
return -1;
|
||||
|
||||
// Check alle 30 Sekunden
|
||||
app.createLogger("PDG ", "log4cxx_pdg.props");
|
||||
ParticipantDataGenerator::MainHandler mainHandler;
|
||||
|
||||
NGL::INGLLogger &logger = app.logger("main");
|
||||
|
||||
int iRet = -1;
|
||||
if (!mainHandler.init(options.domainId(), options.exerciseId(), options.participantCount(), options.hasToMoveAll()))
|
||||
{
|
||||
ERROR_LOG(logger) << "Could not init MainHandler\n"
|
||||
<< "Please make shure, that the following procs are running:\n"
|
||||
<< "svcParticipantManagement -d " << options.domainId() << " -e 0\n"
|
||||
<< "svcParticipantManagement -d " << options.domainId() << " -e " << options.exerciseId() << "\n"
|
||||
<< "... shutting down";
|
||||
return iRet;
|
||||
}
|
||||
|
||||
STARTUP_LOG(logger);
|
||||
|
||||
iRet = app.exec();
|
||||
|
||||
SHUTDOWN_LOG(logger);
|
||||
|
||||
return iRet;
|
||||
}
|
||||
+275
@@ -0,0 +1,275 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Main object for ParticipantDataGenerator
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Hannes Baeuerle, SLSE, 2016-08-09
|
||||
*/
|
||||
|
||||
#include "main_handler.h"
|
||||
#include <NGLLogger/NGLLoggerBootstrap.h>
|
||||
#include <DDS/DDSConnector/dds_connector.h>
|
||||
#include <QtCore/QThread>
|
||||
#include <QtCore/QCoreApplication>
|
||||
#include <QtCore/QDateTime>
|
||||
#include <QtCore/QElapsedTimer>
|
||||
#include <QtCore/QHash>
|
||||
#include <QtCore/QTimer>
|
||||
#include "proxy_emulator.h"
|
||||
|
||||
|
||||
ParticipantDataGenerator::MainHandler::MainHandler(QObject *parent)
|
||||
: QObject(parent)
|
||||
, m_domainId(0)
|
||||
, m_exerciseId(0)
|
||||
, m_maxParticipants(0)
|
||||
, m_hasToMoveAll(false)
|
||||
, m_proxyEmulator(nullptr)
|
||||
, m_participantCreationTimer(new QElapsedTimer())
|
||||
, m_logger(NGL::NGLLoggerBootstrap::getNGLRootLogger().getNGLLogger("PDG.MainHandler"))
|
||||
{
|
||||
qsrand(QDateTime::currentMSecsSinceEpoch());
|
||||
}
|
||||
|
||||
ParticipantDataGenerator::MainHandler::~MainHandler()
|
||||
{
|
||||
delete m_participantCreationTimer;
|
||||
}
|
||||
|
||||
bool ParticipantDataGenerator::MainHandler::init(int32_t domainId, int32_t exerciseId, int32_t maxParticipants, bool hasToMoveAll)
|
||||
{
|
||||
m_domainId = domainId;
|
||||
m_exerciseId = exerciseId;
|
||||
m_maxParticipants = maxParticipants;
|
||||
m_hasToMoveAll = hasToMoveAll;
|
||||
|
||||
delete m_proxyEmulator;
|
||||
m_proxyEmulator = nullptr;
|
||||
|
||||
// DdsConnector
|
||||
DEBUG_LOG(m_logger) << "Creating and initializing DdsConnector ...";
|
||||
m_ddsConnector.reset(new DDSConnector::DdsConnector(m_domainId, IDL::PartitionType::Exercise, m_exerciseId));
|
||||
if (!m_ddsConnector->init())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not init DdsConnector";
|
||||
return false;
|
||||
}
|
||||
m_ddsConnector->initPublisherSubscriber();
|
||||
DEBUG_LOG(m_logger) << "... done";
|
||||
|
||||
// dtc
|
||||
DEBUG_LOG(m_logger) << "Creating and initializing PPM DTC ...";
|
||||
m_ppmDtc = ParticipantManagement::Interface::Dtc::create(m_ddsConnector);
|
||||
QThread::msleep(100);
|
||||
if (!m_ppmDtc->enableParticipant() ||
|
||||
!m_ppmDtc->enableType() ||
|
||||
!m_ppmDtc->enableParticipantPosition())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not init PPM DTC";
|
||||
return false;
|
||||
}
|
||||
DEBUG_LOG(m_logger) << "... done";
|
||||
|
||||
// ftc
|
||||
DEBUG_LOG(m_logger) << "Creating and initializing PPM FTC ...";
|
||||
m_ppmFtc = ParticipantManagement::Interface::Ftc::create(m_ddsConnector);
|
||||
QThread::msleep(100);
|
||||
if (!m_ppmFtc->enableModifyParticipantData())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not init PPM FTC";
|
||||
return false;
|
||||
}
|
||||
DEBUG_LOG(m_logger) << "... done";
|
||||
|
||||
// ProxyEmulator
|
||||
DEBUG_LOG(m_logger) << "Creating and initializing ProxyEmulator ...";
|
||||
m_proxyEmulator = new ProxyEmulator(this);
|
||||
QThread::msleep(100);
|
||||
if (!m_proxyEmulator->init(m_ddsConnector))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not init ProxyEmulator";
|
||||
return false;
|
||||
}
|
||||
DEBUG_LOG(m_logger) << "... done";
|
||||
|
||||
QThread::sleep(1);
|
||||
readTypes();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ParticipantDataGenerator::MainHandler::onModifyParticipantDataReply(const Core::FunctionReplyObject &replyObject)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "It took "
|
||||
<< m_participantCreationTimer->elapsed()
|
||||
<< "msecs to respond to the ModifyParticipantDataRequest";
|
||||
if (replyObject.error())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Got error from ModifyParticipantRequest: " << replyObject();
|
||||
quit();
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "participants successfully created";
|
||||
const unsigned int secondsToWait = 3;
|
||||
DEBUG_LOG(m_logger) << "Waiting " << secondsToWait << " seconds for giving initial positions";
|
||||
QThread::sleep(secondsToWait);
|
||||
m_proxyEmulator->giveInitPositions(m_ppmDtc->participants());
|
||||
}
|
||||
onNewPositions();
|
||||
}
|
||||
|
||||
void ParticipantDataGenerator::MainHandler::readTypes()
|
||||
{
|
||||
m_ppmDtc->waitForHistoricalDataType(30000);
|
||||
DEBUG_LOG(m_logger) << "Reading types ...";
|
||||
m_types = m_ppmDtc->types().values().toVector();
|
||||
if (!m_types.size())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "There are no types available";
|
||||
quit();
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "... done";
|
||||
QThread::sleep(1);
|
||||
createParticipants();
|
||||
}
|
||||
}
|
||||
|
||||
void ParticipantDataGenerator::MainHandler::createParticipants()
|
||||
{
|
||||
m_ppmDtc->waitForHistoricalDataParticipant();
|
||||
if (m_ppmDtc->participants().size() >= m_maxParticipants)
|
||||
{
|
||||
ERROR_LOG(m_logger) << m_maxParticipants
|
||||
<< " participants are demanded, "
|
||||
<< m_ppmDtc->participants().size()
|
||||
<< " exercise participants are existing now, so no more will be created...";
|
||||
m_proxyEmulator->giveInitPositions(m_ppmDtc->participants());
|
||||
onNewPositions();
|
||||
return;
|
||||
}
|
||||
|
||||
// get highest equipment number
|
||||
QVector<int32_t> allocatedEquipmentNumbers;
|
||||
QMap<qint32, ParticipantManagement::Participant> participantMap = m_ppmDtc->participants();
|
||||
unsigned int equipmentNumberCount = 0;
|
||||
|
||||
allocatedEquipmentNumbers.reserve(participantMap.size());
|
||||
|
||||
for (auto it = participantMap.begin(); it != participantMap.end(); ++it)
|
||||
{
|
||||
if (it.value().equipmentNumber().is_set())
|
||||
{
|
||||
allocatedEquipmentNumbers.append(it.value().equipmentNumber().get());
|
||||
++equipmentNumberCount;
|
||||
}
|
||||
}
|
||||
|
||||
if (allocatedEquipmentNumbers.size() != participantMap.size())
|
||||
allocatedEquipmentNumbers.resize(equipmentNumberCount);
|
||||
|
||||
ParticipantManagement::ModifyParticipantDataRequest request;
|
||||
QHash<int32_t, int32_t> inferiorCount; // <modId, number of linked inferiors> ... needed for hierarchy number ...
|
||||
int32_t equipmentNumber = 999;
|
||||
int32_t participantCount = m_maxParticipants - participantMap.size();
|
||||
|
||||
DEBUG_LOG(m_logger) << "Creating " << participantCount << " new participants.";
|
||||
|
||||
request.data().reserve(participantCount);
|
||||
|
||||
for (int32_t counter = 1; counter <= participantCount; ++counter)
|
||||
{
|
||||
ParticipantManagement::ParticipantData newData;
|
||||
ParticipantManagement::Type type = randomType();
|
||||
newData.modId(counter);
|
||||
inferiorCount.insert(counter, 0);
|
||||
int32_t partyId = 2;
|
||||
int32_t superiorModId = 0;
|
||||
|
||||
if (counter > 1)
|
||||
superiorModId = randomSuperiorModId(counter - 1);
|
||||
|
||||
int32_t hierarchyNumber = inferiorCount.value(superiorModId) + 1;
|
||||
newData.superiorModId(superiorModId);
|
||||
newData.hierarchyNumber(counter == 1 ? 1 : hierarchyNumber);
|
||||
inferiorCount.insert(superiorModId, hierarchyNumber);
|
||||
|
||||
// increment equipmentNumber until it is not already allocated
|
||||
while (allocatedEquipmentNumbers.contains(++equipmentNumber));
|
||||
|
||||
allocatedEquipmentNumbers.append(equipmentNumber);
|
||||
newData.equipmentNumber().set(equipmentNumber);
|
||||
newData.isSimulated(true);
|
||||
newData.isDeleted(false);
|
||||
newData.typeId(type.id());
|
||||
newData.symbol(type.symbol());
|
||||
newData.name(QStringLiteral("name_%1").arg(counter).toStdString());
|
||||
newData.designator(QStringLiteral("designator_%1").arg(counter).toStdString());
|
||||
newData.tacticalIdentifier(QStringLiteral("tacticalIdentifier_%1").arg(counter).toStdString());
|
||||
newData.info(QStringLiteral("info_%1").arg(counter).toStdString());
|
||||
newData.assignState(ParticipantManagement::ParticipantAssignState::HandoutExcon);
|
||||
newData.partyId(partyId);
|
||||
|
||||
request.data().push_back(std::move(newData));
|
||||
}
|
||||
|
||||
m_participantCreationTimer->start();
|
||||
m_ppmFtc->modifyParticipantDataRequest(request, this);
|
||||
}
|
||||
|
||||
void ParticipantDataGenerator::MainHandler::quit()
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Are the following procs running?\n"
|
||||
<< "svcParticipantManagement -d " << m_domainId << " -e 0\n"
|
||||
<< "svcParticipantManagement -d " << m_domainId << " -e " << m_exerciseId << "\n"
|
||||
<< "... shutting down";
|
||||
QCoreApplication::exit(-1);
|
||||
}
|
||||
|
||||
void ParticipantDataGenerator::MainHandler::onNewPositions()
|
||||
{
|
||||
QHash<int32_t, int32_t> participantIdToEquipmentnumber; // <participantId, equipmentNumber>
|
||||
const QMap<int32_t, ParticipantManagement::Participant> participants = m_ppmDtc->participants();
|
||||
|
||||
for (auto it = participants.begin(); it != participants.end(); ++it)
|
||||
{
|
||||
if (it.value().equipmentNumber().is_set())
|
||||
participantIdToEquipmentnumber.insert(it.value().id(), it.value().equipmentNumber().get());
|
||||
}
|
||||
|
||||
m_proxyEmulator->moveParticipants(participantIdToEquipmentnumber, m_ppmDtc->participantPositions());
|
||||
QTimer::singleShot(1000, this, &MainHandler::onNewPositions);
|
||||
}
|
||||
|
||||
ParticipantManagement::Type ParticipantDataGenerator::MainHandler::randomType()
|
||||
{
|
||||
ParticipantManagement::Type result;
|
||||
|
||||
if (m_types.size())
|
||||
{
|
||||
do
|
||||
{
|
||||
unsigned int index = qrand() % m_types.size();
|
||||
result = m_types.at(index);
|
||||
}
|
||||
while (result.typeClass() != ParticipantManagement::TypeClass::Human &&
|
||||
result.typeClass() != ParticipantManagement::TypeClass::GroundVehicle &&
|
||||
result.typeClass() != ParticipantManagement::TypeClass::Aircraft &&
|
||||
result.typeClass() != ParticipantManagement::TypeClass::Vessel &&
|
||||
result.typeClass() != ParticipantManagement::TypeClass::VehicleWithGear
|
||||
);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
int32_t ParticipantDataGenerator::MainHandler::randomSuperiorModId(int32_t upperBound)
|
||||
{
|
||||
qsrand(QDateTime::currentMSecsSinceEpoch());
|
||||
auto ret = qrand() % (upperBound + 1);
|
||||
return ret == 0 ? ret + 1 : ret;
|
||||
}
|
||||
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Main object for ParticipantDataGenerator
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Hannes Baeuerle, SLSE, 2016-08-09
|
||||
*/
|
||||
#pragma once
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QVector>
|
||||
#include <NGLLogger/INGLLogger.h>
|
||||
#include <ParticipantManagement/ppm_dtc.h>
|
||||
#include <ParticipantManagement/ppm_ftc.h>
|
||||
#include <nglapplication/nglcoreapplication.h>
|
||||
#include <proxy_emulator.h>
|
||||
|
||||
class QElapsedTimer;
|
||||
|
||||
namespace ParticipantDataGenerator
|
||||
{
|
||||
class MainHandler
|
||||
: public QObject
|
||||
, public ParticipantManagement::Interface::Ftc::ModifyParticipantDataReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit MainHandler(QObject *parent = nullptr);
|
||||
~MainHandler();
|
||||
|
||||
bool init(int32_t domainId, int32_t exerciseId, int32_t maxParticipants, bool hasToMoveAll);
|
||||
|
||||
void onModifyParticipantDataReply(const Core::FunctionReplyObject &replyObject) override final;
|
||||
|
||||
private: // methods
|
||||
void readTypes();
|
||||
void createParticipants();
|
||||
void quit();
|
||||
|
||||
private Q_SLOTS:
|
||||
void onNewPositions();
|
||||
|
||||
ParticipantManagement::Type randomType();
|
||||
int32_t randomSuperiorModId(int32_t upperBound);
|
||||
private: // attributes
|
||||
int32_t m_domainId;
|
||||
int32_t m_exerciseId;
|
||||
int32_t m_maxParticipants;
|
||||
bool m_hasToMoveAll;
|
||||
std::shared_ptr<DDSConnector::DdsConnector> m_ddsConnector;
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_ppmDtc;
|
||||
std::shared_ptr<ParticipantManagement::Interface::Ftc> m_ppmFtc;
|
||||
ProxyEmulator *m_proxyEmulator;
|
||||
QVector<ParticipantManagement::Type> m_types;
|
||||
QElapsedTimer *m_participantCreationTimer;
|
||||
NGL::INGLLogger &m_logger;
|
||||
};
|
||||
}
|
||||
+183
@@ -0,0 +1,183 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* The ProxyEmulator class emulates FTs of the TetraRadio Proxy to send position data
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Hannes Baeuerle, SLSE, 2016-08-09
|
||||
*/
|
||||
|
||||
#include "proxy_emulator.h"
|
||||
#include <QDateTime>
|
||||
#include <QHash>
|
||||
#include <QMap>
|
||||
#include <QPointF>
|
||||
#include <LtsCoordTrans/lts_coord_trans.h>
|
||||
#include <NGLLogger/NGLLoggerBootstrap.h>
|
||||
|
||||
ParticipantDataGenerator::ProxyEmulator::ProxyEmulator(QObject *parent)
|
||||
: QObject(parent)
|
||||
, m_logger(NGL::NGLLoggerBootstrap::getNGLRootLogger().getNGLLogger("PDG.ProxyEmulator"))
|
||||
{}
|
||||
|
||||
bool ParticipantDataGenerator::ProxyEmulator::init(const std::shared_ptr<DDSConnector::DdsConnector> &ddsConnector)
|
||||
{
|
||||
m_tabDts = (TrainingAreaBase::Interface::Dts::create(ddsConnector));
|
||||
|
||||
DEBUG_LOG(m_logger) << "Initializing TAB DTS ...";
|
||||
if (!m_tabDts->enableCtaDataError() ||
|
||||
!m_tabDts->enableEquipmentBite() ||
|
||||
!m_tabDts->enableEquipmentGearAssignment() ||
|
||||
!m_tabDts->enableEquipmentPosition())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not init TAB DTS";
|
||||
return false;
|
||||
}
|
||||
DEBUG_LOG(m_logger) << "... done";
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ParticipantDataGenerator::ProxyEmulator::giveInitPositions(const QMap<qint32, ParticipantManagement::Participant> &participants)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << participants.size()
|
||||
<< " participants found. Trying to give them init positions.";
|
||||
int participantsWithEquipmentNumber = 0;
|
||||
for (auto it = participants.begin(); it != participants.end(); ++it)
|
||||
{
|
||||
const ParticipantManagement::Participant ¤tParticipant = it.value();
|
||||
|
||||
if (currentParticipant.equipmentNumber().is_set())
|
||||
{
|
||||
++participantsWithEquipmentNumber;
|
||||
TrainingAreaBase::EquipmentPosition pos;
|
||||
|
||||
pos.equipmentNumber(currentParticipant.equipmentNumber().get());
|
||||
pos.sampleTime(QDateTime::currentMSecsSinceEpoch());
|
||||
pos.position().position(randomPosition());
|
||||
|
||||
m_tabDts->publish(pos);
|
||||
}
|
||||
}
|
||||
|
||||
if (participants.size() != participantsWithEquipmentNumber)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "Actually gave "
|
||||
<< participantsWithEquipmentNumber
|
||||
<< " participants an init position, because the rest does not have an equipment number";
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "... done";
|
||||
}
|
||||
}
|
||||
|
||||
static constexpr double maxX = 530000;
|
||||
static constexpr double minX = 475000;
|
||||
static constexpr double maxY = 5890000;
|
||||
static constexpr double minY = 5870000;
|
||||
|
||||
Core::GeoPosition ParticipantDataGenerator::ProxyEmulator::movePosition(const Core::GeoPosition &oldPosition)
|
||||
{
|
||||
LtsCoordTrans::UtmCoordinate coord(LtsCoordTrans::UtmCoordinate::fromGeographic(oldPosition.lon(), oldPosition.lat()));
|
||||
|
||||
int ofsX = (qrand() % 200) - 100;
|
||||
int ofsY = (qrand() % 200) - 100;
|
||||
|
||||
coord.x += ofsX;
|
||||
coord.y += ofsY;
|
||||
|
||||
coord.x = qBound(minX, coord.x, maxX);
|
||||
coord.y = qBound(minY, coord.y, maxY);
|
||||
|
||||
const QPointF ret(coord.geographic());
|
||||
return Core::GeoPosition(ret.x(), ret.y(), oldPosition.z());
|
||||
}
|
||||
|
||||
void ParticipantDataGenerator::ProxyEmulator::moveParticipants(const QHash<int32_t, int32_t> &participantIdToEquimentNumber, const QMap<int32_t, ParticipantManagement::ParticipantPosition> &positions)
|
||||
{
|
||||
const int posSelector = (qrand() % 10) + 1;
|
||||
const int biteSelector = (qrand() % 100) + 1;
|
||||
const int equipGearAssignSelector = (qrand() % 200) + 1;
|
||||
const int ctaDataErrorSelector = (qrand() % 100) + 1;
|
||||
int counter = 0;
|
||||
TrainingAreaBase::EquipmentPosition newPosition;
|
||||
newPosition.sampleTime(QDateTime::currentMSecsSinceEpoch());
|
||||
TrainingAreaBase::EquipmentBite newBite;
|
||||
newBite.sampleTime(QDateTime::currentMSecsSinceEpoch());
|
||||
TrainingAreaBase::EquipmentGearAssignment newGearAssignment;
|
||||
newGearAssignment.sampleTime(QDateTime::currentMSecsSinceEpoch());
|
||||
TrainingAreaBase::CtaDataError newCtaDataError;
|
||||
newCtaDataError.sampleTime(QDateTime::currentMSecsSinceEpoch());
|
||||
newCtaDataError.reason(ProjectDataManagement::DataErrorReason::ErrorConfigSelfTest);
|
||||
newCtaDataError.originTelegramId(203);
|
||||
int pC = 0;
|
||||
int bC = 0;
|
||||
int gC = 0;
|
||||
int cC = 0;
|
||||
for (auto it = positions.begin(); it != positions.end(); ++it, ++counter)
|
||||
{
|
||||
const ParticipantManagement::ParticipantPosition &oldPosition = it.value();
|
||||
const int equipNo = participantIdToEquimentNumber.value(oldPosition.participantId());
|
||||
if ((counter % biteSelector) == 0)
|
||||
{
|
||||
newBite.equipmentNumber(equipNo);
|
||||
newBite.configState(counter);
|
||||
newBite.biteState(~counter);
|
||||
m_tabDts->publish(newBite);
|
||||
++bC;
|
||||
}
|
||||
if ((counter % equipGearAssignSelector) == 0)
|
||||
{
|
||||
newGearAssignment.equipmentNumber(equipNo);
|
||||
m_tabDts->publish(newGearAssignment);
|
||||
++gC;
|
||||
}
|
||||
if ((counter % ctaDataErrorSelector) == 0)
|
||||
{
|
||||
newCtaDataError.equipmentNumber(equipNo);
|
||||
m_tabDts->publish(newCtaDataError);
|
||||
++cC;
|
||||
}
|
||||
|
||||
if (counter % posSelector)
|
||||
continue;
|
||||
|
||||
|
||||
if (!participantIdToEquimentNumber.contains(oldPosition.participantId()))
|
||||
continue;
|
||||
|
||||
newPosition.equipmentNumber(equipNo);
|
||||
newPosition.position().position(movePosition(oldPosition.pos()));
|
||||
++pC;
|
||||
|
||||
m_tabDts->publish(newPosition);
|
||||
}
|
||||
NOTICE_LOG(m_logger) << "position changes: " << pC
|
||||
<< ", bite changes: " << bC
|
||||
<< ", gear changes: " << gC;
|
||||
}
|
||||
|
||||
Core::GeoPosition ParticipantDataGenerator::ProxyEmulator::randomPosition()
|
||||
{
|
||||
Core::GeoPosition result;
|
||||
|
||||
LtsCoordTrans::UtmCoordinate coord;
|
||||
coord.zone = 32;
|
||||
coord.northp = true;
|
||||
coord.x = minX;
|
||||
coord.y = minY;
|
||||
|
||||
constexpr int rangeX = qAbs(minX - maxX);
|
||||
constexpr int rangeY = qAbs(minY - maxY);
|
||||
|
||||
const QPointF p(coord.geographic(qrand() % rangeX,
|
||||
qrand() % rangeY));
|
||||
result.z(0);
|
||||
result.lon(p.x());
|
||||
result.lat(p.y());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* The ProxyEmulator class emulates FTs of the TetraRadio Proxy to send position data
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Hannes Baeuerle, SLSE, 2016-08-09
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <QtCore/QObject>
|
||||
#include <DDS/DDSConnector/dds_connector.h>
|
||||
#include <TrainingAreaBase/tab_dts.h>
|
||||
#include <NGLLogger/INGLLogger.h>
|
||||
#include <ParticipantManagement/ppm.hpp>
|
||||
|
||||
namespace ParticipantDataGenerator
|
||||
{
|
||||
class ProxyEmulator : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ProxyEmulator(QObject *parent = nullptr);
|
||||
|
||||
bool init(const std::shared_ptr<DDSConnector::DdsConnector> &ddsConnector);
|
||||
|
||||
void moveParticipants(const QHash<int32_t, int32_t> &participantIdToEquimentNumber, const QMap<int32_t, ParticipantManagement::ParticipantPosition> &positions);
|
||||
void giveInitPositions(const QMap<qint32, ParticipantManagement::Participant> &participants);
|
||||
|
||||
private: // methods
|
||||
static Core::GeoPosition randomPosition();
|
||||
static Core::GeoPosition movePosition(const Core::GeoPosition &oldPosition);
|
||||
|
||||
private: // attributes
|
||||
std::shared_ptr<TrainingAreaBase::Interface::Dts> m_tabDts;
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
#
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
#
|
||||
# CMakeLists.txt fuer qledline
|
||||
#
|
||||
|
||||
IF(BUILD_TESTING)
|
||||
ADD_SUBDIRECTORY(Test)
|
||||
ENDIF(BUILD_TESTING)
|
||||
|
||||
SET(qledline_SRCS
|
||||
qledchar.cpp
|
||||
qledline.cpp
|
||||
)
|
||||
|
||||
SET(qledline_HDRS
|
||||
qledchar.h
|
||||
qledline.h
|
||||
)
|
||||
|
||||
NGL_ADD_LIBRARY(AAR SV WS qledline SHARED ${qledline_SRCS} ${qledline_HDRS})
|
||||
|
||||
NGL_TARGET_INCLUDE_DIRECTORIES(qledline
|
||||
PUBLIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../
|
||||
)
|
||||
|
||||
NGL_TARGET_LINK_LIBRARIES(qledline
|
||||
PUBLIC
|
||||
qledmatrix
|
||||
Qt5::Core
|
||||
Qt5::Widgets
|
||||
)
|
||||
|
||||
NGL_INSTALL_TARGET(qledline)
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
#
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
#
|
||||
# CMakeLists.txt fuer test_qledline
|
||||
#
|
||||
|
||||
|
||||
SET(test_qledline_SRCS
|
||||
content.cpp
|
||||
fullline.cpp
|
||||
main.cpp
|
||||
mainwindow.cpp
|
||||
props.cpp
|
||||
)
|
||||
|
||||
SET(test_qledline_HDRS
|
||||
content.h
|
||||
fullline.h
|
||||
mainwindow.h
|
||||
props.h
|
||||
)
|
||||
|
||||
SET(test_qledline_UICS
|
||||
ui/mainwindow.ui
|
||||
ui/content.ui
|
||||
ui/fullline.ui
|
||||
ui/props.ui
|
||||
)
|
||||
|
||||
NGL_TARGET_INCLUDE_DIRECTORIES(test_qledline
|
||||
PUBLIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../
|
||||
)
|
||||
|
||||
NGL_WRAP_UI(test_qledline_SRCS ${test_qledline_UICS})
|
||||
|
||||
NGL_ADD_EXECUTABLE(WS NO_TRANSLATION test_qledline ${test_qledline_SRCS} ${test_qledline_HDRS} ${test_qledline_UICS})
|
||||
|
||||
NGL_TARGET_LINK_LIBRARIES(test_qledline
|
||||
qledline
|
||||
)
|
||||
@@ -0,0 +1,92 @@
|
||||
#include <QLayout>
|
||||
|
||||
#include "content.h"
|
||||
#include "fullline.h"
|
||||
#include "ui_content.h"
|
||||
|
||||
Content::Content(QWidget *parent) : QWidget(parent)
|
||||
, m_ui(new Ui::Content)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
}
|
||||
|
||||
Content::~Content()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void Content::init()
|
||||
{
|
||||
delete layout();
|
||||
m_layout = new QVBoxLayout(this);
|
||||
m_layout->setSpacing(0);
|
||||
|
||||
while (!m_lines.isEmpty())
|
||||
deleteLastLine();
|
||||
|
||||
while (m_lines.size() < m_lineCount)
|
||||
newLine();
|
||||
}
|
||||
|
||||
void Content::setLineCount(int lineCount)
|
||||
{
|
||||
while(lineCount != m_lines.size())
|
||||
{
|
||||
if(lineCount > m_lineCount)
|
||||
newLine();
|
||||
else if (lineCount < m_lineCount)
|
||||
deleteLastLine();
|
||||
}
|
||||
|
||||
m_lineCount = m_lines.size();
|
||||
}
|
||||
|
||||
void Content::setCharCount(int charCount)
|
||||
{
|
||||
m_charCount = charCount;
|
||||
|
||||
for (FullLine * l : qAsConst(m_lines))
|
||||
l->setCharCount(m_charCount);
|
||||
}
|
||||
|
||||
int Content::charCount() const
|
||||
{
|
||||
return m_charCount;
|
||||
}
|
||||
|
||||
void Content::setHeight(int height)
|
||||
{
|
||||
m_height = height;
|
||||
|
||||
for (FullLine * l : qAsConst(m_lines))
|
||||
l->setHeight(height);
|
||||
}
|
||||
|
||||
int Content::height() const
|
||||
{
|
||||
return m_height;
|
||||
}
|
||||
|
||||
void Content::setCharCountAndHeight(int charCount, int height)
|
||||
{
|
||||
m_charCount = charCount;
|
||||
m_height = height;
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
void Content::newLine()
|
||||
{
|
||||
FullLine *line = new FullLine(m_lines.count()+1, m_height, m_charCount, this);
|
||||
m_layout->addWidget(line);
|
||||
m_lines.append(line);
|
||||
}
|
||||
|
||||
void Content::deleteLastLine()
|
||||
{
|
||||
if (m_lines.isEmpty())
|
||||
return;
|
||||
|
||||
delete m_lines.last();
|
||||
m_lines.remove(m_lines.size()-1);
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
#pragma once
|
||||
|
||||
#include <QWidget>
|
||||
#include <QVector>
|
||||
|
||||
class QVBoxLayout;
|
||||
class FullLine;
|
||||
|
||||
namespace Ui {
|
||||
class Content;
|
||||
}
|
||||
|
||||
class Content : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit Content(QWidget *parent = nullptr);
|
||||
~Content();
|
||||
|
||||
int charCount() const;
|
||||
int height() const;
|
||||
|
||||
public slots:
|
||||
void setLineCount(int lineCount);
|
||||
|
||||
void setCharCount(int charCount);
|
||||
|
||||
void setHeight(int height);
|
||||
|
||||
void setCharCountAndHeight(int charCount, int height);
|
||||
|
||||
private:
|
||||
void init();
|
||||
void newLine();
|
||||
void deleteLastLine();
|
||||
|
||||
Ui::Content *m_ui = nullptr;
|
||||
int m_lineCount = 0;
|
||||
int m_charCount = 0;
|
||||
int m_height = 0;
|
||||
QVBoxLayout *m_layout = nullptr;
|
||||
QVector<FullLine*> m_lines;
|
||||
|
||||
};
|
||||
@@ -0,0 +1,39 @@
|
||||
#include <QLayout>
|
||||
|
||||
#include "fullline.h"
|
||||
#include "ui_fullline.h"
|
||||
|
||||
FullLine::FullLine(int lineIndex, int height, int charcount, QWidget *parent) :
|
||||
QWidget(parent)
|
||||
, m_ui(new Ui::FullLine)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
m_ui->props->setLineIndex(lineIndex);
|
||||
m_ui->ledLine->setCharCountAndHeight(charcount, height);
|
||||
|
||||
connect(m_ui->props, &Props::flashTimeChanged, m_ui->ledLine, &QLedLine::setFlashing);
|
||||
connect(m_ui->props, &Props::colorChanged, m_ui->ledLine, &QLedLine::setColor);
|
||||
connect(m_ui->props, &Props::textChanged, m_ui->ledLine, &QLedLine::setText);
|
||||
connect(m_ui->props, &Props::showText, m_ui->ledLine, &QLedLine::setTextVisible);
|
||||
}
|
||||
|
||||
FullLine::~FullLine()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void FullLine::setCharCount(int count)
|
||||
{
|
||||
m_ui->ledLine->setCharCount(count);
|
||||
}
|
||||
|
||||
int FullLine::charCount() const
|
||||
{
|
||||
return m_ui->ledLine->charCount();
|
||||
}
|
||||
|
||||
void FullLine::setHeight(int height)
|
||||
{
|
||||
m_ui->ledLine->setHeight(height);
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
#pragma once
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
namespace Ui {
|
||||
class FullLine;
|
||||
}
|
||||
|
||||
class FullLine : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit FullLine(int lineIndex, int height, int charcount, QWidget *parent = nullptr);
|
||||
~FullLine();
|
||||
|
||||
void setCharCount(int count);
|
||||
int charCount() const;
|
||||
|
||||
void setHeight(int height);
|
||||
private:
|
||||
Ui::FullLine *m_ui;
|
||||
};
|
||||
@@ -0,0 +1,15 @@
|
||||
#include <QApplication>
|
||||
#include "mainwindow.h"
|
||||
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
QApplication app( argc, argv );
|
||||
|
||||
//Testing examples ░ ▒ ▓ ☺ Hello world! العربي☺Üة
|
||||
|
||||
MainWindow *w = new MainWindow(1, 13, 13);
|
||||
w->show();
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
#include "mainwindow.h"
|
||||
#include "ui_mainwindow.h"
|
||||
#include "content.h"
|
||||
|
||||
MainWindow::MainWindow(int lineCount, int charCount, int height, QWidget *parent)
|
||||
: QMainWindow(parent)
|
||||
, m_ui(new Ui::MainWindow)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
m_ui->sbLineCount->setValue(lineCount);
|
||||
m_ui->sbCharCount->setValue(charCount);
|
||||
m_ui->sbHeight->setValue(height);
|
||||
|
||||
Content *content = new Content(this);
|
||||
content->setCharCountAndHeight(charCount, height);
|
||||
content->setLineCount(lineCount);
|
||||
|
||||
m_ui->scrollArea->setWidget(content);
|
||||
|
||||
connect(m_ui->sbLineCount, QOverload<int>::of(&QSpinBox::valueChanged), content, &Content::setLineCount);
|
||||
connect(m_ui->sbCharCount, QOverload<int>::of(&QSpinBox::valueChanged), content, &Content::setCharCount);
|
||||
connect(m_ui->sbHeight, QOverload<int>::of(&QSpinBox::valueChanged), content, &Content::setHeight);
|
||||
connect(m_ui->pbClose, &QPushButton::clicked, this, &MainWindow::close);
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
#pragma once
|
||||
|
||||
#include <QMainWindow>
|
||||
|
||||
namespace Ui {
|
||||
class MainWindow;
|
||||
}
|
||||
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MainWindow(int lineCount, int charCount, int height, QWidget *parent = nullptr);
|
||||
~MainWindow();
|
||||
|
||||
signals:
|
||||
void onSbLineCountValueChanged(int lineCount);
|
||||
|
||||
private:
|
||||
Ui::MainWindow *m_ui;
|
||||
};
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
#include <QColorDialog>
|
||||
|
||||
#include "props.h"
|
||||
#include "ui_props.h"
|
||||
|
||||
Props::Props(QWidget *parent) : QWidget(parent)
|
||||
, m_ui(new Ui::Props)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
connect(m_ui->slFlashTime, &QSlider::valueChanged, this, &Props::flashTimeChanged);
|
||||
connect(m_ui->leInput, &QLineEdit::textChanged, this, &Props::textChanged);
|
||||
connect(m_ui->pbTextVisible, &QPushButton::clicked, this, &Props::showText);
|
||||
connect(m_ui->pbColor, &QPushButton::clicked, this, &Props::onPbColorClicked);
|
||||
}
|
||||
|
||||
Props::~Props()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
int Props::lineIndex() const
|
||||
{
|
||||
return m_lineIndex;
|
||||
}
|
||||
|
||||
void Props::setLineIndex(int lineIndex)
|
||||
{
|
||||
m_lineIndex = lineIndex;
|
||||
m_ui->lbTitle->setText(tr("%1. Line").arg(m_lineIndex));
|
||||
}
|
||||
|
||||
void Props::onPbColorClicked()
|
||||
{
|
||||
m_color = QColorDialog::getColor(m_color, this, tr("Farbe wählen"));
|
||||
emit colorChanged(m_color);
|
||||
}
|
||||
|
||||
QString Props::inputText() const
|
||||
{
|
||||
return m_ui->leInput->text();
|
||||
}
|
||||
|
||||
void Props::setInputText(const QString &inputText)
|
||||
{
|
||||
m_ui->leInput->setText(inputText);
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
#pragma once
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
namespace Ui {
|
||||
class Props;
|
||||
}
|
||||
|
||||
class Props : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit Props(QWidget *parent = nullptr);
|
||||
~Props();
|
||||
|
||||
int lineIndex() const;
|
||||
void setLineIndex(int lineIndex);
|
||||
QString inputText() const;
|
||||
void setInputText(const QString &inputText);
|
||||
|
||||
signals:
|
||||
void textChanged(const QString& newText);
|
||||
void showText(bool visible);
|
||||
void flashTimeChanged(int msecs);
|
||||
void colorChanged(const QColor &newColor);
|
||||
|
||||
private slots:
|
||||
void onPbColorClicked();
|
||||
|
||||
private:
|
||||
int m_lineIndex = 0;
|
||||
QColor m_color;
|
||||
Ui::Props *m_ui = nullptr;
|
||||
};
|
||||
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Content</class>
|
||||
<widget class="QWidget" name="Content">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>435</width>
|
||||
<height>266</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout"/>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -0,0 +1,92 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>FullLine</class>
|
||||
<widget class="QWidget" name="FullLine">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>871</width>
|
||||
<height>130</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>130</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<property name="margin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="Props" name="props" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>130</width>
|
||||
<height>100</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLedLine" name="ledLine" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>130</width>
|
||||
<height>100</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>Props</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>props.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>QLedLine</class>
|
||||
<extends>QWidget</extends>
|
||||
<header location="global">QLedLine/qledline.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -0,0 +1,218 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MainWindow</class>
|
||||
<widget class="QMainWindow" name="MainWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>823</width>
|
||||
<height>458</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>MainWindow</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QScrollArea" name="scrollArea">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="widgetResizable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
||||
</property>
|
||||
<widget class="Content" name="content">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>813</width>
|
||||
<height>204</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::MinimumExpanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lbCharCount">
|
||||
<property name="text">
|
||||
<string>Charcount:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="sbCharCount">
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>50</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>10</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lbHeight">
|
||||
<property name="text">
|
||||
<string>Height:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="sbHeight">
|
||||
<property name="suffix">
|
||||
<string>px</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>7</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>50</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>20</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lbLineCount">
|
||||
<property name="text">
|
||||
<string>Linecount:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="sbLineCount">
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>5</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pbClose">
|
||||
<property name="text">
|
||||
<string>Close</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menubar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>823</width>
|
||||
<height>19</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="nativeMenuBar">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusbar"/>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>Content</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>content.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -0,0 +1,125 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Props</class>
|
||||
<widget class="QWidget" name="Props">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>130</width>
|
||||
<height>100</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>100</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<property name="leftMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QWidget" name="verticalLayout_2" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="lbTitle">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>11</pointsize>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
<kerning>false</kerning>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="leInput">
|
||||
<property name="frame">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>Input Text</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QPushButton" name="pbTextVisible">
|
||||
<property name="text">
|
||||
<string>On</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pbColor">
|
||||
<property name="text">
|
||||
<string>Color</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSlider" name="slFlashTime">
|
||||
<property name="maximum">
|
||||
<number>1500</number>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="tickInterval">
|
||||
<number>10</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -0,0 +1,210 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Implements a QLedMatrix to display a single character
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Florian Schult, SLSE, 2016-03-18
|
||||
*/
|
||||
|
||||
#include "qledchar.h"
|
||||
|
||||
#include <QFontMetrics>
|
||||
#include <QPainter>
|
||||
|
||||
#define s_fontName QStringLiteral("monospace")
|
||||
|
||||
QLedChar::QLedChar(int height, QWidget *parent, const QChar &letter)
|
||||
: QLedMatrix(parent)
|
||||
, m_ptHeight(findPtHeight(height))
|
||||
, m_font()
|
||||
, m_color()
|
||||
, m_bgColor(QColor(34,34,34))
|
||||
, m_image()
|
||||
, m_size()
|
||||
, m_letter(letter)
|
||||
, m_isTransparent(false)
|
||||
, m_isLetterVisible(true)
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
void QLedChar::init()
|
||||
{
|
||||
m_font = QFont(s_fontName, m_ptHeight);
|
||||
m_font.setStyleStrategy(QFont::NoAntialias);
|
||||
QFontMetrics metrics(m_font);
|
||||
|
||||
m_size.setWidth(metrics.maxWidth());
|
||||
m_size.setHeight(metrics.height());
|
||||
setSize(m_size);
|
||||
}
|
||||
|
||||
QChar QLedChar::letter() const
|
||||
{
|
||||
return m_letter;
|
||||
}
|
||||
|
||||
QLedChar::~QLedChar()
|
||||
{
|
||||
}
|
||||
|
||||
void QLedChar::setLetter(const QChar &letter)
|
||||
{
|
||||
m_letter = letter;
|
||||
|
||||
if (!m_isLetterVisible)
|
||||
{
|
||||
for(int row = 0; row < m_size.height(); ++row)
|
||||
{
|
||||
for(int col = 0; col < m_size.width(); ++col)
|
||||
{
|
||||
setColorAt(row, col, NoColor);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
QImage image(m_size,QImage::Format_RGB32);
|
||||
QPainter painter;
|
||||
painter.begin(&image);
|
||||
painter.setFont(m_font);
|
||||
painter.fillRect(image.rect(), m_bgColor);
|
||||
painter.setPen(m_color);
|
||||
painter.drawText(QPoint(0,m_ptHeight), letter);
|
||||
painter.end();
|
||||
|
||||
setImage(image);
|
||||
drawImage();
|
||||
}
|
||||
|
||||
void QLedChar::drawImage()
|
||||
{
|
||||
for(int row = 0; row < m_size.height(); ++row)
|
||||
{
|
||||
for(int col = 0; col < m_size.width(); ++col)
|
||||
{
|
||||
setColorAt(row, col, m_image.pixel(col, row));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QImage QLedChar::image() const
|
||||
{
|
||||
return m_image;
|
||||
}
|
||||
|
||||
void QLedChar::setImage(const QImage &image)
|
||||
{
|
||||
m_image = image;
|
||||
drawImage();
|
||||
}
|
||||
|
||||
int QLedChar::findPtHeight(int maxPxHeight)
|
||||
{
|
||||
int bestPtHeight = 0;
|
||||
// Starting difference, should be at least 0.35
|
||||
float difference = 0.4f;
|
||||
float differenceStep = difference / 2;
|
||||
bool heightFound = false;
|
||||
|
||||
while(!heightFound)
|
||||
{
|
||||
differenceStep /= 2;
|
||||
float ptHeight = maxPxHeight - (maxPxHeight * difference);
|
||||
|
||||
QFont font(s_fontName,ptHeight);
|
||||
QFontMetrics metrics(font);
|
||||
|
||||
int pxHeight = metrics.height();
|
||||
|
||||
if(pxHeight < maxPxHeight)
|
||||
difference -= differenceStep;
|
||||
else if(pxHeight > maxPxHeight)
|
||||
difference += differenceStep;
|
||||
else
|
||||
{
|
||||
bestPtHeight = ptHeight;
|
||||
heightFound = true;
|
||||
}
|
||||
|
||||
if(differenceStep == 0)
|
||||
{
|
||||
// Catches invalid pixelsizes, which lack proper pointsizes
|
||||
bestPtHeight = ptHeight-1;
|
||||
heightFound = true;
|
||||
}
|
||||
}
|
||||
return bestPtHeight;
|
||||
}
|
||||
|
||||
QSize QLedChar::charSize() const
|
||||
{
|
||||
return m_size;
|
||||
}
|
||||
|
||||
void QLedChar::setLetterVisible(bool visible)
|
||||
{
|
||||
m_isLetterVisible = visible;
|
||||
setLetter(m_letter);
|
||||
}
|
||||
|
||||
bool QLedChar::isTransparent() const
|
||||
{
|
||||
return m_isTransparent;
|
||||
}
|
||||
|
||||
void QLedChar::setTransparent(bool isTransparent)
|
||||
{
|
||||
m_isTransparent = isTransparent;
|
||||
if (isTransparent)
|
||||
setBackgroundMode(Qt::TransparentMode);
|
||||
else
|
||||
setBackgroundMode(Qt::OpaqueMode);
|
||||
}
|
||||
|
||||
bool QLedChar::letterVisible() const
|
||||
{
|
||||
return m_isLetterVisible;
|
||||
}
|
||||
|
||||
void QLedChar::setCharHeight(int height)
|
||||
{
|
||||
m_ptHeight = findPtHeight(height);
|
||||
init();
|
||||
}
|
||||
|
||||
int QLedChar::charHeight() const
|
||||
{
|
||||
return m_size.height();
|
||||
}
|
||||
|
||||
QColor QLedChar::color() const
|
||||
{
|
||||
return m_color;
|
||||
}
|
||||
|
||||
void QLedChar::setColor(const QColor &color)
|
||||
{
|
||||
m_color = color;
|
||||
setLetter(m_letter);
|
||||
}
|
||||
|
||||
QColor QLedChar::bgColor() const
|
||||
{
|
||||
return m_bgColor;
|
||||
}
|
||||
|
||||
void QLedChar::setBgColor(const QColor &bgColor)
|
||||
{
|
||||
m_bgColor = bgColor;
|
||||
setLetter(m_letter);
|
||||
}
|
||||
|
||||
void QLedChar::onFlashTimerTimeout()
|
||||
{
|
||||
m_isLetterVisible = !m_isLetterVisible;
|
||||
setLetter(m_letter);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Implements a QLedMatrix to display a single character
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Florian Schult, SLSE, 2016-03-18
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QLedMatrix/qledmatrix.h>
|
||||
|
||||
class QImage;
|
||||
|
||||
class QLedChar : public QLedMatrix
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit QLedChar(int height, QWidget *parent, const QChar &letter);
|
||||
~QLedChar();
|
||||
|
||||
QChar letter() const;
|
||||
void setLetter(const QChar &letter);
|
||||
|
||||
QColor bgColor() const;
|
||||
void setBgColor(const QColor &bgColor);
|
||||
|
||||
QColor color() const;
|
||||
void setColor(const QColor &color);
|
||||
|
||||
bool isTransparent() const;
|
||||
void setTransparent(bool isTransparent);
|
||||
|
||||
bool letterVisible() const;
|
||||
void setLetterVisible(bool visible = true);
|
||||
|
||||
int charHeight() const;
|
||||
void setCharHeight(int height);
|
||||
|
||||
QSize charSize() const;
|
||||
|
||||
QImage image() const;
|
||||
void setImage(const QImage &image);
|
||||
|
||||
public slots:
|
||||
void onFlashTimerTimeout();
|
||||
void drawImage();
|
||||
|
||||
private:
|
||||
void init();
|
||||
int findPtHeight(int height);
|
||||
|
||||
int m_ptHeight;
|
||||
QFont m_font;
|
||||
QColor m_color;
|
||||
QColor m_bgColor;
|
||||
QImage m_image;
|
||||
QSize m_size;
|
||||
QChar m_letter;
|
||||
bool m_isTransparent;
|
||||
bool m_isLetterVisible;
|
||||
};
|
||||
@@ -0,0 +1,223 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Implements n QLedChars to display a line of Text/Image
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Florian Schult, SLSE, 2016-03-18
|
||||
*/
|
||||
#include "qledline.h"
|
||||
|
||||
#include <QString>
|
||||
#include <QLayout>
|
||||
#include <QTimer>
|
||||
#include <QImage>
|
||||
|
||||
#include "qledchar.h"
|
||||
|
||||
QLedLine::QLedLine(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, m_charCount(0)
|
||||
, m_height(0)
|
||||
, m_visible(true)
|
||||
, m_text()
|
||||
, m_layout(new QHBoxLayout(this))
|
||||
, m_chars()
|
||||
, m_flashTimer(new QTimer(this))
|
||||
, m_color(Qt::red) // Standard color
|
||||
, m_image()
|
||||
{
|
||||
m_layout->setSpacing(0);
|
||||
m_layout->setContentsMargins(0,0,0,0);
|
||||
m_layout->setMargin(0);
|
||||
|
||||
QSpacerItem *sp1 = new QSpacerItem(0,0, QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
QSpacerItem *sp2 = new QSpacerItem(0,0, QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
|
||||
m_layout->addSpacerItem(sp1);
|
||||
m_layout->addSpacerItem(sp2);
|
||||
m_layout->setAlignment(m_layout, Qt::AlignHCenter);
|
||||
}
|
||||
|
||||
QLedLine::~QLedLine()
|
||||
{
|
||||
qDeleteAll(m_chars);
|
||||
// optional. They have "this" as parent and are QT.
|
||||
delete m_layout;
|
||||
delete m_flashTimer;
|
||||
}
|
||||
|
||||
QString QLedLine::shownText() const
|
||||
{
|
||||
return m_text.leftJustified(m_chars.size(), QLatin1Char(' '), true);
|
||||
}
|
||||
|
||||
bool QLedLine::isTextVisible() const
|
||||
{
|
||||
return m_visible;
|
||||
}
|
||||
|
||||
int QLedLine::flashTime() const
|
||||
{
|
||||
return m_flashTimer->interval();
|
||||
}
|
||||
|
||||
QColor QLedLine::color() const
|
||||
{
|
||||
return m_color;
|
||||
}
|
||||
|
||||
void QLedLine::setText(const QString &text)
|
||||
{
|
||||
m_text = text;
|
||||
|
||||
// Todo: Arabic: RightJustified? Automatic?
|
||||
QString shown = shownText();
|
||||
for (int i=0; i<m_chars.size(); ++i)
|
||||
m_chars[i]->setLetter(shown[i]);
|
||||
}
|
||||
|
||||
// Expects a properly sized QImage, corresponding to the count and Pixelsizes of QLedLine and QLedChar
|
||||
void QLedLine::setImage(const QImage &image)
|
||||
{
|
||||
m_image = image;
|
||||
QImage charImage;
|
||||
QSize charSize = m_chars[0]->charSize();
|
||||
|
||||
for (int i=0; i<m_chars.size(); ++i)
|
||||
{
|
||||
charImage = m_image.copy((charSize.width() * i), 0, charSize.width(), charSize.height());
|
||||
m_chars[i]->setImage(charImage);
|
||||
}
|
||||
}
|
||||
|
||||
QSize QLedLine::charSize() const
|
||||
{
|
||||
return m_chars[0]->charSize();
|
||||
}
|
||||
|
||||
QString QLedLine::text() const
|
||||
{
|
||||
return m_text;
|
||||
}
|
||||
|
||||
void QLedLine::addChar()
|
||||
{
|
||||
QLedChar *ledChar = new QLedChar(m_height, this, m_text[m_chars.size()]);
|
||||
ledChar->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
||||
if (!m_chars.isEmpty())
|
||||
ledChar->setLetterVisible(m_chars[0]->letterVisible());
|
||||
connect(m_flashTimer, &QTimer::timeout, ledChar, &QLedChar::onFlashTimerTimeout);
|
||||
ledChar->setColor(m_color);
|
||||
|
||||
// Takes the last stretch-item and puts it behind the new added ledChar
|
||||
QLayoutItem *spacer = m_layout->takeAt(m_layout->count()-1);
|
||||
m_layout->addWidget(ledChar);
|
||||
m_layout->addItem(spacer);
|
||||
|
||||
m_chars.append(ledChar);
|
||||
ledChar->setLetter(shownText().at(m_chars.size()-1));
|
||||
}
|
||||
|
||||
void QLedLine::deleteChar()
|
||||
{
|
||||
if (m_chars.isEmpty())
|
||||
return;
|
||||
|
||||
delete m_chars.last();
|
||||
m_chars.remove(m_chars.size()-1);
|
||||
}
|
||||
|
||||
void QLedLine::setCharCount(int charCount)
|
||||
{
|
||||
m_charCount = charCount;
|
||||
while(m_chars.size() != m_charCount)
|
||||
{
|
||||
if(m_chars.size() > m_charCount)
|
||||
deleteChar();
|
||||
else if(m_chars.size() < m_charCount)
|
||||
addChar();
|
||||
}
|
||||
}
|
||||
|
||||
int QLedLine::charCount() const
|
||||
{
|
||||
return m_charCount;
|
||||
}
|
||||
|
||||
void QLedLine::setHeight(int height)
|
||||
{
|
||||
m_height = height;
|
||||
|
||||
for(int i=0; i<m_chars.size(); ++i)
|
||||
{
|
||||
m_chars[i]->setCharHeight(m_height);
|
||||
}
|
||||
setText(m_text);
|
||||
}
|
||||
|
||||
int QLedLine::height() const
|
||||
{
|
||||
return m_height;
|
||||
}
|
||||
|
||||
void QLedLine::setCharCountAndHeight(int charCount, int height)
|
||||
{
|
||||
setHeight(height);
|
||||
setCharCount(charCount);
|
||||
}
|
||||
|
||||
void QLedLine::setColor(const QColor &color)
|
||||
{
|
||||
m_color = color;
|
||||
for (int i=0; i<m_charCount; ++i)
|
||||
m_chars[i]->setColor(color);
|
||||
}
|
||||
|
||||
void QLedLine::clear()
|
||||
{
|
||||
for (int i=0; i<m_charCount; ++i)
|
||||
{
|
||||
m_chars[i]->setLetterVisible(false);
|
||||
m_chars[i]->setLetterVisible(true);
|
||||
}
|
||||
}
|
||||
|
||||
void QLedLine::setFlashing(int msecs)
|
||||
{
|
||||
m_flashTimer->setInterval(msecs);
|
||||
if (msecs == 0)
|
||||
{
|
||||
if (m_visible)
|
||||
{
|
||||
for (int i = 0; i < m_chars.size(); ++i)
|
||||
m_chars[i]->setLetterVisible();
|
||||
}
|
||||
m_flashTimer->stop();
|
||||
}
|
||||
else
|
||||
{
|
||||
if(m_visible)
|
||||
m_flashTimer->start();
|
||||
else
|
||||
m_flashTimer->stop();
|
||||
}
|
||||
}
|
||||
|
||||
void QLedLine::setTextVisible(bool visible)
|
||||
{
|
||||
m_visible = visible;
|
||||
for (int i=0; i<m_chars.size(); ++i)
|
||||
m_chars[i]->setLetterVisible(m_visible);
|
||||
|
||||
if(m_visible)
|
||||
{
|
||||
if(m_flashTimer->interval() > 0)
|
||||
m_flashTimer->start();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_flashTimer->stop();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Implements n QLedChars to display a line of Text/Image
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Florian Schult, SLSE, 2016-03-18
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <QVector>
|
||||
#include <QWidget>
|
||||
|
||||
#ifndef QLEDLINE_EXPORT
|
||||
# ifdef BUILD_STATIC_LIBRARIES
|
||||
# define QLEDLINE_EXPORT
|
||||
# else
|
||||
# ifdef MAKE_QLEDLINE_LIB
|
||||
# define QLEDLINE_EXPORT Q_DECL_EXPORT
|
||||
# else
|
||||
# define QLEDLINE_EXPORT Q_DECL_IMPORT
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class QLedLine;
|
||||
}
|
||||
|
||||
class QHBoxLayout;
|
||||
class QLedChar;
|
||||
class QTimer;
|
||||
class QImage;
|
||||
|
||||
class QLEDLINE_EXPORT QLedLine : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit QLedLine(QWidget *parent = nullptr);
|
||||
~QLedLine();
|
||||
|
||||
int height() const;
|
||||
void setHeight(int height);
|
||||
|
||||
int charCount() const;
|
||||
void setCharCount(int charCount);
|
||||
|
||||
// Returns the QSize of the first QLedChar
|
||||
QSize charSize() const;
|
||||
|
||||
void setCharCountAndHeight(int charCount, int height);
|
||||
|
||||
bool isTextVisible() const;
|
||||
int flashTime() const;
|
||||
QColor color() const;
|
||||
QString shownText() const;
|
||||
QString text() const;
|
||||
|
||||
private:
|
||||
void addChar();
|
||||
void deleteChar();
|
||||
|
||||
public slots:
|
||||
void setText(const QString &text);
|
||||
void setFlashing(int msecs = 0);
|
||||
void setTextVisible(bool visible = true);
|
||||
void setColor(const QColor &color);
|
||||
void clear();
|
||||
void setImage(const QImage &image);
|
||||
|
||||
private:
|
||||
int m_charCount;
|
||||
int m_height;
|
||||
bool m_visible;
|
||||
QString m_text;
|
||||
QHBoxLayout *m_layout;
|
||||
QVector<QLedChar*> m_chars;
|
||||
QTimer *m_flashTimer;
|
||||
QColor m_color;
|
||||
QImage m_image;
|
||||
};
|
||||
@@ -0,0 +1,6 @@
|
||||
Release 0.6 (March 15, 2009)
|
||||
================================================================================
|
||||
|
||||
Changes
|
||||
-------
|
||||
1. Initial public release.
|
||||
@@ -0,0 +1,32 @@
|
||||
#
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
#
|
||||
# CMakeLists.txt fuer qledmatrix
|
||||
#
|
||||
|
||||
|
||||
SET(qledmatrix_SRCS
|
||||
qledmatrix.cpp
|
||||
)
|
||||
|
||||
SET(qledmatrix_HDRS
|
||||
qledmatrix.h
|
||||
)
|
||||
|
||||
NGL_ADD_LIBRARY(AAR SV WS qledmatrix SHARED ${qledmatrix_SRCS} ${qledmatrix_HDRS})
|
||||
|
||||
|
||||
NGL_TARGET_INCLUDE_DIRECTORIES(qledmatrix
|
||||
PUBLIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../
|
||||
)
|
||||
|
||||
NGL_TARGET_LINK_LIBRARIES(qledmatrix
|
||||
PUBLIC
|
||||
Qt5::Core
|
||||
Qt5::Widgets
|
||||
)
|
||||
|
||||
NGL_INSTALL_TARGET(qledmatrix)
|
||||
@@ -0,0 +1,165 @@
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
|
||||
This version of the GNU Lesser General Public License incorporates
|
||||
the terms and conditions of version 3 of the GNU General Public
|
||||
License, supplemented by the additional permissions listed below.
|
||||
|
||||
0. Additional Definitions.
|
||||
|
||||
As used herein, "this License" refers to version 3 of the GNU Lesser
|
||||
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
||||
General Public License.
|
||||
|
||||
"The Library" refers to a covered work governed by this License,
|
||||
other than an Application or a Combined Work as defined below.
|
||||
|
||||
An "Application" is any work that makes use of an interface provided
|
||||
by the Library, but which is not otherwise based on the Library.
|
||||
Defining a subclass of a class defined by the Library is deemed a mode
|
||||
of using an interface provided by the Library.
|
||||
|
||||
A "Combined Work" is a work produced by combining or linking an
|
||||
Application with the Library. The particular version of the Library
|
||||
with which the Combined Work was made is also called the "Linked
|
||||
Version".
|
||||
|
||||
The "Minimal Corresponding Source" for a Combined Work means the
|
||||
Corresponding Source for the Combined Work, excluding any source code
|
||||
for portions of the Combined Work that, considered in isolation, are
|
||||
based on the Application, and not on the Linked Version.
|
||||
|
||||
The "Corresponding Application Code" for a Combined Work means the
|
||||
object code and/or source code for the Application, including any data
|
||||
and utility programs needed for reproducing the Combined Work from the
|
||||
Application, but excluding the System Libraries of the Combined Work.
|
||||
|
||||
1. Exception to Section 3 of the GNU GPL.
|
||||
|
||||
You may convey a covered work under sections 3 and 4 of this License
|
||||
without being bound by section 3 of the GNU GPL.
|
||||
|
||||
2. Conveying Modified Versions.
|
||||
|
||||
If you modify a copy of the Library, and, in your modifications, a
|
||||
facility refers to a function or data to be supplied by an Application
|
||||
that uses the facility (other than as an argument passed when the
|
||||
facility is invoked), then you may convey a copy of the modified
|
||||
version:
|
||||
|
||||
a) under this License, provided that you make a good faith effort to
|
||||
ensure that, in the event an Application does not supply the
|
||||
function or data, the facility still operates, and performs
|
||||
whatever part of its purpose remains meaningful, or
|
||||
|
||||
b) under the GNU GPL, with none of the additional permissions of
|
||||
this License applicable to that copy.
|
||||
|
||||
3. Object Code Incorporating Material from Library Header Files.
|
||||
|
||||
The object code form of an Application may incorporate material from
|
||||
a header file that is part of the Library. You may convey such object
|
||||
code under terms of your choice, provided that, if the incorporated
|
||||
material is not limited to numerical parameters, data structure
|
||||
layouts and accessors, or small macros, inline functions and templates
|
||||
(ten or fewer lines in length), you do both of the following:
|
||||
|
||||
a) Give prominent notice with each copy of the object code that the
|
||||
Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
|
||||
b) Accompany the object code with a copy of the GNU GPL and this license
|
||||
document.
|
||||
|
||||
4. Combined Works.
|
||||
|
||||
You may convey a Combined Work under terms of your choice that,
|
||||
taken together, effectively do not restrict modification of the
|
||||
portions of the Library contained in the Combined Work and reverse
|
||||
engineering for debugging such modifications, if you also do each of
|
||||
the following:
|
||||
|
||||
a) Give prominent notice with each copy of the Combined Work that
|
||||
the Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
|
||||
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
||||
document.
|
||||
|
||||
c) For a Combined Work that displays copyright notices during
|
||||
execution, include the copyright notice for the Library among
|
||||
these notices, as well as a reference directing the user to the
|
||||
copies of the GNU GPL and this license document.
|
||||
|
||||
d) Do one of the following:
|
||||
|
||||
0) Convey the Minimal Corresponding Source under the terms of this
|
||||
License, and the Corresponding Application Code in a form
|
||||
suitable for, and under terms that permit, the user to
|
||||
recombine or relink the Application with a modified version of
|
||||
the Linked Version to produce a modified Combined Work, in the
|
||||
manner specified by section 6 of the GNU GPL for conveying
|
||||
Corresponding Source.
|
||||
|
||||
1) Use a suitable shared library mechanism for linking with the
|
||||
Library. A suitable mechanism is one that (a) uses at run time
|
||||
a copy of the Library already present on the user's computer
|
||||
system, and (b) will operate properly with a modified version
|
||||
of the Library that is interface-compatible with the Linked
|
||||
Version.
|
||||
|
||||
e) Provide Installation Information, but only if you would otherwise
|
||||
be required to provide such information under section 6 of the
|
||||
GNU GPL, and only to the extent that such information is
|
||||
necessary to install and execute a modified version of the
|
||||
Combined Work produced by recombining or relinking the
|
||||
Application with a modified version of the Linked Version. (If
|
||||
you use option 4d0, the Installation Information must accompany
|
||||
the Minimal Corresponding Source and Corresponding Application
|
||||
Code. If you use option 4d1, you must provide the Installation
|
||||
Information in the manner specified by section 6 of the GNU GPL
|
||||
for conveying Corresponding Source.)
|
||||
|
||||
5. Combined Libraries.
|
||||
|
||||
You may place library facilities that are a work based on the
|
||||
Library side by side in a single library together with other library
|
||||
facilities that are not Applications and are not covered by this
|
||||
License, and convey such a combined library under terms of your
|
||||
choice, if you do both of the following:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work based
|
||||
on the Library, uncombined with any other library facilities,
|
||||
conveyed under the terms of this License.
|
||||
|
||||
b) Give prominent notice with the combined library that part of it
|
||||
is a work based on the Library, and explaining where to find the
|
||||
accompanying uncombined form of the same work.
|
||||
|
||||
6. Revised Versions of the GNU Lesser General Public License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions
|
||||
of the GNU Lesser General Public License from time to time. Such new
|
||||
versions will be similar in spirit to the present version, but may
|
||||
differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Library as you received it specifies that a certain numbered version
|
||||
of the GNU Lesser General Public License "or any later version"
|
||||
applies to it, you have the option of following the terms and
|
||||
conditions either of that published version or of any later version
|
||||
published by the Free Software Foundation. If the Library as you
|
||||
received it does not specify a version number of the GNU Lesser
|
||||
General Public License, you may choose any version of the GNU Lesser
|
||||
General Public License ever published by the Free Software Foundation.
|
||||
|
||||
If the Library as you received it specifies that a proxy can decide
|
||||
whether future versions of the GNU Lesser General Public License shall
|
||||
apply, that proxy's public statement of acceptance of any version is
|
||||
permanent authorization for you to choose that version for the
|
||||
Library.
|
||||
@@ -0,0 +1,50 @@
|
||||
|
||||
QLedMatrix Widget
|
||||
-----------------
|
||||
|
||||
The QLedMatrix widget simulates a LED matrix (dot matrix) display.
|
||||
|
||||
A LED matrix display is a 2-dimensional array of dots used to generate
|
||||
characters, symbols and images. It is often seen on machines, clocks and
|
||||
display boards.
|
||||
|
||||
This generic implementation can configured for any size of rows (greater
|
||||
than 0) and columns. The number of colors is not limited, therefore it
|
||||
can be used to make a monochrome, bi-color or even a full RGB display.
|
||||
|
||||
Individual LEDs can be addressed in the matrix by their row and column
|
||||
position. The index (0,0) is located in the upper left corner. Columns
|
||||
grow from left to right, and rows grow from top to bottom.
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
QLedMatrix library:
|
||||
qmake
|
||||
make
|
||||
make install (or copy the plugin into "<Qt4 dir>/plugins/designer")
|
||||
|
||||
QLedMatrix example:
|
||||
cd example
|
||||
qmake
|
||||
make
|
||||
./qledmatrix_demo
|
||||
|
||||
Copyright
|
||||
---------
|
||||
|
||||
Copyright (C) 2009 Pierre-Etienne Messier <pierre.etienne.messier@gmail.com>
|
||||
http://pemessier.hexpresso.org/
|
||||
|
||||
This library is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This library 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
@@ -0,0 +1,546 @@
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Copyright (C) 2009 Pierre-Etienne Messier <pierre.etienne.messier@gmail.com>
|
||||
** http://pemessier.hexpresso.org/
|
||||
**
|
||||
** This library is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU Lesser General Public License as published by
|
||||
** the Free Software Foundation, either version 3 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** This library 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 Lesser General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU Lesser General Public License
|
||||
** along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
**
|
||||
*******************************************************************************/
|
||||
|
||||
#include "qledmatrix.h"
|
||||
|
||||
#include <qpainter.h>
|
||||
|
||||
/**
|
||||
* \internal
|
||||
*/
|
||||
class QLedMatrixPrivate
|
||||
{
|
||||
Q_DECLARE_PUBLIC(QLedMatrix)
|
||||
|
||||
public:
|
||||
bool isValid(int row, int col) const;
|
||||
void setColorAt(int row, int col, QRgb rgb, bool doUpdate);
|
||||
void drawLEDs(QPainter& painter) const;
|
||||
void calculateAspectRatio();
|
||||
|
||||
QLedMatrix* q_ptr;
|
||||
QBrush backgroundBrush;
|
||||
Qt::BGMode backgroundMode;
|
||||
QColor darkLedColor;
|
||||
QVector< QVector<QRgb> > colorTable;
|
||||
int rowCount;
|
||||
int columnCount;
|
||||
qreal rowHeight;
|
||||
qreal columnWidth;
|
||||
qreal aspectRatio;
|
||||
mutable qreal sizeFactor;
|
||||
};
|
||||
|
||||
/**
|
||||
* \internal
|
||||
*/
|
||||
bool QLedMatrixPrivate::isValid(int row, int col) const
|
||||
{
|
||||
return ( (row >= 0) &&
|
||||
(row < rowCount) &&
|
||||
(col >= 0) &&
|
||||
(col < columnCount) );
|
||||
}
|
||||
|
||||
/**
|
||||
* \internal
|
||||
*/
|
||||
void QLedMatrixPrivate::setColorAt(int row, int col, QRgb rgb, bool doUpdate)
|
||||
{
|
||||
Q_Q(QLedMatrix);
|
||||
if(isValid(row, col))
|
||||
{
|
||||
colorTable[col][row] = rgb;
|
||||
|
||||
if(doUpdate == true)
|
||||
{
|
||||
q->update();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
qWarning("QLedMatrix::setColorAt: coordinate (row=%d, col=%d) out of range", row, col);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* \internal
|
||||
*/
|
||||
void QLedMatrixPrivate::drawLEDs(QPainter& painter) const
|
||||
{
|
||||
Q_Q(QLedMatrix const);
|
||||
for(int row = 0; row < rowCount; ++row)
|
||||
{
|
||||
painter.save();
|
||||
for(int col = 0; col < columnCount; ++col)
|
||||
{
|
||||
painter.setBrush(QColor(q->colorAt(row, col)));
|
||||
painter.drawEllipse(QRectF(0.0, 0.0, 8.0, 8.0));
|
||||
painter.translate(10.0, 0.0);
|
||||
}
|
||||
painter.restore();
|
||||
painter.translate(0.0, 10.0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* \internal
|
||||
*/
|
||||
void QLedMatrixPrivate::calculateAspectRatio()
|
||||
{
|
||||
if(rowHeight > 0.0)
|
||||
{
|
||||
aspectRatio = columnWidth / rowHeight;
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////
|
||||
|
||||
/**
|
||||
* \class QLedMatrix
|
||||
*
|
||||
* \brief The QLedMatrix widget simulates a LED matrix (dot matrix) display.
|
||||
*
|
||||
* A LED matrix display is a 2-dimensional array of dots used to generate
|
||||
* characters, symbols and images. It is often seen on machines, clocks and
|
||||
* display boards.
|
||||
*
|
||||
* This generic implementation can configured for any size of rows (greater
|
||||
* than 0) and columns. The number of colors is not limited, therefore it can
|
||||
* be used to make a monochrome, bi-color or even a full RGB display.
|
||||
*
|
||||
* Individual LEDs can be addressed in the matrix by their row and column
|
||||
* position. The index (0,0) is located in the upper left corner. Columns
|
||||
* grow from left to right, and rows grow from top to bottom.
|
||||
*
|
||||
* \version 0.6
|
||||
*
|
||||
* \author Pierre-Etienne Messier <pierre.etienne.messier\@gmail.com>
|
||||
*/
|
||||
|
||||
/**
|
||||
* \enum QLedMatrix::LEDColor
|
||||
*
|
||||
* This type defines standard LED colors in the QRgb format, provided purely
|
||||
* for convenience.
|
||||
*
|
||||
* \sa QRgb
|
||||
*/
|
||||
|
||||
/**
|
||||
* \var QLedMatrix::LEDColor QLedMatrix::NoColor
|
||||
* Default dark LED color (\#222222)
|
||||
**/
|
||||
|
||||
/**
|
||||
* \var QLedMatrix::LEDColor QLedMatrix::Red
|
||||
* Red (\#FF0000)
|
||||
**/
|
||||
|
||||
/**
|
||||
* \var QLedMatrix::LEDColor QLedMatrix::Green
|
||||
* Green (\#00FF00)
|
||||
**/
|
||||
|
||||
/**
|
||||
* \var QLedMatrix::LEDColor QLedMatrix::Blue
|
||||
* Blue (\#0000FF)
|
||||
**/
|
||||
|
||||
/**
|
||||
* \var QLedMatrix::LEDColor QLedMatrix::White
|
||||
* White (\#FFFFFF)
|
||||
**/
|
||||
|
||||
/**
|
||||
* \var QLedMatrix::LEDColor QLedMatrix::Orange
|
||||
* Orange (\#FF8800)
|
||||
**/
|
||||
|
||||
/**
|
||||
* \var QLedMatrix::LEDColor QLedMatrix::OrangeRed
|
||||
* Orange-Red (\#FF2200)
|
||||
**/
|
||||
|
||||
/**
|
||||
* \var QLedMatrix::LEDColor QLedMatrix::Yellow
|
||||
* Yellow (\#FFFF00)
|
||||
**/
|
||||
|
||||
/**
|
||||
* Constructs a LED Matrix display, sets the background color to black,
|
||||
* the background mode to opaque, the dark LED color to QLedMatrix::NoColor and
|
||||
* the number of rows and columns to 0.
|
||||
*
|
||||
* \sa setBackgroundColor(), setBackgroundMode(), setDarkLedColor(),
|
||||
* setRowCount(), setColumnCount()
|
||||
*
|
||||
* \param parent parent QWidget
|
||||
*/
|
||||
QLedMatrix::QLedMatrix(QWidget* parent): QWidget(parent),
|
||||
d_ptr(new QLedMatrixPrivate)
|
||||
{
|
||||
Q_D(QLedMatrix);
|
||||
d->q_ptr = this;
|
||||
d->backgroundBrush = QBrush(Qt::black, Qt::SolidPattern);
|
||||
d->backgroundMode = Qt::OpaqueMode;
|
||||
d->darkLedColor = QColor(QLedMatrix::NoColor);
|
||||
d->rowCount = 0;
|
||||
d->columnCount = 0;
|
||||
d->rowHeight = 0.0;
|
||||
d->columnWidth = 0.0;
|
||||
d->aspectRatio = 0.0;
|
||||
d->sizeFactor = 1.0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroys the LED Matrix display.
|
||||
*/
|
||||
QLedMatrix::~QLedMatrix()
|
||||
{
|
||||
delete d_ptr;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Clears the LED Matrix display.
|
||||
*
|
||||
* When the display is cleared, all the LEDs are set to the dark LED color.
|
||||
*
|
||||
* \sa darkLedColor(), setDarkLedColor()
|
||||
*/
|
||||
void QLedMatrix::clear()
|
||||
{
|
||||
Q_D(QLedMatrix);
|
||||
for(int i=0; i < d->rowCount; ++i)
|
||||
{
|
||||
for(int j=0; j < d->columnCount; ++j)
|
||||
{
|
||||
d->colorTable[j][i] = d->darkLedColor.rgb();
|
||||
}
|
||||
}
|
||||
update();
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Returns the background color of the widget.
|
||||
*
|
||||
* \return background color of the widget
|
||||
*
|
||||
* \sa setBackgroundColor()
|
||||
*/
|
||||
QColor QLedMatrix::backgroundColor() const
|
||||
{
|
||||
Q_D(const QLedMatrix);
|
||||
return d->backgroundBrush.color();
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Sets the background color of the widget to the given color.
|
||||
*
|
||||
* The background color of the widget will only be visible if the background
|
||||
* mode is set to Qt::OpaqueMode.
|
||||
*
|
||||
* \param color the background color to be set
|
||||
*
|
||||
* \sa backgroundColor(), backgroundMode(), setBackgroundMode()
|
||||
*/
|
||||
void QLedMatrix::setBackgroundColor(const QColor& color)
|
||||
{
|
||||
Q_D(QLedMatrix);
|
||||
d->backgroundBrush.setColor(color);
|
||||
update();
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Returns the background mode of the widget.
|
||||
*
|
||||
* \return background mode of the widget
|
||||
*
|
||||
* \sa setBackgroundMode()
|
||||
*/
|
||||
Qt::BGMode QLedMatrix::backgroundMode() const
|
||||
{
|
||||
Q_D(const QLedMatrix);
|
||||
return d->backgroundMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Sets the background mode of the widget to the given mode.
|
||||
*
|
||||
* Qt::OpaqueMode (the default) fills the widget's background with the current
|
||||
* background color. Qt::TransparentMode doesn't draw any background color.
|
||||
*
|
||||
* \param mode the background mode to be set
|
||||
*
|
||||
* \sa backgroundMode(), backgroundColor(), setBackgroundColor()
|
||||
*/
|
||||
void QLedMatrix::setBackgroundMode(Qt::BGMode mode)
|
||||
{
|
||||
Q_D(QLedMatrix);
|
||||
d->backgroundMode = mode;
|
||||
update();
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Returns the dark LED color.
|
||||
*
|
||||
* \return dark LED color
|
||||
*
|
||||
* \sa setDarkLedColor()
|
||||
*/
|
||||
QColor QLedMatrix::darkLedColor() const
|
||||
{
|
||||
Q_D(const QLedMatrix);
|
||||
return d->darkLedColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Sets the dark LED color to the given color.
|
||||
*
|
||||
* The dark LED color is used to represent a LED in the 'off' state. It is
|
||||
* used when adding rows or cols, and when using the clear() method.
|
||||
*
|
||||
* \param color the color to be set
|
||||
*
|
||||
* \sa darkLedColor(), clear(), setRowCount(), setColumnCount()
|
||||
*/
|
||||
void QLedMatrix::setDarkLedColor(const QColor& color)
|
||||
{
|
||||
Q_D(QLedMatrix);
|
||||
QRgb oldColor = d->darkLedColor.rgb();
|
||||
d->darkLedColor = color;
|
||||
|
||||
for(int i=0; i < d->rowCount; ++i)
|
||||
{
|
||||
for(int j=0; j < d->columnCount; ++j)
|
||||
{
|
||||
if(d->colorTable[j][i] == oldColor)
|
||||
{
|
||||
d->colorTable[j][i] = d->darkLedColor.rgb();
|
||||
}
|
||||
}
|
||||
}
|
||||
update();
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Returns the color of the LED at the specified position.
|
||||
*
|
||||
* This function uses the QRgb data format. If the specified position is
|
||||
* invalid, this function will return the current dark LED color.
|
||||
*
|
||||
* \param row the row index of the LED
|
||||
* \param col the column index of the LED
|
||||
*
|
||||
* \return the color of the LED at the given position
|
||||
*
|
||||
* \sa setColorAt(), darkLedColor()
|
||||
*/
|
||||
QRgb QLedMatrix::colorAt(int row, int col) const
|
||||
{
|
||||
Q_D(const QLedMatrix);
|
||||
if(d->isValid(row, col))
|
||||
{
|
||||
return d->colorTable[col][row];
|
||||
}
|
||||
|
||||
qWarning("QLedMatrix::colorAt: coordinate (row=%d, col=%d) out of range", row, col);
|
||||
return d->darkLedColor.rgb();
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Sets the given color to the LED at the specified position.
|
||||
*
|
||||
* If the specified position is invalid, this function will do nothing.
|
||||
*
|
||||
* \param row the row index of the LED
|
||||
* \param col the column index of the LED
|
||||
* \param rgb the color to be set (in QRgb format)
|
||||
*
|
||||
* \sa colorAt()
|
||||
*/
|
||||
void QLedMatrix::setColorAt(int row, int col, QRgb rgb)
|
||||
{
|
||||
Q_D(QLedMatrix);
|
||||
d->setColorAt(row, col, rgb, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Returns the number of rows in the LED matrix display.
|
||||
*
|
||||
* \return the number of rows in the LED matrix display
|
||||
*
|
||||
* \sa setRowCount(), columnCount()
|
||||
*/
|
||||
int QLedMatrix::rowCount() const
|
||||
{
|
||||
Q_D(const QLedMatrix);
|
||||
return d->rowCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Sets the number of rows in the LED matrix display.
|
||||
*
|
||||
* This function will do nothing if the new number of rows is less than 0
|
||||
* or if it is equal to the current number of rows. If the new number of
|
||||
* rows is less than the current number of rows, the display will be
|
||||
* cropped to the new value. Otherwise, if the new number of rows is
|
||||
* greater than the current number of rows, the new LEDs will be
|
||||
* initialized using the dark LED color.
|
||||
*
|
||||
* \param rows the new number of rows
|
||||
*
|
||||
* \sa rowsCount(), setColumnCount(), darkLedColor()
|
||||
*/
|
||||
void QLedMatrix::setRowCount(int rows)
|
||||
{
|
||||
Q_D(QLedMatrix);
|
||||
if((rows >= 0) && (rows != d->rowCount))
|
||||
{
|
||||
int previousRowCount = d->rowCount;
|
||||
d->rowCount = rows;
|
||||
d->rowHeight = 10.0 * rows;
|
||||
d->calculateAspectRatio();
|
||||
|
||||
for(int i=0; i < d->columnCount; ++i)
|
||||
{
|
||||
d->colorTable[i].resize(rows);
|
||||
if(rows > previousRowCount)
|
||||
{
|
||||
for(int j=previousRowCount; j < rows; ++j)
|
||||
{
|
||||
d->setColorAt(j, i, d->darkLedColor.rgb(), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Returns the number of columns in the LED matrix display.
|
||||
*
|
||||
* \return the number of columns in the LED matrix display
|
||||
*
|
||||
* \sa setColumnCount(), rowCount()
|
||||
*/
|
||||
int QLedMatrix::columnCount() const
|
||||
{
|
||||
Q_D(const QLedMatrix);
|
||||
return d->columnCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Sets the number of columns in the LED matrix display.
|
||||
*
|
||||
* This function will do nothing if the new number of columns is less than 0
|
||||
* or if it is equal to the current number of columns. If the new number of
|
||||
* columns is less than the current number of columns, the display will be
|
||||
* cropped to the new value. Otherwise, if the new number of columns is
|
||||
* greater than the current number of columns, the new LEDs will be
|
||||
* initialized using the dark LED color.
|
||||
*
|
||||
* \param columns the new number of columns
|
||||
*
|
||||
* \sa columnCount(), setRowCount(), darkLedColor()
|
||||
*/
|
||||
void QLedMatrix::setColumnCount(int columns)
|
||||
{
|
||||
Q_D(QLedMatrix);
|
||||
if((columns >= 0) && (columns != d->columnCount))
|
||||
{
|
||||
int previousColumnsCount = d->columnCount;
|
||||
d->columnCount = columns;
|
||||
d->columnWidth = 10.0 * columns;
|
||||
d->calculateAspectRatio();
|
||||
|
||||
d->colorTable.resize(columns);
|
||||
if(columns > previousColumnsCount)
|
||||
{
|
||||
for(int i=previousColumnsCount; i<columns; ++i)
|
||||
{
|
||||
d->colorTable[i].resize(d->rowCount);
|
||||
for(int j=0; j < d->rowCount; ++j)
|
||||
{
|
||||
d->setColorAt(j, i, d->darkLedColor.rgb(), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* \internal
|
||||
* Reimplemented from QWidget::sizeHint()
|
||||
*/
|
||||
QSize QLedMatrix::sizeHint() const
|
||||
{
|
||||
Q_D(const QLedMatrix);
|
||||
if((d->rowCount > 0) && (d->columnCount > 0))
|
||||
{
|
||||
const QSizeF s(d->columnWidth * d->sizeFactor, d->rowHeight * d->sizeFactor);
|
||||
return s.toSize();
|
||||
}
|
||||
else
|
||||
{
|
||||
qWarning("QLedMatrix::sizeHint: no rows or columns to display, defaulting size to (10,10)");
|
||||
return QSize(10, 10);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* \internal
|
||||
* Reimplemented from QWidget::paintEvent()
|
||||
*/
|
||||
void QLedMatrix::paintEvent(QPaintEvent* /*event*/)
|
||||
{
|
||||
Q_D(QLedMatrix);
|
||||
QPainter painter(this);
|
||||
painter.setPen(Qt::NoPen);
|
||||
painter.setRenderHint(QPainter::Antialiasing);
|
||||
|
||||
if(d->backgroundMode == Qt::OpaqueMode)
|
||||
{
|
||||
painter.setBrush(d->backgroundBrush);
|
||||
painter.drawRect(0, 0, d->columnWidth, d->rowHeight);
|
||||
}
|
||||
|
||||
if((d->rowHeight > 0.0) && (d->columnWidth > 0.0))
|
||||
{
|
||||
const qreal w = width();
|
||||
const qreal h = height();
|
||||
|
||||
painter.translate(w / 2.0, h / 2.0);
|
||||
|
||||
qreal sizeFactorHeight = h / d->rowHeight;
|
||||
qreal sizeFactorWidth = w / d->columnWidth;
|
||||
d->sizeFactor = (sizeFactorHeight < sizeFactorWidth ? sizeFactorHeight : sizeFactorWidth);
|
||||
|
||||
painter.scale(d->sizeFactor, d->sizeFactor);
|
||||
painter.translate(1.0 - (d->columnWidth/2), 1.0 - (d->rowHeight/2));
|
||||
|
||||
adjustSize();
|
||||
d->drawLEDs(painter);
|
||||
}
|
||||
}
|
||||
|
||||
// Todo: Matrizen sollen zusammen bleiben und dafür mitscalen
|
||||
Loaded 100 of 18662 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user