LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

calling a piece of code based on event

Hi,

Looking for some help with my project.

I have a code that receives data continuously. But i want to call another piece of code once in a while based on an event (maybe a boolean event for now). I was wondering what would be the best way to do that. Any sample vi or example would be helpful.

 

Thanks

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

This is almost too vague to be able to say too much.  If your "other piece of code" is a sub-VI that "does one thing, then exits", the simplest way to accomplish this would be to have an Event Structure that fires when your Event occurs and contains the sub-VI as the code that it executes.

 

I'm assuming that there's more to your question than this extremely simple, straight-forward answer covers.  I cannot guess, however, what it is.

 

Bob Schor

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

What is this other piece of code doing?  Is it to run in parallel with your acquisition?  What else is happening in your code?

 

You definitely need to give more context in order for us to give you a good answer.  Supplying code also helps.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 3 of 5
(2,504 Views)

Sorry for the brief description. Here are more details:

 

In my main code, I am reading data from the CAN-Ethernet gateway module I am using. I am continuously reading data from it based on the trigger. The trigger occurs every second. This part is working fine. I am using a production consumer loop to take in data and record it into binary file. 

 

But now I have to add more functionality to my code. I have to change settings on the module like changing the CAN speed. I made separate code for this. Now I want to implement this part into my main code. The user will select when he wants to change the speed. So when the boolean event changes, it will run this part of the code. And once done, it will go back to the main code. 

Is it better to use event structure? I have never used event structure, thats why it gets confusing for me. Is there a sample code I can refer to? 

 

Hopefully, this clear things up abit. 

Let me know if more information is needed. 

 

Thanks alot for help

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

As a general rule, GUIs should be handled with an Event Structure.  It can handle control value changes, panels closing, drag and drop, etc.  Just do a quick search on the forums and you will find a ton of code using them.  You can also look in the example finder (help->find examples).


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 5 of 5
(2,436 Views)