O'Reilly logo

Mastering Internet of Things by Peter Waher

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Publishing our nodes

Our data source will only contain two static embedded root nodes. We add these in code:

public static ActuatorNode ActuatorNode = new ActuatorNode(); 
public static SensorNode SensorNode = new SensorNode(); 
 
public IEnumerable<INode> RootNodes => 
   new INode[] { ActuatorNode, SensorNode }; 

Access to all nodes in the source is provided through the GetNodeAsync method. Since our implementation only contains two static nodes, we do a simple if-then-else sequence to check for the identities. In a more dynamic setting, some form of look-up procedure would be used:

public Task<INode> GetNodeAsync(IThingReference NodeRef) { if (SensorNode.SameThing(NodeRef)) return Task.FromResult<INode>(SensorNode); else if (ActuatorNode.SameThing(NodeRef)) ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required