Skip to content

Commit 3dc3236

Browse files
committed
vtd: Handle scenario where VTD sends Stop signal
1 parent c78a4ef commit 3dc3236

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

optional/vtd/src/vtd_binding.cpp

+14-1
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,12 @@ class VtdBinding : public cloe::Simulator {
385385
// b) to catch any restart requests.
386386
this->readall_scp();
387387

388+
// We were operational when starting and are no longer.
389+
// VTD must have signalled that it was stopped.
390+
if (!operational_) {
391+
return sync.time() - sync.step_width();
392+
}
393+
388394
// Send items to TaskControl:
389395
for (auto v : vehicles_) {
390396
v->vtd_step_actuator(*scp_client_, config_.label_vehicle);
@@ -612,7 +618,14 @@ class VtdBinding : public cloe::Simulator {
612618
}
613619
}
614620

615-
void apply_scp_stop(boost::property_tree::ptree&) { operational_ = false; }
621+
void apply_scp_stop(boost::property_tree::ptree&) {
622+
// If SimCtrl.Stop is received and we are operational, then this has been
623+
// sent externally. Update the state and exit.
624+
if (operational_) {
625+
logger()->info("Received stop signal from VTD.");
626+
operational_ = false;
627+
}
628+
}
616629

617630
void apply_scenario_filename(boost::property_tree::ptree& xml) {
618631
auto scenario = xml.get<std::string>("<xmlattr>.filename", "none");

0 commit comments

Comments
 (0)