Initial commit

This commit is contained in:
torsten committed 2026-08-13 18:33:10 +02:00
commit b7d90b9afe
16245 files changed
+3396666

No files matched your search

@@ -0,0 +1,38 @@
#
# @RDE_HEADER@
# $Id$
# $HeadURL$
# $Author$
#
SET(UnitTestSources
effect_cluster_module_test.cpp
effect_cluster_module_test.h
)
IF(BUILD_TESTING)
ADD_EXECUTABLE(aesModuleTestEffectCluster ${LinkedSources} ${UnitTestSources} )
TARGET_LINK_LIBRARIES(aesModuleTestEffectCluster
NGLLogger
nglcoreapplication
LtsCommandLineParser
LtsCoordinate
Qt5::Core
Qt5::Test
ddsconnector
svcAesCommon
svcAesClient
svcBldClient
svcExmClient
svcIsmClient
svcPdmClient
svcPpmClient
svcTabServer
)
# ADD_TEST(NAME aesModuleTestExplosionCluster COMMAND $<TARGET_FILE:aesUnitTestTneAlgorithmen>)
ENDIF()
#NGL_INSTALL(TESTING SV FILES EffectClusterModifyRequest_ESG.spl DESTINATION bin)
NGL_INSTALL(SV FILES EffectClusterModifyRequest_ESG.spl DESTINATION bin)
@@ -0,0 +1,631 @@
<!DOCTYPE Samples>
<Samples>
<Sample>
<TopicName>LTS_EffectClusterModifyRequest</TopicName>
<TypeName>AreaEffectSimulation::EffectClusterModifyRequest</TypeName>
<Pause>1000</Pause>
<DdsData topic="LTS_EffectClusterModifyRequest" type="AreaEffectSimulation::EffectClusterModifyRequest" count="17">
<id>8</id>
<name>eb511ab7d8414b88af248fd32ef03285</name>
<element>eb511ab7d8414b88af248fd32ef03285</element>
<effectStart/>
<effectDuration>0</effectDuration>
<effectSourceId>1</effectSourceId>
<area type="AreaEffectSimulation::Area" count="4">
<cornerBottomLeft type="Core::GeoPosition2D" count="2">
<lon>0.201951</lon>
<lat>0.915259</lat>
</cornerBottomLeft>
<width>50</width>
<height>50</height>
<rotation>0</rotation>
</area>
<explosionGeometry>4</explosionGeometry>
<tla>0</tla>
<effectors count="1">
<effectors.1>
<angleOfFall>0</angleOfFall>
<participantId>240</participantId>
<flightTime>39526.3</flightTime>
<peakHeight>2002</peakHeight>
<interval>0</interval>
<chargeStruct type="AreaEffectSimulation::ChargeStruct" count="3">
<chargeTypeId>367</chargeTypeId>
<igniterTypeId>1</igniterTypeId>
<igniterFunctionId>2</igniterFunctionId>
</chargeStruct>
<chargeAmount>2</chargeAmount>
<mhpScatterLenght>3.08314e-316</mhpScatterLenght>
<mhpScatterWidth>8.76302e-315</mhpScatterWidth>
<mhpScatterLengthDetonationHeight>9.69057e-316</mhpScatterLengthDetonationHeight>
<mhpScatterWidthDetonationHeight>8.76639e-315</mhpScatterWidthDetonationHeight>
<mhpRotation>-45.4373</mhpRotation>
<mhpPosition type="Core::GeoPosition" count="3">
<lon>0.201958</lon>
<lat>0.915263</lat>
<z>88</z>
</mhpPosition>
<trajectory count="95">
<trajectory.1>
<lon>0</lon>
<lat>0</lat>
<z>85</z>
<relativeTime>0</relativeTime>
</trajectory.1>
<trajectory.2>
<lon>41.6079</lon>
<lat>-39.6154</lat>
<z>168.375</z>
<relativeTime>0</relativeTime>
</trajectory.2>
<trajectory.3>
<lon>82.7348</lon>
<lat>-78.773</lat>
<z>249.195</z>
<relativeTime>0</relativeTime>
</trajectory.3>
<trajectory.4>
<lon>123.367</lon>
<lat>-117.46</lat>
<z>327.472</z>
<relativeTime>1000</relativeTime>
</trajectory.4>
<trajectory.5>
<lon>169.188</lon>
<lat>-161.086</lat>
<z>413.849</z>
<relativeTime>1000</relativeTime>
</trajectory.5>
<trajectory.6>
<lon>214.339</lon>
<lat>-204.075</lat>
<z>496.976</z>
<relativeTime>2000</relativeTime>
</trajectory.6>
<trajectory.7>
<lon>258.83</lon>
<lat>-246.435</lat>
<z>576.935</z>
<relativeTime>2000</relativeTime>
</trajectory.7>
<trajectory.8>
<lon>302.659</lon>
<lat>-288.166</lat>
<z>653.787</z>
<relativeTime>3000</relativeTime>
</trajectory.8>
<trajectory.9>
<lon>345.82</lon>
<lat>-329.26</lat>
<z>727.59</z>
<relativeTime>3000</relativeTime>
</trajectory.9>
<trajectory.10>
<lon>388.317</lon>
<lat>-369.722</lat>
<z>798.415</z>
<relativeTime>3000</relativeTime>
</trajectory.10>
<trajectory.11>
<lon>430.153</lon>
<lat>-409.555</lat>
<z>866.336</z>
<relativeTime>4000</relativeTime>
</trajectory.11>
<trajectory.12>
<lon>471.335</lon>
<lat>-448.764</lat>
<z>931.431</z>
<relativeTime>4000</relativeTime>
</trajectory.12>
<trajectory.13>
<lon>511.87</lon>
<lat>-487.359</lat>
<z>993.78</z>
<relativeTime>5000</relativeTime>
</trajectory.13>
<trajectory.14>
<lon>551.768</lon>
<lat>-525.346</lat>
<z>1053.46</z>
<relativeTime>5000</relativeTime>
</trajectory.14>
<trajectory.15>
<lon>591.038</lon>
<lat>-562.736</lat>
<z>1110.56</z>
<relativeTime>5000</relativeTime>
</trajectory.15>
<trajectory.16>
<lon>629.691</lon>
<lat>-599.538</lat>
<z>1165.15</z>
<relativeTime>6000</relativeTime>
</trajectory.16>
<trajectory.17>
<lon>672.451</lon>
<lat>-640.25</lat>
<z>1223.66</z>
<relativeTime>6000</relativeTime>
</trajectory.17>
<trajectory.18>
<lon>714.459</lon>
<lat>-680.247</lat>
<z>1279.22</z>
<relativeTime>7000</relativeTime>
</trajectory.18>
<trajectory.19>
<lon>755.733</lon>
<lat>-719.544</lat>
<z>1331.91</z>
<relativeTime>7000</relativeTime>
</trajectory.19>
<trajectory.20>
<lon>796.291</lon>
<lat>-758.16</lat>
<z>1381.86</z>
<relativeTime>8000</relativeTime>
</trajectory.20>
<trajectory.21>
<lon>836.152</lon>
<lat>-796.112</lat>
<z>1429.17</z>
<relativeTime>8000</relativeTime>
</trajectory.21>
<trajectory.22>
<lon>875.334</lon>
<lat>-833.417</lat>
<z>1473.94</z>
<relativeTime>8000</relativeTime>
</trajectory.22>
<trajectory.23>
<lon>913.857</lon>
<lat>-870.096</lat>
<z>1516.26</z>
<relativeTime>9000</relativeTime>
</trajectory.23>
<trajectory.24>
<lon>951.743</lon>
<lat>-906.167</lat>
<z>1556.24</z>
<relativeTime>9000</relativeTime>
</trajectory.24>
<trajectory.25>
<lon>989.01</lon>
<lat>-941.65</lat>
<z>1593.96</z>
<relativeTime>10000</relativeTime>
</trajectory.25>
<trajectory.26>
<lon>1029.72</lon>
<lat>-980.41</lat>
<z>1633.33</z>
<relativeTime>10000</relativeTime>
</trajectory.26>
<trajectory.27>
<lon>1069.72</lon>
<lat>-1018.49</lat>
<z>1670.15</z>
<relativeTime>11000</relativeTime>
</trajectory.27>
<trajectory.28>
<lon>1109.04</lon>
<lat>-1055.93</lat>
<z>1704.52</z>
<relativeTime>11000</relativeTime>
</trajectory.28>
<trajectory.29>
<lon>1147.71</lon>
<lat>-1092.75</lat>
<z>1736.55</z>
<relativeTime>11000</relativeTime>
</trajectory.29>
<trajectory.30>
<lon>1185.76</lon>
<lat>-1128.98</lat>
<z>1766.34</z>
<relativeTime>12000</relativeTime>
</trajectory.30>
<trajectory.31>
<lon>1223.22</lon>
<lat>-1164.65</lat>
<z>1793.99</z>
<relativeTime>12000</relativeTime>
</trajectory.31>
<trajectory.32>
<lon>1260.12</lon>
<lat>-1199.78</lat>
<z>1819.58</z>
<relativeTime>13000</relativeTime>
</trajectory.32>
<trajectory.33>
<lon>1296.49</lon>
<lat>-1234.41</lat>
<z>1843.2</z>
<relativeTime>13000</relativeTime>
</trajectory.33>
<trajectory.34>
<lon>1335.91</lon>
<lat>-1271.94</lat>
<z>1867</z>
<relativeTime>14000</relativeTime>
</trajectory.34>
<trajectory.35>
<lon>1374.77</lon>
<lat>-1308.94</lat>
<z>1888.6</z>
<relativeTime>14000</relativeTime>
</trajectory.35>
<trajectory.36>
<lon>1413.1</lon>
<lat>-1345.43</lat>
<z>1908.1</z>
<relativeTime>14000</relativeTime>
</trajectory.36>
<trajectory.37>
<lon>1450.94</lon>
<lat>-1381.46</lat>
<z>1925.57</z>
<relativeTime>15000</relativeTime>
</trajectory.37>
<trajectory.38>
<lon>1488.32</lon>
<lat>-1417.05</lat>
<z>1941.1</z>
<relativeTime>15000</relativeTime>
</trajectory.38>
<trajectory.39>
<lon>1525.3</lon>
<lat>-1452.26</lat>
<z>1954.75</z>
<relativeTime>16000</relativeTime>
</trajectory.39>
<trajectory.40>
<lon>1561.9</lon>
<lat>-1487.11</lat>
<z>1966.58</z>
<relativeTime>16000</relativeTime>
</trajectory.40>
<trajectory.41>
<lon>1598.17</lon>
<lat>-1521.64</lat>
<z>1976.64</z>
<relativeTime>16000</relativeTime>
</trajectory.41>
<trajectory.42>
<lon>1634.14</lon>
<lat>-1555.89</lat>
<z>1984.97</z>
<relativeTime>17000</relativeTime>
</trajectory.42>
<trajectory.43>
<lon>1669.86</lon>
<lat>-1589.89</lat>
<z>1991.63</z>
<relativeTime>17000</relativeTime>
</trajectory.43>
<trajectory.44>
<lon>1705.35</lon>
<lat>-1623.69</lat>
<z>1996.63</z>
<relativeTime>18000</relativeTime>
</trajectory.44>
<trajectory.45>
<lon>1740.66</lon>
<lat>-1657.31</lat>
<z>2000</z>
<relativeTime>18000</relativeTime>
</trajectory.45>
<trajectory.46>
<lon>1775.83</lon>
<lat>-1690.79</lat>
<z>2001.77</z>
<relativeTime>19000</relativeTime>
</trajectory.46>
<trajectory.47>
<lon>1810.9</lon>
<lat>-1724.18</lat>
<z>2001.94</z>
<relativeTime>19000</relativeTime>
</trajectory.47>
<trajectory.48>
<lon>1845.89</lon>
<lat>-1757.5</lat>
<z>2000.51</z>
<relativeTime>19000</relativeTime>
</trajectory.48>
<trajectory.49>
<lon>1880.86</lon>
<lat>-1790.79</lat>
<z>1997.5</z>
<relativeTime>20000</relativeTime>
</trajectory.49>
<trajectory.50>
<lon>1915.83</lon>
<lat>-1824.09</lat>
<z>1992.87</z>
<relativeTime>20000</relativeTime>
</trajectory.50>
<trajectory.51>
<lon>1950.85</lon>
<lat>-1857.44</lat>
<z>1986.63</z>
<relativeTime>21000</relativeTime>
</trajectory.51>
<trajectory.52>
<lon>1985.96</lon>
<lat>-1890.86</lat>
<z>1978.74</z>
<relativeTime>21000</relativeTime>
</trajectory.52>
<trajectory.53>
<lon>2021.19</lon>
<lat>-1924.41</lat>
<z>1969.18</z>
<relativeTime>21000</relativeTime>
</trajectory.53>
<trajectory.54>
<lon>2056.58</lon>
<lat>-1958.1</lat>
<z>1957.91</z>
<relativeTime>22000</relativeTime>
</trajectory.54>
<trajectory.55>
<lon>2092.18</lon>
<lat>-1991.99</lat>
<z>1944.87</z>
<relativeTime>22000</relativeTime>
</trajectory.55>
<trajectory.56>
<lon>2128.01</lon>
<lat>-2026.11</lat>
<z>1930.02</z>
<relativeTime>23000</relativeTime>
</trajectory.56>
<trajectory.57>
<lon>2164.13</lon>
<lat>-2060.5</lat>
<z>1913.29</z>
<relativeTime>23000</relativeTime>
</trajectory.57>
<trajectory.58>
<lon>2200.56</lon>
<lat>-2095.19</lat>
<z>1894.62</z>
<relativeTime>23000</relativeTime>
</trajectory.58>
<trajectory.59>
<lon>2237.36</lon>
<lat>-2130.22</lat>
<z>1873.91</z>
<relativeTime>24000</relativeTime>
</trajectory.59>
<trajectory.60>
<lon>2271.16</lon>
<lat>-2162.41</lat>
<z>1853.24</z>
<relativeTime>24000</relativeTime>
</trajectory.60>
<trajectory.61>
<lon>2305.33</lon>
<lat>-2194.94</lat>
<z>1830.75</z>
<relativeTime>25000</relativeTime>
</trajectory.61>
<trajectory.62>
<lon>2339.89</lon>
<lat>-2227.84</lat>
<z>1806.34</z>
<relativeTime>25000</relativeTime>
</trajectory.62>
<trajectory.63>
<lon>2374.89</lon>
<lat>-2261.16</lat>
<z>1779.93</z>
<relativeTime>26000</relativeTime>
</trajectory.63>
<trajectory.64>
<lon>2410.34</lon>
<lat>-2294.92</lat>
<z>1751.41</z>
<relativeTime>26000</relativeTime>
</trajectory.64>
<trajectory.65>
<lon>2446.3</lon>
<lat>-2329.15</lat>
<z>1720.68</z>
<relativeTime>26000</relativeTime>
</trajectory.65>
<trajectory.66>
<lon>2482.79</lon>
<lat>-2363.9</lat>
<z>1687.61</z>
<relativeTime>27000</relativeTime>
</trajectory.66>
<trajectory.67>
<lon>2516.11</lon>
<lat>-2395.63</lat>
<z>1655.75</z>
<relativeTime>27000</relativeTime>
</trajectory.67>
<trajectory.68>
<lon>2549.93</lon>
<lat>-2427.82</lat>
<z>1621.78</z>
<relativeTime>28000</relativeTime>
</trajectory.68>
<trajectory.69>
<lon>2584.26</lon>
<lat>-2460.51</lat>
<z>1585.61</z>
<relativeTime>28000</relativeTime>
</trajectory.69>
<trajectory.70>
<lon>2619.13</lon>
<lat>-2493.71</lat>
<z>1547.11</z>
<relativeTime>28000</relativeTime>
</trajectory.70>
<trajectory.71>
<lon>2654.58</lon>
<lat>-2527.47</lat>
<z>1506.15</z>
<relativeTime>29000</relativeTime>
</trajectory.71>
<trajectory.72>
<lon>2690.64</lon>
<lat>-2561.79</lat>
<z>1462.59</z>
<relativeTime>29000</relativeTime>
</trajectory.72>
<trajectory.73>
<lon>2723.22</lon>
<lat>-2592.82</lat>
<z>1421.57</z>
<relativeTime>30000</relativeTime>
</trajectory.73>
<trajectory.74>
<lon>2756.33</lon>
<lat>-2624.34</lat>
<z>1378.26</z>
<relativeTime>30000</relativeTime>
</trajectory.74>
<trajectory.75>
<lon>2789.99</lon>
<lat>-2656.38</lat>
<z>1332.55</z>
<relativeTime>31000</relativeTime>
</trajectory.75>
<trajectory.76>
<lon>2824.22</lon>
<lat>-2688.98</lat>
<z>1284.3</z>
<relativeTime>31000</relativeTime>
</trajectory.76>
<trajectory.77>
<lon>2859.05</lon>
<lat>-2722.14</lat>
<z>1233.38</z>
<relativeTime>31000</relativeTime>
</trajectory.77>
<trajectory.78>
<lon>2894.51</lon>
<lat>-2755.9</lat>
<z>1179.62</z>
<relativeTime>32000</relativeTime>
</trajectory.78>
<trajectory.79>
<lon>2930.63</lon>
<lat>-2790.29</lat>
<z>1122.88</z>
<relativeTime>32000</relativeTime>
</trajectory.79>
<trajectory.80>
<lon>2962.79</lon>
<lat>-2820.91</lat>
<z>1070.65</z>
<relativeTime>33000</relativeTime>
</trajectory.80>
<trajectory.81>
<lon>2995.5</lon>
<lat>-2852.05</lat>
<z>1015.86</z>
<relativeTime>33000</relativeTime>
</trajectory.81>
<trajectory.82>
<lon>3028.77</lon>
<lat>-2883.73</lat>
<z>958.393</z>
<relativeTime>34000</relativeTime>
</trajectory.82>
<trajectory.83>
<lon>3062.63</lon>
<lat>-2915.97</lat>
<z>898.099</z>
<relativeTime>34000</relativeTime>
</trajectory.83>
<trajectory.84>
<lon>3097.11</lon>
<lat>-2948.8</lat>
<z>834.825</z>
<relativeTime>34000</relativeTime>
</trajectory.84>
<trajectory.85>
<lon>3132.22</lon>
<lat>-2982.23</lat>
<z>768.404</z>
<relativeTime>35000</relativeTime>
</trajectory.85>
<trajectory.86>
<lon>3167.99</lon>
<lat>-3016.29</lat>
<z>698.657</z>
<relativeTime>35000</relativeTime>
</trajectory.86>
<trajectory.87>
<lon>3199.21</lon>
<lat>-3046.01</lat>
<z>636.077</z>
<relativeTime>36000</relativeTime>
</trajectory.87>
<trajectory.88>
<lon>3230.96</lon>
<lat>-3076.24</lat>
<z>570.777</z>
<relativeTime>36000</relativeTime>
</trajectory.88>
<trajectory.89>
<lon>3263.25</lon>
<lat>-3106.99</lat>
<z>502.616</z>
<relativeTime>37000</relativeTime>
</trajectory.89>
<trajectory.90>
<lon>3296.12</lon>
<lat>-3138.28</lat>
<z>431.443</z>
<relativeTime>37000</relativeTime>
</trajectory.90>
<trajectory.91>
<lon>3329.58</lon>
<lat>-3170.14</lat>
<z>357.096</z>
<relativeTime>37000</relativeTime>
</trajectory.91>
<trajectory.92>
<lon>3363.65</lon>
<lat>-3202.58</lat>
<z>279.399</z>
<relativeTime>38000</relativeTime>
</trajectory.92>
<trajectory.93>
<lon>3398.36</lon>
<lat>-3235.63</lat>
<z>198.163</z>
<relativeTime>38000</relativeTime>
</trajectory.93>
<trajectory.94>
<lon>3433.74</lon>
<lat>-3269.31</lat>
<z>113.182</z>
<relativeTime>39000</relativeTime>
</trajectory.94>
<trajectory.95>
<lon>3444.05</lon>
<lat>-3279.13</lat>
<z>88</z>
<relativeTime>39000</relativeTime>
</trajectory.95>
</trajectory>
</effectors.1>
</effectors>
<firePurposeId>2</firePurposeId>
<partyId>4</partyId>
<participantId>239</participantId>
<esmParticipantIds count="0"/>
<externalId>7</externalId>
<effectMarkingInTa>1</effectMarkingInTa>
<properties>{"effectSource":1,"elemente":1,"feuerkampfReferenz":"eb511ab7d8414b88af248fd32ef03285","firingType":1,"ladung":"DM16","ladungsNummer":3,"partyId":4,"subTyp":0,"typ":0,"useReceived":true}</properties>
</DdsData>
</Sample>
</Samples>
@@ -0,0 +1,942 @@
/**
* @RDE_HEADER@
* ModuleTest
* $Id$
* $HeadURL$
* $Author$
*/
#include "effect_cluster_module_test.h"
#include <LtsCoordTrans/lts_coord_trans.h>
#include <nglapplication/nglcoreapplication.h>
// AES
#include <AreaEffectSimulation/Utils/polygons.h>
#include <AreaEffectSimulation/aes_dtc.h>
// PPM
#include "ParticipantManagement/ppm_ftc_types.h"
#include "TrainingAreaBase/tab.hpp"
#include <QDateTime>
#include <QDebug>
#include <QFile>
#include <QJsonArray>
#include <QJsonDocument>
#include <QTimer>
#include <QVector>
#include <QXmlStreamReader>
#include <iostream>
using namespace AreaEffectSimulation;
using namespace LtsCoordTrans;
static QString s_REQUEST_SPL_FILE = QStringLiteral("EffectClusterModifyRequest_ESG.spl");
//
// some helper functions
//
template <typename T> dds::core::optional<T> toOptional(T inVal) { return inVal != T() ? dds::core::optional<T>(inVal) : dds::core::optional<T>(); }
template <typename T> dds::core::optional<T> optional() { return dds::core::optional<T>(); }
// mathematical positive north -> mathematical negativ, east = 0°, 0,01 degree in 1/100° -> factor 100
static inline int compassToMathAngleForSfm(double compassDegree)
{
int ret = qRound((90.0 - compassDegree) * 100.0);
while (ret < 0)
ret += 36000;
while (ret > 36000)
ret -= 36000;
return ret;
}
double distanceMeter(const LtsCoordTrans::UtmCoordinate &utmCoord1, const LtsCoordTrans::UtmCoordinate &utmCoord2)
{
double dist = LtsCoordTrans::distance(utmCoord1, utmCoord2);
return dist;
}
double distanceMeter(const Core::GeoPosition &geoPos, const LtsCoordTrans::UtmCoordinate &utmCoord)
{
const LtsCoordTrans::UtmCoordinate &utmPos = LtsCoordTrans::UtmCoordinate::fromGeographic(geoPos.lon(), geoPos.lat());
return distanceMeter(utmPos, utmCoord);
}
double distanceMeter(const Core::GeoPosition2D &geoPos2D, const LtsCoordTrans::UtmCoordinate &utmCoord)
{
const LtsCoordTrans::UtmCoordinate &utmPos = LtsCoordTrans::UtmCoordinate::fromGeographic(geoPos2D.lon(), geoPos2D.lat());
return distanceMeter(utmPos, utmCoord);
}
ModuleTestEffectCluster::ModuleTestEffectCluster(int domainId, int exerciseId)
: m_domainId(domainId)
, m_exerciseId(exerciseId)
, m_logger(getLogger("ModuleTestEffectCluster"))
{
m_timer = new QTimer(this);
m_timer->setSingleShot(true);
connect(m_timer,
&QTimer::timeout,
this,
[this]()
{
DEBUG_LOG(m_logger) << "Wirkfeldplanung";
doEffectClusterModifyRequest();
});
}
void ModuleTestEffectCluster::onEffectClusterModifyReply(const Core::FunctionReplyObject &replyObject)
{
m_replyError = replyObject.error();
DEBUG_LOG(m_logger) << " got reply - onEffectClusterModifyReply: " << m_replyError << ", aesItemId=" << replyObject.id();
m_aesItemId = replyObject.id();
if (!replyObject.str().empty())
ERROR_LOG(m_logger) << " got reply - onEffectClusterModifyReply: " << replyObject.translated();
}
void ModuleTestEffectCluster::onAcknowledgeExternalAesItemReply(const Core::FunctionReplyObject &replyObject)
{
m_replyError = replyObject.error();
DEBUG_LOG(m_logger) << " got reply - onAcknowledgeExternalAesItemReply: " << m_replyError;
sendTabExFire();
// AES::EffectState von ES_Received -> ES_Created
if (!replyObject.str().empty())
ERROR_LOG(m_logger) << " got reply - onAcknowledgeExternalAesItemReply: " << replyObject.translated();
}
void ModuleTestEffectCluster::onModifyPartyDataReply(const Core::FunctionReplyObject &replyObject)
{
m_replyError = replyObject.error();
DEBUG_LOG(m_logger) << " got reply - onModifyPartyDataReply: " << m_replyError << " " << replyObject.additionalInfo();
if (!replyObject.str().empty())
ERROR_LOG(m_logger) << " got reply - onModifyPartyDataReply: " << replyObject.translated();
if (!m_participantChangeRequestDone)
{
participantChangeRequest();
m_participantChangeRequestDone = true;
}
}
void ModuleTestEffectCluster::onModifyParticipantDataReply(const Core::FunctionReplyObject &replyObject)
{
m_replyError = replyObject.error();
DEBUG_LOG(m_logger) << " \n\ngot reply - onModifyParticipantDataReply error: " << m_replyError << ", additionalInfo: " << replyObject.additionalInfo();
if (!replyObject.str().empty())
ERROR_LOG(m_logger) << " got reply - onModifyParticipantDataReply: " << replyObject.translated();
DEBUG_LOG(m_logger) << "onModifyParticipantDataReply => Set Participant Pos";
QJsonArray jsonArray = QJsonDocument::fromJson(QByteArray::fromStdString(replyObject.additionalInfo())).object().value(QLatin1String("participants")).toArray();
DEBUG_LOG(m_logger) << "available_in_exercise jsonDocument.size()=" << jsonArray.size();
// ParticipantId aus dem Result bestimmen, keine Unit
// Dieser einfache Test arbeitet mit einem Participant
for (auto it = jsonArray.constBegin(); it != jsonArray.constEnd(); ++it)
{
int participantId = it->toInt();
DEBUG_LOG(m_logger) << "participantId=" << participantId;
ParticipantManagement::Participant participant = m_ppmDtc->participant(participantId);
if (m_ppmDtc->type(participant.typeId()).typeClass().underlying() != ParticipantManagement::TypeClass::Unit)
{
DEBUG_LOG(m_logger) << "m_participant1.id=" << participantId;
m_participant1.id(participantId); // wichtig zum loeschen
DEBUG_LOG(m_logger) << "m_participantId keine Unit=" << participantId;
setParticipantPos(participantId);
setEquipmentGearCharge(participantId);
// Wirkfeldplanung
if (!m_timer->isActive())
m_timer->start(500);
}
else
{
DEBUG_LOG(m_logger) << "m_participant0.id=" << participantId;
m_participant0.id(participantId); // wichtig zum loeschen
}
}
}
void ModuleTestEffectCluster::onAesItemViewChanged(const AesItemView &aesItemView, DataModification modType)
{
if (modType == DataModification::eRemoved)
return;
AreaEffectSimulation::AesType_def::type aesType = aesItemView.aesTypeId().underlying();
if (aesType != AreaEffectSimulation::AesType_def::AtEffectCluster)
return;
if (aesItemView.aesItemId() != m_aesItemId)
return;
DEBUG_LOG(m_logger) << " got onAesItemViewChanged: "
<< ", aesItemId=" << aesItemView.aesItemId() << ", aesType=" << aesType << ", effectStateId=" << aesItemView.effectStateId();
QCOMPARE(aesItemView.effectStateId(), m_effectStates[m_effectStateCounter]);
m_effectStateCounter++;
if (aesItemView.effectStateId() == AreaEffectSimulation::AesEffectState::EsReceived)
{
DEBUG_LOG(m_logger) << "sendAcknowledgeExternalAesItemRequest aesItemId=" << aesItemView.aesItemId();
sendAcknowledgeExternalAesItemRequest(aesItemView.aesItemId());
}
}
void ModuleTestEffectCluster::sendTabExFire()
{
DEBUG_LOG(m_logger) << "sendTabExFire";
TrainingAreaBase::EX_Fire exFire;
exFire.effectorId(m_effectorId); // Kenner z.B B1
exFire.identifier(m_identifier.toStdString()); // Verein z.B 451100
exFire.reference(m_reference.toStdString()); // UUID Feuerkampf
exFire.equipmentNumber(m_participant1.id() * -1);
exFire.sampleTime(QDateTime::currentMSecsSinceEpoch() + 500);
m_tabDts->publish(exFire);
}
void ModuleTestEffectCluster::onEffectsChanged(const Effects &effects, DataModification modType)
{
if (modType == DataModification::eRemoved)
return;
AreaEffectSimulation::AesType_def::type aesType = effects.aesTypeId().underlying();
DEBUG_LOG(m_logger) << " got onEffectsChanged - m_data: " << m_data.id() << ", aesType=" << aesType;
++m_counterDds.cntEffectClusterEffects;
m_effects = effects;
DEBUG_LOG(m_logger) << " got onEffectsChanged - m_effects: " << m_effects;
}
void ModuleTestEffectCluster::onChargeEffectChanged(const ChargeEffect &chargeEffect, DataModification modType)
{
DEBUG_LOG(m_logger) << "onChargeEffectChanged state=" << chargeEffect.state();
if (modType == DataModification::eRemoved)
return;
if (chargeEffect.state() == AreaEffectSimulation::AesEffectState::EsActivated)
{
// Compare Position
// mhpPosition.lon(0.201958);
// mhpPosition.lat(0.915263);
// mhpPosition.z(88.0);
double lon = qRound64(chargeEffect.position().lon() * 100000) / 100000.0; // Nur die ersten 5 Nachkommastellen beruecksichtigen
double lat = qRound64(chargeEffect.position().lat() * 100000) / 100000.0;
QCOMPARE(lon, 0.20196);
QCOMPARE(lat, 0.91526);
QCOMPARE(chargeEffect.position().z(), 88.0);
}
else if (chargeEffect.state() == AreaEffectSimulation::AesEffectState::EsExpired)
participantDeleteRequest();
DEBUG_LOG(m_logger) << " got onEffectsChanged - m_effects: " << m_effects;
}
void ModuleTestEffectCluster::onTrajectoryTimeAwareChanged(const TrajectoryTimeAware &data, DataModification modType)
{
Q_UNUSED(modType);
if (data.id() == -1)
return;
++m_counterDds.cntTrajectory;
DEBUG_LOG(m_logger) << " got TrajectoryTimeAwareChanged - data: " << data.id() << ", cntTrajectory=" << m_counterDds.cntTrajectory;
}
void ModuleTestEffectCluster::dumpCnt()
{
DEBUG_LOG(m_logger) << LOGFUNCTION << " Counter: "
<< " cntEffectCluster = " << m_counterDds.cntEffectCluster << ", cntAtEffectCluster = " << m_counterDds.cntAtEffectCluster
<< ", cntGunToTargetLine = " << m_counterDds.cntAtEffectClusterGunToTargetLine << ", cntClusterEffects = " << m_counterDds.cntEffectClusterEffects
<< ", cntTrajectory = " << m_counterDds.cntTrajectory;
}
bool ModuleTestEffectCluster::waitForData(const std::function<bool()> &func, int retryCount)
{
// Maybe give QTRY_VERIFY2 or QTRY_VERIFY2_WITH_TIMEOUT a chance
// Or better QTRY_IMPL ??
// QTRY_IMPL(m_replyError == false, 1);
// wait for data
retryCount *= 10;
for (int i = 0; i < retryCount; ++i)
{
TRACE_LOG(m_logger) << " waitForData - i: " << i;
if (func())
return true;
QTest::qWait(1000);
}
return func();
}
EffectCluster ModuleTestEffectCluster::getEcForTneVerification(const QString &eaName, double rotation)
{
AreaEffectSimulation::EffectCluster eaData;
eaData.id(0);
eaData.effectStart((time(nullptr) + 30) * 1000); // msec
QString name(eaName);
name += QString::number(eaData.effectStart().get());
eaData.name(name.toStdString());
eaData.effectDuration(10000); // 10 seconds
// eaData.chargeStruct().chargeTypeId(s_ChargeTypeId1);
// eaData.chargeStruct().igniterTypeId(s_IgniterTypeProximity);
eaData.partyId(2);
eaData.participantId(7);
// SubStruct FlightCurve
FlightCurve fc;
fc.requestedRelativePeakHeight(100);
// siehe auch: GUEZE-2311 Verifikation des Algorithmus bzgl. MTPs zw. TNE und EXCON.
const double height = 100; // Y
const double width = 40; // X
const double rot = rotation;
// In Kontext GUEZE-2311 werden die MTPs unabhängig von eigentliche WirkfeldGeometrie an die TNE übermittelt.
// Um in der Zentrale den gewünschten MTP zu erhalten, muss das Wirkfeld entsprechend angelegt werden:
LtsCoordTrans::UtmCoordinate cp = LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32U MD 97000 78000"));
QPointF bottomLeft(Polygons::centerPoint2BottomLeft(cp.geographic(), width, height, rot));
DEBUG_LOG(m_logger) << " bottomLeft" << bottomLeft;
eaData.area().cornerBottomLeft(Core::GeoPosition(bottomLeft.x(), bottomLeft.y(), 0.0));
eaData.area().height(height);
eaData.area().width(width);
eaData.area().rotation(rot);
eaData.explosionGeometry(AreaEffectSimulation::AesExplosionGeometry_def::EgArea);
eaData.tla(0); // aka zop
eaData.externalId(0);
return eaData;
}
std::vector<Core::RelativePositionRelativeTime> ModuleTestEffectCluster::parseTrajectory(const QString &filePath)
{
// EffectClusterModifyRequest
// AreaEffectSimulation::EffectorData
// std::vector< Core::GeoPositionRelativeTime >& trajectory
// GeoPositionRelativeTime ( lon, lat, z, relativeTime)
QFile file(filePath);
std::vector<Core::RelativePositionRelativeTime> points;
if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
return points;
QXmlStreamReader xml(&file);
while (!xml.atEnd() && !xml.hasError())
{
xml.readNext();
// Wir suchen nach Start-Elementen, die mit "trajectory." beginnen
if (xml.isStartElement() && xml.name().toString().startsWith(QStringLiteral("trajectory.")))
{
Core::RelativePositionRelativeTime p;
// Wir lesen die Unterelemente (lon, lat, z, relativeTime)
while (!(xml.isEndElement() && xml.name().toString().startsWith(QStringLiteral("trajectory."))))
{
xml.readNext();
if (xml.isStartElement())
{
QString name = xml.name().toString();
QString val = xml.readElementText();
if (name == QStringLiteral("lon"))
p.offsetX(val.toDouble());
else if (name == QStringLiteral("lat"))
p.offsetY(val.toDouble());
else if (name == QStringLiteral("z"))
p.offsetZ(val.toDouble());
else if (name == QStringLiteral("relativeTime"))
p.relativeTime(val.toDouble());
}
}
points.push_back(p);
DEBUG_LOG(m_logger) << "Punkt gelesen: offsetY" << p.offsetX() << ", offsetY" << p.offsetY() << ", offsetZ" << p.offsetZ() << ", time=" << p.relativeTime();
}
}
if (xml.hasError())
{
DEBUG_LOG(m_logger) << "XML Fehler:" << xml.errorString();
}
DEBUG_LOG(m_logger) << "file.close()";
file.close();
DEBUG_LOG(m_logger) << "return points";
return points;
}
int ModuleTestEffectCluster::sendAcknowledgeExternalAesItemRequest(int aesItemId)
{
DEBUG_LOG(m_logger) << "sendAcknowledgeExternalAesItemRequest aesItemId=" << aesItemId;
int ret = m_aesFtc->acknowledgeExternalAesItemRequest(AcknowledgeExternalAesItemRequest(aesItemId), this);
return ret;
}
int ModuleTestEffectCluster::doEffectClusterModifyRequest()
{
EffectCluster eaData;
QString dateTimeString = QDateTime::currentDateTime().toString(QStringLiteral("dd.MM.yyyy hh:mm"));
m_reference = dateTimeString;
if (eaData.effectStart().is_set())
INFO_LOG(m_logger) << " effectClusterModifyRequest with effectStart: " << QDateTime::fromMSecsSinceEpoch(eaData.effectStart().get()).toString();
else
INFO_LOG(m_logger) << " effectClusterModifyRequest with effectStart: not set ";
FlightCurve fc;
// if (eaData.flightCurve().is_set())
// fc = eaData.flightCurve().get();
QJsonObject obj;
obj[QStringLiteral("effectSource")] = 1;
obj[QStringLiteral("elemente")] = 1;
obj[QStringLiteral("feuerkampfReferenz")] = dateTimeString;
obj[QStringLiteral("firingType")] = 1;
obj[QStringLiteral("ladung")] = QStringLiteral("DM16");
obj[QStringLiteral("ladungsNummer")] = 3;
obj[QStringLiteral("partyId")] = 4;
obj[QStringLiteral("subTyp")] = 0;
obj[QStringLiteral("typ")] = 0;
obj[QStringLiteral("useReceived")] = true;
obj[QStringLiteral("effectSource")] = ProjectDataManagement::EffectSource::ES_ADLER;
QString propertiesStr = QString::fromStdString(QJsonDocument(obj).toJson(QJsonDocument::Compact).toStdString());
eaData.properties(propertiesStr.toStdString());
AreaEffectSimulation::ChargeStruct chargeStruct;
chargeStruct.chargeTypeId(367);
chargeStruct.igniterTypeId(1);
chargeStruct.igniterFunctionId(2);
Core::GeoPosition mhpPosition;
mhpPosition.lon(0.201958);
mhpPosition.lat(0.915263);
mhpPosition.z(88.0);
Core::GeoPosition2D cornerBottomLeft;
cornerBottomLeft.lon(0.201951);
cornerBottomLeft.lat(0.915259);
AreaEffectSimulation::Area area;
area.cornerBottomLeft(cornerBottomLeft);
area.width(50);
area.height(50);
area.rotation(0);
eaData.area(area);
eaData.explosionGeometry(AreaEffectSimulation::AesExplosionGeometry::EgPoint);
std::vector<Core::RelativePositionRelativeTime> trajectory = parseTrajectory(s_REQUEST_SPL_FILE);
AreaEffectSimulation::EffectorData effector;
effector.angleOfFall(0);
effector.participantId(m_participant1.id()); // Participant
DEBUG_LOG(m_logger) << "effector.participantId(m_participant1.id()=" << m_participant1.id();
effector.flightTime(39526.3);
effector.peakHeight(2002.0);
effector.interval(0);
effector.chargeStruct(chargeStruct);
effector.chargeAmount(1);
effector.mhpScatterLenght(3.08314e-316);
effector.mhpScatterWidth(8.76302e-315);
effector.mhpScatterLengthDetonationHeight(9.69057e-316);
effector.mhpScatterWidthDetonationHeight(8.76638e-315);
effector.mhpRotation(-45.4373);
effector.mhpPosition(mhpPosition);
effector.trajectoryRelative(trajectory);
DEBUG_LOG(m_logger) << "effector";
std::vector<AreaEffectSimulation::EffectorData> effectors;
effectors.push_back(effector);
DEBUG_LOG(m_logger) << "Nach effector";
eaData.id(0);
eaData.effectSourceId(ProjectDataManagement::EffectSource::ES_ADLER);
eaData.firePurposeId(2);
eaData.partyId(4);
eaData.participantId(m_participant0.id()); // Unit
DEBUG_LOG(m_logger) << "eaData.participantId(m_participant0.id()=" << m_participant0.id();
eaData.externalId(7);
eaData.effectMarkingInTa(1);
eaData.name(dateTimeString.toStdString());
eaData.element(dateTimeString.toStdString());
DEBUG_LOG(m_logger) << "Vor send effectClusterModifyRequest";
int ret = m_aesFtc->effectClusterModifyRequest(EffectClusterModifyRequest(eaData.id(),
eaData.name(),
eaData.element(),
eaData.effectStart(),
eaData.effectDuration(),
eaData.effectSourceId(),
eaData.area(),
eaData.explosionGeometry(), // AimPoint, Radial, Area, Line, Point
eaData.tla(), // ZielOrtungsGenauigkeit
effectors,
eaData.firePurposeId(), // FirePurpose: blenden, niederhalten, vernichten
eaData.partyId(),
eaData.participantId(),
{}, // esmParticipantIds
eaData.externalId(),
eaData.effectMarkingInTa(),
eaData.properties()),
this);
DEBUG_LOG(m_logger) << "send effectClusterModifyRequest ret=" << ret;
return ret;
}
void ModuleTestEffectCluster::waitForEffectStates(int lineNumber, int durPrep, int durAct, int durExp)
{
// expected condition:
if (!waitForData([this]() { return m_replyError == false; }, 1))
{
ERROR_LOG(m_logger) << "Error on request"
<< ", lineNumber = " << lineNumber;
return;
}
INFO_LOG(m_logger) << LOGFUNCTION << " waiting for EsPrepared...";
if (!waitForData([this]() { return m_data.effectStateId() == AreaEffectSimulation::AesEffectState_def::EsPrepared; }, durPrep))
{
ERROR_LOG(m_logger) << "Timeout waiting for EsPrepared of explosion cluster with id " << m_data.id() << ", lineNumber = " << lineNumber;
QVERIFY2(false, "ERROR, exit");
return;
}
INFO_LOG(m_logger) << LOGFUNCTION << " waiting for EsActivated...";
if (!waitForData([this]() { return m_data.effectStateId() == AreaEffectSimulation::AesEffectState_def::EsActivated; }, durAct))
{
ERROR_LOG(m_logger) << "Timeout waiting for EsActivated of explosion cluster with id " << m_data.id() << ", lineNumber = " << lineNumber;
QVERIFY2(false, "ERROR, exit");
return;
}
INFO_LOG(m_logger) << LOGFUNCTION << " waiting for EsExpired...";
if (!waitForData([this]() { return m_data.effectStateId() == AreaEffectSimulation::AesEffectState_def::EsExpired; }, durExp))
{
ERROR_LOG(m_logger) << "Timeout waiting for EsExpired of explosion cluster with id " << m_data.id() << ", lineNumber = " << lineNumber;
QVERIFY2(false, "ERROR, exit");
return;
}
}
void ModuleTestEffectCluster::disconnectFromParty()
{
DEBUG_LOG(m_logger) << "PPM::ModifyPartyDataRequest";
ParticipantManagement::Party party;
party.name("GREEN");
party.role(ParticipantManagement::Role::Neutral);
party.color(-16711936);
party.fadingColor(-6553701);
ModifyPartyDataRequest req;
req.id(m_partyId);
req.name(party.name());
req.color(party.color());
req.fadingColor(party.fadingColor());
req.role(party.role());
req.isUsedBy(true);
req.sampleTime(QDateTime::currentMSecsSinceEpoch());
const HlaForceIdentifierEnum hlaId = HlaForceIdentifierEnum::Neutral_1;
req.hlaForceIdentifier(hlaId);
QString properties = QStringLiteral("{\"Adler\": {\"wsId\": 3, \"SaaName\": \"UI Test\", \"assetId\": -1, \"saaName\": \"SAA1@GUEZ.DE\", \"szenarName\": \"UI Test\", "
"\"isSaaConnected\": 1, \"saaConnectedState\": 2}}");
req.properties(properties.toStdString());
if (!m_ppmFtc->modifyPartyDataRequest(req, this))
{
ERROR_LOG(m_logger) << "Error creating party data";
// failExit();
}
}
void ModuleTestEffectCluster::connectToParty()
{
DEBUG_LOG(m_logger) << "PPM::ModifyPartyDataRequest";
ParticipantManagement::Party party;
party.name("GREEN");
party.role(ParticipantManagement::Role::Neutral);
party.color(-16711936);
party.fadingColor(-6553701);
ModifyPartyDataRequest req;
req.id(m_partyId);
req.name(party.name());
req.color(party.color());
req.fadingColor(party.fadingColor());
req.role(party.role());
req.isUsedBy(true);
req.sampleTime(QDateTime::currentMSecsSinceEpoch());
const HlaForceIdentifierEnum hlaId = HlaForceIdentifierEnum::Neutral_1;
req.hlaForceIdentifier(hlaId);
QString properties = QStringLiteral("{\"Adler\": {\"wsId\": 3, \"SaaName\": \"UI Test\", \"assetId\": -1, \"saaName\": \"SAA1@GUEZ.DE\", \"szenarName\": \"UI Test\", "
"\"isSaaConnected\": 2, \"isVerbund\": true, \"saaConnectedState\": 4}}");
req.properties(properties.toStdString());
if (!m_ppmFtc->modifyPartyDataRequest(req, this))
{
ERROR_LOG(m_logger) << "Error creating party data";
// failExit();
}
}
void ModuleTestEffectCluster::participantChangeRequest()
{
DEBUG_LOG(m_logger) << "PPM::participantChangerequest";
m_participant0.id(0);
m_participant0.partyId(4);
m_participant0.hierarchyNumber(1);
m_participant0.typeId(182);
m_participant0.externalId(0);
m_participant0.symbol(QStringLiteral("AP6D|CMPL|10011000001308000000").toStdString());
m_participant0.name(QStringLiteral("451200").toStdString());
m_participant0.identification(QStringLiteral("").toStdString());
m_participant0.designator(QStringLiteral("451200").toStdString()), m_participant0.tacticalIdentifier(QStringLiteral("451200").toStdString());
m_participant0.info(QStringLiteral("").toStdString());
m_participant0.assignState(ParticipantManagement::ParticipantAssignState::NotAssigned);
m_participant0.isSimulated(false);
m_participant0.isDeleted(false);
m_participant0.properties(QStringLiteral("").toStdString());
m_participant0.modId(1138783559);
m_participant0.superiorModId(0);
m_participant1.id(0);
m_participant1.partyId(4);
m_participant1.hierarchyNumber(1);
m_participant1.typeId(188);
m_participant1.externalId(0);
m_participant1.symbol(QStringLiteral("AP6D|CMPL|10011500001114020000").toStdString());
m_participant1.name(QStringLiteral("C3").toStdString());
m_participant1.identification(QStringLiteral("").toStdString());
m_participant1.designator(QStringLiteral("C3").toStdString()), m_participant1.tacticalIdentifier(QStringLiteral("451200").toStdString());
m_participant1.info(QStringLiteral("").toStdString());
m_participant1.assignState(ParticipantManagement::ParticipantAssignState::NotAssigned);
m_participant1.isSimulated(false);
m_participant1.isDeleted(false);
m_participant1.properties(QStringLiteral("").toStdString());
m_participant1.modId(1390608527);
m_participant1.superiorModId(1138783559);
ModifyParticipantDataRequest req;
std::vector<ParticipantManagement::ParticipantData> data;
data.push_back(m_participant0);
data.push_back(m_participant1);
req.requestId(548288706);
req.data(data);
if (!m_ppmFtc->modifyParticipantDataRequest(req, this))
{
ERROR_LOG(m_logger) << "Error creating party data";
// failExit();
}
}
void ModuleTestEffectCluster::participantDeleteRequest()
{
DEBUG_LOG(m_logger) << "PPM::participantDeleteRequest";
m_participant0.isDeleted(true);
m_participant1.isDeleted(true);
ModifyParticipantDataRequest req;
std::vector<ParticipantManagement::ParticipantData> data;
data.push_back(m_participant0);
data.push_back(m_participant1);
req.requestId(548288707);
req.data(data);
if (!m_ppmFtc->modifyParticipantDataRequest(req, this))
{
ERROR_LOG(m_logger) << "Error creating party data";
// failExit();
}
}
void ModuleTestEffectCluster::setParticipantPos(int participantId)
{
DEBUG_LOG(m_logger) << "setupParticipants";
TrainingAreaBase::TabPosition position;
Core::GeoPosition geoPos;
TrainingAreaBase::EquipmentPosition pos;
geoPos.lon(0.20110363);
geoPos.lat(0.91579597);
geoPos.z(0.0);
DEBUG_LOG(m_logger) << " initTestCase_data1 ...";
pos.equipmentNumber(participantId * -1); // ParticipantId
pos.sampleTime(QDateTime::currentMSecsSinceEpoch());
position.reportingSource(Core::PositionReportingSource::SetByOperator);
position.position(geoPos);
pos.position(position);
m_tabDts->publish(pos);
}
void ModuleTestEffectCluster::setEquipmentGearCharge(int participantId)
{
DEBUG_LOG(m_logger) << "setupEquipmentGearCharge";
TrainingAreaBase::EquipmentGearChargeState egs;
TrainingAreaBase::GearCharge charge;
std::vector<TrainingAreaBase::GearCharge> charges;
egs.equipmentNumber(participantId * -1); // ParticipantId
egs.sampleTime(QDateTime::currentMSecsSinceEpoch());
charges.resize(7);
charge.gearId(138);
charge.gearTypeId(801);
charge.chargeTypeId(367);
charge.remain(50);
charges.push_back(charge); // 0
charge.chargeTypeId(366);
charges.push_back(charge); // 1
charge.chargeTypeId(361);
charges.push_back(charge); // 2
charge.chargeTypeId(362);
charges.push_back(charge); // 3
charge.chargeTypeId(363);
charges.push_back(charge); // 4
charge.chargeTypeId(364);
charges.push_back(charge); // 5
charge.chargeTypeId(365);
charges.push_back(charge); // 6
egs.charge(charges);
m_tabDts->publish(egs);
}
void ModuleTestEffectCluster::onPartyChanged(const ParticipantManagement::Party &data, DataModification modType)
{
DEBUG_LOG(m_logger) << "onPartyChanged:" << data;
// Remove Participant:
if (modType == DataModification::eRemoved)
{
return;
}
if (data.id() != m_partyId)
{
return;
}
DEBUG_LOG(m_logger) << "onPartyChanged id= " << data.id();
if (m_ppmDtc->saaConnectedState(data.id()) == ParticipantManagement::ConnectState::Connected)
{
DEBUG_LOG(m_logger) << "onPartyChanged saaConnectedState == connected";
}
else if (m_ppmDtc->saaConnectedState(data.id()) == ParticipantManagement::ConnectState::Disconnected)
{
DEBUG_LOG(m_logger) << "onPartyChanged saaConnectedState == disconnected => connectToParty";
connectToParty();
}
}
//
// context of textCases
//
void ModuleTestEffectCluster::initTestCase()
{
//
// DdsConnector
//
DEBUG_LOG(m_logger) << "DDSConnector: m_domainId " << m_domainId << ", m_exerciseId " << m_exerciseId;
QFile file(s_REQUEST_SPL_FILE);
const bool bFileExists = file.exists();
QVERIFY2(bFileExists, "ERROR, SPL file does not exists in current path");
// cmd
m_ddsConnector.reset(new DDSConnector::DdsConnector(m_domainId, IDL::PartitionType::Exercise, m_exerciseId));
bool bInit = m_ddsConnector->init();
QVERIFY2(bInit, "ERROR, ddsConnector.init failed!!");
if (!bInit)
{
ERROR_LOG(m_logger) << " ERROR, ddsConnector.init failed!!";
return;
}
INFO_LOG(m_logger) << " ddsConnector.init successfull";
// cmd
m_ddsConnector->initPublisherSubscriber();
INFO_LOG(m_logger) << " ddsConnector.initPublisherSubscriber done";
//
// Aes
//
// cmd
m_aesFtc = AreaEffectSimulation::Interface::Ftc::create(m_ddsConnector);
QVERIFY2(m_aesFtc, "ERROR, create m_aesFtc failed!!");
bool bRet = m_aesFtc->enableAll();
QVERIFY2(bRet, "ERROR, enableAll failed!!");
// cmd
m_aesDtc = AreaEffectSimulation::Interface::Dtc::create(m_ddsConnector);
QVERIFY2(m_aesDtc, "ERROR, create m_aesDtc failed!!");
bRet = bRet && m_aesDtc->enableAll();
QVERIFY2(bRet, "ERROR, enableAll failed!!");
m_aesFtc->enableAll();
m_aesDtc->enableAesItemView();
m_aesDtc->enableChargeEffect();
DEBUG_LOG(m_logger) << " waitForHistoricalDataAesItemView... ";
m_aesDtc->waitForHistoricalDataAesItemView(2000);
DEBUG_LOG(m_logger) << " waitForHistoricalDataAesItemView... Done";
QMap<qint32, AreaEffectSimulation::AesItemView> aesItemViewsCont = m_aesDtc->aesItemViews();
DEBUG_LOG(m_logger) << " aesItemViewsCont.size() " << aesItemViewsCont.size();
//
// PDM
//
m_pdmDtc = ProjectDataManagement::Interface::Dtc::create(m_ddsConnector);
QVERIFY2(m_pdmDtc, "ERROR, create m_pdmDtc failed!!");
//
// ISM
//
m_ismDtc = InfrastructureManagement::Interface::Dtc::create(m_ddsConnector);
QVERIFY2(m_ismDtc, "ERROR, create m_ismDtc failed!!");
bRet = bRet && m_ismDtc->enableAll();
QVERIFY2(bRet, "ERROR, enableAll failed!!");
//
// EXM ExerciseManagement
//
m_exmDtc = ExerciseManagement::Interface::Dtc::create(m_ddsConnector);
QVERIFY2(m_exmDtc, "ERROR, create m_exmDtc failed!!");
bRet = bRet && m_exmDtc->enableAll();
QVERIFY2(bRet, "ERROR, enableAll m_exmDtc failed!!");
m_exmDtc->waitForHistoricalDataExercise(2000);
DEBUG_LOG(m_logger) << " waitForHistoricalDataExercise... Done";
const ExerciseManagement::Exercise &exercise = m_exmDtc->exercise(m_exerciseId);
QVERIFY2(exercise.id() == m_exerciseId, "ERROR, exercise failed!!");
m_traingAreaId = exercise.trainingAreaId();
DEBUG_LOG(m_logger) << " ExerciseManagement"
<< ", m_traingAreaId = " << m_traingAreaId;
//
// PPM ParticipantManagement
//
//
m_ppmDtc = ParticipantManagement::Interface::Dtc::create(m_ddsConnector);
QVERIFY2(m_ppmDtc, "ERROR, create m_ppmDtc failed!!");
bRet = bRet && m_ppmDtc->enableAll();
QVERIFY2(bRet, "ERROR, enableAll m_ppmDtc failed!!");
m_ppmFtc = ParticipantManagement::Interface::Ftc::create(m_ddsConnector);
QVERIFY2(m_ppmFtc, "ERROR, create m_ppmFtc failed!!");
bRet = bRet && m_ppmFtc->enableAll();
m_ppmFtc->enableSetSimulatedPosition();
m_ppmFtc->enableModifyParticipantData();
QVERIFY2(bRet, "ERROR, m_ppmFtc enableAll failed!!");
m_tabDts = TrainingAreaBase::Interface::Dts::create(m_ddsConnector);
QVERIFY2(m_tabDts, "ERROR, create m_tabDts failed!!");
bRet = bRet && m_tabDts->enableAll();
QVERIFY2(bRet, "ERROR, m_tabDts enableAll failed!!");
DEBUG_LOG(m_logger) << "disconnectFromParty";
disconnectFromParty();
// connectToParty();
// connect(m_ppmDtc.get(), &ParticipantManagement::Interface::Dtc::participantChanged,
// this, &ModuleTestEffectCluster::onParticipantChanged);
connect(m_ppmDtc.get(), &ParticipantManagement::Interface::Dtc::partyChanged, this, &ModuleTestEffectCluster::onPartyChanged);
connect(m_aesDtc.get(), &AreaEffectSimulation::Interface::Dtc::aesItemViewChanged, this, &ModuleTestEffectCluster::onAesItemViewChanged, Qt::UniqueConnection);
connect(m_aesDtc.get(),
&AreaEffectSimulation::Interface::Dtc::trajectoryTimeAwareChanged,
this,
&ModuleTestEffectCluster::onTrajectoryTimeAwareChanged,
Qt::UniqueConnection);
connect(m_aesDtc.get(), &AreaEffectSimulation::Interface::Dtc::effectsChanged, this, &ModuleTestEffectCluster::onEffectsChanged, Qt::UniqueConnection);
connect(m_aesDtc.get(), &AreaEffectSimulation::Interface::Dtc::chargeEffectChanged, this, &ModuleTestEffectCluster::onChargeEffectChanged, Qt::UniqueConnection);
// spend some for the eventLoop to "consume" existing topics/samples:
for (int i = 0; i < 10; ++i)
QTest::qWait(1000);
}
void ModuleTestEffectCluster::init()
{
// init will be called before each test function is executed.
m_counterDds.reset();
}
void ModuleTestEffectCluster::cleanupTestCase()
{
// finish last (dds) calls:
waitForData([]() { return false; }, 10);
INFO_LOG(m_logger) << " ddsConnector destroy...";
m_ddsConnector.reset();
INFO_LOG(m_logger) << " ddsConnector destroy...DONE";
}
int main(int argc, char *argv[])
{
NGLCoreApplication app(argc, argv);
app.createLogger("ModuleTest_ExplosionCluster", "log4cxx_aes.props");
// aesModuleTestExplosionCluster -v2 test_long -e42 -d139
// ^^^ ^^^^ // no space!!!
// aesModuleTestExplosionCluster -v2 test_long -e42
// aesModuleTestExplosionCluster -v2 test_long -e42
// aesModuleTestExplosionCluster test_long -e42
// aesModuleTestExplosionCluster -e42
CmdLineParser options;
options.setUnitModuleTestMode(true);
std::cout << " consider 'aesModuleTestEffectCluster -e42' " << std::endl;
if (!options.init(true)) // showHelp , exitOnBadOption
return -1;
if (options.exerciseId() <= 0)
{
fprintf(stderr, "ExerciseId not set!\n");
return -2;
}
std::cout << " DomainId = " << options.domainId() << " - ExerciseId = " << options.exerciseId() << std::endl;
if (options.isSet(QStringLiteral("exerciseid")))
--argc;
if (options.isSet(QStringLiteral("domainid")))
--argc;
const QStringList &slPositionalArgs = options.positionalArguments();
for (const QString &item : qAsConst(slPositionalArgs))
std::cout << " item = " << item << std::endl;
ModuleTestEffectCluster tc(options.domainId(), options.exerciseId());
return QTest::qExec(&tc, argc, argv);
}
@@ -0,0 +1,192 @@
/**
* @RDE_HEADER@
* ModuleTest
* $Id$
* $HeadURL$
* $Author$
*/
// Aufruf: ./aesModuleTestEffectCluster -e42
// Mehr Debug-Ausgaben:
// Aufruf: ./aesModuleTestEffectCluster -v2 -e42
#pragma once
#include <DDS/DDSConnector/dds_connector.h>
#include <LtsCommandLineParser/LtsCommandLineParser.h>
#include <LtsCoordinate/lts_coordinate.h>
#include <AreaEffectSimulation/aes_ftc.h>
#include <AreaEffectSimulation/aes_dtc.h>
#include <AreaEffectSimulation/logger.h>
#include <Plugins/InfrastructureManagement/ism_data_plugin_interface.h>
#include <Plugins/ProjectDataManagement/pdm_data_plugin_interface.h>
#include <ExerciseManagement/exm_dtc.h>
#include <ParticipantManagement/ppm_dtc.h>
#include <ParticipantManagement/ppm_ftc.h>
#include <TrainingAreaBase/tab_dts.h>
#include <QCoreApplication>
#include <QtTest/QTest>
#include <memory>
using namespace AreaEffectSimulation; // JUST FOR LOGGER_T
using namespace ParticipantManagement;
class CmdLineParser : public LtsCommandLineParser::LtsCommandLineParser
{
public:
CmdLineParser()
: LtsCommandLineParser(ProvideCommandLineParameterOptions(DomainId|ExerciseId|NoVersion))
{
}
};
class ModuleTestEffectCluster : public QObject
, protected AreaEffectSimulation::Interface::Ftc::EffectClusterModifyReplyHandler
, protected AreaEffectSimulation::Interface::Ftc::AcknowledgeExternalAesItemReplyHandler
, protected ParticipantManagement::Interface::Ftc::ModifyPartyDataReplyHandler
, protected ParticipantManagement::Interface::Ftc::ModifyParticipantDataReplyHandler
{
Q_OBJECT
public:
ModuleTestEffectCluster(int domainId, int exerciseId);
protected:
void onEffectClusterModifyReply(const Core::FunctionReplyObject &replyObject) override;
void onAcknowledgeExternalAesItemReply(const Core::FunctionReplyObject &replyObject) override;
void onModifyPartyDataReply(const Core::FunctionReplyObject &replyObject) override;
void onModifyParticipantDataReply(const Core::FunctionReplyObject &replyObject) override;
void onAesItemViewChanged(const AreaEffectSimulation::AesItemView &aesItemView, DataModification modType);
void onEffectsChanged(const AreaEffectSimulation::Effects &effects, DataModification modType);
void onChargeEffectChanged(const ChargeEffect &chargeEffect, DataModification modType);
void onTrajectoryTimeAwareChanged(const AreaEffectSimulation::TrajectoryTimeAware &data, DataModification modType);
// pre-condition
void disconnectFromParty();
void connectToParty();
void participantChangeRequest();
void participantDeleteRequest();
void setParticipantPos(int participantId);
void setEquipmentGearCharge(int participantId);
// helper
bool waitForData(const std::function<bool()> &func, int retryCount = 10);
EffectCluster getEcForTneVerification(const QString &eaName = QStringLiteral("ModuleTest_TneVerification__"), double rotation = 0);
int doEffectClusterModifyRequest();
int doExplosionClusterSingleEffectOnlyModifyRequest(const ExplosionClusterSingleEffectOnlyRequest &request);
std::vector< Core::RelativePositionRelativeTime > parseTrajectory(const QString &filePath);
int sendAcknowledgeExternalAesItemRequest(int aesItemId);
void sendTabExFire();
void waitForEffectStates(int lineNumber, int durPrep = 5, int durAct = 60, int durExp = 30);
private Q_SLOTS:
//
// TestCases
//
// void initTestCase_data(); // will be called to create a global test data table.
void initTestCase(); // will be called before the first test function is executed.
void init(); // will be called before each test function is executed.
void cleanupTestCase();
private:
void onPartyChanged(const ParticipantManagement::Party &data, DataModification modType);
void dumpCnt();
private:
int m_domainId{-1};
int m_exerciseId{-1};
int m_traingAreaId{-1};
std::shared_ptr<DDSConnector::DdsConnector> m_ddsConnector;
int32_t m_partyId{4};
ParticipantManagement::ParticipantData m_participant0; // Unit
ParticipantManagement::ParticipantData m_participant1; // Participant
const ProjectDataManagement::L27_EffectorId m_effectorId{ProjectDataManagement::L27_EffectorId::C3};
QString m_reference;
const QString m_identifier{QStringLiteral("451200")};
int m_aesItemId{-1};
std::shared_ptr<AreaEffectSimulation::Interface::Ftc> m_aesFtc;
std::shared_ptr<AreaEffectSimulation::Interface::Dtc> m_aesDtc;
std::shared_ptr<ProjectDataManagement::Interface::Dtc> m_pdmDtc;
std::shared_ptr<InfrastructureManagement::Interface::Dtc> m_ismDtc;
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_ppmDtc;
std::shared_ptr<ParticipantManagement::Interface::Ftc> m_ppmFtc;
std::shared_ptr<ExerciseManagement::Interface::Dtc> m_exmDtc;
std::shared_ptr<TrainingAreaBase::Interface::Dts> m_tabDts;
EffectCluster m_data;
Effects m_effects;
long m_objectRequestedTimePointMsec{-1};
bool m_replyError{false};
QTimer *m_timer;
bool m_participantChangeRequestDone{false};
const QVector<AreaEffectSimulation::AesEffectState> m_effectStates = {AesEffectState::EsReceived,
AesEffectState::EsCreated,
AesEffectState::EsActivated,
AesEffectState::EsExpired};
int m_effectStateCounter = 0;
struct counterDds
{
// ExplosionCluster
int cntEffectCluster{0};
// AesItemView
int cntAtEffectCluster{0};
int cntAtEffectClusterGunToTargetLine{0};
// Effects
int cntEffectClusterEffects{0};
// Trajectory
int cntTrajectory{0};
void reset()
{
cntEffectCluster = 0;
cntAtEffectCluster = 0;
cntAtEffectClusterGunToTargetLine = 0;
cntEffectClusterEffects = 0;
cntTrajectory = 0;
}
}
m_counterDds;
LOGGER_T m_logger;
};