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.

  • Is it feasible to come up with a sort of a unified data model that's just designed to support the specific needs of your application (i.e., it just has the data you need to support these worklflows), and then write all your logic against that? There would be some boilerplate, as you'd have to translate inputs and outputs to/from your own internal format. – Filip Milovanović Jul 12 at 11:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.