Introduces a ICom
interface class that defines common functions for sending/receiving data to a device independent of the actual connection hardware. They are:
send
: send datareceive
: read available datasendreceive
: send and read dataThe input and output data can be specified either as std::string
or a c-string.
All communication functions (send
/receive
/sendreceive
) are required to be multi-process safe and reentrant. That is, no other communication with the device from a different process is allowed until the function completes. To help this, the following interface functions are required:
lock
: Request a lock on the communication hardwareunlock
: Release a lock on the communication hardwareThe lock
/unlock
functions are declared as public for applications to obtain an exclusive lock across multiple consecutive commands.
The ICom
instances can be configured using JSON objects via ICom::setConfiguraton
. The available keys are documented in the setConfiguration
descriptions for the corresponding implementation.
The equipment configuration is now responsible for initializing these classes as part of getPowerSupply
. It uses the ["communication"]["protocol"]
as a name of the class (ie: "SerialCom"
) to identify the right implementation. There is also now a ComRegistry
containing all ICom
implementations.
The IPowerSupply
implementations are no longer responsible for creating their own communication. This is now handled by the equipment registry configuration. Instead a IPowerSupply::setCom(std::shared<ICom> com)
function is added that sets the m_com
protected variable to a configured ICom
object. This is then available to all power supply implementations.
The setCom
replaces the connect
function. The setCom
also checks that the communication is correct (also previous behavior of connect
). This is done in a model-independent way by calling a new pure virtual function called IPowerSupply::ping()
that should return true if a test command was successful.
Also added implementation of AgilentE36300APs
power supply.
The following ICom
implementations are available:
SerialCom
: Communication via serial portsTextSerialCom
: Communication via serial ports using \n\r
delimitated text stringsGPIBSerialCom
: Communication via serial ports using \n\r
delimitated text strings with GPIB addesses settingCharDeviceCom
: Communication via character devicesThere are a few changes to how the serial communication behaves.
sleep
between write and read calls in command
as it was a rather arbitrary time.\n\r
in returned data for TextSerialCom
)