07-30-2017 02:21 AM
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
07-30-2017 05:28 AM
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
07-30-2017 07:39 AM
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.
07-30-2017 02:27 PM
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
07-30-2017 06:23 PM
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).