Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
+57
@@ -0,0 +1,57 @@
|
||||
#
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
#
|
||||
#
|
||||
# --- Library HlaCommon -------------------------------------------------
|
||||
#
|
||||
|
||||
SET(SRCS_exe
|
||||
logger.cpp
|
||||
logger.h
|
||||
player_callback.cpp
|
||||
player_callback.h
|
||||
settings.cpp
|
||||
settings.h
|
||||
identifierstruct.cpp
|
||||
identifierstruct.h
|
||||
typestruct.cpp
|
||||
typestruct.h
|
||||
participantposition.cpp
|
||||
participantposition.h
|
||||
participantinformation.cpp
|
||||
participantinformation.h
|
||||
)
|
||||
# Due to debug output for EntityTypeStruct
|
||||
SET_SOURCE_FILES_PROPERTIES(ngs_connector.cpp PROPERTIES SKIP_UNITY_BUILD_INCLUSION TRUE)
|
||||
|
||||
NGL_ADD_LIBRARY2(HLA HlaCommon SHARED ${SRCS_exe})
|
||||
|
||||
NGL_TARGET_INCLUDE_DIRECTORIES(HlaCommon
|
||||
PUBLIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../
|
||||
)
|
||||
|
||||
NGL_TARGET_LINK_LIBRARIES(HlaCommon
|
||||
LtsCoordTrans # ParticipantPosition
|
||||
NGLLogger
|
||||
nglsettings
|
||||
Qt5::Core
|
||||
svcPpmClient # ParticipantInformation
|
||||
svcPpmCommon
|
||||
ngltools # NGL::findProjectConfigFiles
|
||||
NGS::NGS
|
||||
ddsconnector
|
||||
# RTI::nddsc
|
||||
# RTI::nddscpp2
|
||||
)
|
||||
|
||||
#NGL_INSTALL(AAR SV FILES
|
||||
# log4cxx_hla.props
|
||||
# swconf.cfg
|
||||
# DESTINATION bin)
|
||||
#NGL_INSTALL(AAR SV FILES
|
||||
# RPRFOM20d17E_guez.xml
|
||||
# DESTINATION bin RENAME RPRFOM20d17E.xml)
|
||||
#NGL_ADD_TARGET_LINK(HlaCommon pHLA)
|
||||
@@ -0,0 +1,89 @@
|
||||
/**
|
||||
* Helper Class for handling Entity IdentifierStructs
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Malte Diers, NLE, 2019-07-11
|
||||
*/
|
||||
|
||||
#include "identifierstruct.h"
|
||||
#include "settings.h"
|
||||
#include <EntityIdentifierStruct.h>
|
||||
|
||||
namespace HighLevelArchitecture
|
||||
{
|
||||
|
||||
quint16 IdentifierStruct::s_nextId = 1;
|
||||
quint16 IdentifierStruct::s_ownSiteId = 1;
|
||||
|
||||
IdentifierStruct::IdentifierStruct(const rpr2::EntityIdentifierStruct &eis)
|
||||
: m_siteId(eis.FederateIdentifier.SiteID)
|
||||
{
|
||||
setSiteId(eis.FederateIdentifier.SiteID);
|
||||
setApplicationId(eis.FederateIdentifier.ApplicationID);
|
||||
setEntityNumber(eis.EntityNumber);
|
||||
}
|
||||
|
||||
rpr2::EntityIdentifierStruct IdentifierStruct::toEIS() const
|
||||
{
|
||||
rpr2::EntityIdentifierStruct eis;
|
||||
eis.FederateIdentifier.SiteID = siteId();
|
||||
eis.FederateIdentifier.ApplicationID = applicationId();
|
||||
eis.EntityNumber = entityNumber();
|
||||
return eis;
|
||||
}
|
||||
|
||||
void IdentifierStruct::makeOwn()
|
||||
{
|
||||
setSiteId(ownSiteId());
|
||||
setApplicationId(ownApplicationId());
|
||||
}
|
||||
|
||||
QString IdentifierStruct::toString() const
|
||||
{
|
||||
return QStringLiteral("[Site %1 | Application: %2 | Entity %3]")
|
||||
.arg(siteId())
|
||||
.arg(applicationId())
|
||||
.arg(entityNumber());
|
||||
}
|
||||
|
||||
qint64 IdentifierStruct::toInt64() const
|
||||
{
|
||||
quint64 res = 0;
|
||||
res += siteId();
|
||||
res <<= 16;
|
||||
res += applicationId();
|
||||
res <<= 16;
|
||||
res += entityNumber();
|
||||
return static_cast<qint64>(res);
|
||||
}
|
||||
|
||||
IdentifierStruct IdentifierStruct::fromInt64(qint64 value)
|
||||
{
|
||||
const quint64 uvalue = static_cast<quint64>(value);
|
||||
IdentifierStruct is;
|
||||
if ((uvalue >> 32) == 0)
|
||||
is.setSiteId(ownSiteId());
|
||||
else
|
||||
is.setSiteId((uvalue >> 32) & 0xffffU);
|
||||
|
||||
if (((uvalue >> 16) & 0xffffU) == 0)
|
||||
is.setApplicationId(ownApplicationId());
|
||||
else
|
||||
is.setApplicationId((uvalue >> 16 & 0xffffU));
|
||||
|
||||
is.setEntityNumber(uvalue & 0xffffU);
|
||||
return is;
|
||||
}
|
||||
|
||||
quint16 IdentifierStruct::ownSiteId()
|
||||
{
|
||||
return s_ownSiteId;
|
||||
}
|
||||
|
||||
quint16 IdentifierStruct::ownApplicationId()
|
||||
{
|
||||
static const int s_applicationId = Settings::applicationId();
|
||||
return s_applicationId;
|
||||
}
|
||||
} // namespace
|
||||
@@ -0,0 +1,69 @@
|
||||
/**
|
||||
* Helper Class for handling Entity IdentifierStructs
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Malte Diers, NLE, 2019-07-11
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QString>
|
||||
#include <Common/hlacommon_export.h>
|
||||
|
||||
namespace rpr2
|
||||
{
|
||||
class EntityIdentifierStruct;
|
||||
}
|
||||
|
||||
namespace HighLevelArchitecture
|
||||
{
|
||||
|
||||
class HLACOMMON_EXPORT IdentifierStruct
|
||||
{
|
||||
public:
|
||||
IdentifierStruct() = default;
|
||||
explicit IdentifierStruct(quint16 equipmentNo)
|
||||
: m_siteId(ownSiteId())
|
||||
, m_applicationId(ownApplicationId())
|
||||
, m_entityNumber(equipmentNo)
|
||||
{}
|
||||
|
||||
explicit IdentifierStruct(const rpr2::EntityIdentifierStruct &eis);
|
||||
|
||||
static IdentifierStruct fromInt64(qint64 value);
|
||||
|
||||
quint16 siteId() const { return m_siteId; }
|
||||
void setSiteId(quint16 siteId) { m_siteId = siteId; }
|
||||
|
||||
quint16 applicationId() const { return m_applicationId; }
|
||||
void setApplicationId(quint16 applicationId) { m_applicationId = applicationId; }
|
||||
|
||||
quint16 entityNumber() const { return m_entityNumber; }
|
||||
void setEntityNumber(quint16 entityNumber) { m_entityNumber = entityNumber; }
|
||||
|
||||
static quint16 ownSiteId();
|
||||
static void setOwnSiteId(quint16 siteId) { s_ownSiteId = siteId; }
|
||||
|
||||
rpr2::EntityIdentifierStruct toEIS() const;
|
||||
QString toString() const;
|
||||
qint64 toInt64() const;
|
||||
|
||||
bool isOwnElement() const { return siteId() == ownSiteId() && applicationId() == ownApplicationId(); }
|
||||
void makeOwn();
|
||||
|
||||
bool isNull() const { return (m_siteId == 0 && m_applicationId == 0 && m_entityNumber == 0); }
|
||||
|
||||
static quint16 getNextId() { return s_nextId++; }
|
||||
|
||||
private:
|
||||
quint16 m_siteId = 0;
|
||||
quint16 m_applicationId = 0;
|
||||
quint16 m_entityNumber = 0;
|
||||
|
||||
static quint16 ownApplicationId();
|
||||
static quint16 s_nextId;
|
||||
static quint16 s_ownSiteId;
|
||||
};
|
||||
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Logging for HighLevelArchitecture
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Christian Ehrlicher, SLSE, 2017-04-07
|
||||
*/
|
||||
|
||||
#include "logger.h"
|
||||
|
||||
#include <NGLLogger/NGLLoggerBootstrap.h>
|
||||
|
||||
namespace HighLevelArchitecture
|
||||
{
|
||||
|
||||
LOGGER_T getLogger(const char *name)
|
||||
{
|
||||
static const char ns[] = "HLA.";
|
||||
std::string loggerName;
|
||||
const size_t len = strlen(name);
|
||||
loggerName.reserve(sizeof(ns) + len);
|
||||
loggerName.append(ns, sizeof(ns) - 1);
|
||||
loggerName.append(name, len);
|
||||
|
||||
try
|
||||
{
|
||||
return NGL::NGLLoggerBootstrap::getNGLRootLogger().
|
||||
getNGLLogger(loggerName);
|
||||
}
|
||||
catch (const std::exception &ex)
|
||||
{
|
||||
fprintf(stderr, "Error retrieving logger: %s", ex.what());
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace HighLevelArchitecture
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Logging for HighLevelArchitecture
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Christian Ehrlicher, SLSE, 2017-04-07
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Common/hlacommon_export.h>
|
||||
#include <NGLLogger/INGLLogger.h>
|
||||
|
||||
namespace HighLevelArchitecture
|
||||
{
|
||||
using LOGGER_T = NGL::INGLLogger &;
|
||||
|
||||
HLACOMMON_EXPORT LOGGER_T getLogger(const char *name);
|
||||
inline LOGGER_T getLogger(const QString &loggerName)
|
||||
{
|
||||
return getLogger(loggerName.toUtf8().constData());
|
||||
}
|
||||
} // namespace HighLevelArchitecture
|
||||
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* Helper Class for handling Participant Information
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Malte Diers, NLE, 2019-07-11
|
||||
*/
|
||||
|
||||
#include "participantinformation.h"
|
||||
#include <ParticipantManagement/ppm.hpp>
|
||||
|
||||
namespace HighLevelArchitecture {
|
||||
|
||||
ParticipantInformation::ParticipantInformation(const ParticipantManagement::Participant &participant,
|
||||
const TypeStruct &_typestruct,
|
||||
const ParticipantPosition &_position)
|
||||
: participantId(participant.id())
|
||||
, equipmentNo(participant.equipmentNumber().is_set() ? participant.equipmentNumber().get() : 0)
|
||||
, partyId(participant.partyId())
|
||||
, parentId(participant.superiorId())
|
||||
, typeStruct(_typestruct)
|
||||
, designator(QString::fromStdString(participant.designator()))
|
||||
, position(_position)
|
||||
{}
|
||||
|
||||
} // Namespace HLA
|
||||
@@ -0,0 +1,37 @@
|
||||
/**
|
||||
* Helper Class for handling Participant Information
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Malte Diers, NLE, 2019-07-11
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "participantposition.h"
|
||||
#include "typestruct.h"
|
||||
|
||||
#include <Common/hlacommon_export.h>
|
||||
|
||||
namespace ParticipantManagement
|
||||
{
|
||||
class Participant;
|
||||
}
|
||||
|
||||
namespace HighLevelArchitecture
|
||||
{
|
||||
|
||||
struct HLACOMMON_EXPORT ParticipantInformation
|
||||
{
|
||||
int participantId = 0;
|
||||
int equipmentNo = 0;
|
||||
int partyId = 0;
|
||||
int parentId = 0;
|
||||
HighLevelArchitecture::TypeStruct typeStruct;
|
||||
QString designator;
|
||||
HighLevelArchitecture::ParticipantPosition position;
|
||||
|
||||
ParticipantInformation(const ParticipantManagement::Participant &participant, const TypeStruct &_typestruct, const ParticipantPosition &_position);
|
||||
};
|
||||
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
/**
|
||||
* Helper Class for handling (Participant) Positions
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Malte Diers, NLE, 2019-07-11
|
||||
*/
|
||||
|
||||
#include "participantposition.h"
|
||||
#include <LtsCoordTrans/lts_coord_trans.h>
|
||||
|
||||
namespace HighLevelArchitecture
|
||||
{
|
||||
|
||||
//
|
||||
// ParticipantPosition
|
||||
//
|
||||
rpr2::WorldLocationStruct ParticipantPosition::toWorldLocation() const
|
||||
{
|
||||
rpr2::WorldLocationStruct wl;
|
||||
|
||||
LtsCoordTrans::lonLatAltToGeocentric(lon, lat, -z, wl.X, wl.Y, wl.Z);
|
||||
|
||||
return wl;
|
||||
}
|
||||
|
||||
QString ParticipantPosition::toString(bool mgrs) const
|
||||
{
|
||||
if (!mgrs)
|
||||
return QStringLiteral("lon: %1, lat: %2, z: %3").arg(lon).arg(lat).arg(z);
|
||||
|
||||
const LtsCoordTrans::UtmCoordinate c1(LtsCoordTrans::UtmCoordinate::fromGeographic(lon, lat));
|
||||
return QStringLiteral("MGRS: %1, Z: %2").arg(c1.mgrs()).arg(z);
|
||||
}
|
||||
|
||||
bool ParticipantPosition::hasMoved(const ParticipantPosition &other) const
|
||||
{
|
||||
const LtsCoordTrans::UtmCoordinate c1(LtsCoordTrans::UtmCoordinate::fromGeographic(lon, lat));
|
||||
const LtsCoordTrans::UtmCoordinate c2(LtsCoordTrans::UtmCoordinate::fromGeographic(other.lon, other.lat));
|
||||
|
||||
if (c1.zone != c2.zone)
|
||||
return true;
|
||||
if (std::abs(c1.x - c2.x) > 1)
|
||||
return true;
|
||||
if (std::abs(c1.y - c2.y) > 1)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ParticipantPosition::isNull() const
|
||||
{
|
||||
return (qFuzzyIsNull(lon) && qFuzzyIsNull(lat));
|
||||
}
|
||||
|
||||
ParticipantPosition::ParticipantPosition(const rpr2::WorldLocationStruct &wl)
|
||||
{
|
||||
LtsCoordTrans::geocentric2LonLatAlt(wl.X, wl.Y, wl.Z, lon, lat, z);
|
||||
z *= -1;
|
||||
}
|
||||
|
||||
} // Namespace
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
/**
|
||||
* Helper Class for handling (Participant) Positions
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Malte Diers, NLE, 2019-07-11
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <WorldLocationStruct.h>
|
||||
#include <QString>
|
||||
#include <QPointF>
|
||||
#include <Core/core.hpp>
|
||||
#include <Common/hlacommon_export.h>
|
||||
|
||||
namespace HighLevelArchitecture
|
||||
{
|
||||
|
||||
struct HLACOMMON_EXPORT ParticipantPosition
|
||||
{
|
||||
// lon/lat
|
||||
double lon = 0;
|
||||
double lat = 0;
|
||||
double z = 0;
|
||||
qint64 msec = 0;
|
||||
|
||||
|
||||
ParticipantPosition() = default;
|
||||
explicit inline ParticipantPosition(const QPointF &data)
|
||||
: lon(data.x()), lat(data.y()) {}
|
||||
explicit ParticipantPosition(const rpr2::WorldLocationStruct &wl);
|
||||
explicit inline ParticipantPosition(const Core::GeoPosition &data, qint64 msecsSinceEpoch = 0)
|
||||
: lon(data.lon()), lat(data.lat()), z(data.z()), msec(msecsSinceEpoch) {}
|
||||
explicit inline ParticipantPosition(const Core::GeoPosition2D &data, qint64 msecsSinceEpoch = 0)
|
||||
: lon(data.lon()), lat(data.lat()), msec(msecsSinceEpoch) {}
|
||||
|
||||
bool hasMoved(const ParticipantPosition &other) const;
|
||||
bool isNull() const;
|
||||
rpr2::WorldLocationStruct toWorldLocation() const;
|
||||
QString toString(bool mgrs = true) const;
|
||||
inline Core::GeoPosition2D toGeoPosition2D() const { return Core::GeoPosition2D(lon, lat); }
|
||||
inline Core::GeoPosition toGeoPosition() const { return Core::GeoPosition(lon, lat, z); }
|
||||
inline QPointF toPoint() const { return QPointF(lon,lat); }
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Small callback to NullPlayerCallback to be able to recognize the first tick (which then triggers initialization)
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
#include "player_callback.h"
|
||||
|
||||
namespace HighLevelArchitecture
|
||||
{
|
||||
|
||||
void PlayerCallback::tick()
|
||||
{
|
||||
NullPlayerCallback::tick();
|
||||
|
||||
if (!m_bFirstTick)
|
||||
{
|
||||
m_bFirstTick = true;
|
||||
emit firstTick();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace HighLevelArchitecture
|
||||
@@ -0,0 +1,33 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Small callback to NullPlayerCallback to be able to recognize the first tick (which then triggers initialization)
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
#include <NullPlayerCallback.h>
|
||||
|
||||
#include <Common/hlacommon_export.h>
|
||||
/*
|
||||
* Simple callback for the player instance
|
||||
*/
|
||||
namespace HighLevelArchitecture
|
||||
{
|
||||
class HLACOMMON_EXPORT PlayerCallback final : public QObject, public ngs::NullPlayerCallback
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
PlayerCallback() = default;
|
||||
|
||||
void tick() override;
|
||||
Q_SIGNALS:
|
||||
void firstTick();
|
||||
protected:
|
||||
bool m_bFirstTick = false;
|
||||
};
|
||||
|
||||
} // namespace HighLevelArchitecture
|
||||
+145
@@ -0,0 +1,145 @@
|
||||
/**
|
||||
* Settings for TetraRadio
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Christian Ehrlicher, SLSE, 2017-04-07
|
||||
*/
|
||||
|
||||
#include "settings.h"
|
||||
|
||||
#include <QtCore/QSettings>
|
||||
#include <nglsettings/nglsettings_settings.h>
|
||||
#include <ngltools/ngltools_filesystem.h>
|
||||
|
||||
namespace HighLevelArchitecture
|
||||
{
|
||||
class NGLSettingsClass : public NGL::Settings
|
||||
{
|
||||
public:
|
||||
NGLSettingsClass()
|
||||
: NGL::Settings(s_iniFile.isEmpty() ? NGL::findProjectConfigFile() : s_iniFile)
|
||||
{}
|
||||
static void setIniFile(const QString &fn)
|
||||
{
|
||||
s_iniFile = fn;
|
||||
}
|
||||
static QString s_iniFile;
|
||||
};
|
||||
QString NGLSettingsClass::s_iniFile;
|
||||
Q_GLOBAL_STATIC(NGLSettingsClass, s)
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
NGL::Settings *Settings::settings()
|
||||
{
|
||||
return s();
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void Settings::setIniFile(const QString &ini)
|
||||
{
|
||||
NGLSettingsClass::setIniFile(ini);
|
||||
}
|
||||
|
||||
QString Settings::federationName()
|
||||
{
|
||||
return s()->settings()->value(QLatin1String("hla/FederationName"), QLatin1String("22")).toString();
|
||||
}
|
||||
|
||||
ngs::IObserver::ProtocolType Settings::hlaProtocol()
|
||||
{
|
||||
QString protocol = s()->settings()->value(QLatin1String("hla/Protocol"), QLatin1String("HLA")).toString().toUpper();
|
||||
if (protocol == QLatin1String("HLA"))
|
||||
return ngs::IObserver::HLA;
|
||||
if (protocol == QLatin1String("DIS"))
|
||||
return ngs::IObserver::DIS;
|
||||
// default CORBANOTIFY
|
||||
return ngs::IObserver::CORBANOTIFY;
|
||||
}
|
||||
|
||||
quint16 Settings::siteId()
|
||||
{
|
||||
return s()->settings()->value(QLatin1String("hla/SiteId"), 201).toInt();
|
||||
}
|
||||
|
||||
quint16 Settings::applicationId()
|
||||
{
|
||||
return s()->settings()->value(QLatin1String("hla/ApplicationId"), 100).toInt();
|
||||
}
|
||||
|
||||
int Settings::guezHitGraceTimeMSecs()
|
||||
{
|
||||
return s()->settings()->value(QLatin1String("hla/guezHitGraceTimeMSecs"), 1000).toInt();
|
||||
}
|
||||
|
||||
QString Settings::fomIdentifier()
|
||||
{
|
||||
return s()->settings()->value(QLatin1String("hla/FomIdentifier"), QLatin1String("Saab")).toString();
|
||||
}
|
||||
|
||||
QString Settings::rtiIdentifier()
|
||||
{
|
||||
return s()->settings()->value(QLatin1String("hla/RtiIdentifier"), QLatin1String("MAK")).toString();
|
||||
}
|
||||
|
||||
QString Settings::swConfFileName()
|
||||
{
|
||||
return s()->settings()->value(QLatin1String("hla/SwConfFileName"), QLatin1String("swconf.cfg")).toString();
|
||||
}
|
||||
|
||||
quint16 Settings::webSocketListenPort()
|
||||
{
|
||||
// TODO
|
||||
return s()->settings()->value(QLatin1String("hla/webSocketListenPort"), 12347).toInt();
|
||||
}
|
||||
|
||||
quint16 Settings::hlaPlayerIdIDT()
|
||||
{
|
||||
return s()->settings()->value(QLatin1String("hla/PlayerIdIDT"), 32001).toUInt();
|
||||
}
|
||||
|
||||
quint16 Settings::hlaPlayerIdExcon()
|
||||
{
|
||||
return s()->settings()->value(QLatin1String("hla/PlayerIdExcon"), 32002).toUInt();
|
||||
}
|
||||
|
||||
QByteArray Settings::hlaLicenseServer()
|
||||
{
|
||||
QByteArray ba = s()->settings()->value(QLatin1String("hla/LicenseServer"), QLatin1String("@192.168.99.100")).toByteArray();
|
||||
if (!ba.contains('@'))
|
||||
ba.prepend('@');
|
||||
return ba;
|
||||
}
|
||||
|
||||
Settings::Orientation Settings::spatialStructOrientation()
|
||||
{
|
||||
Orientation orientation;
|
||||
orientation.phi = s()->settings()->value(QLatin1String("hla/SpatialStructOrientation/Phi" ), 3.138309f).toFloat();
|
||||
orientation.psi = s()->settings()->value(QLatin1String("hla/SpatialStructOrientation/Psi" ), 2.446645f).toFloat();
|
||||
orientation.theta = s()->settings()->value(QLatin1String("hla/SpatialStructOrientation/Theta"), -0.879588f).toFloat();
|
||||
|
||||
return orientation;
|
||||
}
|
||||
|
||||
|
||||
QVector<Settings::SocketData> Settings::socketDataList()
|
||||
{
|
||||
int size = s()->settings()->beginReadArray(QLatin1String("hla/SocketReaders"));
|
||||
QVector<SocketData> list;
|
||||
list.reserve(size);
|
||||
for (int i = 0; i < size; ++i)
|
||||
{
|
||||
SocketData sd;
|
||||
s()->settings()->setArrayIndex(i);
|
||||
sd.port = s()->settings()->value(QLatin1String("Port")).toInt();
|
||||
sd.hostname = s()->settings()->value(QLatin1String("Hostname")).toString();
|
||||
sd.hlaRequestIdentifier = s()->settings()->value(QLatin1String("HlaRequestIdentifier")).toInt();
|
||||
|
||||
list.append(sd);
|
||||
}
|
||||
s()->settings()->endArray();
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
} // namespace HighLevelArchitecture
|
||||
+72
@@ -0,0 +1,72 @@
|
||||
/**
|
||||
* Settings for TetraRadio
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Christian Ehrlicher, SLSE, 2017-04-07
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <QString>
|
||||
#include <IObserver.h>
|
||||
#include <Common/hlacommon_export.h>
|
||||
|
||||
namespace NGL
|
||||
{
|
||||
class Settings;
|
||||
}
|
||||
|
||||
namespace HighLevelArchitecture
|
||||
{
|
||||
|
||||
namespace Settings
|
||||
{
|
||||
|
||||
struct SocketData {
|
||||
int port;
|
||||
QString hostname;
|
||||
int hlaRequestIdentifier;
|
||||
};
|
||||
|
||||
struct Orientation
|
||||
{
|
||||
float phi = 0.;
|
||||
float psi = 0.;
|
||||
float theta = 0.;
|
||||
Orientation(float _phi, float _psi, float _theta): phi(_phi), psi(_psi), theta(_theta){}
|
||||
Orientation(){}
|
||||
};
|
||||
|
||||
|
||||
//!< The real NGL::Settings - object
|
||||
NGL::Settings *settings();
|
||||
|
||||
HLACOMMON_EXPORT void setIniFile(const QString &ini);
|
||||
|
||||
HLACOMMON_EXPORT QString federationName();
|
||||
HLACOMMON_EXPORT ngs::IObserver::ProtocolType hlaProtocol();
|
||||
|
||||
quint16 siteId();
|
||||
quint16 applicationId();
|
||||
HLACOMMON_EXPORT int guezHitGraceTimeMSecs();
|
||||
|
||||
HLACOMMON_EXPORT QString fomIdentifier();
|
||||
HLACOMMON_EXPORT QString rtiIdentifier();
|
||||
HLACOMMON_EXPORT QString swConfFileName();
|
||||
|
||||
HLACOMMON_EXPORT QByteArray hlaLicenseServer();
|
||||
|
||||
HLACOMMON_EXPORT Orientation spatialStructOrientation();
|
||||
|
||||
|
||||
HLACOMMON_EXPORT quint16 webSocketListenPort();
|
||||
|
||||
HLACOMMON_EXPORT quint16 hlaPlayerIdIDT();
|
||||
HLACOMMON_EXPORT quint16 hlaPlayerIdExcon();
|
||||
|
||||
HLACOMMON_EXPORT QVector<SocketData> socketDataList();
|
||||
|
||||
|
||||
}
|
||||
|
||||
} // namespace HighLevelArchitecture
|
||||
+209
@@ -0,0 +1,209 @@
|
||||
/**
|
||||
* Helper Class for handling (Entity) Type Structs
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Malte Diers, NLE, 2019-07-11
|
||||
*/
|
||||
|
||||
#include "typestruct.h"
|
||||
#include "settings.h"
|
||||
#include <EntityTypeStruct.h>
|
||||
#include <QStringList>
|
||||
#include <QVector>
|
||||
|
||||
namespace HighLevelArchitecture
|
||||
{
|
||||
|
||||
TypeStruct::TypeStruct(const rpr2::EntityTypeStruct &eis)
|
||||
{
|
||||
setEntityKind(eis.EntityKind);
|
||||
setDomain(eis.Domain);
|
||||
setCountryCode(eis.CountryCode);
|
||||
setCategory(eis.Category);
|
||||
setSubcategory(eis.Subcategory);
|
||||
setSpecific(eis.Specific);
|
||||
setExtra(eis.Extra);
|
||||
}
|
||||
|
||||
TypeStruct TypeStruct::fromString(const QString &string)
|
||||
{
|
||||
const QVector<QStringRef> sl = string.splitRef(QLatin1Char('.'));
|
||||
|
||||
TypeStruct ts;
|
||||
bool bOk;
|
||||
|
||||
const int size = sl.size();
|
||||
|
||||
if (size <= 0)
|
||||
return ts;
|
||||
|
||||
int val = sl[0].toInt(&bOk);
|
||||
if (!bOk || val > 255 || val < 0)
|
||||
{
|
||||
Q_ASSERT(false);
|
||||
return TypeStruct();
|
||||
}
|
||||
ts.setEntityKind(val);
|
||||
|
||||
if (size <= 1)
|
||||
return ts;
|
||||
|
||||
val = sl[1].toInt(&bOk);
|
||||
if (!bOk || val > 255 || val < 0)
|
||||
{
|
||||
Q_ASSERT(false);
|
||||
return TypeStruct();
|
||||
}
|
||||
ts.setDomain(val);
|
||||
|
||||
if (size <= 2)
|
||||
return ts;
|
||||
|
||||
val = sl[2].toUShort(&bOk);
|
||||
if (!bOk)
|
||||
{
|
||||
Q_ASSERT(false);
|
||||
return TypeStruct();
|
||||
}
|
||||
ts.setCountryCode(val);
|
||||
|
||||
if (size <= 3)
|
||||
return ts;
|
||||
|
||||
val = sl[3].toInt(&bOk);
|
||||
if (!bOk || val > 255 || val < 0)
|
||||
{
|
||||
Q_ASSERT(false);
|
||||
return TypeStruct();
|
||||
}
|
||||
ts.setCategory(val);
|
||||
|
||||
if (size <= 4)
|
||||
return ts;
|
||||
|
||||
val = sl[4].toInt(&bOk);
|
||||
if (!bOk || val > 255 || val < 0)
|
||||
{
|
||||
Q_ASSERT(false);
|
||||
return TypeStruct();
|
||||
}
|
||||
ts.setSubcategory(val);
|
||||
|
||||
if (size <= 5)
|
||||
return ts;
|
||||
|
||||
val = sl[5].toInt(&bOk);
|
||||
if (!bOk || val > 255 || val < 0)
|
||||
{
|
||||
Q_ASSERT(false);
|
||||
return TypeStruct();
|
||||
}
|
||||
ts.setSpecific(val);
|
||||
|
||||
if (size <= 6)
|
||||
return ts;
|
||||
|
||||
val = sl[6].toInt(&bOk);
|
||||
if (!bOk || val > 255 || val < 0)
|
||||
{
|
||||
Q_ASSERT(false);
|
||||
return TypeStruct();
|
||||
}
|
||||
ts.setExtra(val);
|
||||
|
||||
return ts;
|
||||
}
|
||||
|
||||
// Todo: Store all DisEntities? To have it for "operator==" or "isAbout(OTHER)" ?!?
|
||||
TypeStruct TypeStruct::fromDisString(const QString &disString)
|
||||
{
|
||||
QString str = disString.split(QLatin1Char('.')).first(); // Sometimes, there are 2 or more DIS Entities, separated by "."
|
||||
str.prepend(QString(21 - str.size(), QLatin1Char('0')));
|
||||
|
||||
// ETS = 3001222001246001000 -> 003001222001246001000 -> 003 001 222 001 246 001 000 -> 3.1.222.1.246.1.0
|
||||
|
||||
TypeStruct ts;
|
||||
int etsInteger[7];
|
||||
bool bOk;
|
||||
for (int i = 0; i < 7; ++i)
|
||||
{
|
||||
etsInteger[i] = str.midRef(3 * i, 3).toInt(&bOk);
|
||||
if (!bOk)
|
||||
return ts;
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
ts.setEntityKind(etsInteger[i++]);
|
||||
ts.setDomain(etsInteger[i++]);
|
||||
ts.setCountryCode(etsInteger[i++]);
|
||||
ts.setCategory(etsInteger[i++]);
|
||||
ts.setSubcategory(etsInteger[i++]);
|
||||
ts.setSpecific(etsInteger[i++]);
|
||||
ts.setExtra(etsInteger[i++]);
|
||||
|
||||
return ts;
|
||||
}
|
||||
|
||||
TypeStruct TypeStruct::fromDisInt(qint64 value)
|
||||
{
|
||||
TypeStruct ts;
|
||||
|
||||
ts.setExtra(value % 1000);
|
||||
value /= 1000;
|
||||
ts.setSpecific(value % 1000);
|
||||
value /= 1000;
|
||||
ts.setSubcategory(value % 1000);
|
||||
value /= 1000;
|
||||
ts.setCategory(value % 1000);
|
||||
value /= 1000;
|
||||
ts.setCountryCode(value % 1000);
|
||||
value /= 1000;
|
||||
ts.setDomain(value % 1000);
|
||||
value /= 1000;
|
||||
ts.setEntityKind(value % 1000);
|
||||
return ts;
|
||||
}
|
||||
|
||||
TypeStruct TypeStruct::fromULong(quint64 value)
|
||||
{
|
||||
TypeStruct ts;
|
||||
ts.setEntityKind (( value & 0xFF00000000000000) >> 56);
|
||||
ts.setDomain (( value & 0x00FF000000000000) >> 48);
|
||||
ts.setCountryCode(( value & 0x0000FFFF00000000) >> 32);
|
||||
ts.setCategory (( value & 0x00000000FF000000) >> 24);
|
||||
ts.setSubcategory(( value & 0x0000000000FF0000) >> 16);
|
||||
ts.setSpecific (( value & 0x000000000000FF00) >> 8);
|
||||
ts.setExtra (( value & 0x00000000000000FF) >> 0);
|
||||
return ts;
|
||||
}
|
||||
|
||||
|
||||
rpr2::EntityTypeStruct TypeStruct::toETS() const
|
||||
{
|
||||
rpr2::EntityTypeStruct ets;
|
||||
ets.EntityKind = entityKind();
|
||||
ets.Domain = domain();
|
||||
ets.CountryCode = countryCode();
|
||||
ets.Category = category();
|
||||
ets.Subcategory = subcategory();
|
||||
ets.Specific = specific();
|
||||
ets.Extra = extra();
|
||||
|
||||
return ets;
|
||||
}
|
||||
|
||||
QString TypeStruct::toString() const
|
||||
{
|
||||
const QStringList sl({QString::number(entityKind()),
|
||||
QString::number(domain()),
|
||||
QString::number(countryCode()),
|
||||
QString::number(category()),
|
||||
QString::number(subcategory()),
|
||||
QString::number(specific()),
|
||||
QString::number(extra())});
|
||||
|
||||
return sl.join(QLatin1Char('.'));
|
||||
}
|
||||
|
||||
} // Namespace
|
||||
+66
@@ -0,0 +1,66 @@
|
||||
/**
|
||||
* Helper Class for handling (Entity) Type Structs
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Malte Diers, NLE, 2019-07-11
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QString>
|
||||
#include <Common/hlacommon_export.h>
|
||||
|
||||
namespace rpr2
|
||||
{
|
||||
class EntityTypeStruct;
|
||||
}
|
||||
|
||||
namespace HighLevelArchitecture
|
||||
{
|
||||
|
||||
class HLACOMMON_EXPORT TypeStruct
|
||||
{
|
||||
public:
|
||||
TypeStruct() = default;
|
||||
explicit TypeStruct(const rpr2::EntityTypeStruct &eis);
|
||||
static TypeStruct fromString(const QString &string); // 1.2.3.4.5.6.7
|
||||
static TypeStruct fromDisString(const QString &disString); // 001002003004005006007
|
||||
static TypeStruct fromDisInt(qint64 value); // 1002003004005006007
|
||||
static TypeStruct fromULong(quint64 value); // single data squeezed into ULong
|
||||
|
||||
rpr2::EntityTypeStruct toETS() const;
|
||||
QString toString() const;
|
||||
|
||||
quint8 entityKind() const { return m_entityKind; }
|
||||
void setEntityKind(quint8 entityKind) { m_entityKind = entityKind; }
|
||||
|
||||
quint8 domain() const { return m_domain; }
|
||||
void setDomain(quint8 domain) { m_domain = domain; }
|
||||
|
||||
quint16 countryCode() const { return m_countryCode; }
|
||||
void setCountryCode(quint16 countryCode) { m_countryCode = countryCode; }
|
||||
|
||||
quint8 category() const { return m_category; }
|
||||
void setCategory(quint8 category) { m_category = category; }
|
||||
|
||||
quint8 subcategory() const { return m_subcategory; }
|
||||
void setSubcategory(quint8 subcategory) { m_subcategory = subcategory; }
|
||||
|
||||
quint8 specific() const { return m_specific; }
|
||||
void setSpecific(quint8 specific) { m_specific = specific; }
|
||||
|
||||
quint8 extra() const { return m_extra; }
|
||||
void setExtra(quint8 extra) { m_extra = extra; }
|
||||
|
||||
private:
|
||||
quint8 m_entityKind = 0;
|
||||
quint8 m_domain = 0;
|
||||
quint16 m_countryCode = 0;
|
||||
quint8 m_category = 0;
|
||||
quint8 m_subcategory = 0;
|
||||
quint8 m_specific = 0;
|
||||
quint8 m_extra = 0;
|
||||
};
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user