SDK: wait for devices to be in running

This commit is contained in:
Alexey Rybalchenko
2019-07-24 16:41:58 +02:00
parent 5d535163f1
commit ac8cd19915
5 changed files with 20 additions and 8 deletions

View File

@@ -320,23 +320,23 @@ auto DDS::SubscribeForCustomCommands() -> void
fDDSCustomCmd.send(id + ": " + ToStr(GetCurrentDeviceState()), to_string(senderId));
} else if (cmd == "INIT DEVICE") {
if (ChangeDeviceState(ToDeviceStateTransition(cmd))) {
fDDSCustomCmd.send(id + ": queued " + cmd + " transition", to_string(senderId));
fDDSCustomCmd.send(id + ": queued, " + cmd, to_string(senderId));
while (fStateQueue.WaitForNext() != DeviceState::InitializingDevice) {}
ChangeDeviceState(DeviceStateTransition::CompleteInit);
} else {
fDDSCustomCmd.send(id + ": could not queue " + cmd + " transition", to_string(senderId));
fDDSCustomCmd.send(id + ": could not queue, " + cmd , to_string(senderId));
}
} else if (fTransitions.find(cmd) != fTransitions.end()) {
if (ChangeDeviceState(ToDeviceStateTransition(cmd))) {
fDDSCustomCmd.send(id + ": queued " + cmd + " transition", to_string(senderId));
fDDSCustomCmd.send(id + ": queued, " + cmd, to_string(senderId));
} else {
fDDSCustomCmd.send(id + ": could not queue " + cmd + " transition", to_string(senderId));
fDDSCustomCmd.send(id + ": could not queue, " + cmd , to_string(senderId));
}
} else if (cmd == "END") {
if (ChangeDeviceState(ToDeviceStateTransition(cmd))) {
fDDSCustomCmd.send(id + ": queued " + cmd + " transition", to_string(senderId));
fDDSCustomCmd.send(id + ": queued, " + cmd, to_string(senderId));
} else {
fDDSCustomCmd.send(id + ": could not queue " + cmd + " transition", to_string(senderId));
fDDSCustomCmd.send(id + ": could not queue, " + cmd , to_string(senderId));
}
if (ToStr(GetCurrentDeviceState()) == "EXITING") {
unique_lock<mutex> lock(fStopMutex);

View File

@@ -170,7 +170,7 @@ auto DDSSession::SubmitAgents(Quantity agents) -> void
fImpl->fSession.sendRequest<dds::tools_api::SSubmitRequest>(submitRequest);
blocker.Wait();
// Not perfect, but best we can do
// perfect
WaitForIdleAgents(agents);
}

View File

@@ -80,6 +80,7 @@ class DDSSession
};
auto RequestCommanderInfo() -> CommanderInfo;
auto WaitForIdleAgents(Quantity) -> void;
auto WaitForOnlyIdleAgents() -> void;
auto WaitForExecutingAgents(Quantity) -> void;
auto ActivateTopology(const Path& topoFile) -> void;
auto ActivateTopology(DDSTopology) -> void;

View File

@@ -94,6 +94,8 @@ Topology::Topology(DDSTopology topo, DDSSession session)
if (parts[2] != "OK") {
LOG(error) << "state-changes-unsubscription failed with return code: " << parts[2];
}
} else if (parts[1] == "could not queue") {
LOG(warn) << "Could not queue " << parts[2] << " transition on " << senderId;
}
});
fDDSSession.StartDDSService();