Implementing a device

In order to implement a new Karabo beckhoff device, you will need to add three files to the Netbeans project. For example, for the digital output device, you will need SD_digitalOut.hh (being digitalOut the name of the PLC soft-device), BeckhoffDigitalOutput.hh and BeckhoffDigitalOutput.cc (being BeckhoffDigitalOutput the name of the Karabo class implementing the digital output).

Note

All beckhoff device classes names shall start with “Beckhoff”.

Warning

Please remember to compile in both Debug and Release mode from Netbeans, such that the corresponding Makefiles are updated.

Generation of the soft-device header file

The soft-device header file can be generated automatically from a live device A device with a class that has not been added to the Beckhoff project will appear as a BeckhoffGeneric device.

The following Karabo macro will fill in the boiler plate code for you. For example: if a device of softdevice class SD_leyboldTP is instantiated as a BeckhoffGeneric devices with deviceId leybold, calling the macro

python bin/PLCcodeGeneratorKarabo.py generate target=leybold className=Leybold

will generate the file SD_leyboldTP.hh header file, the BeckhoffLeybold.hh header file as well as the BeckhoffLeybold.cc implementation file.

The Necessary Adaptations

Unfortunately not all information is available from the self description. The developer is tasked with completing the device by adapting the autogenerated code in the following way:

  • modifying the description of each key
  • implement a “FSM-like” behaviour by adding the .allowedStates( … , State::INTERLOCK_BROKEN) where needed.
  • implement the hardware State to Karabo State decoding in the function decodeHardwareState