I'm looking for some design-patterns to implement a IoT-Device-Interface in a flexible way.
The scenario is: We have a group of devices (say different Temperature sensors) which has some common functionalities ...
StartMeasurement - to start a temperature reading.
The device types differs in different specialisation. The second device-type addiotinaly implements a Method to configure the temperature resolution.
It's easy to write this device hirachy as Interface-Classes:
interface BasicTempSensor
{
StartMeasurement()
}
interface ConfigureableSensor : public BasicTempSensor
{
ConfigureResolution(config)
}
Now, these devices should be connect as a IoT device. We want to use the Microsoft IoT Device SDK. In it's basics, it provides a way to register Methods (by name) for a Device an register corresponding callbacks. -> In general, it's the communication layer, which provides functionality to send and receive commands and messages.
The question is: I'm looking for a way to make a good and flexible abstraction for the communication layer to the upper layers. Also the common interface structure should take into account. Is there a design pattern to make such a abstraction?
My first approach is to implement the shown interface structure on device and application side. The Interface implementation maps to commands which could be send through the communication layer. (adapter pattern?)
I also had a look at the http://johnny-five.io/ framework. On application side, the device functionalilty is build up from small basic classes . Don't know how it's implented on device side. Maybe some information in this direction is also helpflul.
In short: I'm looking for patterns to implement a typesafe device api description which also covers the common parts of the devices in a polymorphic way.
Thanks. Tobu
Aucun commentaire:
Enregistrer un commentaire