question

Patrick Zweekhorst avatar image
0 Likes"
Patrick Zweekhorst asked Phil BoBo commented

OnStateChange node under behaviour/eventfunctions as flexscript

Hi All,

I have a module where I have added an OnStateChange dll function to an object in the library. This function worked good and did what I wanted, until I used a wait for event in processFlow where I am waiting for the OnStateChange on the same object. It looks like the wait for event in the processFlow creates a flexscript node in the behaviour node of the object in the model:

I think this causes that the dll function in the library is no longer called ( below the dll function in the library )

How can I fix this? Manually copying the dll node from the library over the flexscript node in the model works, but that then needs to be done for each object in the model.

Thank you for any help,

Patrick

Flexsim 17.1.6
modulesonstatechange
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

·
Phil BoBo avatar image
0 Likes"
Phil BoBo answered Phil BoBo commented

Try binding your OnStateChange node within your object's bindEvents() cppfunction:

bindEventByName("OnStateChange", node_b_OnStateChange, "OnStateChange");
· 14
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Patrick Zweekhorst avatar image Patrick Zweekhorst commented ·

Hi @phil.bobo ,

Thanks for your solution. Is it correct that I no longer need to have the OnStateChange dll node under behaviour/eventfunctions? This node should now be under variables as I understand correctly? It does work if I do that.

0 Likes 0 ·
Phil BoBo avatar image Phil BoBo ♦♦ Patrick Zweekhorst commented ·

"Is it correct that I no longer need to have the OnStateChange dll node under behaviour/eventfunctions?"

I don't know what your object is or what you were using the OnStateChange attribute for. So I can't definitively answer this question.

"This node should now be under variables as I understand correctly?"

The location of attribute nodes is irrelevant. You can put them anywhere in the object's attribute tree and the object can find them.

0 Likes 0 ·
Patrick Zweekhorst avatar image Patrick Zweekhorst Phil BoBo ♦♦ commented ·

Hi @phil.bobo

The object is a custom crane, which has a custom state profile. I however do want to use the states set by FlexSim. I had therefore added the OnStateChange event to the eventfunctions. This did not work completely in combination with the wait for event in processFlow.

After I added the bindEventByName in the cppfunction I got an OnStateChange node under the variables in the custom crane when I drag it in the model. This looks to be working fine and I therefore removed the OnStateChange node from under the eventfunctions node in the library and added that node under variables in the library object. I thought that otherwise I would have a OnStateChange node under eventfunctions and under variables, and that does not look efficient.

0 Likes 0 ·
Show more comments

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.