This document discusses using Microsoft Orleans grains as software agents or "avatars" to represent physical IoT devices in the cloud. An example railway simulation app is described that uses grains to represent trains. Each train has a corresponding "physical train" device that can detect its proximity to stations and rails using Bluetooth beacons and communicates with its grain avatar using MQTT. The frontends use SignalR for the web UI and MQTT for machine-to-machine communication. Physical trains are programmed using .NET Micro Framework and detect beacons using BLE, with an MQTT/iBeacon gateway and feedback simulator implemented in Node-Red.
1 of 5
Downloaded 11 times
More Related Content
Microsoft Orleans & IoT
1. IoT & Microsoft Orleans
Software Agents living on cloud as Avatars for physical
devices livingin real world!
Lorenzo Maiorfi Innovactive - MVP
2. Grains as Device 束Avatars損
Mentally mapping a Grain (type) to a Device (type)
is easy, since:
Both work in a parallel, asynchronous and independent
way
Both interact by exchanging structured data by mean of
well-known channels, schemas, formats, messaging
patterns
Both are replicated in many, many instances, each
producing and consuming an impressive amount of
messages
Both maintain a persistent state, either in nature
(devices physical state) or through persistent storage
(grains)
3. Orleans Railway Sample
Sample implements a fictitious railway network,
inspired by real-world systems
Railway graph is made of nodes (Stations) and
directed edges (Rails), the latter featuring a traversal
cost (simulated by time needed to cross and
represented graphically by color scale: brownslow,
cyanfast)
Each Train features a buddy Grain that represents its
Avatar living on cloud
Sample leverages an external notification engine
that processes signals coming from Trains in order to
provide synthetic feedback coming from real-world
(i.e. telling Trains theyre near to a certain Station/Rail
after routing system sends them command to get
there as part of a end-to-end optimal path)
4. Orleans Railway Sample #2
In order to 束validate損 system with physical devices
we need 束Physical Train損 :
Process commands received by its 束avatar損 Grain
Raise notifications (through M2M front-end, not
Web one) toward its 束avatar損 Grain
Interact with physical world!
束feel損 Stations/Rails proximity
束move損 along railway graph
5. How did we do it?
Web front-end UI has been implemented with SignalR
(over OWIN) and plain HTML+JavaScript
M2M front-end has been implemented as an MQTT
client (publishing move commands and subscribed to
proximity messages)
Proximity detecting for 束physical Trains損 has been
implemented by BLE iBeacons
束Physical Trains損 device firmware has been
implemented with .NET Micro Framework (by mean of
M2Mqtt and NetMFBLE open projects)
iBeacon/MQTT gateway, as well as 束feedback損
simulator, has been implemented with Node-Red