| 64 | }; |
| 65 | |
| 66 | int write_if_ready(const RelayConfig& config, |
| 67 | RelayConfigDataWriter_var& relay_config_data_writer, |
| 68 | const DDS::WaitSet_var& waiter, |
| 69 | bool& write_pending) |
| 70 | { |
| 71 | DDS::PublicationMatchedStatus matches{}; |
| 72 | if (relay_config_data_writer->get_publication_matched_status(matches) != ::DDS::RETCODE_OK) { |
| 73 | ACE_ERROR((LM_ERROR, "ERROR: get_publication_matched_status failed\n")); |
| 74 | return EXIT_FAILURE; |
| 75 | } |
| 76 | if (matches.current_count) { |
| 77 | if (relay_config_data_writer->write(config, DDS::HANDLE_NIL) != ::DDS::RETCODE_OK) { |
| 78 | ACE_ERROR((LM_ERROR, "ERROR: write failed\n")); |
| 79 | return EXIT_FAILURE; |
| 80 | } |
| 81 | constexpr DDS::Duration_t timeout{DDS::DURATION_INFINITE_SEC, DDS::DURATION_INFINITE_NSEC}; |
| 82 | if (relay_config_data_writer->wait_for_acknowledgments(timeout) != ::DDS::RETCODE_OK) { |
| 83 | ACE_ERROR((LM_ERROR, "ERROR: wait_for_acknowledgments failed\n")); |
| 84 | return EXIT_FAILURE; |
| 85 | } |
| 86 | std::cerr << "Sent control" << std::endl; |
| 87 | if (!keep_running) { |
| 88 | std::cerr << "Running until status contains requested changes" << std::endl; |
| 89 | } |
| 90 | DDS::StatusCondition_var status_cond{relay_config_data_writer->get_statuscondition()}; |
| 91 | DDS::ConditionSeq conditions; |
| 92 | waiter->get_conditions(conditions); |
| 93 | for (DDS::UInt32 i{0}; i < conditions.length(); ++i) { |
| 94 | if (status_cond == conditions[i]) { |
| 95 | waiter->detach_condition(status_cond); |
| 96 | } |
| 97 | } |
| 98 | write_pending = false; |
| 99 | } |
| 100 | return EXIT_SUCCESS; |
| 101 | } |
| 102 | |
| 103 | int read(const RelayConfigDataReader_var& reader, RelayConfig& config, bool& done) |
| 104 | { |
no test coverage detected