question

Jay Khedekar avatar image
0 Likes"
Jay Khedekar asked Borja Lorenzo commented

How to create a button to enable or disable certain process flow?

I want to add a button in dashboard which would enable to disable certain process flow in my model. Is it possible to do that?

FlexSim 23.0.0
process flowdashboard button
· 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.

Natalie White avatar image Natalie White commented ·

Hi @Jay K9, was Jonah K's answer helpful? If so, please click the "Accept" button at the bottom of their 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 comment back to reopen your question.

0 Likes 0 ·

1 Answer

Jonah K avatar image
1 Like"
Jonah K answered Borja Lorenzo commented

There's a couple of different ways you can accomplish this. One way that you can do it is to create a GUI button that changes the "enabled" variable in a source activity, using this code in the OnPress node (Flow1):

treenode mysource1 = getactivity("ProcessFlow", "Source1");
int enableval = getvarnum(mysource1, "enabled");
setvarnum(mysource1, "enabled", !enableval);
function_s(mysource1, "updateIcon");
repaintall();

The downside is that this method requires that you reset the model each time you press the button.

If you want to be able to click the button during the model run, you could create a button which will redirect tokens to an alternate branch on a Decide activity using a Global Variable, with this code (Flow2):

treenode globalvar = Model.find("Tools/GlobalVariables/Variable1");
globalvar.subnodes[3].value = !globalvar.subnodes[3].value;

You can reconfigure any of these two methods to fit your needs. Here's an example model:

GUIEnableProcessFlow.fsm


· 2
5 |100000

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

Jason Lightfoot avatar image Jason Lightfoot ♦♦ commented ·
Depending on the type of process flow and token source, and when you want to make the change, you might also remove an instance member from an object process flow or change the number of tokens to produce to zero either directly or via a model parameter.
0 Likes 0 ·
Borja Lorenzo avatar image Borja Lorenzo commented ·

Hello
This contribution has helped me a lot.

It’s very important to note that this works if the Model Reset button is pressed. In my case, I enabled a checkbox in the GUI to activate or desactivate the Source Events and added this code in a Model Trigger on Reset. If I put it on Start, it didn’t work until I pressed Reset again, which is why I noticed that Jonah K mentioned it worked if Reset was pressed.


If anyone is interested, I can upload a sample model of how I did it, but I think Jonah's response is very well explained.

0 Likes 0 ·