msg: RTPS: pass RTPS ID msg definition file as an EmPy global var

This commit is contained in:
TSC21
2018-09-24 19:28:40 +02:00
committed by Beat Küng
parent eac8f8813a
commit 0227ea3835
7 changed files with 44 additions and 57 deletions
+3 -11
View File
@@ -19,14 +19,6 @@ from px_generate_uorb_topic_files import MsgScope # this is in Tools/
topic_names = [single_spec.short_name for single_spec in spec]
send_topics = [s.short_name for idx, s in enumerate(spec) if scope[idx] == MsgScope.SEND]
recv_topics = [s.short_name for idx, s in enumerate(spec) if scope[idx] == MsgScope.RECEIVE]
yaml_file = os.path.abspath('uorb_rtps_message_ids.yaml')
try:
msg_ids = parse_yaml_msg_id_file(yaml_file)
except OSError as e:
if e.errno == errno.ENOENT:
raise IOError(errno.ENOENT, os.strerror(errno.ENOENT), yaml_file)
else:
raise
}@
/****************************************************************************
*
@@ -97,7 +89,7 @@ void RtpsTopics::publish(uint8_t topic_ID, char data_buffer[], size_t len)
switch (topic_ID)
{
@[for topic in send_topics]@
case @(rtps_message_id(msg_ids, topic)): // @(topic)
case @(rtps_message_id(ids, topic)): // @(topic)
{
@(topic)_ st;
eprosima::fastcdr::FastBuffer cdrbuffer(data_buffer, len);
@@ -125,7 +117,7 @@ bool RtpsTopics::hasMsg(uint8_t *topic_ID)
switch (_sub_topics[_next_sub_idx])
{
@[for topic in recv_topics]@
case @(rtps_message_id(msg_ids, topic)): if (_@(topic)_sub.hasMsg()) *topic_ID = @(rtps_message_id(msg_ids, topic)); break;
case @(rtps_message_id(ids, topic)): if (_@(topic)_sub.hasMsg()) *topic_ID = @(rtps_message_id(ids, topic)); break;
@[end for]@
default:
printf("Unexpected topic ID to check hasMsg\n");
@@ -149,7 +141,7 @@ bool RtpsTopics::getMsg(const uint8_t topic_ID, eprosima::fastcdr::Cdr &scdr)
switch (topic_ID)
{
@[for topic in recv_topics]@
case @(rtps_message_id(msg_ids, topic)): // @(topic)
case @(rtps_message_id(ids, topic)): // @(topic)
if (_@(topic)_sub.hasMsg())
{
@(topic)_ msg = _@(topic)_sub.getMsg();