question

rod avatar image
0 Likes"
rod asked Jeff Nordgren commented

In the source, i set a code to go read a planning table in order to display a value, but the code reads only the first line

rotomolding.fsm

Choose One
global table
rotomolding.fsm (244.8 KiB)
· 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.

Jeff Nordgren avatar image Jeff Nordgren commented ·

@rod dibanda

I have no clue what you are trying to do in your code because it is doing exactly what the code tells it to do. If you are wanting it to do something else, I don't know what that is because you did not give any explanation of what you want to accomplish.

In your code, if(i < i+1) {setitemtype(involved,newtype); break; is always going to be true, so it will break on the first iteration of i. i will always be less than i+1. So I'm confused as to what you are trying to do. You need to explain more what you are trying to accomplish.

0 Likes 0 ·
rod avatar image rod commented ·

if I don't put the break condition if, the code is going to give me the last value of my planning table. what I want from my code is to display the value of every line in my planning table but I don't know to write the perfect code to do it

0 Likes 0 ·
Adrian Haws avatar image Adrian Haws rod commented ·

@rod dibanda The reason it sets the value as the last cell in that column is because every time it goes through the while loop it overwrites the last value on the itemtype. Are you trying to set the itemtype as the sum of all values in that column? With the while loop logic, it would change the itemtype 12 times for every single item that is created in the source.

0 Likes 0 ·
rod avatar image rod commented ·

rotomolding-2.fsm yeah I understand your point of view, what I want is for every flow item bin which has been created ( tote in this case), flexsim should go inside my planning table, got the value correspondent ( first line for the first tote, second line for the second tote, and so one) in order to define this value as flow item type on the bin. The goal is to have different batch size inside the combiner as you can see herewith with my solution, but it's not optimal because I should every time reset my test table when I reset my flexsim model.

0 Likes 0 ·
rotomolding-2.fsm (244.4 KiB)
Logan Gold avatar image
1 Like"
Logan Gold answered

You can use the Set Itemtype (or Set Itemtype and Color) picklist option to set the itemtype without needing to add custom code. For the Item Type (or Type) field, use something like this:

gettablenum("Planning Table", getoutput(current)+1, 5)

The getoutput() command uses the output statistic of the Source to determine which flowitem is being created. For instance, for the first flowitem, the getoutput() command will return a 0. So we add a 1 and this tells us the first flowitem is being created. The gettablenum() command will then look at the first row in the Planning Table. The second flowitem will return a 1, so we add a 1, and this logic will look at the second row in the Planning Table.

The real question is since Planning Table only has 12 row, what do you want to do for when the 13th flowitem (and above) is created? If you want item 13 to look at row 1, item 14 to look at row 2, and so on, then we can use this logic instead:

gettablenum("Planning Table", (getoutput(current)%12)+1, 5)

We are still using the getoutput() command, except we're using a modulus operator. The modulus divides the two numbers and returns the remainder. In this case, getoutput(current)%12 will only ever return numbers 0 through 11. So we add a 1 to make sure the final number returned is 1 through 12. The end result is gettablenum() will sequentially look at each row in the table and start back over at 1 when the 13th item is created, row 2 when the 14th item is created, and so on.

5 |100000

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

Jeff Nordgren avatar image
0 Likes"
Jeff Nordgren answered Jeff Nordgren commented

@rod

Rod,

Attached is your model with the changes that I've made according to what I understand that you are wanting to do. What I understand is that you want to read the Planning Table, set each tote to the 5th column (Item type (batch size)) for it's itemtype as well as the number to place (batch) into the tote with flowitems of the same itemtype as the tote. That is the assumption upon which I made the changes to your model.

I changed the quantity the queue "tank supply" because it ran out of itemtypes that the tote was asking for. All the rest of the changes are in the combiner "Combiner Loading Station". I added two labels that are used in code so that it knows what the batch qty (and itemtype) and well as the tote number. The bulk of the changes are in the code area of the OnEntry trigger. Rather than try to go through the changes here, if you have any questions as to what I've done or why, please let me know. Otherwise, I'm curious if this is what you are trying to do?

rotomolding-2-jn1.fsm


rotomolding-2-jn1.fsm (347.8 KiB)
· 1
5 |100000

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

Jeff Nordgren avatar image Jeff Nordgren commented ·

@rod

Rod,

Attached is another version of you model where you were trying to set the batch size/itemtype of the tote in Source1. I changed the code in Source1 to do that then I also modified the code in the combiner to use the itemtype of the tote.

rotomolding-2-jn2.fsm

0 Likes 0 ·
rotomolding-2-jn2.fsm (347.7 KiB)

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.