-
Notifications
You must be signed in to change notification settings - Fork 20
Simple Device IOT
We want to track on Neo4j how a generic Device is working. Every step/routine will be stored into the database, holding up some information about what the device is doing, how the step/routine ends, some additional information for some specific states, and so on. A job will use different devices, on a production environment, so we will also store some job information.
-
Device: it's our Entity node. Every Device will have more States, for each step/routine that they will run. It will have the following immutable properties:
- serialNumber: unique device id;
- model: specific device model;
- info: additional device information.
-
State: it represent what a Device was doing at a specific time. It will have information about what the step/routine is doing, how is it ended, what job is launching that step/routine. It will have, for example, the following mutable properties:
- job: the whole working job, for example a name or an id;
- activity: what the device is doing;
- context: additional information about what happened (either if it was a success or a faiulre).
-
We will also add different labels to the State node, based on what's happening: for example:
- Success: if the step/routine ended succesfuly;
- Error: if the step/routine failed;
- Warning: if the step/routine ended well, but giving some warnings.
Every Device can be created without an initial state, for example:
CALL graph.versioner.init('Device', {serialNumber: 92837573, model: 'Laser Scanner FT95', info: 'Car Park Entrance Laser'})
This Laser is used, for example to track a car entering in a car park, and we want to track it, for example, registering some data about how the driver will search for a free spot. Every job can be a unique car, entering into the car park. So for each car passing near that device, we can call for a success step/routine as this example:
MATCH (d:Device {serialNumber: 92837573}) WITH d CALL graph.versioner.update(d, {job: 'FB123AC', activity: 'Car registration', context:'some data about the device output'}, 'Success') YIELD node RETURN node