Communication Model

The communication model used for Beckhoff devices is depicted in here:

_images/communication.png

All the communication between a Karabo device and the hardware will go first to a BeckhoffCom device. The communication between Karabo Beckhoff devices and BackhoffCom is broker based (short-cut if Karabo devices and BeckhoffCom runs on the same cppServer).

BeckhoffCom device and the PLC do communicate via TCP/IP socket (the PLC being the server, and BeckhoffCom its client).

Establishing the connection with BeckhoffCom

The BeckhoffCom device receives from the PLC a list of IDs for the soft-devices running there. Those IDs must match the IDs of the Karabo beckhoff devices.

Once the BeckhoffCom has got this list, it will call the registerComDevice slot on all devices in the list. In this way, the BeckhoffDevice will know to which BeckhoffCom it must talk.

The order in which BeckhoffCom and the BeckhoffDevices are started is not important.

Communication with BeckhoffCom

The communication between the BeckhoffDevice and BeckhoffCom follows the request-reply pattern. BeckhoffCom exposes three slots which can be called by the BeckhoffDevice to communicate with it: plcReadRequest, plcWriteRequest and plcCallRequest.

plcReadRequest

The BeckhoffDevice can read a property from the PLC by calling the plcReadRequest slot on BeckhoffCom, which requires the following arguments:

  • const unsigned int requestId - a monotonically increasing number;
  • const std::string& deviceName - the BeckhoffDevice ID;
  • const karabo::util::Hash& readValues - a Hash containing a list of keys (PLC property names); the values are irrelevant, will not be used.

plcWriteRequest

The BeckhoffDevice can set a property on the PLC by calling the plcWriteRequest slot on BeckhoffCom, which requires the following arguments:

  • const unsigned int requestId - see plcReadRequest;
  • const std::string& deviceName - see plcReadRequest;
  • const karabo::util::Hash& writeValues - a Hash containing a list of keys (PLC property names) and the values to be set on PLC.

plcCallRequest

The BeckhoffDevice can read a property from the PLC by calling the plcWriteRequest slot on BeckhoffCom, which requires the following arguments:

  • const unsigned int requestId - see plcReadRequest;
  • const std::string& deviceName - see plcReadRequest;
  • const karabo::util::Hash& commandHash - a Hash containing a list of keys (PLC commands); the values are irrelevant, will not be used.