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.
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
@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.
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.
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.
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?
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.
9 People are following this question.
FlexSim can help you understand and improve any system or process. Transform your existing data into accurate predictions.
FlexSim is a fully 3D simulation software environment. FlexSim can be used to simulate any process in any industry.
FlexSim®, FlexSim Healthcare™, Problem Solved.®, the FlexSim logo, the FlexSim X-mark, and the FlexSim Healthcare logo with stylized Caduceus mark are trademarks of FlexSim Software Products, Inc. All rights reserved.
Privacy | Do not sell or share my personal information | Cookie preferences | Report noncompliance | Terms of use | Legal | © Autodesk Inc. All rights reserved