From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Execute order of an event trigged by other event

Solved!
Go to solution

In the interest of finding a solution:

What do you want to happen?

You have two buttons.

What should happen if A is pressed?

What should happen if B is pressed?

Do they both need to be pressed for something to happen?

 

Maybe if you can clearly describe what you want to happen, we can help. I'll go out on a limb and say it's DEFINITELY do-able.

0 Kudos
Message 11 of 63
(1,201 Views)

Take a look at the JKI State Machine; download it from VIPM.

 

It has an event structure in it, along with a string based State Machine. My suggestion is keep your event structure BUT do the the processing outside of the event structure. Here using the JKI State Machine as an example:

  1. Event Write is fired by a button Press.
  2. Event Write passes two states to the State queue, Read: Data, then Write: Data
  3. Now it occurs in the order you want.
  4. Event Read is fired by a button Press.
  5. Event Read passes Read: Data to the State queue.

So what I am trying to say, make you code more modular and do not do any processing in the event structure, always outside of it.

 

If you do not know about state machine look at the examples.

 

mcduff

0 Kudos
Message 12 of 63
(1,197 Views)

My point was whether LV could implement an event that fires event handlers in reverse order which text base can. If so, then the problem solved. Initially, I did not plan for the dynamically register events, and I only use it for additional features for additional requirents/or modifications.

 

0 Kudos
Message 13 of 63
(1,197 Views)

As others have said, you are not understanding events or the principles of dataflow, so the problem is not with LabVIEW. You simply need to step back and stop digging. There are trivially simple solutions to your problem (and none involve signaling properties, sequences, or duplication of code!) and we will help you once you post some simplified code.

 

For example, the same event case can be assigned to both booleans and contain a case structure to skip some parts depending on the boolean states.

 

If the other event should operate in parallel, use a separate while loop and event structure.

Message 14 of 63
(1,186 Views)

@Autenbach

My initial question was the 'executipon order of events' NOT how to code an event. You are not understanding the question.

 

Anyway, I have a number of solutions on my own. I just want to show the weak/strong points of LV.

 

Thank you all

0 Kudos
Message 15 of 63
(1,176 Views)

@John4191 wrote:

I just want to show the weak/strong points of LV.


Yes, this (i.e. dataflow paradigm) is one of the strongest points of LabVIEW, of course. Embrace it instead of trying to fight it.  😄

Message 16 of 63
(1,165 Views)

@John4191 wrote:

@Autenbach

My initial question was the 'executipon order of events' NOT how to code an event. You are not understanding the question.

 

Anyway, I have a number of solutions on my own. I just want to show the weak/strong points of LV.

 

Thank you all


@John4191 - I'm not sure what your point is. Your code is doing exactly what you tell it to do. Events are executed in the order received. You asked for a solution to a problem but didn't really want a solution. You are using poor LabVIEW programming practice but want to bash the programming language instead of accepting the help given voluntarily. Doing what you said that you wanted to do is EASY in LabVIEW. Personally I would make this a QMH as I like to use my event structure to capture and fire events - not execute code.

0 Kudos
Message 17 of 63
(1,139 Views)

@johntrich1971: Please read the whole thread of this topic again. I asked question about event execution order and from the discussion, it seems like LV have no capability to reverse the order of events like the text base does. As a result, I think it's a weakpoint of LV and that is not bashing. It seems like this forum is not helping but accusing for one's opinion about LV.

 

BTW, I am not approved for the SOLUTION but it marked anyway...

 

0 Kudos
Message 18 of 63
(1,120 Views)

@John4191 wrote:

@johntrich1971: Please read the whole thread of this topic again. I asked question about event execution order and from the discussion, it seems like LV have no capability to reverse the order of events like the text base does. As a result, I think it's a weakpoint of LV and that is not bashing. It seems like this forum is not helping but accusing for one's opinion about LV.

 

BTW, I am not approved for the SOLUTION but it marked anyway...

 


Sorry you feel that way about the forum, it generally is really helpful. I think the accusations are a result of treating LabVIEW like a text language.

  1. LabVIEW is not a text language.
  2. LabView is data flow language, From O'Reilly "This means it allows users to describe how data from one or more inputs should be read, processed, and then stored to one or more outputs in parallel."
  3. With data flow you have inputs and outputs, cannot go to the next stage unless what goes in comes out.

In your case example it seems like you want "goto" statements, go to this section and when finished return here. Data flow does not work like that. (In text programs you may be able to do that.)

 

In the code snippet you posted, the logic can be dangerous. For example you fire Event B, but before processing Event B you fire Event A. What happens to the program if it returns to the wrong place, the beginning of Event B, then you Fire another Event A, etc and end up in an infinite loop.

 

I am not a computer programmer, but I assume you want events to fire off in the order received. Each event then fires off States, functions, etc, typically not other events.

 

Think of a oscilloscope trigger. It waits for a threshold event then fires off a Start Data Acquisition State, not another event.

 

mcduff

Message 19 of 63
(1,110 Views)

Hi Mcduff,

Your words are reasonable and I totally agree about that. For instrument controls and automation, LV is #1 for a quick turn around solutions and no doubt about that. On top of this one LV also has a number of weakpoints like the "formula note" are still not working correctly, the logic of saving project and VIs is so uncommon.

 

Anyway, my solutions for this one are many. For example:

1) create another event which goes out the 'case' and fire the 'read' and 'write' event the order I wanted

2) add the 'read' code into the 'write event'

3) 'write' case (not in event anymore) and fire the 'read' event...

 

Thanks,'

J

0 Kudos
Message 20 of 63
(1,100 Views)