Promotic
WikipediaLinkedInYoutubeTwitterFacebook

Example of communication by means of XML

Example is placed in the folder: /Pm/Examples/Commun/XML. There are two applications (Client and Server) in this folder.

This is an example of data communication between two PROMOTIC applications over Ethernet. XML is the standard for data communication over HTTP protocol. For the general description of the XML communication see XML data sharing.

For full testing of the XML communication it is advisable to use two computers (even more) connected into the PC network. The XML Server application is started on one PC, the XML Client application is started on the other (third..). The communication can be tested also on one computer, the XML Server application can be started together with the XML Client application.
 

XML Server - PROMOTIC example of XML communication

Description of controlling the application:

After starting the application, the emulation of provided data starts. The operator can control the data emulation by the buttons "Stop data emulation/Start data emulation" and "Reset data".

 
Description of the application implementation:

The XML Server application is an example of the communication for providing data in the PC network by means of the XML communication. The whole "XmlServer" object can be used (after copying and setting) in the real applications, where the data have to be provided to other applications by means of the PC network (Intranet) or the Internet. The provided data can be browsed even by the Web-explorer without installing the PROMOTIC system.

 
- The "Data1" object in the application tree serves for the emulation of the data that are further provided to other applications in the XML form. On the Methods page the "NulData" method is defined that serves for setting the emulated data to original (null) values. The method uses both the "Reset data" button and also the "Timer" object (see the condition in the onTick script). The "Window" graphic object serves for the data visualization, for controlling the data emulation. The "Data1" object serves for storing the emulated data. On Web Server page there is set "Enable as WEB component" configurator, link to the PmWeb object and the identifier of provided component is defined.

The provider (XML Server) and the user (XML Client) must have the same type of the shared data (componenets) and their identifier.

- The "Web" object provides the data in the XML format.

XML Client - PROMOTIC example of XML communication

Description of controlling the application:

After starting the application, at first the window opens where a Server name is set, i.e. the computer name where the data provider XML Server runs. After setting the Server name, the window for controlling the communication opens as next. The operator has the "Start data receive" button available, by which enables/disables reading the data from the Server in regular intervals. Further, the "Stop receiving data" button and the "Send null data" button, by which original (null) data are sent to the provider (Server). In the "Communication period" edit box it is possible to set the communication period (see the PmTimer object) in seconds after the communication is stopped. If the period is set to 0 seconds, the communication is not performed in regular intervals, but reading the data is performed immediately after the previous reading has been finished. The read data are displayed in the data panel, and moreover, the operator has the "Transmission statistics" window available where success rate of individual transfers is evaluated.

 
Note: The Server name (of the computer where the XML Server runs) can be found on the computer in:
OS Windows XP - go to "Control Panel", then "Network" and the "Computer Name" tab.
in more recent OS Windows - go to "Control Panel" and then the "Network" item.
The IPv4 server address can also be used for connection.
 
Description of the application implementation: The XML Client application is an example of the communication, providing the data in the PC network by means of the XML communication. The whole "XmlClient" object can be used (after copying and setting) in the real applications, where the data have to be received or sent to other applications by means of the PC network (Intranet) or the Internet.
 
- The Base object is used for setting the computer name that is running the XML Server, the computer of the data provider. It contains the "Window" object including the PmiWEdit graphic item for entering the provider address. The address is stored in the Data_Par object into "Addr" data. In the "Open the window for Data1 communication" button the OpenView method is used for opening the panel displaying transmitted data.
- The Data1 object in the application tree serves for reading or sending the data. On the Methods page there are defined methods for reading or sending the data to the XML Server.
- "Read" method - reads the data from the XML Server
- "Write" method - sends the null data ("Send null data" button).
- Window object serves for visualization of the data, for controlling the communication.
- "ReadStart" method - enables reading the data ("Start receiving data" button).
- "ReadStop" method - stops reading the data ("Stop receiving data" button).
- "Write" method - sends the null data ("Send null data" button).
- Timer object calls the "Read" method (page of the onTick event). Here the interval for the reading is set (Timer page).
- DataRead object serves for storing the read data. On the page of the onEndOfTransfer event the success rate of the reading is evaluated and also the reading is started with the period 0 second (see the condition).
- DataWrite object are the null data for sending.
- Statistic object serves for storing the statistics values of the success rate of the communication.
 
Object Data_Par in the application tree is used for defining the basic communication parameters.
- "Addr" is used for storing the server address (Server name).
- "Period" is used for storing the value of the period from the "Communication period" edit box.
- "Reading" is used for storing the enable/disable flag of reading.
© MICROSYS, spol. s r. o.Tavičská 845/21 703 00 Ostrava-Vítkovice