Promotic

Data transfer in the network over Sockets

The communication over the sockets in the PROMOTIC system is now regarded as the oldest method of the data transfer and it was replaced by the simpler and more transparent communication using XML, see the description: XML data sharing.
The socket communication serves first of all for a data exchange between applications in the network.
The model client-server is used for the communication in the network. It means that the designer must define two (or more) applications that will communicate to each other and decide which of the applications will provide an access to its data and which of the applications will access these data (read or write). If the application provides the data for the usage, then this application is of the the server type, if the application accesses other (provisioned) data, then this application is of the client type. Practically it means that we define so-called server socket groups in the PROMOTIC server application, and that we define client socket groups in the PROMOTIC client application.
While at the server socket group only its name and operational parameters are defined, client socket group says which nodal computer will be communicated with and which server group will be referenced from this client group.
The user defines the client part of the communication thereby that it creates client socket groups in the "Sockets" configuration window. The client in this case is specified by the address of the destination computer and by the name of the server group.
The server part of the communication is analogously defined by the creation of client server groups on the same tab.
The communication itself is implemented by the PmaData object that is located into one of the defined (client or server) groups at the configuration and the transmission is initialized by methods PmaData.ReadFromSocket or PmaData.WriteToSocket.
Caution: The socket communication is licenced in the PROMOTIC system, i.e. for its running in runtime (with runtime licence), it is necessary to purchase an item for the network clients of the "PmDataClient" type. The licence must be purchased only if the server socket group is defined in the application and so many licences must be purchased how many clients the application is supposed to communicate at the most. In the development environment the socket communications are functional automatically for testing 5 clients at the most.

Two types of the network protocol can be used for the transfer:
1st TCP protocol that enables to transfer the unlimited size of data as well as to check the correct sequence and to control the data and the connection. But establishing the connection with the target computer isn't so quick as for the UDP protocol.
2nd UDP protocol that enables very quick establishing the connection but the length of the transferred data is limited to 512 bytes. In the "Limited data length (UDP)" configurator in the "Socket server group" window it is the item "Limited data length (UDP)".

Both types of the protocols are used in the PROMOTIC system by default in such a way that at first the PROMOTIC head is sent and then the transferred data follows. There is a data identifier in the head that serves for the unambiguous determination of the data on the target side. This unambiguous determination is given by the "Item" item name in the socket configuration at the data (see the "PmaData > Sockets" tab). Thus standard socket messages are wrapped up in the head and that's why only PROMOTIC applications can be connected to each other using this type of the communication by default.

UDP without PROMOTIC head:
To enable sending any user data over the sockets, a subtype of the UDP communication was created - UDP without PROMOTIC head. By this type of the communication it is possible to transfer any data defined in the data object. Because the PROMOTIC system doesn't add anything to these data, the designer can construct exactly such data that are requested by the application on the other side.
Bytes of the Integer and Long types are sent in the reverse order than on the computer (at first the HIGH and then the LOW byte). Thus sent format of Integer and Long values (so-called Big-endian) is a standard namely in the Socket communication. If it is required to send these values in the PC format (so-called Little-endian), then it is necessary to set the text "e=L;" into the item PmaData > Sockets > Item. Otherwise this item should be blank (because the head isn't sent, this item doesn't serve for the data identification).
When choosing this type of the transfer a server object (i.e. an object connected to the server socket group) can only receive data and a client object can only send data and thus only the WriteToSocket method can be called. But there can be more server objects (i.e. objects that receive data from sockets) and therefore a mechanism must exist that recognizes on the data receipt what a data object this message belongs to. For this purpose it is necessary to consider the first three variables as the system ones at server data objects and the received message is stored only into the next items. Now we'll describe the form of these three system items:
0th item (let's call it PM_enable) must be of the Integer type. The value 0 means that this object now doesn't receive, 1 that it receives. The value can be dynamically changed.
1st item (let's call it PM_id) must be of the String type. The value specifies whether the received data belongs to this object (if it isn't inhibited by 0.item). The value consists of a text that has the form, for example: "l=24;b3=235;b7=4;". In this case it means that received data belongs to this object only if its length is 24 bytes (l=24, l as length), the 3rd byte has the value 235 (b3=235, b as byte) and the 7th byte has the value 4 (b7=4). While each item is terminated by semicolon (;), the "bx=y;" definition can occur more than one time and if the whole text is empty, then it means that the received message belongs always to this object if no other data object with a non-empty text wants it.
2nd item (let's call it PM_size) must be of the Long type. If the message belongs to this object, then the received data are placed into items after three system items. Then a number of data items that were filled by the message, is stored into the 2nd item.
PROMOTIC 9.0.27 SCADA system documentation MICROSYS, spol. s r.o.

Send page remarkContact responsible person
© MICROSYS, spol. s r.o.