Tools->EJS+TwinCAT->Communication Library

The communication library encapsulates all the funcionality that is needed to exchange information between the EJS applet and the server (in the Indirect Communication Class) and between the server and the PLC (in the Direct Communication Class), and to easily replicate the structure of the PLC variables in the EJS applet. Examples of use of these classes can be found in the applet provided in here.

Direct Communication Class

The direct use of the classes provided by TwinCAT to access the PLC variables from any JAVA application requieres 1) the knowledge of the address map of the PLC in order to be able to carry out reading/writing operation at byte level and 2) the use of functions that convert the arrays of bytes into JAVA variables (char, int, float, double) and viceversa.

In order to simplify all these labours we have developed the methods of the Direct Communication Class, which also support the access to the structured variables of the PCL in a single reading/writing operation. Therefore, the methods encapsulate the calls to the low level TwinCAT communication methods as well as the types conversions.

This class is responsible of supporting the communication between the server and the PLCs. Nevertheless it can also be used from any JAVA application (including an EJS applet) that will be run in a registered Windows PC. Nevertheless, this type of application should not be provided to the students as the registration step doesn't protect the PLC to be simultaneously accessed by two applications.

Indirect Communication Class

The indirect Communication Class encapsulates the required functionality to let the EJS applets communicate with the intermediate server application, using text messages and sockets.

Besides the reading/writing structured variable instructions supported by the Direct Communication Class, the Indirect Communication Class supports the concatenations, in a single message, of a reading/writing instruction of multiple structured variables. With this characteristic the number of exchanged messages between the applet and the server can be easily minimized.

This class is responsible of supporting the communication between the applet and the server. Nevertheless it can also be used from any JAVA application that can run in any PC with the JAVA run-time installed. As the communication of the methods of this class is stablished with the PLC through the intermediate server application, any application that makes use of this methods can be provided to anybody wanting to access the PLCs from any computer.

TwinCAT Structure Class

Finally, in order to replicate easily the structure of the TwinCAT variables in the EJS applet, and store their values in the applet and exchange them with the PLC, we have developed the TwinCAT structure Class.

The configuration methods of this class let any user define a complex structure similar to the one in the PLC in the applet, while their set/get methods permit the access to the values stored in the EJS applet, and their read/write methods generate the instructions that have to be sent to the PLC, either directly or through the server application.

Finally, it is worth highlighting that the combined use of variables of this class with the read/write variables of either a Direct or Indirect communication library one, significanly simplifies the communication operations that have to be carried out by the EJS applet (or other JAVA application).