question

Savannah avatar image
0 Likes"
Savannah asked Jason Lightfoot commented

Queue batch size changes based on the length of another queue

I found the following code that changes the target batch size for a Combiner based on the length of the queue before it.

Object current = ownerobject(c);

Object item = param(1);

int port = param(2);

{ // ************* PickOption Start ************* //

/***popup:CompleteTray*/

/***tag:description*//**CompleteTray*/

/***tag:tray*//**/

if (current.inObjects[2].subnodes.length == 0)

{

treenode targetComponent = getvarnode(current, "targetcomponentsum");

int newTarget = current.subnodes.length;

setnodenum(targetComponent, newTarget);

}/**/

; // leave a no-op statement in case they leave it empty

} // ******* PickOption End ******* //

Is it possible to do that with a queue batch size instead of a Combiner Target?

The queue after the processor has a predermined batch size value but when the queue before the processor is empty, the batch size changes to however many objects are already in the queue. It will also have to have a delay time for the batch size to change so the last object in the processor can join the rest of the batch.

FlexSim 20.0.9
flexscriptqueue contentflexsim 20.0.9
5 |100000

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

1 Answer

Jason Lightfoot avatar image
0 Likes"
Jason Lightfoot answered Savannah edited
You could instead check that the upstream queue is empty when the item arrives (on entry) and if it is release the items as per this answer. (but you would use a different expression for the if condition).
· 2
5 |100000

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

Savannah avatar image Savannah commented ·

@jason.lightfoot I tried to change the condition expression to the following, but it still did not release the "smaller than a batch" objects.

I was unable to open your model, as my license doesn't support the latest versions of FlexSim.


/**Custom Code*/

Object current = ownerobject(c);

Object item = param(1);

int port = param(2);

if (Model.find("Station 1/Ceramic Disk Batch").subnodes.length==0) {

releaseitem(current.first,1);

}


0 Likes 0 ·
Jason Lightfoot avatar image Jason Lightfoot ♦♦ Savannah commented ·

Here's an example with model attached.

I put label pointers on Queue2 after the processor for easy reference to the processor and upstream queue:

Then the entry trigger is just this:

if (current.proc.subnodes.length==0&&current.queue.subnodes.length==0) {
    while (content(current))
       releaseitem(current.first,2);
    current.setVariable("currentbatchsize",-1);
}

Savannah_earlyReleaseQcondition.fsm

0 Likes 0 ·