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>
119 lines
3.2 KiB
C++
119 lines
3.2 KiB
C++
/**
|
|
* SystemCaller to set Time and Date
|
|
* $Id$
|
|
* $HeadURL$
|
|
* $Author$
|
|
* Created by Patric Karwat, NLE, 07-03-2019
|
|
*/
|
|
#include "system_caller.h"
|
|
#include <QTimer>
|
|
#include <QDateTime>
|
|
|
|
namespace DateTimeSyncer
|
|
{
|
|
|
|
SystemCaller::SystemCaller(QObject *parent)
|
|
: QObject(parent)
|
|
, m_tcpServer(new TcpServer(this))
|
|
, m_sockets(QVector<QTcpSocket*>())
|
|
, m_logger(getLogger("SystemCaller"))
|
|
{}
|
|
|
|
SystemCaller::~SystemCaller()
|
|
{
|
|
for (auto socket : qAsConst(m_sockets))
|
|
{
|
|
socket->close();
|
|
socket->deleteLater();
|
|
}
|
|
|
|
m_tcpServer->close();
|
|
|
|
delete m_tcpServer;
|
|
}
|
|
|
|
bool SystemCaller::init(int tcpPort)
|
|
{
|
|
connect(m_tcpServer, &TcpServer::newConnection, this, &SystemCaller::newConnection);
|
|
bool result = m_tcpServer->listen(QHostAddress::Any, tcpPort);
|
|
quint16 actualPort = m_tcpServer->serverPort();
|
|
|
|
NOTICE_LOG(m_logger) << "Start listen to port " << actualPort << " result: " << result;
|
|
|
|
if (!result)
|
|
return false;
|
|
|
|
return true;
|
|
}
|
|
|
|
void SystemCaller::newConnection()
|
|
{
|
|
while (m_tcpServer->hasPendingConnections())
|
|
{
|
|
// store socket and connect to signals
|
|
QTcpSocket *socket = m_tcpServer->nextPendingConnection();
|
|
connect(socket, &QTcpSocket::readyRead, this, &SystemCaller::readTcp);
|
|
connect(socket, &QTcpSocket::disconnected, this, &SystemCaller::tcpDisconnected);
|
|
m_sockets.append(socket);
|
|
|
|
NOTICE_LOG(m_logger) << "New TCP-connection on port " << m_tcpServer->serverPort();
|
|
}
|
|
}
|
|
|
|
void SystemCaller::readTcp()
|
|
{
|
|
QTcpSocket *socket = qobject_cast<QTcpSocket *>(sender());
|
|
if (!socket)
|
|
return;
|
|
|
|
QByteArray ba = socket->readAll();
|
|
qint64 time = ba.toLongLong();
|
|
DEBUG_LOG(m_logger) << "New Time " << time;
|
|
|
|
QDateTime newDateTime = QDateTime::fromSecsSinceEpoch(time);
|
|
|
|
if (newDateTime.isValid())
|
|
{
|
|
#ifndef WIN32
|
|
//linux
|
|
QString string = newDateTime.toString(QStringLiteral("\"yyyy-MM-dd hh:mm:ss\""));
|
|
QString dateTimeString(QStringLiteral("date --set="));
|
|
dateTimeString.append(string);
|
|
int systemDateTimeStatus = system(dateTimeString.toStdString().c_str());
|
|
if (systemDateTimeStatus == -1)
|
|
WARNING_LOG(m_logger) << "Failed to change date time";
|
|
int systemHwClockStatus = system("/sbin/hwclock -w");
|
|
if (systemHwClockStatus == -1)
|
|
WARNING_LOG(m_logger) << "Failed to sync hardware clock";
|
|
#else
|
|
QString dateString = newDateTime.toString(QStringLiteral("dd-MM-yy"));
|
|
QString timeString = newDateTime.toString(QStringLiteral("hh:mm:ss"));
|
|
QString systemDateString(QStringLiteral("date "));
|
|
QString systemTimeString(QStringLiteral("time "));
|
|
systemDateString.append(dateString);
|
|
systemTimeString.append(timeString);
|
|
int systemDateStatus = system(systemDateString.toLocal8Bit().data());
|
|
if (systemDateStatus == -1)
|
|
WARNING_LOG(m_logger) << "Failed to change date";
|
|
int systemTimeStatus = system(systemTimeString.toLocal8Bit().data());
|
|
if (systemTimeStatus == -1)
|
|
WARNING_LOG(m_logger) << "Failed to change date";
|
|
#endif
|
|
|
|
}
|
|
}
|
|
|
|
void SystemCaller::tcpDisconnected()
|
|
{
|
|
QTcpSocket *socket = qobject_cast<QTcpSocket *>(sender());
|
|
m_sockets.removeOne(socket);
|
|
}
|
|
|
|
void SystemCaller::handleTcpError(QAbstractSocket::SocketError error)
|
|
{
|
|
Q_UNUSED(error)
|
|
//TODO: TCP-Socket Error handling
|
|
}
|
|
|
|
} //namespace DateTimeSyncer
|