ADD: added tracklist update and systemstate update messages with tests and some improvements of simtrack
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
|
||||
#include <thread>
|
||||
#define CATCH_CONFIG_MAIN
|
||||
#include <catch2/catch.hpp>
|
||||
|
||||
@@ -24,7 +25,8 @@ SCENARIO("Testing the SimCore Sensor")
|
||||
THEN("check if Track attributes are correct")
|
||||
{
|
||||
REQUIRE(Name.getValue() == "hello world");
|
||||
REQUIRE(Name.getValidity() == true);
|
||||
REQUIRE(Name.isValid() == true);
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
||||
REQUIRE(Name.getWriteTime() < std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count());
|
||||
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ SCENARIO("Testing the SimCorePositionClass")
|
||||
REQUIRE(std::abs(pos1b.getGeocentricPos()(SimCore::Z) - GeocentPos1(SimCore::Z)) <= 0.001);
|
||||
|
||||
|
||||
REQUIRE(pos2.getGeocentricPos() == pos1.getGeocentricPos());
|
||||
REQUIRE(pos2 == pos1);
|
||||
REQUIRE(pos2.getGeodesicPos() == pos1.getGeodesicPos());
|
||||
|
||||
|
||||
|
||||
72
tests/test_SystemStateUpdate.cpp
Normal file
72
tests/test_SystemStateUpdate.cpp
Normal file
@@ -0,0 +1,72 @@
|
||||
|
||||
#include "SimCore/EffectorData.hpp"
|
||||
#include "SimCore/Identifier.hpp"
|
||||
#include "SimCore/SimCore.hpp"
|
||||
#include "WHISPER/Messages/Message.hpp"
|
||||
#define CATCH_CONFIG_MAIN
|
||||
#include <catch2/catch.hpp>
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <SimCore/Messages/SystemStateUpdate.hpp>
|
||||
|
||||
|
||||
SCENARIO("Testing the SimCore Sensor")
|
||||
{
|
||||
GIVEN("different Attributes for a Track in different forms")
|
||||
{
|
||||
|
||||
SimCore::Identifier OwnID;
|
||||
|
||||
SimCore::SystemStateUpdate update(OwnID);
|
||||
|
||||
SimCore::Identifier Idsensor1;
|
||||
std::string NameSensor1 = "TRS3D";
|
||||
SimCore::SensorData sensor1(Idsensor1,NameSensor1);
|
||||
sensor1.SensorKind.setValue(SimCore::SensorKinds::RADAR);
|
||||
sensor1.Range.setValue(120000);
|
||||
sensor1.Status.setValue(SimCore::Status::ACTIVE);
|
||||
update.addSensorData(sensor1);
|
||||
|
||||
|
||||
SimCore::Identifier Idsensor2;
|
||||
std::string NameSensor2 = "Smart-S";
|
||||
SimCore::SensorData sensor2(Idsensor2,NameSensor2);
|
||||
sensor1.SensorKind.setValue(SimCore::SensorKinds::RADAR);
|
||||
sensor1.Range.setValue(90000);
|
||||
sensor1.Status.setValue(SimCore::Status::OFF);
|
||||
update.addSensorData(sensor1);
|
||||
|
||||
SimCore::Identifier Ideffector1;
|
||||
std::string NameEffector1 = "MLG";
|
||||
|
||||
SimCore::EffectorData effector1(Ideffector1,NameEffector1);
|
||||
update.addEffectorData(effector1);
|
||||
|
||||
|
||||
|
||||
|
||||
auto msg = update.buildMessage().serialize();
|
||||
|
||||
auto resMess = WHISPER::Message(msg);
|
||||
auto resUpdate = SimCore::SystemStateUpdate::unpack(resMess);
|
||||
WHEN("constructing Track Object with data")
|
||||
{
|
||||
|
||||
THEN("check if Track attributes are correct")
|
||||
{
|
||||
REQUIRE(resMess.msgType_ == WHISPER::MsgType::SYSTEMSTATE_UPDATE);
|
||||
REQUIRE(resUpdate->getOwnID() == OwnID);
|
||||
REQUIRE(resUpdate->getSensorData().size() == 2);
|
||||
REQUIRE(resUpdate->getEffectorData().size() == 1);
|
||||
REQUIRE(resUpdate->getEffectorData()[0].EffectorID == effector1.EffectorID);
|
||||
REQUIRE(resUpdate->getEffectorData()[0].Name.getValue() == NameEffector1);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
} //THEN
|
||||
} // WHEN
|
||||
} // GIVEN
|
||||
} //SCENARIO
|
||||
59
tests/test_TracklistUpdate.cpp
Normal file
59
tests/test_TracklistUpdate.cpp
Normal file
@@ -0,0 +1,59 @@
|
||||
|
||||
#include "SimCore/Identifier.hpp"
|
||||
#include "SimCore/Messages/SimTrack.hpp"
|
||||
#include "SimCore/Position.hpp"
|
||||
#define CATCH_CONFIG_MAIN
|
||||
#include <catch2/catch.hpp>
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <SimCore/Messages/TracklistUpdate.hpp>
|
||||
|
||||
|
||||
SCENARIO("Testing the SimCore Sensor")
|
||||
{
|
||||
GIVEN("different Attributes for a Track in different forms")
|
||||
{
|
||||
SimCore::Identifier OwnID;
|
||||
SimCore::TracklistUpdate update(OwnID);
|
||||
SimCore::SimTrack track1;
|
||||
track1.Course.setValue(273);
|
||||
track1.Speed.setValue(11);
|
||||
track1.Pitch.setValue(45);
|
||||
|
||||
SimCore::Position pos1;
|
||||
pos1.setGeodesicPos(55, 10, 0);
|
||||
track1.setPosition(pos1);
|
||||
|
||||
update.addTrack(track1);
|
||||
|
||||
|
||||
WHEN("constructing Track Object with data")
|
||||
{
|
||||
|
||||
auto msg = update.buildMessage().serialize();
|
||||
|
||||
auto resMess = WHISPER::Message(msg);
|
||||
auto resUpdate = SimCore::TracklistUpdate::unpack(resMess);
|
||||
|
||||
THEN("check if Track attributes are correct")
|
||||
{
|
||||
REQUIRE(update.getOwnID() == OwnID);
|
||||
REQUIRE(update.getTracks().size() == 1);
|
||||
REQUIRE(resMess.msgType_ == WHISPER::MsgType::TRACKLIST_UPDATE);
|
||||
REQUIRE(resUpdate->getOwnID() == OwnID);
|
||||
REQUIRE(resUpdate->getTracks().size() == 1);
|
||||
REQUIRE(resUpdate->getTracks()[0].getIdentifier() == track1.getIdentifier());
|
||||
REQUIRE(resUpdate->getTracks()[0].Course.getValue() == 273);
|
||||
REQUIRE(resUpdate->getTracks()[0].Speed.getValue() == 11);
|
||||
REQUIRE(resUpdate->getTracks()[0].Pitch.getValue() == 45);
|
||||
REQUIRE(resUpdate->getTracks()[0].getPosition() == pos1);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
} //THEN
|
||||
} // WHEN
|
||||
} // GIVEN
|
||||
} //SCENARIO
|
||||
Reference in New Issue
Block a user