Performing actions on control value / state changes 
Author Message
 Performing actions on control value / state changes

Hi,

I am looking for a *good* means of performing some action when the
state of a control changes.  For example, perhaps I would update the
size of an array when a Numeric Control was changed.  In CVI, I would
have use a callback to do this.  Unfortunately, I see no efficient way
to do this in labview.

For example, I posted a similar question some time ago and I received
a response or two confirming my worst fears:

The only way to do this is to set up a loop (hopefully with a wait so
that the CPU is not slammed) to check the current value and compare to
the old value.  I do not guess that this is so inherently bad (for
this is the sequence of actions that has to occur on some level
anyway), but this technique does not lend itself to a modularized
implementation.

For example, one would expect a VI to handle the read and compare
operations - then call another VI if a change was noted.  However,  I
cannot determine a means of passing a VI (like a function pointer in
C/C++).  Thus, I am left with hardwired connections and a different
read/compare VI for *each* control that I want to test.  Blech.

Surely there is a better way.  The undying gratitude of a bunch of PhD
students awaits the poster with a better solution!

Brett



Mon, 23 Dec 2002 03:00:00 GMT  
 Performing actions on control value / state changes
See on the Brian Renken's site the Changed VIs.

http://Brian.Renken.com/LabVIEW/

Put in a loop and reading a control, these VIs detect a change of the input
value from the previous call.
Use the output to call another VI when a change is detected. You can modify
it to accept any data type.

Alternatively you can add some code in the change detection VI to call
another VI from within. You simply add an input to accept a VI path or name
to call a VI after opening a reference to it, or to accept a VI reference
directly.
VI reference is LabVIEW equivalent to function pointer.

It is only few pointers, post again for any other questions.

Regards,

Jean-Pierre Drolet
Scientech R&D inc
Cap-de-la-Madeleine (Quebec)
CANADA



Quote:

> Hi,

> I am looking for a *good* means of performing some action when the
> state of a control changes.  For example, perhaps I would update the
> size of an array when a Numeric Control was changed.  In CVI, I would
> have use a callback to do this.  Unfortunately, I see no efficient way
> to do this in LabVIEW.

> For example, I posted a similar question some time ago and I received
> a response or two confirming my worst fears:

> The only way to do this is to set up a loop (hopefully with a wait so
> that the CPU is not slammed) to check the current value and compare to
> the old value.  I do not guess that this is so inherently bad (for
> this is the sequence of actions that has to occur on some level
> anyway), but this technique does not lend itself to a modularized
> implementation.

> For example, one would expect a VI to handle the read and compare
> operations - then call another VI if a change was noted.  However,  I
> cannot determine a means of passing a VI (like a function pointer in
> C/C++).  Thus, I am left with hardwired connections and a different
> read/compare VI for *each* control that I want to test.  Blech.

> Surely there is a better way.  The undying gratitude of a bunch of PhD
> students awaits the poster with a better solution!

> Brett



Mon, 23 Dec 2002 03:00:00 GMT  
 Performing actions on control value / state changes


Quote:
>See on the Brian Renken's site the Changed VIs.

>http://Brian.Renken.com/LabVIEW/

>Put in a loop and reading a control, these VIs detect a change of the
>input value from the previous call.
>Use the output to call another VI when a change is detected. You can
>modify it to accept any data type.

>Alternatively you can add some code in the change detection VI to call
>another VI from within. You simply add an input to accept a VI path or
>name to call a VI after opening a reference to it, or to accept a VI
>reference directly.
>VI reference is LabVIEW equivalent to function pointer.

>It is only few pointers, post again for any other questions.

>Regards,

You could also use strictly typed VI references to allow a dynamic use of
of the particular VI's controllng code as required. In other words this
is equivalent to a function pointer in C/C++. Check out the VI server
references on your LabVIEW install for some examples.

I think Brian Renken's solution probably involves un-initialised shift
registers. These are handy things to experiment with (for saving states).
Remember that you can also expand left shift register to return the n
-1st, n-2nd, n-3rd etc values for the current call around a loop.

--

Alexander C. Le Dain, PhD
ICON Technologies Pty Ltd
http://www.icon-tech.com.au



Tue, 24 Dec 2002 03:00:00 GMT  
 Performing actions on control value / state changes
I've done this on a number of occassions.  However it is always when I am
writing my programs in state machine format.  This provides an inherent loop
structure so that you can watch for changes.

For instance I set up a cluster with all of my verticle controls; at the
beginning of the "verticle settings" state I compare it to the previous state
of my verticle controls cluster which is carried trough using a shift
register; if changed I call the change_verticle_settings subVI. One of the
outputs of the change_verticle_settings subVI is the actual values of the
verticle settings.  I use this value to both update the verticle controls
cluster, via a local variable, and feed it into a shift register for the next
time through the loop.

Tom Powers
Thomas Jefferson National Accelerator Facility

Quote:



> >See on the Brian Renken's site the Changed VIs.

> >http://Brian.Renken.com/LabVIEW/

> >Put in a loop and reading a control, these VIs detect a change of the
> >input value from the previous call.
> >Use the output to call another VI when a change is detected. You can
> >modify it to accept any data type.

> >Alternatively you can add some code in the change detection VI to call
> >another VI from within. You simply add an input to accept a VI path or
> >name to call a VI after opening a reference to it, or to accept a VI
> >reference directly.
> >VI reference is LabVIEW equivalent to function pointer.

> >It is only few pointers, post again for any other questions.

> >Regards,

> You could also use strictly typed VI references to allow a dynamic use of
> of the particular VI's controllng code as required. In other words this
> is equivalent to a function pointer in C/C++. Check out the VI server
> references on your LabVIEW install for some examples.

> I think Brian Renken's solution probably involves un-initialised shift
> registers. These are handy things to experiment with (for saving states).
> Remember that you can also expand left shift register to return the n
> -1st, n-2nd, n-3rd etc values for the current call around a loop.

> --

> Alexander C. Le Dain, PhD
> ICON Technologies Pty Ltd
> http://www.icon-tech.com.au



Tue, 24 Dec 2002 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Tab and Space Bar action locks true value on Boolean Control

2. search for multiple words with awk and then perform action

3. last action performed

4. How to perform a single action within a while loop

5. performing periodic actions

6. Changing default control values in LV application?

7. how can i change the knob control to have only 3 values

8. changing the value of the loop control variable.

9. changing the value of loop-control variable in loop

10. changing value of loop control variable.

11. TIP #218: Tcl Channel Driver Thread State Actions

 

 
Powered by phpBB® Forum Software