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>
83 lines
2.6 KiB
C++
83 lines
2.6 KiB
C++
/*
|
|
* @RDE_HEADER@
|
|
* Simulate players
|
|
* $Id$
|
|
* $HeadURL$
|
|
* $Author$
|
|
* Created by Hanna E. Rathje, SLTE, 2022-03-29
|
|
*/
|
|
|
|
#include "simulated_player.h"
|
|
#include "position_helper.h"
|
|
|
|
#include <WirelessLocationSystem/wls_sfm_message_converter.h>
|
|
#include <NGLLogger/NGLLoggerBootstrap.h>
|
|
#include <LtsUtils/LtsUtilsCore/sfm_bytemessage_converter.h>
|
|
#include <LtsCoordTrans/lts_coord_trans.h>
|
|
|
|
#include <QTimer>
|
|
|
|
#include "math.h"
|
|
|
|
namespace WlsRandomPositions
|
|
{
|
|
|
|
SimulatedPlayer::SimulatedPlayer(int equipNo, qint64 mac, int msecs, int jitter, double maxDistance, QObject *parent)
|
|
: QObject(parent)
|
|
, m_equipNo(equipNo)
|
|
, m_macAddress(toMacString(mac))
|
|
, m_msecs(msecs)
|
|
, m_jitter(jitter)
|
|
, m_maxDistance(maxDistance)
|
|
, m_pos({{},0.0})
|
|
, m_logger(NGL::NGLLoggerBootstrap::getNGLRootLogger().getNGLLogger(QString::fromLatin1("SimulatedPlayer.%1").arg(QString::number(m_equipNo)).toStdString()))
|
|
{
|
|
}
|
|
|
|
void SimulatedPlayer::start()
|
|
{
|
|
QString eqNoString = QString::number(m_equipNo);
|
|
QString initialTelegram = QString::fromLatin1("%1;%2;%3").arg(4).arg(m_macAddress).arg(eqNoString);
|
|
|
|
INFO_LOG(m_logger) << "initTelegram: " << initialTelegram;
|
|
|
|
WirelessLocationSystem::SfmMsgEquipmentId msg;
|
|
msg.setEquipmentNumber(m_equipNo);
|
|
QByteArray ba = WirelessLocationSystem::SfmMessageConverter::generateTxMessage(msg);
|
|
|
|
emit sendInitTelegram(m_macAddress, ba);
|
|
|
|
QTimer::singleShot(m_msecs + (((rand() % 200) - 100) / 100) * m_jitter, this, &SimulatedPlayer::onTimerTimeout);
|
|
}
|
|
|
|
void SimulatedPlayer::onTimerTimeout()
|
|
{
|
|
QPair<QPointF,double> pos;
|
|
if (qFuzzyIsNull(m_maxDistance) || m_pos.first.isNull())
|
|
pos = PositionHelper::randPos();
|
|
else
|
|
pos = PositionHelper::randPos(m_pos.first, m_maxDistance);
|
|
|
|
DEBUG_LOG(m_logger) << "posTelegram: x: " << pos.first.x() << ", y: " << pos.first.y() << ", z: " << pos.second;
|
|
DEBUG_LOG(m_logger) << "MGRS: " << LtsCoordTrans::UtmCoordinate::fromGeographic(pos.first).mgrs(5, true);
|
|
|
|
emit sendPositionTelegram(m_macAddress, pos.first, pos.second);
|
|
|
|
m_pos = pos;
|
|
QTimer::singleShot(m_msecs + (((rand() % 200) - 100) / 100) * m_jitter, this, &SimulatedPlayer::onTimerTimeout);
|
|
}
|
|
|
|
QString SimulatedPlayer::toMacString(qint64 mac)
|
|
{
|
|
QString macString = QString::number(mac, 16);
|
|
macString = macString.prepend(QString(12 - macString.length(), QLatin1Char('0')));
|
|
macString.insert(10, QLatin1Char(':'));
|
|
macString.insert( 8, QLatin1Char(':'));
|
|
macString.insert( 6, QLatin1Char(':'));
|
|
macString.insert( 4, QLatin1Char(':'));
|
|
macString.insert( 2, QLatin1Char(':'));
|
|
return macString;
|
|
}
|
|
|
|
} // Namespace WlsRandomPositions
|