LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I get continuous data acquisition using web services?

I am relatively new to LabView. I know how to use the NI cDAQ-9174 to read the changing voltage from a power supply and output that on a graph. I now want to use the web services to be able to continuously view that as if it were a website (which technically I guess it is). For right now I am fine with viewing it by typing in http://localhost:8080/...etc. I have gone through the tutorial that adds together two number you give it and returns the answer in an XML format. What is the simplest way to do this?

0 Kudos
Message 1 of 10
(5,896 Views)

@tayexdrums wrote:

I am relatively new to LabView. I know how to use the NI cDAQ-9174 to read the changing voltage from a power supply and output that on a graph. I now want to use the web services to be able to continuously view that as if it were a website (which technically I guess it is). For right now I am fine with viewing it by typing in http://localhost:8080/...etc. I have gone through the tutorial that adds together two number you give it and returns the answer in an XML format. What is the simplest way to do this?


Are you basically saying you want a LabVIEW user interface that displays data from a webservice, rather than just displaying the xml in a browser? In order to do this, you can use the Get.vi in the HTTP palette. You would feed the URL into that VI just like you would type it into your browser address bar, and the XML you see in the browser will be returned. You then need to parse that XML and display it however you choose.

 

If you want to pass more complex parameters such as clusters, you can't just put the cluster in the URL string like you can with the numbers in the add example. So, in this case, you will more than likely have to use the post method. In my opinion, the webservices example NI provides is way to dumbed down for any real application, and I struggled with this at first much like you are.

 

In order to continually update the UI, you have to keep calling the get.vi function with the appropriate URL. Don't slam the webservice though; I'd only update a couple times a second.

0 Kudos
Message 2 of 10
(5,894 Views)

The XML part wasn't really important. I'm not worried about how it is displayed at the moment. I will try what you suggested. When you say "parse" do you mean a while loop?

I agree about the NI example though.lol

0 Kudos
Message 3 of 10
(5,887 Views)

@tayexdrums wrote:

The XML part wasn't really important. I'm not worried about how it is displayed at the moment. I will try what you suggested. When you say "parse" do you mean a while loop?

I agree about the NI example though.lol


Webservices will return a string. That string is XML. You may need a while loop to parse out your data, you may not, it depends what you need to parse out of it how many return parameters you have etc. What you will want to do (for simplicities sake, there are more complex ways but I don't think you need them for this) is create a shared variable. Put the shared variable in your application and write the data to it. Then put the same shared variable in your webservice, read it, and return it like you would return the output of the math function. Then use the Get.VI to call your webservice. When the webservice gets the call, it will read the shared variable. 

 

I am assuming your data can be lossy, otherwise you probably don't want to use a webservice and would be better off having direct communication with your host application via tcp/ip, network streams, etc. 

 

Have a look at the "weather" example in the example finder. This shows how you can use shared variables to get data from a webservice. Only, don't put the URL in a web browser, feed the URL into the get.vi. It should start to become more clear at this point.

0 Kudos
Message 4 of 10
(5,882 Views)

Here is what I am using to get the voltage reading from the power supply. How do I get this displayed continuously on a webpage?

0 Kudos
Message 5 of 10
(5,880 Views)

What you are showing will be your pplication. Your webservice is separate from this and it interfaces with this application. So, create a shared variable called voltage and wire the dynamic data (what you have wired into numeric) into the shared variable, then run this VI

 

Then create another VI. This will be your webservice VI. Drop the same shared variable in this VI and read it. Wire it up to an indicator and put that indicator on the connector pane. Build a webservice just like you did in the tutorial.

 

Then, put that URL into your browser and voila, the data should show up. As I said, please look at the weather example that ships with LabVIEW. You will have far fewer questiosn after that; it's almost exactly what you're trying to do.

 

Also, I think you may be a bit confused. Webservices do not continuously run and pump out data, you have to explicitly call them, at which point they will get the data and return it to you. So, you can't have data continously updating in a webpage unless you automate a repeated call to the webservice.

0 Kudos
Message 6 of 10
(5,876 Views)

Ohhh, okay. That clears things up then. I'll go and look at the weather example. If I have any problems I will know who to contact!

Thanks!

0 Kudos
Message 7 of 10
(5,871 Views)

It will not let me connect the ouput of the data to the shared variable. The arrow on the shared variable looks like it needs to be on the left side as an input but instead its on the right side as an output.

 

 

Nevermind....I was trying to create a shared variable using the functions palette. I tried using the project manager and I have got it.

0 Kudos
Message 8 of 10
(5,868 Views)

Okay, so I have now been able to output my data on a webpage. What I want to do now is have it continuously update without me having to repeatedly refresh the page. I have configured the web service VI to stream data. I looked at an example of how to do this from NI but it didn't tell me much. It just told me what VI's to use. It didn't tell me HOW to use and configure them. Also, how do I format the HTML code that is being displayed on the web page? All I see is a blank page when I navigate to http://localhost:8080/VoltageReader/voltage/7481.

0 Kudos
Message 9 of 10
(5,842 Views)

Hello tayexdrums,

 

I am curious what example you are talking about, perhaps if you link to it we can discuss how to use the VI's you mentioned.  To get your page to continuously refresh itself, try placing the VIs that send information to the web page inside a While loop with a 1 second wait timer to get the page to update once every second.

 

In terms of troubleshooting your own webpage, I think you should start by verifying that you configured the setup options properly.  Check out this page for a detailed walk-through of the necessary setup.  Also, it helps to try and access the web-page through Internet Explorer.  The pages should be available through Firefox and Chrome as well, but you must ensure you have the Microsoft Silverlight add-on enabled - Explorer has this by default.  You might also check out the Web Services FAQ to find some more information about what might be wrong; specifically check the How do I Debug Web Services? section.  After enabling debugging, if you post some of the information you figure out I can help you continue to troubleshoot this issue.

 

Directly using the HTML code to change what is displayed on the webpage is tedious at best.  To better control the appearance of your page, check out the UI Builder.  At the top of this page, you can see two links: Home and Developer Resources.  Home has general imformation about the UI Builder; Developer Resources includes documentation and examples to aid in deploying a web service.  This example details how to deploy a web service using UI Builder.  Hopefully you will find these various resources to be useful.

 

Please let me know how your progress is coming with deploying your web page, and I will be happy to answer any further questions.  Good luck!

Patrick
CLA
0 Kudos
Message 10 of 10
(5,819 Views)