87 if (
_impl->_type ==
nullptr) {
88 std::cerr <<
"Invalid TypeSupport" << std::endl;
92 efd::DomainParticipantQos pqos = efd::PARTICIPANT_QOS_DEFAULT;
94 auto factory = efd::DomainParticipantFactory::get_instance();
95 _impl->_participant = factory->create_participant(0, pqos);
96 if (
_impl->_participant ==
nullptr) {
97 std::cerr <<
"Failed to create DomainParticipant" << std::endl;
102 _impl->_type.register_type(
_impl->_participant);
104 efd::PublisherQos pubqos = efd::PUBLISHER_QOS_DEFAULT;
105 _impl->_publisher =
_impl->_participant->create_publisher(pubqos,
nullptr);
106 if (
_impl->_publisher ==
nullptr) {
107 std::cerr <<
"Failed to create Publisher" << std::endl;
112 efd::TopicQos tqos = efd::TOPIC_QOS_DEFAULT;
113 const std::string topic_name {
"rt/clock" };
114 _impl->_topic =
_impl->_participant->create_topic(topic_name,
_impl->_type->getName(), tqos);
115 if (
_impl->_topic ==
nullptr) {
116 std::cerr <<
"Failed to create Topic" << std::endl;
121 efd::DataWriterQos wqos = efd::DATAWRITER_QOS_DEFAULT;
123 _impl->_datawriter =
_impl->_publisher->create_datawriter(
_impl->_topic, wqos, listener);
124 if (
_impl->_datawriter ==
nullptr) {
125 std::cerr <<
"Failed to create DataWriter" << std::endl;
143 eprosima::fastrtps::rtps::InstanceHandle_t instance_handle;
145 eprosima::fastrtps::types::ReturnCode_t rcode =
_impl->_datawriter->write(&
_impl->_clock, instance_handle);
147 if (rcode == erc::ReturnCodeValue::RETCODE_OK) {
151 if (rcode == erc::ReturnCodeValue::RETCODE_ERROR) {
152 std::cerr <<
"RETCODE_ERROR" << std::endl;
155 if (rcode == erc::ReturnCodeValue::RETCODE_UNSUPPORTED) {
156 std::cerr <<
"RETCODE_UNSUPPORTED" << std::endl;
160 if (rcode == erc::ReturnCodeValue::RETCODE_BAD_PARAMETER) {
161 std::cerr <<
"RETCODE_BAD_PARAMETER" << std::endl;
165 if (rcode == erc::ReturnCodeValue::RETCODE_PRECONDITION_NOT_MET) {
166 std::cerr <<
"RETCODE_PRECONDITION_NOT_MET" << std::endl;
170 if (rcode == erc::ReturnCodeValue::RETCODE_OUT_OF_RESOURCES) {
171 std::cerr <<
"RETCODE_OUT_OF_RESOURCES" << std::endl;
175 if (rcode == erc::ReturnCodeValue::RETCODE_NOT_ENABLED) {
176 std::cerr <<
"RETCODE_NOT_ENABLED" << std::endl;
180 if (rcode == erc::ReturnCodeValue::RETCODE_IMMUTABLE_POLICY) {
181 std::cerr <<
"RETCODE_IMMUTABLE_POLICY" << std::endl;
185 if (rcode == erc::ReturnCodeValue::RETCODE_INCONSISTENT_POLICY) {
186 std::cerr <<
"RETCODE_INCONSISTENT_POLICY" << std::endl;
190 if (rcode == erc::ReturnCodeValue::RETCODE_ALREADY_DELETED) {
191 std::cerr <<
"RETCODE_ALREADY_DELETED" << std::endl;
195 if (rcode == erc::ReturnCodeValue::RETCODE_TIMEOUT) {
196 std::cerr <<
"RETCODE_TIMEOUT" << std::endl;
200 if (rcode == erc::ReturnCodeValue::RETCODE_NO_DATA) {
201 std::cerr <<
"RETCODE_NO_DATA" << std::endl;
205 if (rcode == erc::ReturnCodeValue::RETCODE_ILLEGAL_OPERATION) {
206 std::cerr <<
"RETCODE_ILLEGAL_OPERATION" << std::endl;
210 if (rcode == erc::ReturnCodeValue::RETCODE_NOT_ALLOWED_BY_SECURITY) {
211 std::cerr <<
"RETCODE_NOT_ALLOWED_BY_SECURITY" << std::endl;
215 std::cerr <<
"UNKNOWN" << std::endl;