Testing the double subscription

This commit is contained in:
Alexey Rybalchenko 2019-07-23 09:25:04 +02:00 committed by Dennis Klein
parent 18dc536f3d
commit cf26dd6aa7
5 changed files with 16 additions and 13 deletions

View File

@ -46,8 +46,6 @@ bool Sampler::ConditionalRun()
return false;
}
this_thread::sleep_for(chrono::seconds(5));
if (fIterations > 0) {
++fCounter;
if (fCounter >= fIterations) {

View File

@ -141,7 +141,7 @@ struct Machine_ : public state_machine_def<Machine_>
Row<RESETTING_TASK_S, AUTO_E, DEVICE_READY_S, DefaultFct, none>,
Row<RESETTING_DEVICE_S, AUTO_E, IDLE_S, DefaultFct, none>,
Row<OK_S, ERROR_FOUND_E, ERROR_S, DefaultFct, none>> {};
Row<OK_S, ERROR_FOUND_E, ERROR_S, DefaultFct, none>> {};
void CallStateChangeCallbacks(const State state) const
{

View File

@ -227,7 +227,11 @@ void DDSSession::StartDDSService() { fImpl->fDDSService.start(fImpl->fId); }
void DDSSession::SubscribeToCommands(std::function<void(const std::string& msg, const std::string& condition, uint64_t senderId)> cb)
{
fImpl->fSession.unsubscribe(); // TODO REMOVE THIS HACK!!!!
fImpl->fDDSCustomCmd.subscribe(cb);
fImpl->fDDSCustomCmd.subscribeOnReply([](const std::string& reply) {
LOG(debug) << reply;
});
}
void DDSSession::SendCommand(const std::string& cmd) { fImpl->fDDSCustomCmd.send(cmd, ""); }

View File

@ -65,6 +65,7 @@ Topology::Topology(DDSTopology topo, DDSSession session)
std::vector<uint64_t> deviceList = fDDSTopo.GetDeviceList();
for (const auto& d : deviceList) {
LOG(info) << "fair::mq::Topology Adding device " << d;
fTopologyState.emplace(d, DeviceStatus{ false, DeviceState::Ok });
}
fDDSSession.SubscribeToCommands([this](const std::string& msg, const std::string& condition, uint64_t senderId) {

View File

@ -18,21 +18,21 @@ using Topology = fair::mq::test::TopologyFixture;
TEST_F(Topology, Construction)
{
fair::mq::sdk::Topology topo(mDDSTopo, mDDSSession);
fair::mq::sdk::Topology topo(mDDSTopo, mDDSSession);
}
TEST_F(Topology, ChangeState)
{
using fair::mq::sdk::Topology;
using fair::mq::sdk::TopologyTransition;
using fair::mq::sdk::Topology;
using fair::mq::sdk::TopologyTransition;
Topology topo(mDDSTopo, mDDSSession);
fair::mq::tools::Semaphore blocker;
topo.ChangeState(TopologyTransition::Stop, [&](Topology::ChangeStateResult result) {
LOG(info) << result;
blocker.Signal();
});
blocker.Wait();
Topology topo(mDDSTopo, mDDSSession);
fair::mq::tools::Semaphore blocker;
topo.ChangeState(TopologyTransition::Stop, [&](Topology::ChangeStateResult result) {
LOG(info) << result;
blocker.Signal();
});
blocker.Wait();
}
} // namespace