tango-simlib: Easily generate TANGO device simulators

Hi All

SKA SA (CAMmers) created a user friendly library to ease creation of useful simulated devices.

tango-simlib is a library that aids the data-driven development of TANGO device simulators. It aims to make it easy to develop basic simulators while making it possible to implement more complex simulators. In addition to the simulated device interface, a separate TANGO simulation-control interface is generated, allowing the simulator to be manipulated via a back-channel to simulate e.g. failure conditions on the simulated device interface.

Using only the basic TANGO interface description captured via a POGO generated XMI file, a basic simulator with attributes and no-op command handlers can be generated with no further coding. Attribute simulation parameters and simple command behaviour can be specified using a JSON Simulator Description Datafile (SimDD). Custom behavior is implemented selectively using Python code by defining an override class containing a method for each command.

The planned SKA radio telescope chose the TANGO controls framework, thus this library will be of immediate convenience for use by the element consortia to develop their local control and monitoring (LMC) simulators and device simulators and also will enable telescope manager (TM) to support early assembly, integration and verification efforts.

The library is open-source and free for use:
Manual - https://media.readthedocs.org/pdf/tango-simlib/latest/tango-simlib.pdf
Homepage - http://tango-simlib.readthedocs.io
Source - https://github.com/ska-sa/tango-simlib
Author email - cam@ska.ac.za

NB: This package is also available on PyPI, allowing : pip install tango-simlib


Feel free to use, it’s free anyway smile!
Control And Monitoring @ SKA SA / CAMmers
Many thanks for posting all the links in the forum!!, I'll give it a try in the next weeks

Sergi Rubio
Keep on dancing,

http://www.tango-controls.org/resources/howto/how-fandango/
Hi Javas

Thanks

I had installed tango-simlib successfully, but from the documentation, i can not get what's the relationship between Weather and WeatherSimControl device
Hi Jimmy

The WeatherSimControl is used to control the behavior of the Weather simulator in real time. It can be used to change tango attributes values in real time and simulation parameters, that includes min/max range in which the tango attribute values should vary between in the case where the SimDD is used to specify simulation parameters.

As you will be aware that when the SimControl is registered into tangoDB, a device property model_key is provided, which is the name of the main simulator say Weather device. Through this model_key property the SimControl locates the main simulator model, which containing quantities and action handlers, whereby the quantities are represented by the tango attributes on the Weather simulator. Once the SimControl has a ref to the Weather device model, it gets all quantity/attribute names and populate the enum labels of the DevEnum attribute with label 'Attribute name'.

The attachment shows a scenario where a temperature attribute is selected for manipulation using WeatherSimControl, where its current value is incremented to 100 degrees Celsius, and the Weather device behaves accordingly. i.e it goes into alarm state, since the temperature attribute value is above the nominal range of the attribute values.

Feel free to keep in contact.

Javas
Edited 6 years ago
Hi Javas

many thanks, i get a little.

Based my old learning project "EvenTest" (EvenTest.xmi attached, it has three attributes: one Scalar attribute of DevLong named Value1, one Spectrum attribute of DevLong named Value2, one Image Attribute of DevULong named Value3), i find it seems tango-simlib only support Scalar datatype attribute process, not properly process Spectrum and Image attribute. At same time i find PyTango 9.2.1 seems not properly process unsigned data type.

firstly:
$ tango-simlib-generator –sim-data-file ~/Dev/EventTest/EventTest.xmi –directory . –dserver-name EventTest.py
$ tango-simlib-launcher –name ev/evtest/1 –class EventTest\
    –name evSim/evtest/1 –class EventTestSimControl\
    –server-command EventTest.py –port 0\
    –server-instance test\
    –put-device-property evSim/evtest/1:model_key:ev/evtest/1

Attempting to register TANGO device 'ev/evtest/1'
    class: 'EventTest'  server: 'EventTest/test'.
