From 5fd709f21f4d3bddf74c106a06f87d45d35d448c Mon Sep 17 00:00:00 2001 From: Nobuhiko Miyamoto Date: Wed, 9 Feb 2022 09:43:28 +0900 Subject: [PATCH 1/2] [compat] add SSMTransport option. --- src/ext/transport/SSMTransport/CMakeLists.txt | 20 ++++++++++ src/ext/transport/SSMTransport/SSMOutPort.cpp | 2 +- .../transport/SSMTransport/SSMTransport.cpp | 38 +++++++++++++++++-- .../transport/SSMTransport/rtc.ssm.conf.in | 10 +++++ 4 files changed, 66 insertions(+), 4 deletions(-) create mode 100644 src/ext/transport/SSMTransport/rtc.ssm.conf.in diff --git a/src/ext/transport/SSMTransport/CMakeLists.txt b/src/ext/transport/SSMTransport/CMakeLists.txt index b163d20df..a0b483f90 100644 --- a/src/ext/transport/SSMTransport/CMakeLists.txt +++ b/src/ext/transport/SSMTransport/CMakeLists.txt @@ -5,7 +5,14 @@ project (SSMTransport LANGUAGES CXX) +set(SSM_ROOT ${SSM_ROOT} CACHE PATH "set SSM_ROOT") + + + link_directories(${ORB_LINK_DIR}) +if(SSM_ROOT) + link_directories(${SSM_ROOT}/lib ${SSM_ROOT}/lib64) +endif() add_definitions(${ORB_C_FLAGS_LIST}) if(WIN32) @@ -29,6 +36,9 @@ if(VXWORKS AND NOT RTP) openrtm_set_link_props_shared(${target}) openrtm_include_rtm(${target}) target_link_libraries(${target} ${libs} ssm) + if(SSM_ROOT) + target_include_directories(${target} SYSTEM PUBLIC ${SSM_ROOT}/include) + endif() install(TARGETS ${target} LIBRARY DESTINATION ${INSTALL_RTM_EXT_DIR}/transport ARCHIVE DESTINATION ${INSTALL_RTM_EXT_DIR}/transport @@ -43,6 +53,9 @@ else() openrtm_include_rtm(${target}) openrtm_set_link_props_shared(${target}) target_link_libraries(${target} PRIVATE ${libs} ${RTM_LINKER_OPTION} ssm) + if(SSM_ROOT) + target_include_directories(${target} SYSTEM PUBLIC ${SSM_ROOT}/include) + endif() set_target_properties(${target} PROPERTIES PREFIX "") set_target_properties(${target} PROPERTIES @@ -65,3 +78,10 @@ if(VXWORKS) endif(RTP) endif(VXWORKS) +set(INSTALL_SSMTRANSPORT_DIR ${INSTALL_RTM_EXT_DIR}/transport) +configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/rtc.ssm.conf.in ${PROJECT_BINARY_DIR}/rtc.ssm.conf @ONLY) +install( + FILES ${PROJECT_BINARY_DIR}/rtc.ssm.conf + DESTINATION ${INSTALL_RTM_ETC_DIR}/transport + COMPONENT ext) diff --git a/src/ext/transport/SSMTransport/SSMOutPort.cpp b/src/ext/transport/SSMTransport/SSMOutPort.cpp index 2a5ec249d..b79548a69 100644 --- a/src/ext/transport/SSMTransport/SSMOutPort.cpp +++ b/src/ext/transport/SSMTransport/SSMOutPort.cpp @@ -67,7 +67,7 @@ namespace RTC RTC_PARANOID(("SSMOutPort::init()")); m_stream_name = prop.getProperty("ssm.stream_name", "sensor_test"); - std::string stream_id_str = prop.getProperty("stream_id", "0"); + std::string stream_id_str = prop.getProperty("ssm.stream_id", "0"); if(!coil::stringTo(m_stream_id, stream_id_str.c_str())) { RTC_ERROR(("stream_id is invalid value")); diff --git a/src/ext/transport/SSMTransport/SSMTransport.cpp b/src/ext/transport/SSMTransport/SSMTransport.cpp index 0f158d5ab..b3b1bc538 100644 --- a/src/ext/transport/SSMTransport/SSMTransport.cpp +++ b/src/ext/transport/SSMTransport/SSMTransport.cpp @@ -24,6 +24,34 @@ namespace SSMRTM { + static const char* const ssm_inport_option[] = + { + "stream_name.__value__", "sensor_test", + "stream_name.__widget__", "text", + "stream_id.__value__", "0", + "stream_id.__widget__", "spin", + "stream_id.__constraint__", "0 <= x <= 10000", + "" + }; + static const char* const ssm_outport_option[] = + { + "stream_name.__value__", "sensor_test", + "stream_name.__widget__", "text", + "stream_id.__value__", "0", + "stream_id.__widget__", "spin", + "stream_id.__constraint__", "0 <= x <= 10000", + "stream_size.__value__", "0", + "stream_size.__widget__", "spin", + "stream_size.__constraint__", "0 <= x <= 2147483647", + "life_ssm_time.__value__", "5.0", + "life_ssm_time.__widget__", "slider.0.01", + "life_ssm_time.__constraint__", "0.00 <= x <= 1000.00", + "cycle_ssm_time.__value__", "0.05", + "cycle_ssm_time.__widget__", "slider.0.01", + "cycle_ssm_time.__constraint__", "0.00 <= x <= 1000.00", + "" + }; + ManagerActionListener::ManagerActionListener() { @@ -69,25 +97,29 @@ extern "C" { if(!initSSM()) { - return; + throw; } { + coil::Properties prop(SSMRTM::ssm_inport_option); RTC::OutPortConsumerFactory& factory(RTC::OutPortConsumerFactory::instance()); factory.addFactory("ssm", ::coil::Creator< ::RTC::OutPortConsumer, ::RTC::SSMInPort>, ::coil::Destructor< ::RTC::OutPortConsumer, - ::RTC::SSMInPort>); + ::RTC::SSMInPort>, + prop); } { + coil::Properties prop(SSMRTM::ssm_outport_option); RTC::InPortConsumerFactory& factory(RTC::InPortConsumerFactory::instance()); factory.addFactory("ssm", ::coil::Creator< ::RTC::InPortConsumer, ::RTC::SSMOutPort>, ::coil::Destructor< ::RTC::InPortConsumer, - ::RTC::SSMOutPort>); + ::RTC::SSMOutPort>, + prop); } diff --git a/src/ext/transport/SSMTransport/rtc.ssm.conf.in b/src/ext/transport/SSMTransport/rtc.ssm.conf.in new file mode 100644 index 000000000..5eeec8bb3 --- /dev/null +++ b/src/ext/transport/SSMTransport/rtc.ssm.conf.in @@ -0,0 +1,10 @@ +logger.enable: YES +logger.log_level: DEBUG +#logger.file_name: stdout + +manager.modules.load_path: @CMAKE_INSTALL_PREFIX@/@INSTALL_SSMTRANSPORT_DIR@ +manager.preload.modules: SSMTransport@CMAKE_SHARED_LIBRARY_SUFFIX@ + +manager.components.preactivation: ConsoleOut0, ConsoleIn0 +manager.components.preconnect: ConsoleOut0.in?interface_type=ssm&ssm.stream_name=test_stream&dataflow_type=pull, ConsoleIn0.out?interface_type=ssm&ssm.stream_name=test_stream + From b865b5d3a9d4d1c68a5e8b17e361893aa559f37d Mon Sep 17 00:00:00 2001 From: Nobuhiko Miyamoto Date: Fri, 11 Mar 2022 09:14:13 +0900 Subject: [PATCH 2/2] [compat] fixed raise exeption. --- src/ext/transport/SSMTransport/SSMInPort.cpp | 1 + src/ext/transport/SSMTransport/SSMOutPort.cpp | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/src/ext/transport/SSMTransport/SSMInPort.cpp b/src/ext/transport/SSMTransport/SSMInPort.cpp index 1e58f229a..82c260d2e 100644 --- a/src/ext/transport/SSMTransport/SSMInPort.cpp +++ b/src/ext/transport/SSMTransport/SSMInPort.cpp @@ -80,6 +80,7 @@ namespace RTC if(!coil::stringTo(m_stream_id, stream_id_str.c_str())) { RTC_ERROR(("stream_id is invalid value")); + throw std::bad_alloc(); } } diff --git a/src/ext/transport/SSMTransport/SSMOutPort.cpp b/src/ext/transport/SSMTransport/SSMOutPort.cpp index b79548a69..fce1c8b11 100644 --- a/src/ext/transport/SSMTransport/SSMOutPort.cpp +++ b/src/ext/transport/SSMTransport/SSMOutPort.cpp @@ -71,21 +71,25 @@ namespace RTC if(!coil::stringTo(m_stream_id, stream_id_str.c_str())) { RTC_ERROR(("stream_id is invalid value")); + throw std::bad_alloc(); } std::string stream_size_str = prop.getProperty("ssm.stream_size", "0"); if(!coil::stringTo(m_stream_size, stream_size_str.c_str())) { RTC_ERROR(("stream_size is invalid value")); + throw std::bad_alloc(); } std::string life_ssm_time_str = prop.getProperty("ssm.life_ssm_time", "5.0"); if(!coil::stringTo(m_life_ssm_time, life_ssm_time_str.c_str())) { RTC_ERROR(("life_ssm_time is invalid value")); + throw std::bad_alloc(); } std::string cycle_ssm_time_str = prop.getProperty("ssm.cycle_ssm_time", "0.05"); if(!coil::stringTo(m_cycle_ssm_time, cycle_ssm_time_str.c_str())) { RTC_ERROR(("cycle_ssm_time is invalid value")); + throw std::bad_alloc(); } if(m_stream_size > 0)