JKI State Machine Objects

cancel
Showing results for 
Search instead for 
Did you mean: 

Adding Published Event data from the SMO

I am a little confused by the examples.  I have an SMO where I send commands as a string, but I want this SMO to "publish" certain events, and I need that to be a separate data type.  How do I add additional events with differing data types that can be registered by other VI event structures?

0 Kudos
Message 1 of 11
(11,253 Views)

Hi Jed, thanks for the question.

I assume you started with one of the templates that has an event example. If you want to publish events of different types, you need to add all your events to the PublicEvents.ctl

Screen Shot 2016-03-09 at 10.35.47 AM.png

After that, any event structures that want to register for them need to call the GetPublicEvents.vi method from your SMO.

Screen Shot 2016-03-09 at 10.37.16 AM.png

I hope this helps you. Let me know if you have any further question.

Javier Ruiz - Partner at JKI
jki.net
vipm.io
0 Kudos
Message 2 of 11
(10,119 Views)

Apparently I also have to overload/create a parallel version of Set Data?

The problem I am having is that the use of the word "data" is very general.  I cannot tell which methods I would need to create/overload/modify and which will take care of themselves due to class relationships.

I duplicated your modification to the Control with a DBL.  It seems that I have to create a parallel function to setData to update the DBL.  Is that the case?

0 Kudos
Message 3 of 11
(10,119 Views)

Hi Jed,

If this is a Public Event (event for which other event structures will register), you need to "generate" that user event from within your SMO. You are correct that a way to do it would be to use a similar method to SetData, which in its simplest form would look like this (assuming you have a Public Event called "New DBL"):

Screen Shot 2016-03-09 at 1.00.09 PM.png

This is a method that DOES NOT override any other method from the parent class.

I just posted a link to a new version of the SMO Editor, which creates these Events for you.

Javier Ruiz - Partner at JKI
jki.net
vipm.io
0 Kudos
Message 4 of 11
(10,119 Views)

I just posted a link to a new version of the SMO Editor, which creates these Events for you.

Haha!  I just checked it out.  Nice work!  Thank you!

0 Kudos
Message 5 of 11
(10,119 Views)

Thank you, I just tried it out, and it works well.  A bug you might want to address though, is that I dropped a TypeDef cluster into the create event utility, and this wreaked havoc.

0 Kudos
Message 6 of 11
(10,119 Views)

Thanks Jed,

I will test this and make sure it gets fixed. Your usecase was: "you have a typedef that needs to be part of your event, along with other control types", is this correct?

Javier Ruiz - Partner at JKI
jki.net
vipm.io
0 Kudos
Message 7 of 11
(10,119 Views)

It was a typedef cluster with 4 DBLs in it.  That caused problems.  I reverted the code and then placed the 4 DBLs separately on the editor and it worked.  I can't tell you if the problem was the cluster or the TypeDef.

Note:  I did notice that the first thing it did was to add a cluster around the TypeDef cluster.

0 Kudos
Message 8 of 11
(10,119 Views)

OK, here's another question...

What's the best way to make a data request from an SMO?  I need a public function that will return data currently being processed by the SMO.

-The simplest way seems to be to maintain that data in the SMO Class defintion.  This way public member functions can access it for non-member code.  However, this would require modifying the class private data definition, and I am not sure if this would break your code (or the tools used to add events).

-The other method seems to be much too convoluted... create one event INTO the SMO to trigger an event OUT of the SMO.  Of course, the problem here is that all subscribers would be updated, which isn't necessarily what we want.

0 Kudos
Message 9 of 11
(10,119 Views)

Hi Jed:

Modifying the private data will not break the editor, so this is a valid option as long as the ByVal vs ByRef differences are understood.

I personally like the following way, with a private reply event, but we don't have the scripting working for this yet.

(This is the public method that waits for a reply)

ReplyMsg.png

Javier Ruiz - Partner at JKI
jki.net
vipm.io
0 Kudos
Message 10 of 11
(10,119 Views)