I have flowitems identified by label. The lable directs where the flowitem should go and prgramatically which transporter is to take it to the location (code below). The routing and transporter code is working, however for the last 2 options, the transporter should load 4 items, not 1. I've tried everything I can think of to do this but the cannot get this to work. The transporter is configured to load 4 items, the queue batches 4 items, is there a specific task to define the quantity. I would have thought to just loop through the load command would have accomplished the requirement.
/**Custom Code*/
Object item = param(1);
Object current = ownerobject(c);
string destination = getlabel(item, "TargetQueue");
Object dispatcher;
if (destination == "queue1") {
dispatcher = model().find("Transporter1");
// Create and dispatch a task sequence for Transporter1
TaskSequence ts = TaskSequence.create(dispatcher);
ts.addTask(TASKTYPE_TRAVEL, item, outobject(current, 1)); // Travel to the item
ts.addTask(TASKTYPE_LOAD, item); // Load the item
ts.addTask(TASKTYPE_TRAVEL, outobject(current, 1)); // Travel to the destination
ts.addTask(TASKTYPE_UNLOAD, item, outobject(current, 1)); // Unload the item
ts.dispatch();
return 1; // Send to port 1
} else if (destination == "queue2") {
dispatcher = model().find("Transporter1");
// Create and dispatch a task sequence for Transporter1
TaskSequence ts = TaskSequence.create(dispatcher);
ts.addTask(TASKTYPE_TRAVEL, item, outobject(current, 2)); // Travel to the item
ts.addTask(TASKTYPE_LOAD, item); // Load the item
ts.addTask(TASKTYPE_TRAVEL, outobject(current, 2)); // Travel to the destination
ts.addTask(TASKTYPE_UNLOAD, item, outobject(current, 2)); // Unload the item
ts.dispatch();
return 2; // Send to port 2
} else if (destination == "queue3") {
dispatcher = model().find("Transporter1");
// Create and dispatch a task sequence for Transporter1
TaskSequence ts = TaskSequence.create(dispatcher);
ts.addTask(TASKTYPE_TRAVEL, item, outobject(current, 3)); // Travel to the item
ts.addTask(TASKTYPE_LOAD, item); // Load the item
ts.addTask(TASKTYPE_TRAVEL, outobject(current, 3)); // Travel to the destination
ts.addTask(TASKTYPE_UNLOAD, item, outobject(current, 3)); // Unload the item
ts.dispatch();
return 3; // Send to port 3
} else if (destination == "queue4") {
dispatcher = model().find("Trolley");
// Create and dispatch a task sequence for Trolley
TaskSequence ts = TaskSequence.create(dispatcher);
ts.addTask(TASKTYPE_TRAVEL, item, outobject(current, 4)); // Travel to the item
ts.addTask(TASKTYPE_SETNODENUM, item, NULL, 4);
//ts.addTask(TASKTYPE_LOAD, item); // Load the item
for (int i = 0; i < 4; i++) {
ts.addTask(TASKTYPE_LOAD, item);
}
ts.addTask(TASKTYPE_TRAVEL, outobject(current, 4)); // Travel to the destination
ts.addTask(TASKTYPE_UNLOAD, item, outobject(current, 4)); // Unload the item
ts.dispatch();
return 4; // Send to port 4
} else if (destination == "queue5") {
dispatcher = model().find("Transporter2");
// Create and dispatch a task sequence for Transporter2
TaskSequence ts = TaskSequence.create(dispatcher);
ts.addTask(TASKTYPE_TRAVEL, item, outobject(current, 5)); // Travel to the item
ts.addTask(TASKTYPE_SETNODENUM, dispatcher, NULL, 4);
//ts.addTask(TASKTYPE_LOAD, item); // Load the item
for (int i = 0; i < 4; i++) {
ts.addTask(TASKTYPE_LOAD, item);
}
ts.addTask(TASKTYPE_TRAVEL, outobject(current, 5)); // Travel to the destination
ts.addTask(TASKTYPE_UNLOAD, item, outobject(current, 5)); // Unload the item
ts.dispatch();
return 5; // Send to port 5
} else {
return 0; // Default: No port
}