=Paper= {{Paper |id=Vol-2023/140-143-paper-22 |storemode=property |title=Tango module for WebSocket connection |pdfUrl=https://ceur-ws.org/Vol-2023/140-143-paper-22.pdf |volume=Vol-2023 |authors=Vladimir Elkin,Evgeny Gorbachev,Georgy Sedykh }} ==Tango module for WebSocket connection== https://ceur-ws.org/Vol-2023/140-143-paper-22.pdf
     Proceedings of the XXVI International Symposium on Nuclear Electronics & Computing (NEC’2017)
                           Becici, Budva, Montenegro, September 25 - 29, 2017



      TANGO MODULE FOR WEBSOCKET CONNECTION
                      V.G. Elkina, E.V. Gorbachev, G.S. Sedykh
   Laboratory of High Energy Physics, Joint Institute for Nuclear Research, 6 Joliot-Curie, Dubna,
                                Moscow region, 141980, Russia

                                       E-mail: a elkin@jinr.ru


WebSocket is a computer communications protocol, providing full-duplex communication channels
over a single TCP connection. This module allows carrying out both monitoring and management of
TANGO devices. The module also has several modes of operation. Depending on the selected mode,
you can control one or more of required tango devices. The exchange of messages between the client
and the server is in JSON format.

Keywords: TANGO, WebSocket

                                       © 2017 Vladimir G. Elkin, Evgeny V. Gorbachev, Georgy S. Sedykh




                                                                                                     140
     Proceedings of the XXVI International Symposium on Nuclear Electronics & Computing (NEC’2017)
                           Becici, Budva, Montenegro, September 25 - 29, 2017




1. Introduction
        TANGO Controls is an object oriented control system based on CORBA for Windows, Linux
and Unix. It is a free open source controls toolkit for controlling any kind of hardware or software and
building SCADA systems. This system is used for controlling various kinds of lasers, synchrotrons,
physics experiments [1]. It is being actively developed by a consortium of research institutes including
JINR.
        TANGO Controls is based on the concept of Device Servers. Devices implement service
oriented and object oriented approaches to software architecture. At the moment, TANGO is actively
used by the Nuclotron control system.
        In TANGO, there are various tools for creating client applications. It’s TangoATK (JAVA),
QTango (C++), Taurus (Python) also LV bindings (LabView). They all use the standard TANGO
protocol (CORBA) for data exchange.
        For greater versatility, a TANGO module that provides communication via the standard
WebSocket protocol was developed.


2. HTML5 WebSocket protocol
        WebSocket [2] is a revolutionary new communication feature in the HTML5 specification,
which defines a full-duplex communication channel that operates over the Web through a single
socket. WebSocket is not just another incremental enhancement to conventional HTTP
communications; it represents a major advance, especially for real-time, event-driven web
applications.
        To establish a WebSocket connection, the client and server upgrade from the HTTP protocol
to the WebSocket protocol during their initial handshake.
        The WebSocket protocol is currently supported in most major browsers including Google
Chrome, Microsoft Edge, Internet Explorer, Firefox, Safari and Opera. WebSocket also requires web
applications on the server to support it.


3. WebSocketDS TANGO module for WebSocket connection
        This TANGO module is used to connect TANGO devices with the outside world using the
WebSocket protocol. It supports automatic retrieval of updated data, acquisition of data on demand,
and execution of commands. The TANGO-protocol’s possibility of communication can be limited by
a firewall. However, the WebSocket allows one to connect to standard ports (http:80 or https:443).
        The WebSocketDS TANGO module supports the following features:
                  periodic attributes reading;
                  attributes reading on demand;
                  commands execution;
                  TANGO events subscription (change, periodic, archiving, user).
        There are several application modes, which are a combination of the client and server modes,
or only the server mode or only the client mode.
        In the server mode, it is allowed to read TANGO attributes and pipes, as well as execute
commands for the TANGO device (group) specified in the properties for the module.
        If the client mode is used, the client can manage the updated data. The client manages both the
value of the update period and the content of the data (the list of TANGO attributes and pipes). Single
execution of a TANGO command, as well as reading data from TANGO attributes and pipes, is also
possible.




                                                                                                     141
     Proceedings of the XXVI International Symposium on Nuclear Electronics & Computing (NEC’2017)
                           Becici, Budva, Montenegro, September 25 - 29, 2017




                                     Figure 1. How WebSocket works
         Access to TANGO devices can be easily provided by using one or more WebSocketDS
devices. Several WebSocketDS devices with different modes can be used for tasks separation. A client
application can retrieve the data from any subscribed TANGO device or execute a command on it by
sending a request in JSON format.
         Compared to other protocols, such as REST (http), the ability to subscribe to events allows a
significant reduction in network traffic. Once the connection is upgraded to WebSocket, messages can
flow from the server to the browser the moment they arrive (see Figure 1).
         Client programs can be written in any programming language supporting WebSocket. At the
present time, support is available in almost all languages. Browser applications (with a special
Javascript object created) and desktop applications can be used as clients. To create desktop
applications, there are libraries for almost all modern environments: QT, С#, boost, python and
others. JSON format is used for requests and responses.


4. Connection security
        Various methods are used to protect the connection when executing commands. Different
authentication methods can be used. In case of the standard method, a login and password are sent in
URL. For example, ws://host?login=login&password=pass.
        There are several implementations that use the random identifier method. Instead of a
password, two values are sent to the server. The first one is the word sent by the server (can be sent by
any method). The second is the response from the client, calculated from the first one by the method
known to the server. Authentication is carried out in several stages. The implementation depends on
the server responsible for authentication. For example:
              The client sends a message requesting a random number.
              The server generates a random number, stores and sends it to the client.
              The client calculates (depending on the requirements of the authorization module) the
                required response, and sends it to the server.
              The server sends a response. (OК or not)


5. WebSocketDS module usage
         WebsocketDS TANGO module is actively used in the control system of LHEP JINR LU-20
linear accelerator (Figure 2).



                                                                                                     142
     Proceedings of the XXVI International Symposium on Nuclear Electronics & Computing (NEC’2017)
                           Becici, Budva, Montenegro, September 25 - 29, 2017


         There are two TANGO devices for monitoring the temperature of the cooling system. There
are TANGO devices for controlling the power sources of the hard focus magnetic lens. The client
applications are using WebSocketDS to communicate with these TANGO devices. It’s also planned
to use this module for future client applications.
         The module is also used in the Nuclotron beam slow Extraction web client [5].




                            Figure 2. Web clients for control system of LU-20


        Access to the WebsocketDS source code is provided via TANGO community web site [6], and
Git repository at tangodevel.jinr.ru [3].



6. Conclusions
        The WebSocketDS Tango device server has been developed. It provides access to TANGO
control system components via WebSocket protocol and allows communications between TANGO
devices and Web or desktop client applications. The WebSocketDS module is successfully used in the
control system of the LU-20 linear accelerator (LHEP JINR).


References
[1] http://www.esrf.eu/computing/cs/tango/tango_doc/icaleps99/index.html
[2] http://websocket.org/
[3] WebSocketDS Git repository http://tangodevel.jinr.ru/git/elkinvg/WebSocketDS
[4] Tango Controls official website, http://www.tango-controls.org/
[5] V. A. Andreev, V. I. Volkov, E. V. Gorbachev et al. TANGO standard software to control the
       Nuclotron beam slow extraction.// Physics of Particles and Nuclei Letters, vol. 13, №5, pp.
       605-608.
[6] http://www.tango-controls.org/resources/dsc/ds/1802




                                                                                                     143