• RSS
  • Add To My MSN
  • Add To Windows Live
  • Add To My Yahoo
  • Add To Google

Microsoft Orleans & IoT : Software Actors living on Cloud as avatars for physical devices living in real world 

Posted by Lorenzo Maiorfi Sunday, May 24, 2015 1:28:52 PM
Rate this Content 0 Votes

On April 18th, within Internet Of Things Conference 2015 in Naples, I had a Talk about taking advantage of Microsoft Orleans in IoT enterprise systems. As part of such talk, I developed a sample, Orleans Railway, showing a possible “model” for cloud-aware IoT application design: mapping each physical device to a “software” counterpart (I purposely called “avatar”) living on Cloud, leveraging Actor Model implemented by Microsoft Orleans as an effective way to enforce such “binding”.

Today, I published a running demo of Orleans Railway on http://orleansrailway.cloudapp.net , where you can “play” by assigning destinations to trains and see them moving onto graph following optimal path. I also published a “sideshow” presentation on SlideShare, at following address: http://www.slideshare.net/maiorfi/microsoft-orleans-iot

Some additional info:

  • Sample graph is made of 300 stations/nodes, 700 rails/edges (directed, i.e. that can be traversed in one direction only) and 50 simulated (+2 physical) Trains
  • Each edge/rail features a traversal cost/time: the purpose of (server-side) system is providing the best possible route/path toward requested destination
  • In order to show different traversal cost/time, rails are depicted using a color scale going from brown (slow) to cyan (fast)
  • In order to assign a destination to a Train, user has to choose a Train, using upper dropdown list, a destination, using lower dropdown list and press “Go To” button
  • Stations containing trains are depicted with orange border; similarly, edges/rails occupied by trains are shown using orange color
  • If train isn’t already moving and there is a possible path connecting current train position to requested destination, the train will start (acquiring MOVING state), moving across graph following optimal routing; if no suitable route exist, train will remain in “IDLE” state without moving at all
  • Both Train state and position are persisted (through Orleans Azure Table Storage provider), i.e. they will survive to cloud service reboot/updates
  • Web app uses SignalR in order to push notifications to listening browsers: such notifications include Train position and state updates. Also, sound notifications are  provided for significative events (no suitable route found, train moving, train starting, train arrived, etc.). Thank to bidirectional communication feature all browsers pointing to Web front-end UI will see trains moving in realtime!
  • Please note (as kind of “caveat”) that Web UI is rather computational intensive: your browser will be responsible for high CPU load caused by graph rendering HTML5 engine used by VisJs library

As a Microsoft Orleans sample, it should be emphasized that:

  • Application runs inside an Azure Cloud Service embedding following 3 roles: a worker role as Silo host, a web role as UI front-end (for humans) and another worker role as M2M front-end (for devices)
  • The M2M front-end role has been implemented as an MQTT client/endpoint, using a sample public MQTT broker powered by amazing HiveMQ features
  • Application defines only 2 type of Grains: Map and Train, the first is a Singleton responding only to graph topology definition requests, while the latter, instanced “per Train”, solves all “shortest path algorithms” requests coming from users, leveraging optimal parallelization features of Orleans
  • Sample also depicts one of “killer pattern” of Microsoft Orleans: modeling Grains as Automas (additionally with persisted long-term state) , by mean of Finite State Machine design
  • Interaction between physical devices (trains) and software service living on the Cloud uses a MQTT/iBeacon gateway developed (by meSmile) with .NET Micro Framework, using M2Mqtt (by Paolo Patierno, @ppatierno) and NETMFBLE (by me, @maiorfi) open projects
  • During my Talk, Paolo Patierno was responsible for…moving physical devices (whose name in sample system is purposely different from other, simulated, ones) in a room “tagged” with 10 iBeacons. While Paolo was moving across the room (take a look at photos below!) people was able to follow trains moving on web UI projected on wallscreen as well as on their smartphone browsers!
  • For non-physical trains (whose names are N_1…N_50), movement is simulated by an external (i.e. IoT Orleans-based system doesn’t actually know they’re not real!) MQTT signal subscriber/publisher. Such simulator has been developed as a Node-Red flow; also it simulates different traversal cost using delays, with a “0.5 seconds per cost unit” factor

If you are interested in implementation details, project sources can be downloaded using following link: https://dl.dropboxusercontent.com/u/7414592/TinyCLR.it/Blog/orleans-railway/SistemaGestioneNavette.7z

Internet of Things “wrap up” : events, slides, libraries and …. demo with a lot of code !! 

Posted by Paolo Patierno Saturday, May 23, 2015 3:57:52 PM
Rate this Content 0 Votes

Last month I developed a lot and I had the pleasure of being speaker to three national events and an international one in California (but from remote).

I was greatly involved to write code and content that I decided to summarize hoping that you could enjoy them.

mec2015

iotday

With the slides I tried to describe the most important features of the Azure Service Bus focusing on the Event Hubs and its use within the telemetry pattern in IoT :

