question

Chan L2 avatar image
0 Likes"
Chan L2 asked Chan L2 commented

How to control certain objects via a button in my GUI?

Hello!

There are several objects in my model (convoyer1, processor1, processor 2, combiner1, ...), and I want to make a GUI where there are several buttons, and each button can get only one object started. For example, when I click button1, convoyer1 will start working, but the other objects (processor1, processor 2, combiner1,...) will not work.

I've tried to add the code below to the attribute of "OnPress" of the button1, but it's not correct. Could you help me to correct my code? Or do you have any example that can be helpful for me? Thank you very much!

treenode machine_c1 = model().find("/Convoyeur 1");
{
    go(1)
}

Have a nice day!

FlexSim 20.0.2
guiflexsim 20.0.2
· 1
5 |100000

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

Ben Wilson avatar image Ben Wilson ♦♦ commented ·

Hi @Chan L2, was Allister Wilson's answer helpful? If so, please click the red "Accept" button at the bottom of his answer. Or if you still have questions, add a comment and we'll continue the conversation.

If we haven't heard back from you within 3 business days we'll auto-accept an answer, but you can always unaccept and comment back to reopen your question.

0 Likes 0 ·

1 Answer

·
Allister Wilson avatar image
1 Like"
Allister Wilson answered Chan L2 commented

You'll want to :

  1. stop all the objects when the simulation starts : Object.stop
  2. resume each object in the OnPress of its associated button : Object.resume

For point 1, the cleanest approach would probably be an instanced process flow (Process Flow Instances) attached to all the objects you want to stop, which creates a token when the simulation starts, and stops the attached object (Custom Code activity, Control / Stop Object picklist).
Alternatively, you could add all the objects to a group, then create a user event which fires at time 0 and iterates over the group, stopping each object.

· 1
5 |100000

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

Chan L2 avatar image Chan L2 commented ·

Thank you very much!

0 Likes 0 ·

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.