ADD: added smal prototype

This commit is contained in:
Henry Winkel
2023-07-05 18:29:09 +02:00
parent 64f37e59f5
commit 5485c8550e

View File

@@ -104,11 +104,13 @@ namespace Entities
{ {
LOG_S(INFO)<< "TODO: starting the movement app from here"; LOG_S(INFO)<< "TODO: starting the movement app from here";
if (MovemtServer_->countClients() > 0 ) if (MovemtServer_->countClients() > 0 )
{ {
auto msg = MovemtServer_->getLatestMessage(); std::string msg = MovemtServer_->getLatestMessage();
if (*msg.get() == "Hello Server") if (msg == "Hello Server")
{ {
MovementWorkerStarted = true;
MovemtServer_->sendMessage(OwnShipTrack->buildMessage().serialize()); MovemtServer_->sendMessage(OwnShipTrack->buildMessage().serialize());
} }
} }
@@ -122,16 +124,27 @@ namespace Entities
void Entity::MainLoop() void Entity::MainLoop()
{ {
LOG_S(INFO)<< "main loop started";
while (!stopMainLoop) while (!stopMainLoop)
{ {
if (!MovementWorkerStarted) if (!MovementWorkerStarted)
{ {
startMovementWorker(); startMovementWorker();
}else
{
std::string msg = MovemtServer_->getLatestMessage();
auto newTrack = SimCore::SimTrack::unpack(msg);
if (newTrack != nullptr)
{
OwnShipTrack->setPosition(newTrack->getPosition());
LOG_S(INFO)<< "new POS: LAT: "<< OwnShipTrack->getPosition().getGeodesicPos()(SimCore::LATITUDE) << " LON: " << OwnShipTrack->getPosition().getGeodesicPos()(SimCore::LONGITUDE);
} }
}
std::this_thread::sleep_for(std::chrono::milliseconds(500)); std::this_thread::sleep_for(std::chrono::milliseconds(500));
} }