LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to organize Actors for a hardware interface?

I'm somewhat new to Actor framework and this is my first major project using it. I've completed a few simple Actors before and integrated them into larger applications.

 

I am communicating with a device over Ethernet. A proprietary program takes in ASCII commands and passes them to the device. Data is returned along the same TCP connection as ASCII strings.

 

I want to display the data to the user in a UI. In the future, the proprietary communication program may be swapped out for a custom in-house program. There are likely to be different UIs in the future.

 

I decided to create 3 Actors: a Hardware Interface / Listener actor, a Controller actor, and a UI actor. I want to keep communication between the three Actors simple and consistent, so potential future Actors are able to handle the same messages. The Listener and UI actors may be substituted for other actors in the future (a certainty in the case of the UI actor).

 

A critical task of the UI is to be able to display the parameters/settings of the device. There are several dozen different settings. The UI is interested in displaying some of them as indicators, issuing warnings depending on other parameters, and ignoring other updates. The UI's response to a specific parameter would change depending on which UI is being used.

 

What I'm struggling with is this:

 

  1. Which Actor should store the hardware's current parameters/settings?
  2. Should there be multiple copies of the hardware's current settings in each Actor?
  3. How should the parameters be passed around? Should there be an abstract Parameter class?
  4. If I used an abstract Parameter class, would dynamic dispatch be the best way to handle different UI reactions?

I'm afraid of coupling Actors too tightly together. On the other hand, it's not clear to me where the Parameter data should be stored, because it seems like the Controller and UI would need to have access to it.

 

If anyone has any thoughts/advice, I'd greatly appreciate it.

0 Kudos
Message 1 of 5
(2,839 Views)

Hi Mike,

 

Although I am not profficient with the Actor framework, since there have been no replies yet, in the meantime you might want to take a look at the "Documentation and Learning Tools" section of this page:

 

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

 

In particular, the NI Week 2012 Hands-On Session on Actor framework may be helpful.

 

Best of luck,

Eric

0 Kudos
Message 2 of 5
(2,800 Views)

Thanks, Eric. I have actually already gone through the Hands-On session, as well as the Simple Actor Example, the Cooler Example, and a couple others that were online. Unfortunately, a real-world project is quite a bit more complicated, and I'm struggling somewhat with the jump from example code to generating my own system.

0 Kudos
Message 3 of 5
(2,793 Views)

Mike,

Have you thought about making your device an actor(model in MVC structure) instead of the Listener/interface? The controller would then send/receive messages to and from the device actor. A UI base class to generate events based on messages received from the controller could then be subclassed to handle the messages differently for different UIs.

0 Kudos
Message 4 of 5
(2,733 Views)

Hi, I believe you should store these settings within the Controller Actor. Having a copy of the setting in UI Actor could result a bad coherency. In my opinion, UI Actor should be used only for the display and the user interaction purpose. The source of the displaying data must always come from Controller, but not UI Actor itself.

 

Let's say you have a UI Actor (with a single boolean display and a numeric control) and a Controller Actor that communicate with each other. Even controls (not only indicators) should be under the Controller Actor's control. Then you can have a structure like this:

 

UI Actor (Assuming your UI is Actore Core.vi)

  • Private data
    • Boolean Control reference ( set this at Actor Core.vi )
    • Numeric Control reference ( set this at Actor Core.vi )
  • Method
    • Update Boolean Indicator.vi (within this VI, use the control reference in Private data to update data. Use a property node with Value selected.)
    • Update Numeric Control.vi (within this VI, uses the control reference in Private data to update data. Use a property node with Value selected.)
  • Messages (from AF Message maker)
    • Send Update Boolean Indicator Msg.vi ...(1)
    • Send Update Numeric Control Msg.vi  ...(2)

Controller Actor

  • Private Data
    • Boolean Setting
    • Numeric Setting
  • Method
    • Refresh UI.vi (Use data from the Controller Actor's Private Data and use Message VIs, (1) and (2), to update the display in UI Actor.)
    • Event - Numeric Control Value Changed.vi ... Add a numeric terminal to this VI. In this VI, write a code that handles this event change.  ...(a)
  • Messages (from AF Message maker)
    • Send Event - Numeric Control Value Changed Msg.vi ... (Message for (a) )     ... Use this VI within UI Actor's Actor Core.vi when a numeric control value is changed within the event structure.

 

This is what I would do, but I am also new to Actor Framework so I may want to hear an opinion from others.

TailOfGon
Certified LabVIEW Architect 2013
0 Kudos
Message 5 of 5
(2,720 Views)