Modelling device-oriented domain

by maelgrove   Last Updated July 12, 2019 06:05 AM

My application is connected to several hardware devices, where as for each device, there is a dedicated device client containing it's own representation of the device protocol, response/request or other message types, usually coupled with serialization frameworks and what not. The data returned from those devices are usually just a list of logically grouped primitives.

class DeviceStateResponse
    [FieldOrder(0)] // serialization framework
    bool IsRemote;
    string FirmwareVersion;
    SomeEnumState State;

I now need to execute superordinate workflows on those devices (where one workflow sometimes spans multiple devices), and also provide all kinds of data from the devices to an UI.

My first approach was just to set up a data model that consists of several types representing all those states, just to get rid of the dependency to the device client types for further processing.

class DeviceState
    bool IsRemote;

However, this usually ended up with me replicating the entire device model 1:1, with many things duplicated, e.g. enums representing some type of device state code. For several devices, sometimes in an awkward aggregation as some devices deliver data not in the form I need them.

My question is, is there a better approach? Just store each "data point" in a generic key-value list, with string constants floating around everywhere, and then aggregate later? Or a symbol-store based model?

I looked for possible solutions in open source home automation and IoT software, and they mostly rely on an highly generic and extensible data model which is usually configuration based, which seems rather an overkill for my current scope.

Related Questions

Updated May 10, 2017 20:05 PM

Updated August 22, 2018 13:05 PM

Updated August 01, 2017 11:05 AM