This repository is an example of a tango device server.
This tango device server is suppose to control a virtual scope throught tcp/ip.
The project contains:
- An utils folder with:
- tcp server (
utils/tcp_server.py
) which serves a dummy scope. - A dummy plc tango device that pushes event.
- tcp server (
- A tests folder that contains a test protocol. It can be used to validate the required features.
- A training python package which contains an empty tango device file and a basic example of a possible implementation (Please look at it only after the training session)
- Request should end with
b'\n'
- Get scope state:
- request:
b'STATE\n'
- reply:
b'State:ON\n'
orb'State:OFF\n'
- request:
- Turn acquisition on:
- request:
b'ON\n'
- reply:
b'State:ON\n'
- request:
- Turn acquisition off:
- request:
b'OFF\n'
- reply:
b'State:OFF\n'
- request:
- Get Waveform:
- request:
b'DATA\n'
- reply example:
b'Data:2.938672855118084e-10, 1.9815536275824104e-10, ...., 3.88063288479267e-10\n''
- request:
This protocol can be test from the linux shell with a basic tcp client:
$ nc host port
ON
State:ON
from telnetlib import Telnet
telnet = Telnet()
telnet.open(host, port)
telnet.write(b"ON\n")
print(telnet.read_until(b"\n"))
telnet.close()
Validation:
- tests/test_device.py::test_server_running: PASSED
Requires:
- tango property: host
- tango property: port
Validation:
- tests/test_device.py::test_server_running: PASSED
Requires:
- Tango command "TurnOn" (start the acquisition)
- Tango command "TurnOff" (stop the acquisition)
- Tango State handling:
- FAULT if the connection failed
- ON if the scope is acquiring
- OFF if the scope is not acquiring
Validation:
- tests/test_device.py::test_on_state
- tests/test_device.py::test_off_state
Requires:
- A Tango spectrum float attribute named "waveform".
- It should be not allowed to read this attribute if the scope is not acquiring.
Validation:
- tests/test_device.py::test_wavefrom_attribute
Requires:
- A Tango scalar float attribute named "maximum"
Validation:
- tests/test_device.py::test_maximum_attribute
Requires:
- Tango writable scalar float attribute named "offset"
- Add the offset setpoint to the waveform tango attribute
Validation:
- tests/test_device.py::test_offset_attribute
Requires:
- Tango expert polled command named "Update"
- The Update command should manage the tcp request.
Requires:
- Add a alarm tag attribute: test/fakeplc/1/fb_r1_105s_dia_rto_ad__inalarm
- Switch the tango State to
Alarm
if the tag is raised
Run with setup.py:
$ python3 setup.py test
Test state:
- xfail: The feature is not implemented.
- ERROR: The test has failed.
- PASSED: The test succeed.
Add extra test argument:
$ python3 setup.py --addopts "-k test_server_running"
(The previous command line runs only the test named test_server_running
)
python setup build
$ sudo yum makecache --enablerepo=maxiv-testing
$ sudo yum install tangods-training --enablerepo=maxiv-testing
$ python setup.py install --user