ADD: added ownship sender to Sensorcontrol and fixed a bug in trackfusion

This commit is contained in:
hwinkel
2024-02-16 12:21:20 +01:00
parent f839ea4815
commit bf263b64f6
5 changed files with 58 additions and 13 deletions

View File

@@ -61,11 +61,12 @@ namespace Entities
{
PodController_ = std::make_shared<kubecontrol::PodController>("docs/config");
SensorManager_ = std::make_unique<Entities::SensorManager>(OwnID, PodController_,SensorPort_);
OwnShipTrack = std::make_shared<SimCore::SimTrack>(OwnID, EnttityName, EntityKind,EntitySide);
OwnShipTrack->setPosition(SimCore::Position());
OwnShipTrack->RCS.setValue(RCS_);
SensorManager_ = std::make_unique<Entities::SensorManager>(OwnShipTrack, PodController_,SensorPort_);
MovemtServer_ = std::make_shared<DirectCommunication::DirectCommunicationServer>(__MOVEMENT_SERVER_PORT__,OwnID.getUUID());
CommandCommsServer_ = std::make_shared<DirectCommunication::DirectCommunicationServer>(CommandPort,OwnID.getUUID());
@@ -154,7 +155,8 @@ namespace Entities
LOG_S(INFO)<<"Pods stoppt";
stopChild();
LOG_S(INFO)<<"childs stoppt";
SensorManager_->stop();
for (std::vector<std::thread>::iterator it = threads.begin(); it != threads.end();)
@@ -296,12 +298,12 @@ namespace Entities
auto TrackListRequest = Orders::TracklistRequest::unpack(whisperMsg);
if (TrackListRequest == nullptr)
{
break;
break;
}
if (TrackListRequest->EntityID == OwnShipTrack->getIdentifier())
{
std::string senderUUID = whisperMsg.senderUUID_;
CommandCommsServer_->sendMessage(SensorManager_->getTrackListUpdate()->buildMessage().serialize(OwnShipTrack->getIdentifier().getUUID()),senderUUID);
CommandCommsServer_->sendMessage(SensorManager_->getTrackListUpdate()->buildMessage(),senderUUID);
}
break;
}

View File

@@ -12,13 +12,27 @@
namespace Entities
{
SensorManager::SensorManager(SimCore::Identifier OwnID,std::shared_ptr<kubecontrol::PodController> PodController,ushort sensorPort):
OwnId_(OwnID),PodController_(PodController)
SensorManager::SensorManager(std::shared_ptr<SimCore::SimTrack> OwnShipTrack,std::shared_ptr<kubecontrol::PodController> PodController,ushort sensorPort):
OwnId_(OwnShipTrack->getIdentifier()),OwnShiptrack_(OwnShipTrack),PodController_(PodController)
{
SensorServer_ = std::make_shared<DirectCommunication::DirectCommunicationServer>(SensorPort_,OwnID.getUUID());
SensorServer_ = std::make_shared<DirectCommunication::DirectCommunicationServer>(SensorPort_,OwnId_.getUUID());
SensorServer_->registerMessageCallback(std::bind(&SensorManager::handlSensorMessages,this,std::placeholders::_1));
stopUpdater_ = false;
sensorUpdater_ = std::thread(&SensorManager::sendOwnShipTrackToSensors,this);
}
void SensorManager::stop()
{
for(auto sensor: SensorStore)
{
PodController_->stopPod(sensor.first);
}
SensorStore.clear();
stopUpdater_ = true;
sensorUpdater_.join();
}
void SensorManager::startSensor(std::shared_ptr<kubecontrol::KubePod> pod,SimCore::SensorKinds SensorKind)
{
PodController_->startPod(pod);
@@ -120,7 +134,7 @@ namespace Entities
{
return;
}
sensor->TrackStore.addTrack(std::move(track));
sensor->TrackStore.addTrack(track);
// auto it = SensorStore.find(uuidSensor);
// if( it != SensorStore.end())
// {
@@ -237,6 +251,23 @@ namespace Entities
}
void SensorManager::sendOwnShipTrackToSensors()
{
while(stopUpdater_ == false)
{
if(SensorServer_->countClients() > 0)
{
SensorServer_->sendMessage(this->OwnShiptrack_->buildMessage());
}
std::this_thread::sleep_for(std::chrono::milliseconds(500));
}
}

View File

@@ -116,7 +116,7 @@ namespace TrackList
for (auto it :TrackStore_)
{
// update->addTrack(*it.second);
update->addTrack(*it.second);
}