LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

fire event from another event in the same structure

Hi
 
this should be simple, yet i am unsuccessfull doing it.
i want to fire an event from another event in the same structure.
why it doesnt work?
-----------------------------------------------------------------------------------------------------
... And here's where I keep assorted lengths of wires...
0 Kudos
Message 1 of 9
(3,158 Views)

what kind of event is handled in the event you want to trigger: a value change, mouse move?...

What you can do is trigger this event from the previous event case. For instance, using the property node "change value (signaling)" if the event is set to "value change".

0 Kudos
Message 2 of 9
(3,150 Views)

look at this thread. http://forums.ni.com/ni/board/message?board.id=170&message.id=81266

It is exactly what you are looking for!

0 Kudos
Message 3 of 9
(3,143 Views)

thanks titi.

it doesnt work for me, i must have then an other problem. will update on devellopements.

-----------------------------------------------------------------------------------------------------
... And here's where I keep assorted lengths of wires...
0 Kudos
Message 4 of 9
(3,127 Views)
When you say you are "unsuccessful" what does that mean exactly? Nothing happens? An error is generated? A hole is torn in the space-time continuium?

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
Message 5 of 9
(3,123 Views)

Mike,

i am not sure about the hole in the time-space continuum or the phase-space density, did not checked that yet Smiley Very Happy

i think my problem is i can go to another event only if i change (signaling) a value. but this makes my code very ugly with lots of local variables. my event structure handles more than 20 events, each one triggered by several possibilities. that is why i am looking for more elegant ways around.

i think i am getting lost in my own code...i need to write the whole thing on paper. it is all Altenbach fault (just kidding), because he proved me my codes could be much more efficient by finding alternatives to sequences. so that is what i try to do Smiley Very Happy

-----------------------------------------------------------------------------------------------------
... And here's where I keep assorted lengths of wires...
0 Kudos
Message 6 of 9
(3,107 Views)
Actually this is exactly what the Val(sgnl) property is for - programatically firing value change type events. To simplify things there are several places to look. To begin with look for controls that need to respond in essentially the same way. For example, say you have five buttons labeled "Via 1", "Via 2", "Via 3", "Via 4", and "Via 5". Let's further assume that when pressed these buttons all have to do something very similar - like delete a column from an array of data. The only difference is that the VIa 1 button removes column 0, the VIa 2 button removes column 1, and so on. You could have four event cases that each deleted the column associated with that button.

Alternately, you could have one event that handles any of the buttons. To make this work you use the CtrlRef value in the event data. This contains a reference to the button that was actually pressed. Use this reference to read the button's Label:Text property and parse the name to extract the number part, turn the value into an integer, decrement by one and (TADA! Smiley Surprised ) you have the index of the column you need to remove.

Another thing to look for are controls that are in clusters. You can create a single value change event for the entire cluster and in the event case use the OldVal and NewVal event data values to determine which item changed.

Finally, I'm not clear on why what you're doing results in a lot of local variables...

Mike...

PS: I think it's a good approach to blame it all on Altenbach Smiley Very Happy . But he is right about sequences: They are completely unnecessary. As I recall, the last one I used in code was some time in the spring of '85...


Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
Message 7 of 9
(3,086 Views)


@Gabi1 wrote:
i think my problem is i can go to another event only if i change (signaling) a value. but this makes my code very ugly with lots of local variables. my event structure handles more than 20 events, each one triggered by several possibilities. that is why i am looking for more elegant ways around.

i think i am getting lost in my own code...i need to write the whole thing on paper. it is all Altenbach fault (just kidding), because he proved me my codes could be much more efficient by finding alternatives to sequences. so that is what i try to do Smiley Very Happy


Yeah, blame the messenger! 🙂

I somehow think that you're still doing this way too complicated. Why would you need lots of local variables? All data that needs to be accessed in multiple cases belongs in shift registers (For some ideas, have a look at the tic tac toe program I posted in your other thread).

Properly designed, an event structure with 20 event cases, each linked to multiple events should not need many val(sgl) property writes (still each instance replaces one local variable). If all event cases fire other event cases, you soon run into an event avalance. 🙂

You could use two loops, one for UI handling using events and one for the processing using a state machine, then link the two via a queue.

You might even be able to do everything with one loop (+ event structure) by placing the state machine case structure in the timeout case and manipulate the correct case from within other events via a shift register.  If no events happen, the state machine proceeds through its regular states.

Message 8 of 9
(3,075 Views)

Altenbach and Mike,

i am sorry only now i read the email notifiying me of your answers.

Thanks a lot for the tips. i never used before the ctrlref in the event structure. it makes my processing of UI much easier to figure out. i still have some trouble with transforming arrays into clusters tough ( only way to get reference to all the controls inside...). i really wish there would be such a beast as extendable cluster of clusters (effectively an array of clusters, but that would give me the ref to all clusters ( and controls) inside). i will try make myself such a creature, that will (hopefully) recieve the cluster type externally.

Altenbach, as you predicted i ended up with event avalanche, mainly because as i have more and more events, i forget to check the follow up of firing events from within events. i am now changing it to state machine solution, and we'll see where it goes.

the reason i have lots of local variables, is that if one wants to signal the value, the type of booleans cannot be anymore latch and release, and one has to release manually, using a local. the way i do it is in the event handling the boolean, i have a small event structure with 200ms timout, where the local is reset.

Thanks guys!

 

Message Edited by Gabi1 on 06-06-2007 04:00 PM

-----------------------------------------------------------------------------------------------------
... And here's where I keep assorted lengths of wires...
0 Kudos
Message 9 of 9
(2,987 Views)