Hello,
I have the processors, each of them has a queue. I want to know the content of the queues and then program the source to send the item to the queue with one object. That is, i want to priorize the queue with one item.
Hello,
I have the processors, each of them has a queue. I want to know the content of the queues and then program the source to send the item to the queue with one object. That is, i want to priorize the queue with one item.
Use this in the sendtoport to prioritse queues with one item first and then send to the shortest queue.
treenode item = parnode(1); treenode current = ownerobject(c); /**Queues with 1 items then Shortest Queue if Available*/ /**Send to the port corresponding to the shortest queue downstream that is available.*/ treenode tempobject; int curmincontent = 1000000000; // this sets the integer to the largest possible value that an integer can hold. double curminindex = 0; for (int index = 1; index <= nrop(current); index++) { tempobject = outobject(current, index); if (opavailable(current,index) && (content(tempobject) ==1)) { return index; } } for (int index = 1; index <= nrop(current); index++) { tempobject = outobject(current, index); if (opavailable(current,index) && content(tempobject) < curmincontent) { curmincontent = content(tempobject); curminindex = index; } } return curminindex ;
Model attached.
Firstly, your code has differents lines that you should correct. You can't compare a treenode variable with an integer, so you have to declarate contenidoM1, contenidoM2 and contenidoM3 as an integer. Moreover, i think that this code is not going to work properly because you are going to send only the items to the first port, because in the initial moment you are going to have 0 content for all queues, so you going to send one item for the first queue. Then, you are going to send other item to the first queue because you are going to be in the case: contenidoM1=1 contenidoM2=0 contenidoM3=0, and then, you are going to be in this case: contenidoM1=2, contenidoM2=0 contenidoM3=0 so you are going to send the item to the queue 1 . Then, when the items exit the queue 1,you are going to be back to the previous cases (in which you always send the item to the first queue). So I recommend you to set this code in send to port (SCMarcado) :
Don´t forget to have the correct conexions!
I attach the model, if you have problems for open it, you can download the latest version of flexsim and open it with this version, you don´t need license to open this example. I hope it helps!
Hi @Ines L , I have created an example trying to get the solution that you are looking for. I have done a simple process with two processors that have do decide to what port send the processed item. I've created a simple processFlow logic for decide and send the box to the correct queue.To do this, I made a custom code within the decision activity in which we decided to queue by prioritizing the queue with content 1 and then the queue with content 0. If these conditions are not met, the queue is chosen randomly. I've attached the example model, if you have any questions please tell me.
Hi Begoña,
I can´t oper your model. In my process, I want to send the items from "SCM marcado" to "MM1 MM2 o MM3" when the queue content =1.
I have used an exit trigger on SMC marcado but it doesn't work:
/**Custom Code*/
treenode item = parnode(1);
treenode current = ownerobject(c);
treenode station = parnode(2);
double tiempo=time();
setlabelnum(item, "SCMarcado",tiempo);
treenode contenidoM1=outobject(current,2);
treenode contenidoM2=outobject(current,3);
treenode contenidoM3=outobject(current,4);
if (contenidoM1==0 && contenidoM2==1 && contenidoM3==0)
{return 3;}
else if (contenidoM1==0 && contenidoM2==0 && contenidoM3==3)
{return 4;}
else
{return 2;}
13 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