LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Statechart module: Using a master statechart to launch a slave statechart more than once without getting Error 1100 at Obtain Queue (No object of that name was found)

Hello,

 

I am trying to create a project using the statechart module, and one of the techniques I am trying to use is a "master-slave" statechart structure, illustrated by the code I have attached to this post (you probably need the statechart module installed to look at my example code).  The problem I have recently discovered is that the slave statecharts cannot be launched more than once without raising an Error 1100 at Obtain Queue.  I have gathered from a few other posts that the cause of this error is the fact that the First Call primitive is used by the Statechart module to initialize the statechart when it is first run.  This works fine for the first launch of the slave statechart, but the second launch and subsequent launches of the statechart fail on Error 1100, since the First Call primitive won't let the statechart initialize (the First Call primitive tells the statechart it has already been initialized (this isn't the first call), and the External Trigger function then tries to send an external trigger to a queue that doesn't exist).

 

What I can't gather from those posts is the correction I need to make to get this design to work.  I tried to send the slave statecharts a boolean flag for the "Init?" terminal, to force a reinitializing of the slave statechart.  I couldn't get that to work.  I tried to not load the slave sub VI as a slave sub VI, and launch it using some VI Server code, so that maybe the slave sub VI would be loaded and unloaded, therefore causing the statechart to properly initialize, but I couldn't get that to work either.  What correction should I make?  How do I get this to work?

 

I really want to use this design pattern, first of all since I wrote a lot of code already with this structure, and second of all, it makes a lot of sense to me.  How do I make it work?  If someone could post a version of my code that functions the same, but without the error, I would appreciate that.  If you don't have time for that, but would be able to outline the steps I need to take to get it to work, that would be helpful, as well.

 

Thanks to anyone for any assistance they can provide.  If you need any other information, please let me know.

0 Kudos
Message 1 of 6
(2,265 Views)

Can anyone help me with the "Error 1100" issue above?  Thanks.

0 Kudos
Message 2 of 6
(2,234 Views)

Morning Al,

 

You have a subVI that contains your slave SC.  What if you call it by reference?  That way when you close the reference, it should be removed from memory.

0 Kudos
Message 3 of 6
(2,202 Views)

Hello Al,

 

I think the problem is with the actual Run Statechart Function. Look at the detailed help for the function, specifically the Init? input terminal. The behavior is as such:
"Init? is TRUE if you want to restart the statechart from any initial conditions you provide. Init? is FALSE if you do not want to restart the statechart. The default value is FALSE."

So basically we can't restart it within the same run of code because the default value is false. Wire a true constant to that terminal and it should work. Let us know, hope this helps!

 

Regards,

Deborah Y.

Deborah Burke
NI Hardware and Drivers Product Manager
Certified LabVIEW Architect
0 Kudos
Message 4 of 6
(2,195 Views)

Thanks,  Wayne.C, that sounds like a good idea.  I will research how to pull this off, since I haven't done that sort of thing before.  I have strictly been a subVI kind of guy.

0 Kudos
Message 5 of 6
(2,178 Views)

Thanks, Deborah.  I tried this approach out, and it turns out you can't just wire a TRUE to the "Init?" terminal.  You have to wire a TRUE for the first run of the slave statechart, and then it has to become a FALSE.  If you wire a TRUE, it will constantly try to reset the statechart, which doesn't work.

 

The master statechart has to keep track of whether it has called the slave statechart, and communicate that to the slave statechart.  On the very first call of the slave statechart, the "First Call?" function inside of the "Run Statechart" function will give a TRUE, which initializes the statechart properly, and then gives a FALSE from that point after.  After that, the "First Call?" function doesn't work anymore (it will always return FALSE), and an initial TRUE, with subsequent FALSE values, has to be provided manually.

 

I attached a version that does this, which appears to work.  Let me know if it doesn't work for someone, or if you have a better idea to implement the correction.

 

Thanks to everyone for the replies!

0 Kudos
Message 6 of 6
(2,177 Views)