MOD: made modification to fit to SIMCORE
This commit is contained in:
@@ -25,7 +25,7 @@
|
||||
|
||||
|
||||
#define __MOVEMENT_SERVER_PORT__ 5556
|
||||
#define __EXTERNAL_SERVER_PORT__ 5557
|
||||
#define __SENSOR_SERVER_PORT__ 5557
|
||||
|
||||
|
||||
|
||||
@@ -35,13 +35,11 @@ namespace Entities
|
||||
Entity::Entity(const SimCore::Identifier OwnID,
|
||||
std::string EnttityName,
|
||||
WHISPER::SourceType OwnType,
|
||||
SimCore::Identifier ParentID,
|
||||
SimCore::EntityKind EntityKind,
|
||||
std::uint32_t GroundTruthPort,
|
||||
ushort CommandPort,
|
||||
bool online):
|
||||
EntityName_(EnttityName),
|
||||
ParentID_(ParentID),
|
||||
EntityKind_(EntityKind),
|
||||
online_(online)
|
||||
|
||||
@@ -50,11 +48,11 @@ namespace Entities
|
||||
OwnShipTrack = std::make_shared<SimCore::SimTrack>(OwnID, OwnType, EntityKind);
|
||||
OwnShipTrack->setPosition(SimCore::Position());
|
||||
|
||||
MovemtServer_ = std::make_shared<DirectCommunication::DirectCommunicationServer>(__MOVEMENT_SERVER_PORT__);
|
||||
MovemtServer_ = std::make_shared<DirectCommunication::DirectCommunicationServer>(__MOVEMENT_SERVER_PORT__);
|
||||
|
||||
// ExternalCommsServer_ = std::make_shared<DirectCommunication::DirectCommunicationServer>(8000);
|
||||
CommandCommsServer_ = std::make_shared<DirectCommunication::DirectCommunicationServer>(CommandPort);
|
||||
|
||||
// ExternalCommsServer_->registerMessageCallback(std::bind(&Entity::handleExternalComms,this,std::placeholders::_1));
|
||||
CommandCommsServer_->registerMessageCallback(std::bind(&Entity::handleExternalComms,this,std::placeholders::_1));
|
||||
}
|
||||
|
||||
|
||||
@@ -62,6 +60,7 @@ namespace Entities
|
||||
{
|
||||
PodController_->stopAllPods();
|
||||
stop();
|
||||
MovemtServer_.reset();
|
||||
}
|
||||
|
||||
|
||||
@@ -187,13 +186,26 @@ namespace Entities
|
||||
// LOG_S(INFO)<< "new POS: LAT: "<< OwnShipTrack->getPosition().getGeodesicPos()(SimCore::LATITUDE) << " LON: " << OwnShipTrack->getPosition().getGeodesicPos()(SimCore::LONGITUDE);
|
||||
}
|
||||
}
|
||||
|
||||
if (MovemtServer_->countClients() == 0)
|
||||
{
|
||||
MovementWorkerStarted = false;
|
||||
}
|
||||
}
|
||||
|
||||
void Entity::handleExternalComms(std::string msg)
|
||||
{
|
||||
LOG_S(INFO)<<msg;
|
||||
auto MoveOrder = Orders::MoveOrder::unpack(msg);
|
||||
|
||||
LOG_S(INFO)<<this->ExternalCommsServer_->countClients();
|
||||
if (MoveOrder != nullptr)
|
||||
{
|
||||
if(MoveOrder->Speed.isValid()) this->setSpeed(MoveOrder->Speed.getValue());
|
||||
|
||||
}
|
||||
|
||||
LOG_S(INFO)<<this->CommandCommsServer_->countClients();
|
||||
CommandCommsServer_->sendMessage("Hello Client");
|
||||
|
||||
}
|
||||
|
||||
@@ -202,14 +214,11 @@ namespace Entities
|
||||
|
||||
void Entity::MainLoop()
|
||||
{
|
||||
auto server = DirectCommunication::DirectCommunicationServer(35000);
|
||||
LOG_S(INFO)<< "main loop started";
|
||||
while (!stopMainLoop)
|
||||
{
|
||||
handleMovement();
|
||||
LOG_S(INFO)<<server.countClients();
|
||||
server.sendMessage("hello client");
|
||||
LOG_S(INFO)<<"hello";
|
||||
|
||||
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user