Attempting to register TANGO device 'evSim/evtest/1'
    class: 'EventTestSimControl'  server: 'EventTest/test'.
Setting device 'evSim/evtest/1' property 'model_key': 'ev/evtest/1'
Starting TANGO device server:
'python EventTest.py' 'test'
Traceback (most recent call last):
  File "EventTest.py", line 16, in <module>
    main()
  File "EventTest.py", line 11, in main
    model = configure_device_model(sim_data_files)
  File "/home/ics/py27env/local/lib/python2.7/site-packages/tango_simlib-0.1.4.dev336+master.dfc08ef-py2.7.egg/tango_simlib/tango_sim_generator.py", line 374, in configure_device_model
    klass_name = get_device_class(data_file)
  File "/home/ics/py27env/local/lib/python2.7/site-packages/tango_simlib-0.1.4.dev336+master.dfc08ef-py2.7.egg/tango_simlib/tango_sim_generator.py", line 460, in get_device_class
    parser_instance = get_parser_instance(data_file)
  File "/home/ics/py27env/local/lib/python2.7/site-packages/tango_simlib-0.1.4.dev336+master.dfc08ef-py2.7.egg/tango_simlib/tango_sim_generator.py", line 345, in get_parser_instance
    parser_instance.parse(sim_datafile)
  File "/home/ics/py27env/local/lib/python2.7/site-packages/tango_simlib-0.1.4.dev336+master.dfc08ef-py2.7.egg/tango_simlib/sim_xmi_parser.py", line 216, in parse
    class_description_data)
  File "/home/ics/py27env/local/lib/python2.7/site-packages/tango_simlib-0.1.4.dev336+master.dfc08ef-py2.7.egg/tango_simlib/sim_xmi_parser.py", line 343, in extract_attributes_description_data
    self._get_arg_type(description_data))
  File "/home/ics/py27env/local/lib/python2.7/site-packages/tango_simlib-0.1.4.dev336+master.dfc08ef-py2.7.egg/tango_simlib/sim_xmi_parser.py", line 456, in _get_arg_type
    .format(*(3*(arg_type,))))
AttributeError: PyTango has no attribute 'DevUInt.
 Try replacing 'UInt' with 'VarUInt' in the configuration file
It seems data type problem, so edit EventTest.xmi, change Value3 attribute's data type from DevULong to DevLong(pogoDsl:UIntType —> pogoDsl:IntType), re-run:
$ tango-simlib-generator –sim-data-file ~/Dev/EventTest/EventTest.xmi –directory . –dserver-name EventTest.py
$ tango-simlib-launcher –name ev/evtest/1 –class EventTest\
    –name evSim/evtest/1 –class EventTestSimControl\
    –server-command EventTest.py –port 0\
    –server-instance test\
    –put-device-property evSim/evtest/1:model_key:ev/evtest/1

Starting TANGO device server:
'python EventTest.py' 'test'
Exiting: Server exited with PyTango.DevFailed:
DevFailed[
DevError[
    desc = Attribute : Value2:  Data type is not supported
  origin = Attr::check_type
  reason = API_AttrWrongDefined
severity = ERR]
]

Exited
Segmentation fault (core dumped)
Edited 6 years ago
Hi Jimmy,

It seems like PyTango does not support attributes of data_type DevInt when we are creating them dynamically
attr = Attr(attribute_name, attr_dtype, rw_type)
I have created an issue regarding this on pytango.

At the moment we have made a separate branch on tango-simlib that handles this error appropriately.
try:
    attr = Attr(attribute_name, attr_dtype, rw_type)
except Exception as e:
    …

However at the moment I would suggest that you use DevShort or DevLong for your attribute data types. We do handle Spectrum attributes, but currently do not process Image attributes.

We do encourage you to also raise issues that you might be having whilst using the package on github.smile

Kind regards,
K.Madisa
Edited 6 years ago
 
Register or login to create to post a reply.