These slides have related demos where I used my last Azure SB Lite library, thanks to which you can access to the Microsoft Azure Service Bus using the same API of the "original" SDK but on embedded platforms such as .Net Micro Framework and .Net Compact Framework as well as Mono (on Linux) and WinRT (then Windows 8.1 and Windows 10). It is based on the AMQP .Net Lite library which hides the concepts on the AMQP protocol.

 

overall

Regarding the demos :

  • BLE2Azure : IoT gateway concept from BLE devices to Microsoft Azure (Event Hubs) built with the .Net Micro Framework and the FEZ Spider and Netduino 3 Wi-Fi boards
  • Azure SB Lite Examples : examples of usage of the Azure SB Lite library that allowed me (in Venice) to explain how the access to the Service Bus works through the AMQP protocol and discover what lies beneath the simple APIs.

Obviously I do not stop here despite the deserved rest !

Smile

.Net Micro Framework and regular expressions … “out of range exception” ! 

Posted by Paolo Patierno Thursday, May 07, 2015 9:34:00 PM
Rate this Content 0 Votes

Developing a new library for accessing to the Microsoft Azure Service Bus (event hubs, queues, topics / subscriptions) based on AMQP (and AMQP .Net Lite library) I came across a bug in the code of the regular expression in the .Net Micro Framework.

The bug occurred by chance, when I had a "connection string" in which there was the "SharedAccessSignature" field that has a value when we use the AMQP connection with CBS (Claim Based Security); for example when we publish to a "publisher" endpoint in the event hubs with a SAS-based security token.

In this case, the above field has a quite long value. Following the "connection string" I came across :

To extract all the fields from the connection string, I wrote the following code :

   1: Regex regex = new Regex("([^=;]+)=([^;]+)");
   2:  
   3: IDictionary connectionStringParams = new Hashtable();
   4:  
   5: MatchCollection matches = regex.Matches(connectionString);
   6: foreach (Match match in matches)
   7: {
   8:     connectionStringParams[match.Groups[1].Value] = match.Groups[2].Value;
   9: }

On second iteration extracting the "SharedAccessSignature" field I came across an OutOfRangeException ... due to what ?

 

regex_netmf

 

The screenshot shows that the field "Length" of the match has a negative value of -80. Why ?

Well, the value of the "SharedAccessSignature" field (the SAS token) has a length equal to 208 and doing a simple subtraction 128-208 is exactly equal to -80.

Probably in the .Net Micro Framework, a variable of the type "signed byte" is used to hold such a value that causes an obvious overflow; the maximum length of a value in a match was probably set at 128.

I suggest you avoid matching with values longer than 128 characters waiting the team to fix the bug

Winking smile

Windows IoT Core, Raspberry PI 2 and HDMI to VGA Converter 

Posted by Mirco Vanini Monday, May 04, 2015 9:31:38 AM
Rate this Content 0 Votes

Last week I installed the Windows IoT Core Technical Preview on my Raspberry PI 2 but I had some issues with my cheaper HDMI to VGA converter. During the test, I used my old Samsung CRT monitor without any output from the board! I tried using a HDMI cable with other monitor and the board work fine. Then I connected the converter to my laptop HDMI port and it worked. The problem was on the board OS Image. After a few hours, I found the solution. On the OS Image root path there is the config.txt file. On this file I appended the following lines:

hdmi_drive=2
hdmi_group=2
hdmi_mode=16
hdmi_force_hotplug=1

Here there is a brief description about the parameters available for the config.txt

Enjoy

MQTT & Eclipse Paho : new releases for M2Mqtt client and GnatMQ broker !! 

Posted by Paolo Patierno Saturday, March 28, 2015 2:20:33 PM
Rate this Content 0 Votes

Finally the new M2Mqtt 4.1 version is out !

In the last months, my library was under pressure thanks to my friends Olivier Vigliengo (from Adeneo) and Nicolas Besson (Microsoft MVP on Windows Embedded, from Adeneo). They used the MQTT client for their hobbistic projects and stressed it a lot !

After exchanging a lot of emails with log traces, I fixed some bugs and added some improvements to the library :

  • Exposed IsPublished flag in the published event to know if message is published or not due to timeout;
  • Internal changes for event management;
  • Fixed bug on negative timeout;
  • Improved stability on not reliable network;
  • Fixed bug on session management;
  • Added trace on queueing operations;

Of course, all changes had a great impact on the GnatMQ broker project related to M2Mqtt. The MQTT broker is still in Beta but I’d like to release it as Stable : I hope that people using it give me a feedback. It seems that XSocket team is using it to support MQTT in their platform. Smile

As always you can find M2Mqtt under Eclipse Paho project, CodePlex and Nuget. GnatMQ is available only on CodePlex. Finally, I updated the M2Mqtt4CE (for Windows Embedded Compact 2013 OS) on CodePlex as well.

Page 1 of 48 1 2 3 4 5 6 7 8 9 10 20 > >>