This FlexSim Community Forum is read-only. Please post any new questions, ideas, or discussions to our new community (we call it Answers) at https://answers.flexsim.com/. Our new Question & Answer site brings a modern, mobile-friendly interface and more focus on getting answers quickly. There are a few differences between how our new Q&A community works vs. a classic, threaded-conversation-style forum like the one below, so be sure to read our Answers Best Practices.
This model simulates a Queue that has a weight limit (default 100 units) that cannot be exceeded. Play with the process time and maximum weight to get custom results.
Model Implementation:
Open the FlowitemBin and create a label on the TexturedColoredBox called weight.
Open the Queue’s Properties window, and create two labels, called maxweight and currentweight respectively.
Open the Source’s Parameters window, click the SourceTriggers tab, and add a function to the OnCreation trigger using the SetLabel option. Edit the blue text to read as follows:
Object: item
Label: “weight”
Value: uniform(5,10)
Click OK
Open the Conveyor’s Parameters window, click the Triggers tab, and create a function on the OnConveyEnd by clicking the A| button. Enter the following code:
//if the item's weight makes the total weight go over 100 if((maxweight-currentweight)<itemweight)
{
//close the ports because the item weighs too much
closeinput(outobject(current, 1));
} else
{
//keep the ports open because the item will fit
openinput(outobject(current, 1));
}
Click OK on the Code Edit window, and the Parameters window.
Open the Queue’s Parameters window and click the QueueTriggers tab. Add a function to the OnReset trigger using the SetLabel option. Edit the blue text to read as follows:
Object: current
Label: “currentweight”
Value: 0
Next, add a function to the OnEntry trigger using the IncrementValue option. Edit the blue text to read as follows:
Next, add another function to the OnExit trigger using the SendMessage option. Edit the blue text to read as follows:
Delay Time: 0
To: current
From: current
Param1: 0
Param2: 0
Param3: 0
Condition: getlabelnum(current,"currentweight"<90)
Next, add a function to the OnMessage trigger using the CloseandOpen Ports option. Edit the blue text to read as follows:
Condition: 1
Action: openinput
Object: current
Click OK to close the Parameters window
Open the Visual Tool’s Parameters window. Select Text from the VisualDisplay list, then Select DisplayLabelValue from the TextDisplay list. Edit the blue text to read as follows: