question

ahmedmedhat avatar image
0 Likes"
ahmedmedhat asked Jacob W2 commented

close input port based on processor state

How to close a processor input port based on its state?

I want to close it when the state is "Changeover"

FlexSim 23.0.0
closeinputchangeover
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

·
Jacob W2 avatar image
0 Likes"
Jacob W2 answered Jacob W2 commented

Hi @ahmedmedhat,

This is something that can be done fairly easily by using process flow. In the attached model I created an event triggered source that fires each time the processor's state changes. I made sure that I created labels for the to and from states. I then used two decide activities to filter out state changes that I don't need to look at (this can be simplified into a single decide if you want.) Once a token with the toState for changeover is found, I then close the input on the processor, wait for the changeover to occur, (a delay activity.) And then I open the ports again to allow items to enter.

It is helpful to have a state table open so that you can make sure that you know what state a number references. These can be found in the toolbox.

Open-close ports_JW.fsm


· 5
5 |100000

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

ahmedmedhat avatar image ahmedmedhat commented ·

great it works but now I am trying to input time in the delay with referral to a global table by looking for the flowitem's code and retrieve the time, the code i use in the 3D model doesn't work when I place it in the delay code

here's the code:

/**Custom Code*/
Object current = ownerobject(c);
Object item = param(1);
int port = param(2);

double Time=Table.query("SELECT Time FROM [C1] WHERE Code = $1",item.Code)[1][1];

print(Time);
return Time;
0 Likes 0 ·
ahmedmedhat avatar image ahmedmedhat ahmedmedhat commented ·
also how can i apply this single process flow to multiple similar processors that will require the same exact sequence of actions?
0 Likes 0 ·
Jacob W2 avatar image Jacob W2 ♦ ahmedmedhat commented ·

For the delay activity, if the flowitem's code is a label stored on the item, one way is to use the prebuilt global table search. To make this work, on the Source I added a label for the assign event object to. This will create a reference to the processor that is changing states. Then in the delay activity I select the using global table lookup option, and in the row or column, depending on how you set up your data. I put the following

token.Processor.subnodes[1].Type

The subnodes callout looks at the item currently in the processor. the [1] says to look at the first item in the array, which in the case of most processors will be the item being processed, and the .Type refers to the label Type that I stored on the item. If pulling values from a table, it is generally best practice to use the prebuilt option if possible.

In regards to your second question, you can create a group of all of the processors that you want to have stop, and then on the event triggered source, you can listen to that group. If you set up the assign event object label, you can use that to differentiate what processor to stop. In the custom Code activites that close and open the ports, you can now use token.Processor to control which object's ports you want to close and open.

The attached model has implemented most of these things other than the group of processors.

open-close-ports-jw1.fsm

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.