JKISoftware / JKI-State-Machine-Objects

Object-oriented framework for LabVIEW based on the JKI State Machine
BSD 3-Clause "New" or "Revised" License
96 stars 55 forks source link

the Process of parent smo cannot be skipped #32

Closed zwzhen closed 7 years ago

zwzhen commented 7 years ago

The setting in "Register Process.vi" works incorrectly, while doing the inheritence. I set "forces self to run" in the parent process to false, and set "parent call" of the child process to "does not request parent to run", but the parent always runs (it should goes to exiting case in state "Process: Sync", am I right?)

It seems the problem is in "WaitOnProcessSync.vi". Shall we check whether the process can run in the default case, just as what we do in case "Started" ?

francois-normandin commented 7 years ago

Thanks for your report. I know this was working in an earlier version and I don't have a unit test to validate this. Would you happen to have some code you could share that reproduces the issue? I'd like to create a unit test for this specific case.

It should be possible to do what you describe.

The WaitOnProcessSync checks if the process caller is still valid only on sync'ing to Stop the process. This is why there is extra code in the "Started" case. The issue that could happen otherwise is that you try to wait for sync for a VI that has been killed preemptively and is out of memory, causing a deadlock situation. The other case (Default) is for ProcessSync to Start the process.

At first glance, I believe I see that the ProcessSync will never return "True" in the Default case, which is the problem. The Process Sync should get a message to inform it that itself should not run...

If I'm not mistaken, this might do it:

1- In Register Process.vi (We replace the Notifier constant with a valid notifier and a SkipSelf=true boolean) image

2- In ProcessSync.vi (We check to see if StopSelf = true when we destroy the notifier) image

Can you check if those simple changes work for you? If so, I'll include those in the next build.

francois-normandin commented 7 years ago

OK, I made a quick unit test class and here's the fix: In Register Process.vi, the notifier needs to be initialized to True when process is to be overwritten. image

This results in "Don't Run?" = TRUE, which prevents loop from running. With a simplified State Machine process VI, here's what it looks like:

image

That will be fixed in the next build.