LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Controlling an existing application via webservices

Hi all,

 

I just came across labview webservices whilst at one of the NI Tech symposiums in the UK last week and I want to use them for a specific application. However my initial playing hasn't worked very well! I want to know if I'm doing something wrong, or if what I'm trying to do isn't possible!

 

We have an existing application which controls a piece of measurement kit. It has multiple moving axes and some data acquisition and automated measurements etc etc. The application is all based on queued state machines and event structures for UI etc. At the moment the system is controlled by a user next to the machine with a PC. For some of the measurement setup, it can be useful for the user to move around and view the system from different angles whilst positioning the moving axes. At the moment that means walking round the system, looking to see how the alignment is, jusdging what change needs to be made, going back to the pc, making the change walking round... you get the idea!

 

What I wanted to do was to set up a webservice "interface" to the system giving fairly basic control of the positioning system. My plan was to write an intermediate VI which is opened by the user on the PC (via the existing application) to enable "remote" operation. This intermediate VI would then wait for the webservice vi to be called by the user on his/her mobile web enabled device and then pass instructions directly into the main applications Queue. The use of the intermediate means we don't have to re-write any of the main application and also gives a layer of security since the user has to manually call that VI from the main application. 

 

In the ideal world that intermediate vi would be "event driven" i.e. it would either contain an event structure or Queue system and wait for the webservice to fire that event/queue (and send in instructions). However this is the bit that doesn't seem to work. I tried creating a user event within the intermediate vi and writing the reference to that event into a shared variable which the webservice could see, but that failed (apparently user events can't be written to shared variables?). Then I tried with a Queue, but nothing happened... I could of course have the intermediate vi just polling shared variables written by the webservice VI, but that doesn't sound great to me... 

 

Does anyone have any thoughts on this? Is there a sensible way to "tack on" a webservice to an existing application? Other than network shared variables is there any other communication method that works between webservices and other VIs running? (I think this may be the key question)...

 

Thanks in advance for your thoughts!

 

Paul

 

0 Kudos
Message 1 of 3
(2,345 Views)

Getting data from your LabVIEW built web service over to your LabVIEW application is the trickies part of using LV web services because they run in seperate LabVIEW contexts.

 

Since you are using an event based and queue based archtiecture, you are in a good position to add remote support in. This is an excellent architecture for extensibility.

 

I can put forth 2 recommendations for you to try out. I agree with you that shared variables are a bad idea, they are lossy and would require you to add polling to your event driven architecture.

 

1) TCP/IP

You could open a TCP/IP port between the web service VI and your main application. I would recommend wrapping the TCP calls into a set of new API VIs that allows your application to block on a TCP request. For instance, you could create your own queue API that uses TCP under the hood to pass data. Your web service would use this new Queue API to put items into the queue, and your main app would then have another queued event handler to service items put into the queue. When this new queued event hanlder sees something on the queue, it could either fire user events in your main app's LV event handler, or just pass events over to your original queued state machine.

 

2) VI Server

create a simple VI that can invoke a user event on your main app's event handler, or can push something into your main app's queued state machine.  Then open and run this VI via VI Server from your web method.  This VI should just run once and exit, and all it does it pushes something into your state machine or queue. You can either have many of these VIs to match the specific events, or have one VI with a string on the front panel, then via VI server, put a value into that control from your web method. 

 

 

I personally find the 2nd option the easiest to implement.

 

Good luck.

 

-Jared

 

 

 

 

 

0 Kudos
Message 2 of 3
(2,342 Views)

Jared - Thanks for that, I'll give those to ideas a play later on (I'm still at the playing stage before putting it together for real! I do labview by trial and error to work out how to do something and then put it together properly once I get it right!).

 

Unfortunately, although this is very high up the "Wish list" its not quite on the high priority list yet, so I may not be able to let you know how I got on for a while!

 

Thanks again for the suggestions though!

 

Paul

0 Kudos
Message 3 of 3
(2,325 Views)