I think I have found a bug in the JKI State Machine.
Let me explain it in details :
1) "Macro: Exit"
If "Close Panel on Exit" is TRUE, ie :
-executable mode
-or Front Panel originaly closed (called by a splash screen for example)
Macro: Exit
so, the states put in "FIFO" by "Macro: Exit" state are :
UI:Front Panel State >> Close
then
Data:Cleanup
then
Exit
2) "UI:Front Panel State >> Close"
The first executed state "UI:Front Panel State >> Close" execute the "FP : Close" method, if the Front Panel is "Open".
HERE IS THE POINT
The "FP : Close" method put the VI out of memory if there is not at least one reference open to it.
So, code in "Data: Cleanup" state DOES NOT EXECUTE (no code has to be put in the "Exit" state).
3) Application 1
-Put a new blank JKI state machine on a diagram
-Shunt the "Close Panel on Exit" to TRUE
-Put break points in "Exit" state and "Data: Cleanup" state
-Run the VI
---> You see that the code stops before breakpoints, or just at the first break point put in "Data: Cleanup Up". This is due to the fact the "FP : Close" method take a certain amount of time to totally execute. IT IS A RACE CONDITION. If code in "Data: Cleanup" take a lot of tim, it would not be completly executed.
4) Application 2
-Put 3 sequenced dialog boxes in the "Data: Cleanup" state. Compile the code. Execute it and quit it. The 3 dialog boxes are not displayed.
5) Note 1
NI says : "In order for any VI to run, it must have at least one reference open to it. When you display the front panel of a VI, the front panel itself serves as an open reference to the VI".
---> In the case of the JKI state machine, the VI server reference constant "This VI" is used. For me, the reference "This VI" does not open explicitly a reference on a VI, so it's not necessary to close it as it is done in the state machine. If "This VI" was an explicitly open reference on the VI, the "Close Panel on Exit" method would not stop the execution of the VI but just hide the FP.
6) Note 2
The "exit labview" function is not used in the JKI State Machine. If the VI concerned is the main VI, the "exit labview" has to be used, I think, no?
Conclusion, to discuss
-The close reference function used in the Data:Cleanup has not be used. I'm interesting to know your point of view about the "This VI" reference. For me it is not an explicitly open reference able to maintain the vi in memory.
-The "FP: Close" and "FP: Open" methods can be used without wiring the reference inputs
-The order of the states in "Macro: Exit" has to be changed :
Data:Cleanup
Exit
UI:Front Panel State >> Close
-Maybe the "FP : Close" method has to be put out of the main while loop of the state machine, to properly stop this loop.
-In a main VI, the "exit labview" function has to be used if there is more than one main VI to ensure the total close of all VI. But in this case, if "exit labview" is used, "FP : Close" method can't be used before.
Please, let me know your point of view. All this topic is done after some tests, but errare humanum est.
Callahan
This post has been edited by Callahan: 30 December 2009 - 12:26 PM




Back to top










