Multiple domains in Lua

6 posts / 0 new
Last post
Offline
Last seen: 8 years 2 weeks ago
Joined: 04/29/2016
Posts: 9
Multiple domains in Lua

I would like to use Lua to perform unit testing and I have tried to read the documentation for Lua and the RTI Prototyper. The application that shall be tested takes input from one domain and produces output in another so the script has to be able work in both domains and assert the results.

Is my understanding correct that it is not possible to use multiple domains within one script in this manner?
Is it possible with the RTI Connector and Python to use multiple domains (e.g. multiple instances of rti.Connector) in one script?

gianpiero's picture
Offline
Last seen: 9 months 3 weeks ago
Joined: 06/02/2010
Posts: 177

Hello Micke, 

You are correct: as of today you cannot have multiple domain using the RTI Prototyper with Lua. But you can do it using the RTI Connector in Python. I create and example for you here:

https://gist.github.com/gianpiero/2977a4b7e03068d21090579458fb32e8

As you can see in the linked files, you can create two connector in the same file:

connector = rti.Connector("MyParticipantLibrary::Zero", filepath + "/../ShapeExample.xml");
output = connector.getOutput("MyPublisher::MySquareWriter")
connectorOne = rti.Connector("MyParticipantLibrary::One", filepath + "/../ShapeExample.xml");
outputOne = connectorOne.getOutput("MyPublisher::MySquareWriter")

Just put the writer.py in your example/python/simple directory and the xml file in example/pythong and run 

python simple/writer 

from the example/python directory

Let me know if you have more questions,
 Gianpiero

Offline
Last seen: 8 years 2 weeks ago
Joined: 04/29/2016
Posts: 9

Thanks, the RTI Connector with Python works great for my unit tests.
/Micke

Offline
Last seen: 8 years 2 weeks ago
Joined: 04/29/2016
Posts: 9

Is there any way to dispose of existing instances using the RTI Connector?

Even better if there is a possibility to remove and recreate the DataWriter entities from the RTI Connector because I am trying to clean up (e.g. get rid of transient local samples) between test steps.

gianpiero's picture
Offline
Last seen: 9 months 3 weeks ago
Joined: 06/02/2010
Posts: 177

Hello,

Is there any way to dispose of existing instances using the RTI Connector?
 
There wasn't.. but I added a delete() function to the python connector that calls the correspondent C function. 
You can use it by calling:
 
connector = rti.Connector(.....)
 ...
 ...
 connector.delete()
 
and all the entities will get removed. 
 
For more detail on the change, check this commit
 
Even better if there is a possibility to remove and recreate the DataWriter entities from the RTI Connector because I am trying to clean up (e.g. get rid of transient local samples) between test steps.
 
No. You have to use the connector.delete(). The idea behind the connector is too keep the number of API limited.. of course being an experimental product we are open to input: is calling connector.delete() acceptable for you and your use case?
 
Best,
   Gianpiero
Offline
Last seen: 8 years 2 weeks ago
Joined: 04/29/2016
Posts: 9

Thank you that also solved another problem for me. When using python unittest, I was having trouble when I had too many TestCases in my test suite because each TestCase created 2 new connectors. With the delete() being called in the class tear down I don't have this problem any more :-)

On a slightly related note I saw in the code that there is a wait() function in the Input class, but no example/documentation for how to use this. I am currently using take/sleep in a loop to emulate taking samples with a timeout, but I would prefer to use a real wait and then take. Is the timeout parameter in seconds? What is the return value when an instance is received or when the wait times out?

Regards
/Micke