02-29-2016 05:08 AM
Hello,
In the initialization phase (please see the screenshot below) I want that all 3 event cases be executed once VI starts.
Is it possible ?
Or I should add additional frame and put there the code from these 3 cases ?
Thanks in advance.
Pavel.
02-29-2016 05:27 AM - edited 02-29-2016 05:27 AM
There is no 'VI Start' event...your code just runs when the VI starts so having an event for it doesn't make sense!
- I would discourage you from using the flat sequence structure - it is always better to use a state machine instead (with an 'initialise' case, then you would probably have a 'setup' and a 'run' case). Because you have data flow from your while loop to your for loop - the sequence structure actually serves no purpose.
- You could use the 'Value Change (signalling)' property node on one of the controls in each event structure to generate each event
- You could use a 'User Event' to generate an event programmatically (which could contain your 'initialise' code)
(Another note - rather than wire your 'start' button to the stop of the while loop, you could create an event case for the 'start' button and wire a true to the while loop stop terminal - this stops you from needing the timeout)
02-29-2016 06:11 AM
Thank Sam,
I'll implement your suggestions in the final version of VI.
But concerning this one, I din't properly understand how to initialize values without any actions from user.
To be more clear, I want that once VI starts, the values X, Y, Z take values of X0, Y0, Z0 respectively, what is actually not the case (please see the 1st screenshot).
I've added "Value Change (signalling)" into timeout case (please, see the 2nd screenshot), but it didn't help.
02-29-2016 06:20 AM
Flat sequence removed
02-29-2016 06:23 AM
02-29-2016 06:49 AM
No, I have no cases for X, Y, Z.
Except timeout I have 3 event cases:
With your current implementation - it will update the values in every timeout - you might want to put a case structure around it (perhaps with first call?)
"it will update the values ... " You mean X, Y, Z ?
Yes, I thaught that 3 event cases be executed automatically once VI starts, so X0, Y0, Z0 take theirs values from corresponding controls. And then until user clicks on "START" button, the timeout case should be executed repeattedly, where X, Y, Z are assigned from X0, Y0, Z0. But such scenario doesn't work.
Also, if you wire a 0 to the timeout in the first iteration, and then 100 in following iterations - the timeout case will execute immediately instead of waiting 100ms.
I've implemented this (at least as I understood it) - please see the screenshot below.
I've also added mouse event to the event case (to the X-related for the moment) ... well the initial assignment could be done with mous movement, but it requires minor user action nevertheless
02-29-2016 07:36 AM
02-29-2016 08:08 AM
I'm not sure that I correctly implemented your suggestions, but now it works.
I've made 2 modifications (please, see the screenshot below):
Can you confirm that you meant these modifs.
Thanks
02-29-2016 08:34 AM - edited 02-29-2016 08:35 AM
Pavel,
Forgive me if I've entirely missed the point, but I don't "get" what you are trying to do, nor do I understand why you are making so much work for yourself.
The Snippet below does the following (I just used X, instead of X, Y, and Z, for simplicity). It's goal is to step X from X0 to X1 in steps of Step X, and do to this every 100 msec (hence the value in the TimeOut, which I'm using as my "Clock"). The following "Rules" are in effect:
There are no Case statements, no Frames, nothing more complicated than shift registers and a little logic. There are also no "Value Signalling" Events ...
Bob Schor
02-29-2016 09:08 AM
Bob,
Your snippet looks much more "elegant" that mine.
My scenario is a little bit different ...
1. VI starts ... and X,Y, Z take immediately their starting values, i.e. X0, Y0, Z0
2. User do modifications (X0, X1, step X, Y0, etc.)
3. User run loops (click "START" button") ... and during running user can't do any modifications: loops cannot be interrupted
But Ok, I'll try adapt it to my 3-loop (X, Y, Z) case.
Thanks !
Pavel