View Single Post
  #3  
Old 12-08-2008
BenjaminBuecklein's Avatar
BenjaminBuecklein BenjaminBuecklein is offline
Flexsim User
 
Join Date: Sep 2008
Location: Cottbus, Germany
Posts: 11
Downloads: 6
Uploads: 0
Thanks: 3
Thanked 0 Times in 0 Posts
Rep Power: 140
BenjaminBuecklein is on a distinguished road
Lightbulb

Hey Steve,

thanks for the very quick reply and your ideas. But now I figured something out for myself.

Here is my solution:

In the Queue's flow-tab I just modified the code for "send to random available port a little bit. I created a label called "PortNr" and the code looks like this:

treenode item = parnode(1);
treenode current = ownerobject(c);
/**Random Available Port*/
/** \nIf no ports are are available, send to the first port to become available.*/

double arraysize = nrop(current);
doublearray openports = makearray(arraysize);
int nrofportsopen = 0;

if (getlabelnum(current,"portnr")==-1)
{
for( int index = 1; index <= arraysize; index++)
{
if( objectexists(outobject( current , index)) && ipopen(outobject( current , index), opipno( current , index)) && get(connectionsin(outobject( current , index)))==0 )
{
nrofportsopen++;
openports[ nrofportsopen ]
[h1] index;
}
}

double returnvalue;
if(nrofportsopen > 0)
{
int returnindex [/h1]
duniform(1, nrofportsopen);
returnvalue = openports[returnindex];
setlabelnum(current,"portnr",returnvalue);
}
else
returnvalue = 0;

return returnvalue;
setlabelnum(current,"portnr",-1);

}
else
{
return getlabelnum(current,"portnr");
}




And in the OnReset and OnEntry trigger I used this:

/**BB: R├╝cksetzen PortNr*/
treenode item = parnode(1);
treenode current = ownerobject(c);
int port = parval(2);
setlabelnum(current,"portnr",-1);


Now the Queue sends the batched contents completely to one port and close the receiveport for the other queues.

But your answer might be useful in other ways.

So, thanks a lot.

Best regards
Reply With Quote