Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
paulbourelly999 committed Jul 18, 2024
1 parent 4173d33 commit d63f552
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
3 changes: 1 addition & 2 deletions src/tmx/TmxUtils/src/PluginClientClockAware.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,13 @@ namespace tmx::utils {
clock = std::make_shared<CarmaClock>(_simulation_mode);
if (_simulation_mode) {
AddMessageFilter<tmx::messages::TimeSyncMessage>(this, &PluginClientClockAware::HandleTimeSyncMessage);

}

}


void PluginClientClockAware::HandleTimeSyncMessage(tmx::messages::TimeSyncMessage &msg, routeable_message &routeableMsg ) {
if (sim::is_simulation_mode() ) {
if (_simulation_mode ) {
PLOG(logDEBUG) << "Message Received " << msg.to_string() << std::endl;
this->getClock()->update( msg.get_timestep() );
SetStatus(Key_Simulation_Time_Step, Clock::ToUtcPreciseTimeString(msg.get_timestep()));
Expand Down
12 changes: 9 additions & 3 deletions src/v2i-hub/SpatPlugin/src/SpatPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ namespace SpatPlugin {

SpatPlugin::SpatPlugin(const std::string &name) :PluginClientClockAware(name) {
spatReceiverThread = std::make_unique<tmx::utils::ThreadTimer>(std::chrono::milliseconds(5));
if ( PluginClientClockAware::isSimulationMode() ) {
if (PluginClientClockAware::isSimulationMode()) {
PLOG(logDEBUG1) << "Subscribing to TimeSyncMessages ... " ;
SubscribeToMessages();
}
}
Expand Down Expand Up @@ -64,6 +65,10 @@ namespace SpatPlugin {
try {
spatReceiverThread->AddPeriodicTick([this]()
{
// Ensure Clock has received its first update
if (PluginClientClockAware::isSimulationMode()) {
PluginClientClockAware::getClock()->wait_for_initialization();
}
this->processSpat();
if (!this->isConnected) {
SetStatus(keyConnectionStatus, "CONNECTED");
Expand All @@ -72,7 +77,7 @@ namespace SpatPlugin {
}, // end of lambda expression
std::chrono::milliseconds(5)
);
PluginClientClockAware::getClock()->wait_for_initialization();

spatReceiverThread->Start();
}
catch (const TmxException &e) {
Expand Down Expand Up @@ -110,6 +115,7 @@ namespace SpatPlugin {
PLOG(tmx::utils::logWARNING) << spatMode << " is an unsupport SPAT MODE. Defaulting to BINARY. Supported options are BINARY and J2735_HEX";
}
auto spat_ptr = std::make_shared<SPAT>();
PLOG(logDEBUG) << "Starting SPaT Receiver ...";
scConnection->receiveBinarySPAT(spat_ptr, PluginClientClockAware::getClock()->nowInMilliseconds());
tmx::messages::SpatMessage _spatMessage(spat_ptr);
auto spatEncoded_ptr = std::make_shared<tmx::messages::SpatEncodedMessage>();
Expand All @@ -133,7 +139,7 @@ namespace SpatPlugin {
}
}
void SpatPlugin::OnConfigChanged(const char *key, const char *value) {
PluginClientClockAware::OnConfigChanged(key, value);
PluginClient::OnConfigChanged(key, value);
UpdateConfigSettings();
}

Expand Down

0 comments on commit d63f552

Please sign in to comment.