ADD: added orders and implemented order and moveorder and test for moveorder
This commit is contained in:
@@ -7,10 +7,10 @@
|
||||
#include <thread>
|
||||
#define CATCH_CONFIG_MAIN
|
||||
#include <catch2/catch.hpp>
|
||||
#include <SimCore/Templates/Entity.hpp>
|
||||
#include <Entities/Entity.hpp>
|
||||
|
||||
// SimCore::Identifier OwnID, SimCore::Identifier ParentID, SimCore::SensorKinds SensorKind,std::uint32_t GroundTruthPort, std::uint32_t ParentPort,std::string ParentIPAddress
|
||||
class Ship : public SimCore::Entity
|
||||
class Ship : public Entities::Entity
|
||||
{
|
||||
public:
|
||||
Ship(SimCore::Identifier OwnID,
|
||||
|
||||
12
tests/test_EntityImplementation.cpp
Normal file
12
tests/test_EntityImplementation.cpp
Normal file
@@ -0,0 +1,12 @@
|
||||
#include <iostream>
|
||||
#include <loguru.hpp>
|
||||
|
||||
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
LOG_S(INFO)<< "hello world";
|
||||
|
||||
return 0;
|
||||
}
|
||||
71
tests/test_MoveOrder.cpp
Normal file
71
tests/test_MoveOrder.cpp
Normal file
@@ -0,0 +1,71 @@
|
||||
|
||||
#include "Orders/Order.hpp"
|
||||
#include "SimCore/Identifier.hpp"
|
||||
#include "WHISPER/Messages/Message.hpp"
|
||||
#include <chrono>
|
||||
#include <memory>
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
#define CATCH_CONFIG_MAIN
|
||||
#include <catch2/catch.hpp>
|
||||
|
||||
#include <Orders/MoveOrder.hpp>
|
||||
#include <SimCore/IdentifierMaker.hpp>
|
||||
|
||||
|
||||
SCENARIO("Testing the SimCore Sensor")
|
||||
{
|
||||
GIVEN("different Attributes for a Track in different forms")
|
||||
{
|
||||
auto OrderID = SimCore::Identifier(0,1);
|
||||
auto IDMaker = SimCore::IdentifierMaker();
|
||||
auto ID1 = IDMaker.getNewIdentifier(0, SimCore::ObjectSource::INTERNAL);
|
||||
auto ID2 = IDMaker.getNewIdentifier(1, SimCore::ObjectSource::INTERNAL);
|
||||
|
||||
std::shared_ptr<Orders::MoveOrder> movOrd = std::make_shared<Orders::MoveOrder>(OrderID,*ID1.get(),*ID2.get(),WHISPER::SourceType::GATEWAY);
|
||||
auto list = std::vector<std::shared_ptr<Orders::Order>>();
|
||||
list.push_back(movOrd);
|
||||
|
||||
auto rev = list[0];
|
||||
std::shared_ptr<Orders::MoveOrder> mvOrder2 = nullptr;
|
||||
if (rev->getOrderType() == Orders::MOVE_ORDER) {
|
||||
mvOrder2 = std::dynamic_pointer_cast<Orders::MoveOrder>(rev);
|
||||
}
|
||||
|
||||
WHEN("constructing Track Object with data")
|
||||
{
|
||||
|
||||
movOrd->setPosition(SimCore::Position(100,200,500));
|
||||
auto pos = SimCore::Position(100,200,500);
|
||||
bool res = false;
|
||||
if (movOrd->getPosition() == pos) {
|
||||
res = true;
|
||||
}
|
||||
|
||||
movOrd->setSpeed(100);
|
||||
|
||||
movOrd->setStartTime(duration_cast<std::chrono::seconds>(std::chrono::system_clock::now().time_since_epoch()).count()+3);
|
||||
|
||||
THEN("check if Track attributes are correct")
|
||||
{
|
||||
REQUIRE(movOrd->getOrderID() == OrderID);
|
||||
REQUIRE(movOrd->getOrderingEntity() == *ID1.get());
|
||||
REQUIRE(movOrd->getOrderedEntity() == *ID2.get());
|
||||
REQUIRE(res == true);
|
||||
REQUIRE(movOrd->getSpeed() == 100);
|
||||
REQUIRE(movOrd->getStartTime() > duration_cast<std::chrono::seconds>(std::chrono::system_clock::now().time_since_epoch()).count());
|
||||
|
||||
std::this_thread::sleep_for(std::chrono::seconds(5));
|
||||
REQUIRE(movOrd->getStartTime() < duration_cast<std::chrono::seconds>(std::chrono::system_clock::now().time_since_epoch()).count());
|
||||
|
||||
|
||||
REQUIRE(mvOrder2->getSpeed() == movOrd->getSpeed());
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
} //THEN
|
||||
} // WHEN
|
||||
} // GIVEN
|
||||
} //SCENARIO
|
||||
@@ -1,14 +1,14 @@
|
||||
|
||||
#include "SimCore/Identifier.hpp"
|
||||
#include <SimCore/Identifier.hpp>
|
||||
#include <SimCore/SimCore.hpp>
|
||||
#include <memory>
|
||||
#include <thread>
|
||||
#define CATCH_CONFIG_MAIN
|
||||
#include <catch2/catch.hpp>
|
||||
#include <SimCore/Templates/Sensor.hpp>
|
||||
#include <Entities/Sensor.hpp>
|
||||
|
||||
// SimCore::Identifier OwnID, SimCore::Identifier ParentID, SimCore::SensorKinds SensorKind,std::uint32_t GroundTruthPort, std::uint32_t ParentPort,std::string ParentIPAddress
|
||||
class Radar : public SimCore::Sensor
|
||||
class Radar : public Entities::Sensor
|
||||
{
|
||||
public:
|
||||
Radar(SimCore::Identifier OwnID,
|
||||
@@ -17,7 +17,7 @@ class Radar : public SimCore::Sensor
|
||||
std::uint32_t GroundTruthPort,
|
||||
std::uint32_t ParentPort,
|
||||
std::string ParentIPAddress,
|
||||
std::string radarType):SimCore::Sensor(OwnID, ParentID, SensorKind, GroundTruthPort, ParentPort, ParentIPAddress),radarType_(radarType)
|
||||
std::string radarType):Sensor(OwnID, ParentID, SensorKind, GroundTruthPort, ParentPort, ParentIPAddress),radarType_(radarType)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user