Skip to content

Instantly share code, notes, and snippets.

@gianpiero
Created July 8, 2019 18:49
Show Gist options
  • Save gianpiero/4beaa36eb9e21b70a92e5fadb52c0576 to your computer and use it in GitHub Desktop.
Save gianpiero/4beaa36eb9e21b70a92e5fadb52c0576 to your computer and use it in GitHub Desktop.
<?xml version="1.0" encoding="UTF-8"?>
<!--
(c) 2005-2015 Copyright, Real-Time Innovations. All rights reserved.
No duplications, whole or partial, manual or electronic, may be made
without express written permission. Any such copies, or revisions thereof,
must display this notice unaltered.
This code contains trade secrets of Real-Time Innovations, Inc.
-->
<dds xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://community.rti.com/schema/5.3.1/rti_dds_profiles.xsd" version="5.3.1">
<!-- types -->
<types>
<struct name="ShapeType" extensibility="appendable">
<member name="color" type="string" stringMaxLength="128" id="0" key="true"/>
<member name="x" type="long" id="1"/>
<member name="y" type="long" id="2"/>
<member name="shapesize" type="long" id="3"/>
<member name="ull" type="uint64" id="4"/>
</struct>
<enum name="ShapeFillKind" extensibility="appendable">
<enumerator name="SOLID_FILL" value="0"/>
<enumerator name="TRANSPARENT_FILL" value="1"/>
<enumerator name="HORIZONTAL_HATCH_FILL" value="2"/>
<enumerator name="VERTICAL_HATCH_FILL" value="3"/>
</enum>
<struct name="ShapeTypeExtended" baseType="ShapeType" extensibility="appendable">
<member name="fillKind" type="nonBasic" nonBasicTypeName="ShapeFillKind" id="5"/>
<member name="angle" type="float" id="6"/>
</struct>
</types>
<!-- Qos Library -->
<qos_library name="QosLibrary">
<qos_profile name="DefaultProfile" base_name="BuiltinQosLibExp::Generic.StrictReliable" is_default_qos="true">
<participant_qos>
<transport_builtin>
<mask>UDPV4 | SHMEM</mask>
</transport_builtin>
<!-- Turn on monitoring -->
<!-- Begin Monitoring
<property>
<value>
<element>
<name>rti.monitor.library</name>
<value>rtimonitoring</value>
</element>
<element>
<name>rti.monitor.create_function_ptr</name>
<value>$(NDDS_MONITOR)</value>
</element>
</value>
</property>
End Monitoring -->
</participant_qos>
</qos_profile>
</qos_library>
<!-- Domain Library -->
<domain_library name="MyDomainLibrary">
<domain name="MyDomain" domain_id="0">
<register_type name="ShapeType" type_ref="ShapeType"/>
<topic name="Square" register_type_ref="ShapeType"/>
</domain>
</domain_library>
<!-- Participant library -->
<domain_participant_library name="MyParticipantLibrary">
<domain_participant name="Zero" domain_ref="MyDomainLibrary::MyDomain">
<publisher name="MyPublisher">
<data_writer name="MySquareWriter" topic_ref="Square"/>
</publisher>
<subscriber name="MySubscriber">
<data_reader name="MySquareReader" topic_ref="Square"/>
</subscriber>
</domain_participant>
</domain_participant_library>
</dds>
###############################################################################
# (c) 2005-2015 Copyright, Real-Time Innovations. All rights reserved. #
# No duplications, whole or partial, manual or electronic, may be made #
# without express written permission. Any such copies, or revisions thereof, #
# must display this notice unaltered. #
# This code contains trade secrets of Real-Time Innovations, Inc. #
###############################################################################
"""Samples's writer."""
from sys import path as sysPath
from os import path as osPath
from time import sleep
filepath = osPath.dirname(osPath.realpath(__file__))
sysPath.append(filepath + "/../../../")
import rticonnextdds_connector as rti
connector = rti.Connector("MyParticipantLibrary::Zero",
filepath + "/../ShapeExample.xml")
outputDDS = connector.getOutput("MyPublisher::MySquareWriter")
#get the native pointer to the c dynamic data
nativePtr = outputDDS.instance.getNative()
#create the mapping for the c function
import ctypes
rtin_DDS_DynamicData_set_ulonglong = rti.rti.DDS_DynamicData_set_ulonglong
rtin_DDS_DynamicData_set_ulonglong.restype = ctypes.c_int
rtin_DDS_DynamicData_set_ulonglong.argtypes = [ctypes.c_void_p,ctypes.c_char_p,ctypes.c_int,ctypes.c_ulonglong]
for i in range(1, 500):
ulonlongvalue = 18446744073709551615;
#call the native function
membername = "ull"
rtin_DDS_DynamicData_set_ulonglong(nativePtr,membername.encode('utf8') , 0 ,ulonlongvalue)
# outputDDS.instance.setNumber("ull", ulonlongvalue) --> If we use this one we get 0! --> ERROR
outputDDS.instance.setNumber("x", i)
outputDDS.instance.setNumber("y", i*2)
outputDDS.instance.setNumber("shapesize", 30)
outputDDS.instance.setString("color", "BLUE")
outputDDS.write()
sleep(2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment