itemtype from a queue

itemtype from a queue

carlos_s3
Not applicable
135 Views
5 Replies
Message 1 of 6

itemtype from a queue

carlos_s3
Not applicable

[ FlexSim (other) ]

Hello,

Is there any way to determine the itemtype of queue, assuming that the queue only contain a single type of item.

For example, I wanna tell my code that if a queue is not contained by itemtype1, then I can use the queue to contain other types of items.

I'm using Flexim 7.3.6

Thanks

0 Likes
Accepted solutions (1)
136 Views
5 Replies
Replies (5)
Message 2 of 6

joerg_vogel_HsH
Mentor
Mentor

A queue isn't restricted to a special attribute of an item. You can pull items into the queue matching an atrribute like the itemtype. You push items into the queue from the previous objects by typical attributes.

If you set a label in the queue containing the attribute's value you compare with the receiving item towards to the queue, you can read this value or change it.

As long as there is an item in the queue you read the values of the attributes of the item by referencing the item by code. You use last(obj Queue) to get access to the last item of the queue. first(obj Queue) for the first item or rank(obj Queue, num order number) for nth item in the queue.

Message 3 of 6

carlos_s3
Not applicable

Thanks @Jörg Vogel

I tried to use the last(obj Queue) but I couldn't make it work, probably there is something wrong with the code.

if (QCybex2 <= 3 && last(outobject(item,2)) != 1)
{
return 2;
}

In addition, I wanna try labeling the queue containing the attribute. How to do this?

0 Likes
Message 4 of 6

joerg_vogel_HsH
Mentor
Mentor

probably the reference item in the outobject function isn't correct. It should be an object, which second output port is connected to the object you want to evaluate for the last item in it. The command last returns a pointer to the item. You need a command that evaluates an attribute on the item that you can compare with not being equal to 1. It can be the itemtype or a label value at the item.

getitemtype(last(outobject(current,2))) !=1

or

getlabelnum(last(outobject(current,2)),"mylabel at the item") != 1 
Message 5 of 6

joerg_vogel_HsH
Mentor
Mentor

If you have another request like "how to do labeling" then it is the time to ask a new question describing what you want to achieve and link this question to this current thread. If you look for labels in YouTube you find a useful video like Basic Flexsim: Labels.

0 Likes
Message 6 of 6

mischa_spelt
Advisor
Advisor
Accepted solution

Hi Carlos,

The Send To Port option on the Flow tab in the properties has a "Matching Itemtype" option:

9072-itemtypeperqueueflow.png

This will check all available output ports to check if one of the connected objects already has items of the exiting item's type and send them there. If not, it will select an empty object to send the item to. If you select this option and then click the Script ("yellow scroll") button you can see the code-behind for this option and change it to your needs (for example, if no empty objects can be found either the item will be released to the first available port, you may want to change this).