question

Carlos S3 avatar image
0 Likes"
Carlos S3 asked Mischa Spelt answered

itemtype from a queue

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

FlexSim (other - please specify)
FlexSim (other)
queueitemtype
· 4
5 |100000

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

Joerg Vogel avatar image Joerg Vogel commented ·

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.

1 Like 1 ·
Carlos S3 avatar image Carlos S3 Joerg Vogel commented ·

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 0 ·
Joerg Vogel avatar image Joerg Vogel Carlos S3 commented ·

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 
1 Like 1 ·
Show more comments

1 Answer

Mischa Spelt avatar image
1 Like"
Mischa Spelt answered

Hi Carlos,

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

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).


5 |100000

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