ADD: added ownship sender to Sensorcontrol and fixed a bug in trackfusion
This commit is contained in:
@@ -23,9 +23,12 @@ namespace Entities
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
SensorManager(SimCore::Identifier OwnID,std::shared_ptr<kubecontrol::PodController> PodController, ushort sensorPort = 5557);
|
SensorManager(std::shared_ptr<SimCore::SimTrack> OwnShipTrack,std::shared_ptr<kubecontrol::PodController> PodController, ushort sensorPort = 5557);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief stops the sensor manager
|
||||||
|
*/
|
||||||
|
void stop();
|
||||||
/**
|
/**
|
||||||
*@brief starts a Sensor based on a KubePod Object
|
*@brief starts a Sensor based on a KubePod Object
|
||||||
*@param KubePod - a KubePod Item ready to start
|
*@param KubePod - a KubePod Item ready to start
|
||||||
@@ -116,10 +119,16 @@ namespace Entities
|
|||||||
*/
|
*/
|
||||||
std::unique_ptr<SimCore::TracklistUpdate> getTrackListUpdate();
|
std::unique_ptr<SimCore::TracklistUpdate> getTrackListUpdate();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief send the ownShipTrack to all connected Sensors
|
||||||
|
*/
|
||||||
|
void sendOwnShipTrackToSensors();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const SimCore::Identifier OwnId_;
|
const SimCore::Identifier OwnId_;
|
||||||
|
std::shared_ptr<SimCore::SimTrack> OwnShiptrack_;
|
||||||
ushort SensorPort_ = 5557;
|
ushort SensorPort_ = 5557;
|
||||||
|
|
||||||
std::map<std::string, std::shared_ptr<Sensor::SensorControl>> SensorStore;
|
std::map<std::string, std::shared_ptr<Sensor::SensorControl>> SensorStore;
|
||||||
@@ -128,6 +137,9 @@ namespace Entities
|
|||||||
|
|
||||||
TrackList::Trackfusion Trackfusion_;
|
TrackList::Trackfusion Trackfusion_;
|
||||||
|
|
||||||
|
std::thread sensorUpdater_;
|
||||||
|
std::atomic_bool stopUpdater_;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
std::shared_ptr<DirectCommunication::DirectCommunicationServer> SensorServer_ = nullptr;
|
std::shared_ptr<DirectCommunication::DirectCommunicationServer> SensorServer_ = nullptr;
|
||||||
|
|||||||
Submodule libs/KubeControl updated: 7bc5e3f22e...a413b412df
@@ -61,11 +61,12 @@ namespace Entities
|
|||||||
{
|
{
|
||||||
PodController_ = std::make_shared<kubecontrol::PodController>("docs/config");
|
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 = std::make_shared<SimCore::SimTrack>(OwnID, EnttityName, EntityKind,EntitySide);
|
||||||
OwnShipTrack->setPosition(SimCore::Position());
|
OwnShipTrack->setPosition(SimCore::Position());
|
||||||
OwnShipTrack->RCS.setValue(RCS_);
|
OwnShipTrack->RCS.setValue(RCS_);
|
||||||
|
|
||||||
|
SensorManager_ = std::make_unique<Entities::SensorManager>(OwnShipTrack, PodController_,SensorPort_);
|
||||||
|
|
||||||
MovemtServer_ = std::make_shared<DirectCommunication::DirectCommunicationServer>(__MOVEMENT_SERVER_PORT__,OwnID.getUUID());
|
MovemtServer_ = std::make_shared<DirectCommunication::DirectCommunicationServer>(__MOVEMENT_SERVER_PORT__,OwnID.getUUID());
|
||||||
|
|
||||||
CommandCommsServer_ = std::make_shared<DirectCommunication::DirectCommunicationServer>(CommandPort,OwnID.getUUID());
|
CommandCommsServer_ = std::make_shared<DirectCommunication::DirectCommunicationServer>(CommandPort,OwnID.getUUID());
|
||||||
@@ -155,6 +156,7 @@ namespace Entities
|
|||||||
stopChild();
|
stopChild();
|
||||||
LOG_S(INFO)<<"childs stoppt";
|
LOG_S(INFO)<<"childs stoppt";
|
||||||
|
|
||||||
|
SensorManager_->stop();
|
||||||
|
|
||||||
|
|
||||||
for (std::vector<std::thread>::iterator it = threads.begin(); it != threads.end();)
|
for (std::vector<std::thread>::iterator it = threads.begin(); it != threads.end();)
|
||||||
@@ -301,7 +303,7 @@ namespace Entities
|
|||||||
if (TrackListRequest->EntityID == OwnShipTrack->getIdentifier())
|
if (TrackListRequest->EntityID == OwnShipTrack->getIdentifier())
|
||||||
{
|
{
|
||||||
std::string senderUUID = whisperMsg.senderUUID_;
|
std::string senderUUID = whisperMsg.senderUUID_;
|
||||||
CommandCommsServer_->sendMessage(SensorManager_->getTrackListUpdate()->buildMessage().serialize(OwnShipTrack->getIdentifier().getUUID()),senderUUID);
|
CommandCommsServer_->sendMessage(SensorManager_->getTrackListUpdate()->buildMessage(),senderUUID);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,13 +12,27 @@
|
|||||||
|
|
||||||
namespace Entities
|
namespace Entities
|
||||||
{
|
{
|
||||||
SensorManager::SensorManager(SimCore::Identifier OwnID,std::shared_ptr<kubecontrol::PodController> PodController,ushort sensorPort):
|
SensorManager::SensorManager(std::shared_ptr<SimCore::SimTrack> OwnShipTrack,std::shared_ptr<kubecontrol::PodController> PodController,ushort sensorPort):
|
||||||
OwnId_(OwnID),PodController_(PodController)
|
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));
|
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)
|
void SensorManager::startSensor(std::shared_ptr<kubecontrol::KubePod> pod,SimCore::SensorKinds SensorKind)
|
||||||
{
|
{
|
||||||
PodController_->startPod(pod);
|
PodController_->startPod(pod);
|
||||||
@@ -120,7 +134,7 @@ namespace Entities
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
sensor->TrackStore.addTrack(std::move(track));
|
sensor->TrackStore.addTrack(track);
|
||||||
// auto it = SensorStore.find(uuidSensor);
|
// auto it = SensorStore.find(uuidSensor);
|
||||||
// if( it != SensorStore.end())
|
// 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));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ namespace TrackList
|
|||||||
|
|
||||||
for (auto it :TrackStore_)
|
for (auto it :TrackStore_)
|
||||||
{
|
{
|
||||||
// update->addTrack(*it.second);
|
update->addTrack(*it.second);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user