LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Multiple action engine objects

Solved!
Go to solution

Hi there,

 

I have created an action engine that is used to control a camera. The action engine has the following actions:

  • Initialize
  • StartAcquiring
  • RenderImage
  • StopAcquiring
  • LoadParameters
  • Exit

The action engine functions on a .NET reference that is saved in a USR. However, I want to create multiple camera objects that are identified by the CameraID and for that I would need multiple .NET references. Two options I can think of right now are, making a case for every CameraID that each contain a separate USR or duplicating the function for every CameraID. But I don't really like these solutions. How would you go about doing this?

Ongelofeloos_0-1648632655980.png

 

0 Kudos
Message 1 of 7
(1,877 Views)

Use a class instead of an FGV. Then you can easily have multiple instances of the class.

Sam Taggart
CLA, CPI, CTD, LabVIEW Champion
DQMH Trusted Advisor
Read about my thoughts on Software Development at sasworkshops.com/blog
GCentral
Message 2 of 7
(1,874 Views)

This is why you want to program by wire (even if .NET is by reference).

 

If you insist on a FGV, you can also keep an array in the USR, and give the VI an index. Obviously, you could use an add, list, remove, etc.

 

I'd also use a (by wire value) class... 

Message 3 of 7
(1,857 Views)

A little tip for the OP:

 

When you move from an action engine to a class-based solution it's gonna feel a little like you're turning all your code inside out.   Instead of a bunch of action cases all held together in a single case structure, you'll be spreading them out among distinct member functions.  Instead of USR's that contain hidden internal persistent data, you'll pass class wires in and out of your functions to preserve the changes you make to your private class data.

 

 

-Kevin P

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
Message 4 of 7
(1,832 Views)
Solution
Accepted by topic author Ongelofeloos

@Ongelofeloos wrote:

Hi there,

 

I have created an action engine that is used to control a camera. The action engine has the following actions:

  • Initialize
  • StartAcquiring
  • RenderImage
  • StopAcquiring
  • LoadParameters
  • Exit

The action engine functions on a .NET reference that is saved in a USR. However, I want to create multiple camera objects that are identified by the CameraID and for that I would need multiple .NET references. Two options I can think of right now are, making a case for every CameraID that each contain a separate USR or duplicating the function for every CameraID. But I don't really like these solutions. How would you go about doing this?

Ongelofeloos_0-1648632655980.png

 


When I run into this I just stuff the USR with an array of refs and make "Channel " or "Device Index" a required input.  This avoided a lot of duplicate code at the cost of a IPE between the while and the case

 

Using a FBN instead of a single iteration while loop cleans it up very nice.


"Should be" isn't "Is" -Jay
0 Kudos
Message 5 of 7
(1,822 Views)

@JÞB wrote:

 

When I run into this I just stuff the USR with an array of refs and make "Channel " or "Device Index" a required input. 

I was also thinking about doing it like this, using classes is something I still need to get used to.

 


@JÞB wrote:

This avoided a lot of duplicate code at the cost of a IPE between the while and the case

 

Using a FBN instead of a single iteration while loop cleans it up very nice.


What do IPE and FBN mean?

0 Kudos
Message 6 of 7
(1,801 Views)


@JÞB wrote:

This avoided a lot of duplicate code at the cost of a IPE between the while and the case

Using a FBN instead of a single iteration while loop cleans it up very nice.


What do IPE and FBN mean?


IPE: In Place Element Structure

FBN: Feedback Node

Both are in Programming -> Structures palette

Message 7 of 7
(1,790 Views)