09-18-2015 02:19 AM
hi all,
I have a VI which reads data from a IMU unit and displays data via a graph. I want to do a web app version of it with javascript.
Would I have to extend the same VI as a new copy under web services to perform control from the browser or use a shared variable to convert the data into JSON and send to the browser for visualization
Thanks
09-18-2015 03:06 AM
I saw this presentation at the most recent NI Week, and gives a nice overview of web services and how to integrate them in your application: https://decibel.ni.com/content/docs/DOC-42490
In terms of what you're asking, you're probably best breaking the app up into an acquisition VI, and a graph display VI. You could then add the web service as another type of display, sourcing the data from the acquisition VI in the same way the display VI does. Depending on what data you want to display, a shared variable would be a quick and easy starting point. If it turns out the variable is too lossy (your graph looks very steppy), you could use network streams or something similar.
09-18-2015 03:34 AM - edited 09-18-2015 03:34 AM
Take a look at the WebSockets link in my signature - it's a good way to send/receive data between a LabVIEW application and a web-browser with low-latency - which is ideal for displaying graph data!
09-21-2015 11:40 AM
Thanks for replying. I tried using a shared variable and the result was, just as you mentioned, more or less stepped. Am I losing data by using a shared variable?
can network streams be used to pass data to the browser?
And do you know of a way to display graph on a browser such as in labview. I came across Google graphs API. Have to look into it though
Cheers
Gokul
09-22-2015 04:12 AM
Yes, shared variables store a 'snapshot' of the data - so you may lose data if you don't read the shared variable quickly enough.
No, you can't use network streams - the browser wouldn't understand the network streams protocol.
WebSockets with JSON is pretty much the only way I can think of doing this.
As for graphing, when I have done my WebSockets stuff I used flot.js - it's a nice looking graph API, it's pretty easy to use and covers most types of graphs we needed for our applications.