Skip to content

Add registry for devices defined in libDevCom

Daniel Joseph Antrim requested to merge dantrim_devcom_registry into devel

What

This MR adds libDevCom/DeviceComRegistry which defines a macro REGISTER_DEVCOM that one should call when implementing new physical devices. The "registry" being defined is not of the same type as the class registries already being defined in libPS, for example, since we do not have a common -- or default -- constructor for our devices. If we did have default constructors that all devices shared (and a common base class) we could have a similarly defined class registry, but this may not be needed.

Instead, the "registry" defined in this MR is simply a mapping between the "device types" and the "device names" (i.e. std::map<std::string, std::vector<std::string>>). The "device_types" are the base classes for the various types of devices ( ADCDevice, DACDevice, ClimateSensor, etc...) that a given driver/implementation for a specific device inherits from. The "device names" are just the name of the component/part/etc... that a given implementation is defining.

Such a "registry" is useful for being able to list out all of the known devices that labRemote is supporting, at least as long as REGISTER_DEVCOM is called for each device. Other utilities that wish to know this information can then call DeviceComRegistry::listDevCom to get this information (e.g. for checking configurations or for user-interfaces). If the devices were to have a common constructor/base interface then this would be a much stricter check since we could then define createDevice methods (like what we have for libPS) which take the device name and, perhaps, a JSON object which configures the given device. This could perhaps be a future change.

Executable for listing supported devices

An executable is defined, listSupportedDevices, which tabulates each of the known devices under a given device type:

./bin/listSupportedDevices
| Device Type           | Supported Devices                                              |
|-----------------------|----------------------------------------------------------------|
| ADCDevice             | AD799X ADCDevComuino LTC2451 MAX11619 MCP3425 MCP3428          |
| AMAC                  | AMAC                                                           |
| ClimateSensor         | HIH4000 HIH6130 NTCSensor PtSensor SHT85 Si7021                |
| DACDevice             | AD56X9 DAC5571 DAC5574 MCP4801                                 |
| I2CCom                | PCA9548A                                                       |
| IOExpander            | MCP23008 MCP23017                                              |
| MPSSEChip             | FT232H                                                         |
| MuxDevice             | PGA11x                                                         |
Edited by Daniel Joseph Antrim

Merge request reports