Actor Framework Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Linked network actor between 2 executables on the same machine

Hi there,

I've written an actor framework app but now need to modify it so that I can still read data from some sensors when nobody is logged on to the PC. In an ideal work I'd implement it as a real-time platform but that would be tricky in this instance. So...I've split my app into 2 executables, the first just reads from the sensors and will be run as a Windows service and it will send data across to the main app when that is open using the Linked Network Actor. It nearly works perfectly...

If I run the sensor-reading executable I find that if I then connect my main app in development mode it works perfectly.  The connection is made and the message is sent across the network between the 2 applications as it should, no problem.  However, if I build my main app into an executable and try again then it doesn't work - the connection is still made and no errors are generated, but the message never makes it across the network.

I'm aware of the issue of setting the context etc when using network streams and I've done that, and as the connections and no errors are being made I don't think that is the problem (eg //localhost:LabVIEW/SensorService vs //localhost:MyApp/SensorService). 

Has anyone seen anything similar please?  If I get to the bottom of it I'll post back.

Thanks,

Martin

0 Kudos
Message 1 of 10
(6,103 Views)

I have solved this already.

The LNA uses flattening to string. In the dev environment the dependencies get pulled in, but in an exe if the class isn't present it can't get called. The solution is to put the class constants for any messages on a block diagram that will be called. Including the classes as dependencies didn't work.

The way I do this is I override actor core on any actors that use a LNA. I put the class constants there.

Let me know if this doesn't make sense or if you have problems.

Casey

Casey Lamers


Phoenix, LLC


casey.lamers@phoenixwi.com


CLA, LabVIEW Champion


Check Out the Software Engineering Processes, Architecture, and Design track at NIWeek. 2018 I guarantee you will learn things you can use daily! I will be presenting!

Message 2 of 10
(3,873 Views)

Ahh fantastic thank you, that worked a treat.  I'd made sure to include the message class in the dependencies but as you say that doesn't fix it so I was stumped.

I now have crossed that hurdle to be met by a very similar one but one that won't be fixed in the same way it seems...

My sensor-read/background actor is up and running fine. I then load the main UI app which connects fine.  However, whenI  then close down the main UI app it correctly disconnects but then about 5s later the sensor-read actor stops being able to send messages to itself.  I'm using a variant of the 'Timed Loop' actor that ships with LV, my own basic version which is only used in this background actor, and I've included the constants on the block diagrams.  It doesn't generate any errors and if I debug it I can see that it is happily trying to send the 'read data' message every Xs to itself but it never arrives.

Any ideas what this might be? I assume it is something going out of memory but I can't seem to fix it.

Thanks very much for the help,

Martin

0 Kudos
Message 3 of 10
(3,873 Views)

My guess would be that you need to stop the parallel loop in your actor core with the timed loop. I can't remember the way the example does it,  but I think the parallel loop used a wait for notifier with a timeout and the actor core main loop exiting triggering the notifier. Make sure that you have something like that.

Casey

Casey Lamers


Phoenix, LLC


casey.lamers@phoenixwi.com


CLA, LabVIEW Champion


Check Out the Software Engineering Processes, Architecture, and Design track at NIWeek. 2018 I guarantee you will learn things you can use daily! I will be presenting!

0 Kudos
Message 4 of 10
(3,873 Views)

If the loop in your Actor Core.vi is a timed loop, there's a function you can use to abort a timed loop from another VI (i.e. from the handle stop msg core.vi). I don't have a clue how recommended that practice is, but I've seen it used in various RT projects. YMMV.

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

HI,

I'm writing an application for serveral singel testbeds, controlled by one RT. I used the Actor framework, so I could launch as much Actors of my tesbed class as I need and I can use the LNA to connect server (RT) and Client (Win7). This is quite an easy way to multply the functionalaties and connection (every server launches its own LNA-Actor Core). The app works fine and I compiled the rtexe, also fine. The Client - for every testbed a seperate Client - works fine, too. But if I try to start 2 Clients as exes on one Win7 PC, I got error -314350. For example I connect the 1st Client with Server1 its fine, then I connect Client 2 with Server 2 I got the error. If I directly lauch 2 clients in one exe, I can connect to the 2 servers seperately without any error. Another point is: If i run the Client1 exe and Client2 exe on different Win7 PCs, it is everything fine.

Have anyone testet such a szenario or can anyone give me a hint?

0 Kudos
Message 6 of 10
(3,873 Views)

The error is saying data is already being streamed using the address that you're trying to make a second connection to.  Network streams are 1:1 so it won't have it.

Have you seen this article: http://zone.ni.com/reference/en-XX/help/371361J-01/lvconcepts/endpointurls/ . I had to make a mod to the LNA code and correctly specify the context part of the endpoint url to get it to work, I set my url to be something like this: //localhost:FlowService/FlowService. If yuo're doing that but setting the context using the executable name then if you've got 2 clients running with the same name (eg using AllowMultipleInstances) then it would still clash.

0 Kudos
Message 7 of 10
(3,873 Views)

Hi,

I found two places where the LNA concatenate the strings for the name and the URL: Connect.vi and Actor Core.vi.

Do you thik that I can use "reader" or "writer" in every server/client instance? (//localhost:Client1/reader, //localhost:Client2/reader)

0 Kudos
Message 8 of 10
(3,873 Views)

Yes, that's okay.  The issue is that the LNA code just creates the address //localhost/reader and not setting the context causes problems with multiple connections and run-time mode.

0 Kudos
Message 9 of 10
(3,873 Views)

Hi,

thank you for your help. It works.

Perhaps the next Update should fix this problem. I got no idea, why the actual implementation should be better.

0 Kudos
Message 10 of 10
(3,873 Views)