question

David Seo avatar image
0 Likes"
David Seo asked Ryan Clark commented

how to toggle (on/off) 'enable' of the inter-arrival source Activity?

2022-02-25-174413.pngMy customer want to know how to control 'enable' of the inter-arrival source activity to On/Off.

Is there a way to control the Enable field to 'check' or 'uncheck' using custom code activity?

FlexSim 22.0.1
'enable' check orinter-arrival source activityuncheckusing script
· 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.

Ryan Clark avatar image Ryan Clark commented ·

Hi @David Seo, was Felix Möhlmann'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 unaccept and comment back to reopen your question.

0 Likes 0 ·

1 Answer

·
Felix Möhlmann avatar image
1 Like"
Felix Möhlmann answered Jason Lightfoot commented
activity.as(Object).setVariable("enabled", value);
// OR
setvarnum(activity, "enabled", value);

These can set the source to be enabled (value == 1) or not (value == 0). To immediately update the icon, add

function_s(activity, "updateIcon");

The necessary code can be auto-generated by choosing a process flow source as reference for a parameter in the Parameters table.

Since you are asking about doing this is a custom code activity I presume your customer wants to switch the source on/off while the model is running? In that case a different solution would be required, since the "enabled" setting only takes effect on a reset.

A simple decide activity controlled by a global variable or process flow label that sends created tokens directly to a sink can achieve this. (You could of course also have the decide look at the "enabled" variable that is changed in the above code but that seems unnecessarily complicated).

1645782495590.png1645782564289.png


1645782495590.png (4.9 KiB)
1645782564289.png (12.6 KiB)
· 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.

David Seo avatar image David Seo commented ·

My customer wants to switch the source 'Enabled' on/off while the model is running as you presume. He wants to do it dynamically using parameter or global variables .


0 Likes 0 ·
Jason Lightfoot avatar image Jason Lightfoot ♦ David Seo commented ·
Then the condition in the decide activity would just refer to that global variable which is either 1 or 0.
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.