JKI State Machine Objects

cancel
Showing results for 
Search instead for 
Did you mean: 

Error Handling

I am curious about the error handling.  I had an unhandled DAQ error and noticed the "Parent will fire a public event if the error is not handled up the chain of classes."  However I did not detect any events, nor do I see any that can handle an error cluster built in.

As it was unhandled, my SMO Exited and then I got a "SMO is not running" error in the caller.  But that did not pass through the critical error.  What is the preferred way to deal with that?

0 Kudos
Message 1 of 5
(7,796 Views)

Great question Jed.

A couple of things here:

All SMO classes have a Public Event for Errors that the caller can register to. If you look at the TestLauncher for the SMO.Basic, we register for errors and merge them with the error in the loop.

Error.png

Also, if you go to the Process.vi, in the Error Handler case, you have the option to stop or not when the SMO process throws an error:

Error_Stop.png

Personally, I like to have a global Error Logger SMO that is listening to the Error event from all the SMOs and then can log errors:

ErrorLogger.png

Javier Ruiz - Partner at JKI
jki.net
vipm.io
0 Kudos
Message 2 of 5
(6,871 Views)

I realize you don't do this in the By Ref Templates.  Why is this?

Also, you are allowing NL/CRs in the SMO editor fields! 

0 Kudos
Message 3 of 5
(6,871 Views)

I see what happens... the in the more complicated examples you have a GetPublicEventsRegistration method which pulls the subclass events from SMO.SUBLCASS.GetPublicEvents and runs it through a registration node.

In order to get the parent class events you need to call SMO.Getublic events and register them separately (or edit the subclass method after it's generated by the editor).  Did i get that right?

This works, but seems to be cumbersome.  Is there a reason that the parent class events are not included in GetPublicEventsRegistration by default?

0 Kudos
Message 4 of 5
(6,871 Views)

Hi Jed,

Adding the Public Events from the parent to the child could be done, but this would need to be done manually or via scripting. I like the idea of being able to separately register for SMO Public Events and SMO.Child Public Events.

A good example is an Error Logger, which could have an array of SMOs in its private data that you set at initialization with N number of SMOs (children, grand children, grand grand childre, etc). Then, the Error Logger SMO would use the GetPublicEvents from the parent SMO and be able to register for errors from all kinds of SMOs, even if they are more specific types of SMOs.

I hope this helps.

Javier Ruiz - Partner at JKI
jki.net
vipm.io
0 Kudos
Message 5 of 5
(6,871 Views)