CustomInstrument

CustomInstrument is the CommunicationProtocol subclass for hardware that does not communicate over RS-232, TCP, or GPIB. It carries no QIODevice: initialize() and testConnection() are no-ops, and _device() returns nullptr. What makes the class useful is the convention it establishes for collecting the connection parameters that are needed for such hardware — file paths, device handles, serial numbers, USB IDs — from the user.

A HardwareObject whose communication type is CommunicationProtocol::Custom declares its connection parameters at static initialization time using the REGISTER_CUSTOM_COMM macro from hardwareregistration.h. Each CustomCommDef descriptor specifies the settings key, user-facing label, description, type (String, Int, or FilePath), and optional bounds. The HardwareRegistry makes these descriptors available to the UI before any hardware object is constructed, so both the AddProfileDialog (new profiles) and the CommunicationDialog (existing profiles) can render the appropriate input widgets without instantiating the driver. The driver reads user-supplied values back from the BC::Key::Comm::custom group of its SettingsStorage inside testConnection().

See also SettingsStorage for the REGISTER_HARDWARE_SETTINGS macro family, which follows the same registration pattern for hardware configuration parameters.

API Reference

class CustomInstrument : public CommunicationProtocol

An instrument which has a non-QIODevice communication method.

Similar to VirtualInstrument, this class leaves the device pointer null. Implementations declare the connection parameters they need from the user (device path, serial number, file handle, etc.) via the REGISTER_CUSTOM_COMM macro family in hardwareregistration.h. The CommunicationDialog and AddProfileDialog read those descriptors from HardwareRegistry at startup — before any hardware object is constructed — and render the appropriate input widgets. The driver reads the user-supplied values back from the BC::Key::Comm::custom group of its SettingsStorage inside testConnection().

Public Functions

explicit CustomInstrument(QString key, QObject *parent = nullptr)

Constructs a CustomInstrument with the given identifier.

Parameters:
virtual QIODevice *_device() override

Returns nullptr because CustomInstrument has no underlying QIODevice.

Returns:

nullptr.

Public Slots

void initialize() override

No-op initialization. CustomInstrument has no QIODevice to create.

bool testConnection() override

Always reports a successful connection. Real verification of a custom-protocol device happens inside the owning HardwareObject’s own testConnection() override, which inspects the user-supplied values and attempts whatever vendor-specific handshake is required.

Returns:

Always true.