ATTENTIONThis FlexSim Community Forum is read-only. Please post any new questions, ideas, or discussions to our new community (we call it Answers) at https://answers.flexsim.com/. Our new Question & Answer site brings a modern, mobile-friendly interface and more focus on getting answers quickly. There are a few differences between how our new Q&A community works vs. a classic, threaded-conversation-style forum like the one below, so be sure to read our Answers Best Practices. |
flexsim.com |
#1
|
|||
|
|||
to take from the rack
Hi All,
I have a model with source ->rack -> transporter->queue->sink. The transporter takes the items from the rack object. In the model the trasporter continuously draws from the rack object. I don't want that. What I need is the trasporter drew, for example every 800 seconds, a specified number of flowitems. The number of flowitems is variable ed it has, for example, mean=10 and standard deviation=3. How can I realize that? Thanks |
#2
|
||||
|
||||
Mario,
You could try closing the output port on reset and then sending a delayed message everytime you want the transport to pull from the rack. The transport would have to have a max content greater than the maximum value you want. On the message you can set a label on the rack to the number of items you want to leave, send another delayed message to start the sequence again, and finally open the output port of the rack. Each time an item leaves you would increment a different label than before. then you would check to see if the labels were equal and if they were you would close the output port again. This is off the top of my head so it may need some tweaking. Good Luck, Brandon
__________________
thats not normal. |
#3
|
||||
|
||||
Mario,
I found this problem is interesting and just gave it a quick try. I found a solution. This is different from Brandon's solution and requires understanding of tasksequence in Flexsim. But once you know, the idea is simple. Basically I create tasksequence to load/unload several items every time. When you open the attached model, take a look at the Operator's OnMessage trigger, in which I created tasksequence for Operators. In Operator's OnReset trigger, I kicked off the first move. And the only other place I changed is the Rack's Minimum Dwell Time, which I set to "Do not release items". Hope this is helpful. Alan
__________________
Best, Alan |
The Following User Says Thank You to AlanZhang For This Useful Post: | ||
Tom David (04-10-2009) |
#4
|
||||
|
||||
Mario,
A third solution is a combination of brandon's and alan's. You do not release the items when they enter the rack by selecting the "Do Not Release Items" option on the Dwell time. And then send a delayed message to itself and on the onmessage create a small for loop to release the right amount of items with the "releaseitem" command. Steven |
The Following User Says Thank You to Steven Hamoen For This Useful Post: | ||
Tom David (04-10-2009) |
#8
|
||||
|
||||
The model does not continuously draw items. It wait every 3 time units. You can change the following lines in the OnMessage trigger of the operator to have some other logic, say every 800 seconds.
Code:
// do next draw double delayTime = 800; inserttask(ts, TASKTYPE_SENDMESSAGE, current, NULL, 0, 0, 0, delayTime);
__________________
Best, Alan |
#9
|
||||
|
||||
Alan,
When I run your model, I also got a task error. I had a look into it and I guess it is that on the rack you did not choose "Do not release items", even if you said this in your post. Still at the end if the rack is empty or nearly empty you get a task error. That’s strange, because you check if item exits, but I did not have a deep look into it, and just might have something overseen. I guess this error occurs because there is a check to fill the itemArray but none before creating the tasks. I like your model and solution and the questions in my eyes is, if we need to post a perfect solution or if it is enough to give hints and help?
__________________
tom the (A)tom: "We have solved our problems ... now we have to fight the solutions." |
#10
|
|||
|
|||
Alan,
I have Tom's problem too. I have selected “Do not release items” but the error message remains. Moreover I have modified code inserting 800 but nothing has changed and the operator continuously draws from the rack object. Why? |
#11
|
||||
|
||||
Mario,
I thought I already gave you the solution in telling that there is a check (if the item exists) to fill the itemArray, but not before creating the tasks. If you create a task with a bad pointer (in this case that the item does not exists) you get an error message. If you have a look into the error message you posted you can see that the Involved 1 is NULL. That’s a bad pointer to a not existing item. So this item can not be loaded. I guess this happens if the rack is nearly empty. In my eyes the model works find beside this issue. I guess that it looks like that the operator works continuously is because Alan gave him a very high speed. Change the speed of the operator and the run speed of the simulation and you will see that it works. If you change the speed of the operator to a low speed than the rack will also not getting empty and you do not get the error message. :-) Anyway, I had a short look into the code and I would make the check in the code before creating the tasks. Just put a if(objectexists(itemArray[i])) Before the inserttask for FRLOAD and FRUNLOAD and the error message will not occur any longer. Code:
treenode ts = createemptytasksequence(current,0,0); treenode rack = centerobject(current, 1); int batchSize = normal(5,1); // how many items will be draw every time if(batchSize<1) batchSize = 1; treenodearray itemArray = makearray(batchSize); inti; for(i=1;i<=batchSize;i++) { if(objectexists(rank(rack, i))) itemArray[i] = rank(rack, i); } inserttask(ts,TASKTYPE_TRAVEL,rack,NULL); for(i=1;i<=batchSize;i++) if(objectexists(itemArray[i])) inserttask(ts,TASKTYPE_FRLOAD,itemArray[i],rack,1); inserttask(ts,TASKTYPE_BREAK,NULL,NULL); inserttask(ts,TASKTYPE_TRAVEL,outobject(rack,1),NULL); for(i=1;i<=batchSize;i++) if(objectexists(itemArray[i])) inserttask(ts,TASKTYPE_FRUNLOAD,itemArray[i],outobject(rack,1),opipno(rack,1)); // do next draw double delayTime = 3; inserttask(ts, TASKTYPE_SENDMESSAGE, current, NULL, 0, 0, 0, delayTime); dispatchtasksequence(ts);
__________________
tom the (A)tom: "We have solved our problems ... now we have to fight the solutions." |
The Following 3 Users Say Thank You to Tom David For This Useful Post: | ||
Roland Tainton (04-28-2009) |
#12
|
||||
|
||||
Here is my model. Only code in: OnReset, Onmessage and dwelltime.
And to be honest, a lot less code then in the previous post! |
The Following 2 Users Say Thank You to Steven Hamoen For This Useful Post: | ||
Roland Tainton (04-28-2009) |
#13
|
||||
|
||||
One formal remark to keep the level of basic statistic knowledge in this forum:
You used the variable BatchSize type integer and set that to a value from a normal distribution, which is a continuous distribution. Doesn´t make a difference here but could confuse less experienced users. Ralf aka ralle Flexsim Germany |
The Following User Says Thank You to RalfGruber For This Useful Post: | ||
Carsten Seehafer (04-15-2009) |
#14
|
||||
|
||||
Ralf, I did the same with my model. The question clearly stated a mean and a standard deviation. If you can give me statistic that returns an integer with those parameters I'm happy to use that.
So this solution is, I think, the easiest way and as far as I can think of now the only one with those parameters. Good that you point it out though, but it is called casting (getting an integer from a double), which is a normal programming feature Steven PS you are on a holiday, get your butt of this forum |
The Following User Says Thank You to Steven Hamoen For This Useful Post: | ||
Carsten Seehafer (04-15-2009) |
#15
|
||||
|
||||
Thank you David. I was in a hurry and did not run long enough time to check the model. You are right.
You modified code should work. However, I still get an invalid task one time. And I checked the item that the operator loaded is in the Flowitem Bin. I am not sure how that happen. But here is another slightly different solution, which may be safer than just using objectexists command. Code:
/**Custom Code*/ treenode current = ownerobject(c); treenode ts = createemptytasksequence(current,0,0); treenode rack = centerobject(current, 1); int batchSize = normal(5,1); // how many items will be draw every time if(batchSize<1) batchSize = 1; treenodearray itemArray = makearray(batchSize); int i; int actualBatchSize = batchSize; for(i=1;i<=batchSize;i++) { if(objectexists(rank(rack, i))) itemArray[i] = rank(rack, i); else{ actualBatchSize = i - 1; break; } } inserttask(ts,TASKTYPE_TRAVEL,rack,NULL); for(i=1;i<=actualBatchSize;i++) { inserttask(ts,TASKTYPE_FRLOAD,itemArray[i],rack,1); } inserttask(ts,TASKTYPE_BREAK,NULL,NULL); inserttask(ts,TASKTYPE_TRAVEL,outobject(rack,1),NULL); for(i=1;i<=actualBatchSize;i++) inserttask(ts,TASKTYPE_FRUNLOAD,itemArray[i],outobject(rack,1),opipno(rack,1)); // do next draw double delayTime = 3; inserttask(ts, TASKTYPE_SENDMESSAGE, current, NULL, 0, 0, 0, delayTime); dispatchtasksequence(ts);
__________________
Best, Alan |
The Following User Says Thank You to AlanZhang For This Useful Post: | ||
Roland Tainton (04-28-2009) |
#16
|
||||
|
||||
Quote:
I like your model. It also demonstrate why there is a break task within the standard task sequence created for operators. But if I change the delay time to a short time such as 2, I will get a lot of exceptions in the System Console and I have to quite Flexsim. I guess you need some sort of checking before the releaseitem command in the OnMessage trigger. But just using objectexists does not work. The reason is that when the next message is fired, the operator has not pick up the item yet. This will cause items being released by more than once. Maybe a flag to mark if the item is already released or not is required.
__________________
Best, Alan |
The Following 2 Users Say Thank You to AlanZhang For This Useful Post: | ||
Tom David (04-21-2009) |
#17
|
|||
|
|||
AlanZhang you are right ,I chang code like this.
/**Custom Code*/ treenode current = ownerobject(c); int Content = content( current ); //We sample the nr of items. We use the max because sample could be negative //and negative nr's are not possible int NrOfItems = max( 1, normal( 10, 3, 0) ); //Then we check only the max amount of products in rack int Result = min( NrOfItems, Content ); //Then release the right amount of items for( int x = 1 ; x <= Result ; x++) { addlabel(rank( current, x ),"rls",0); if(getlabelnum(rank( current, x ),"rls")==0) { setlabelnum(rank( current, x ),"rls",1); releaseitem( rank( current, x ) ); } } //And create this event again senddelayedmessage( current, 1, current, 0, 0, 0 ); it works very well. Last edited by Tom David; 08-06-2009 at 01:29 AM. Reason: Useless Quote |
Thread | Thread Starter | Forum | Replies | Last Post |
lifo fom a rack?? | Kevin Baird | Q&A | 4 | 06-26-2008 04:23 PM |