Tuesday, August 25, 2015

Allowing end-users to perform custom computations on real-time data


This post is an introduction to a new project CalcRx that allows you to write applications to give users ability to run custom expressions on Observables. A couple of example scenarios are also discussed. To learn technical aspects about CalcRx in detail, visit the project page. This post does not assume you know about .NET and Reactive Extensions already. But in order to understand the technical aspects of CalcRx, those two are required.

You may have learned the about importance of usability, abstraction, and inference of real-time data already. In this post, I am going to jump straight in to one of the ways that we can accomplish this in .NET Applications.

Scenario 1

First consider this scenario, you have an application that displays the real-time chart of radiation levels monitored in Earth's atmosphere. The satellite is pounding your application with tons of data. The user of your application wants to see only so much, suppose your user wants to see the data where radiation levels are higher than 2 microsieverts, but your application is getting the 100 readings per seconds and your chart is animating too fast to be effectively read by the users. Now the users are telling you to show only the levels higher than 2 microsieverts, or one user wants to see only those spots where the radiation level is 2+ for at least 1 minute other wise he or she wants to ignore the reading.

Scenario 2

Another scenario is, you are the developer of the application that is showing the live chart of stock prices. Every time there is a tick, the chart has a point added. Suppose your user is monitoring Apple's stock which is changing every 2 seconds, your user does not like to be overwhelmed with a lot of unrelated information, he asks you to change your application to show you the Moving Average of last 5 ticks only. While your code change might work for the user watching Apple's stock, it will not do much good for the person who is watching a stock that does not change frequently.

CalcRx can help you in both of the scenarios described above. As long as your application is a .NET Application and the radiation levels or stock prices you are getting are received in IObservable<T>, CalcRx can make the job so much easier.

IObservable<T> is an interface for an implementation of a Publish-Subscribe model. You can convert anything coming into your .NET Application into IObservable<T>. For instance, if you have an event that is fired up every time you receive a new reading of radiation level, you could easily create an observable out of it. For more information, Checkout www.introtorx.com.

Once you are receiving your data through an Observable. You don't have to change your code anymore. You just add a Textbox to your application and ask your users to write their own custom formulas into that. CalcRx uses the expression language which is very close to what Excel uses for formulas.

For a detailed into on CalcRx, visit the Project Page