Let rack output goods under specified circumstances

Let rack output goods under specified circumstances

wie_k
Not applicable
71 Views
15 Replies
Message 1 of 16

Let rack output goods under specified circumstances

wie_k
Not applicable

[ FlexSim 23.0.1 ]

How can I make rack send goods with a specific label (for example: the color is orange) at a specific time without using processflow

0 Likes
Accepted solutions (1)
72 Views
15 Replies
Replies (15)
Message 2 of 16

moehlmann_fe
Observer
Observer
Accepted solution

You could configure the On Message trigger to release items of a given type up to a specified quantity.

Object current = ownerobject(c);
Object fromObject = param(1);
Variant msgparam1 = param(2);
Variant msgparam2 = param(3);
Variant msgparam3 = param(4);

int type = msgparam1;
int qty = msgparam2;

// Search for items in rack
Array Items = Storage.system.queryItems("WHERE Type == $1 AND item.slot.storageObject == $2", 0, type, current);

// Release found items up to specified quantity
for(int i = 1; i <= Math.min(Items.length, qty); i++)
{
    Object item = Items.as(Storage.Slot.Item).item;    
    releaseitem(item, 1);
}

If the release is timed, the respective message could be send by a user event (Toolbox -> Modeling Logic)

Writing this logic into the On Message trigger makes it easily accessible from anywhere in the model through the "sendmessage()" command. If the release is only triggered at a single place, you can also place the code there directly (just make sure to assign the correct rack to "current") and forego the use of the trigger.

timed_release_fm.fsm

0 Likes
Message 3 of 16

jason_lightfootVL7B4
Autodesk
Autodesk

You can also put the same code on a label of the rack with an appropriate 'functional' name and invoke that 'user method' label with the evaluate() method, passing in the two parameters.

rack.labels["releaseNofType"].evaluate(<type>, <quantity>);


Or you can create a user command where you pass in the rack, type and quantity (least preferred technique).

0 Likes
Message 4 of 16

wie_k
Not applicable

Can I apply the same pattern to queues?

0 Likes
Message 5 of 16

jason_lightfootVL7B4
Autodesk
Autodesk
Yes but you'll then want to find all the items of a type iteratively, through a query or record them in a label array, table or map on the queue - you can't use findItem() as that's a Storage.System method.
0 Likes
Message 6 of 16

wie_k
Not applicable

may i ask how can i make this?

0 Likes
Message 7 of 16

jason_lightfootVL7B4
Autodesk
Autodesk

The equivalent query would be done with a Table.query() call. Here's the documentation for that using a queue (scroll down to the section "Advanced Query Techniques")


0 Likes
Message 8 of 16

jason_lightfootVL7B4
Autodesk
Autodesk
We encourage students to make sure they indicate their academic status on their profile, and to look for solutions in the academic material provided to them, FlexSim's documentation and in the forum such that they can first attempt a solution themselves.
0 Likes
Message 9 of 16

wie_k
Not applicable
ok , Thanks
0 Likes
Message 10 of 16

moehlmann_fe
Observer
Observer

The basic principle, certainly. But the queue is not part of the storage system, so you need to query for available items in a different way.

The attached model demonstrates a general approach that would also work for the rack, if you want to unify the logic.

The queue pushes all entering items to a global list in the "Send to Port" option. The list has a "Type" field that mirrors the value of the Type label and is partitioned by the object that pushed the item to the list (so you only need a single list for multiple objects).

1675250888091.png

The OnMessage code then pulls items with matching type from the correct partition, up to the specified quantity. If there are not enough items on the list to reach the quantity, the rest is ignored.

Object current = ownerobject(c);
Object fromObject = param(1);
Variant msgparam1 = param(2);
Variant msgparam2 = param(3);
Variant msgparam3 = param(4);

int type = msgparam1;
int qty = msgparam2;

// Pull matching items from list
string pullQuery = "WHERE Type == " + string.fromNum(type, 0);
Variant pulledItems = List("ItemList").pull(pullQuery, qty, 0, current, current);

// Release pulled items
for(int i = 1; i <= pulledItems.length; i++)
{
    releaseitem(pulledItems, 1);
}

timed-release-fm_1.fsm

0 Likes
Message 11 of 16

wie_k
Not applicable

I would like to know how to set up if there are more than two output?

0 Likes
Message 12 of 16

moehlmann_fe
Observer
Observer
The second parameter in "releaseitem(item, port)" controls through which port the item is send. Leaving it blank means that the "Send to Port" option will be evaluated to determine the port.
0 Likes
Message 13 of 16

wie_k
Not applicable

I want to know where my settings are wrong, all the items on the rack are taken in one execution

Is there a mistake in setting the ID?螢幕擷取畫面-2023-02-01-224021.png

0 Likes
Message 14 of 16

moehlmann_fe
Observer
Observer
Everything looks correct. Did you reset the model after changing the "Send to Port" option?

Could you upload the model so I can have a look what might be going wrong?

0 Likes
Message 15 of 16

wie_k
Not applicable

queue_found_time.fsmHere is the model, I reset the model after changing it, but it doesn't workhere is the model , i reset the model after changed

0 Likes
Message 16 of 16

moehlmann_fe
Observer
Observer

Huh, interesting. The rack seems to behave differently for the default return value that the "Push to ItemList" option in the "Send to Port" field uses.

By default it returns a number than is larger than the number of output connections. If you replace this with a -1 it seems to work properly again.

1675698081047.png

0 Likes