Actor Framework Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Actor Framework Web Service Interface

I have come a little distance into my sbRIO system with a handful of actors for measurement, control and application.

The system will only have a Machine-Machine Interface, specifically a SCPI protocoll, transported over serial or or TCP.

And such a structured protocoll, translates pretty well into Message Objects (it would be nice if either our GDS  tool or NIs Message Maker had a specific API for creating mesasge classes from XML).

Up until now I have been using the Linked Network Actor method shown in the AF-cRIO example. And I am really pleased with its robustness, whenever I get it to work, its hard to break.

But, of course there is a but, I've spent a lot of time troubleshooting the setup, getting it to work, keeping it working as the app grows, seeing to it that the right messages are sent across the net and so on.

I am now considering a Web Service interface, and when doing so, have one basic question:

In my Web Service VIs (running in the web server App instance), whats the best way to send messages to / get messages from my Interface Actor ?

What i'm going to try first is using VI-server to call a repository VI in the .rtexe which holds the message-enqueuer/message-dequeuer refs. and in the same way run the Send methods for the specific messages.

Whatd'ya think?

/Marcus

0 Kudos
Message 1 of 11
(13,334 Views)

Marcus Johnson wrote:

What i'm going to try first is using VI-server to call a repository VI in the .rtexe which holds the message-enqueuer/message-dequeuer refs. and in the same way run the Send methods for the specific messages.

Whatd'ya think?

Since web services run in a separate application instance, I think that's pretty much how you'll need to do it.  I tried this approach a couple of years ago, and I seem to recall that it worked well. (I was experimenting, so that code didn't go into an actual application.)

Web services are command-response, so you will want to use Reply Messages to query your actor system.

0 Kudos
Message 2 of 11
(5,228 Views)

You might also try an approach of downloading niACS's example of how to communicate between actors running on a desktop and actors running on RT and use that exact same model to establish communication between the web service and the interface.

0 Kudos
Message 3 of 11
(5,228 Views)

Whould you be so kinda as to provide a link to the example? I seem to fail at searching.

Ryan Podsim, CLA
0 Kudos
Message 4 of 11
(5,228 Views)

rpodsim wrote:

Whould you be so kinda as to provide a link to the example? I seem to fail at searching.

https://decibel.ni.com/content/docs/DOC-24051

https://decibel.ni.com/content/docs/DOC-24187

0 Kudos
Message 5 of 11
(5,228 Views)

I was able to get this working as part of research for LabVIEW Work-Dispatcher  utilizing the. Here are the things I had to change from the default 2012 actor framework project to get it working.

Build Settings

  1. The Splash Screen VI's Window Appearance >> Window Behavior must be changed from Modal to Default
    • This prevents the splash screen from running in the dev environment during deployment.  This is likely a LabVIEW bug.
  2. The Splash Screen VI must be designated as a Service VI >> Auxiliary VI.
  3. All LVLIBs that contain Actor classes must be designated as always included.
  4. My two web service VI (described later) WM_GetState and WM_SetState are designated as RESTful web method VIs.

Implementation Notes

  1. I created an Actor that is to serve as a delegate between my Web methods and the rest of the actor framework. I'll refer to this as WebService Actor.
    • WebService Actor has a private data member Enum called State.  I will be describing getting and setting this state later.
    • Web Service Actor has two methods (GetState, and SetState) and Message Classes for each.
  2. I created a Method of WebService Actor that is a functional global variable which stores the to-self queue of this actor. I set the value of this FGV when WebService Actor's Actor Core starts.
  3. I created two VIs that will my Web method VIs (WM_GetState.vi, WM_SetState.vi).  These are method's of WebService Actor but I did not use the static or dynamic dispatch templates.
    1. Each Web method VIs begins by obtaining the to-self queue from the FGV.
    2. In WM_SetState I can call the Send SetState.vi directly.
    3. In WM_GetState I have to use the Send Message and Wait for Response VI
      • Yes I know I should be extra super-duper careful when using this VI.  This still seemed the best way to retrieve data from an actor.
      • To use the Send Message and Wait for Response VI I created a class that inherits from Reply Msg.lvclass and overrides Do Core.

All the other rules for creating web methods apply (controls and indicators on connector pane, avoiding illegal characters in this control, etc). Attached is the project I got this working in.  Please note this project is as-is and I didn't spend any time cleaning it up (sorry guys) so it includes some shared variables I used to instrument and debug my code.

Cheers!

Mark

Mark
NI App Software R&D
0 Kudos
Message 6 of 11
(5,228 Views)

Hi MarkBlack

There is missing file "Instrument Variables.lvlib" in the attachment file.

DAKBIAS
0 Kudos
Message 7 of 11
(5,228 Views)

Ha, sorry about that. A new zip archive is attached.

Mark
NI App Software R&D
0 Kudos
Message 8 of 11
(5,228 Views)

Hey Marcus,

It looks like this thread died with no resolution.  What did you end up going with?  I am running into the same issue and am considering using the LNA as AQ suggested above, but I started first with building an entire heiarchy around an engine polling a bunch of shared variables which are exchanging data between the web services and the main application.  In the past, I have used shared variables for communication with applications on a host because they are 1) easy and 2) can be manipulated using the system manager.  Since I am working on my first application using web services,  I am a little nervous about completely ditching this approach and hence I am using shared variables to communicate with web service and which can also be used to communicate with a host.  This feels a little hacky to me, so I am looking for a better approach before I sink too much time into this.  Hence the desire to find out what your resolution was (or for that matter anyone else's who may have encountered this problem and found a reasonable solution).

Cheers, Matt

0 Kudos
Message 9 of 11
(5,228 Views)

The second zip I posted should work. It was build using LabVIEW 2012.  It should still work in LabVIEW 2013, but its untested.

In LabVIEW 2013 and newer Web Services can communicate with LabVIEW applications using globals, queues, notifiers and other type of inter-process communication.  You no longer have to use Shared Variables and other network inter-process communication to move data between your Web service and your app.  This idea works well with the actor framework, and my example should be able to be augmented to make this happen.

Good luck!

Mark
NI App Software R&D
0 Kudos
Message 10 of 11
(5,228 Views)