Multiple parallel AssignOrder calls to the same AGV result in not all callback functions being raised
Closed this issue · 1 comments
Seydell commented
Issue
If we assign one order after another everything worked fine. If we assign a new order (new order id) before the last order was finished, the orders will accepted and the AGV is driving as expected but not all order callbacks being raised.
The picture below will show the difference between these two scenarios. First we assign one order after another then we switch to the mode that we assign a new order before the last was completed.
AssignOrder implementation:
async function processOrder(agv, order) {
return new Promise(async(resolve, reject) => {
try {
const headeredOrder = await masterController.assignOrder(agv, order, {
onOrderProcessed: (withError, byCancelation, active, context) => {
if (withError) {
console.error("mca: " + new Date().toISOString() + " rejected orderId: %s orderUpdateId: %d with error %o", context.order.orderId, context.order.orderUpdateId, withError);
reject(withError);
} else if (byCancelation) {
console.log("mca: " + new Date().toISOString() + " canceled orderId: %s orderUpdateId: %d", context.order.orderId, context.order.orderUpdateId);
resolve();
} else if (active) {
console.log("mca: " + new Date().toISOString() + " processed (still active) orderId: %s orderUpdateId: %d", context.order.orderId, context.order.orderUpdateId);
resolve();
} else {
console.log("mca: " + new Date().toISOString() + " processed (complete) orderId: %s orderUpdateId: %d", context.order.orderId, context.order.orderUpdateId);
resolve();
}
},
onNodeTraversed: (node, nextEdge, nextNode, context) => {
console.log("mca: " + new Date().toISOString() + " node traversed %o", node);
},
onEdgeTraversing: (edge, startNode, endNode, stateChanges, invocationCount, context) => {
console.log("mca: " + new Date().toISOString() + " edge traversing %o with state changes %o on invocation %d", edge, stateChanges, invocationCount);
},
onEdgeTraversed: (edge, startNode, endNode, context) => {
console.log("mca: " + new Date().toISOString() + " edge traversed %o", edge);
},
onActionStateChanged: (actionState, withError) => {
if (withError) {
console.error("mca: " + new Date().toISOString() + " action state changed %o with error %o", actionState, withError);
} else {
console.log("mca: " + new Date().toISOString() + " action state changed %o", actionState);
}
},
});
if (headeredOrder === undefined) {
console.log("mca: " + new Date().toISOString() + " discarded orderId: %s orderUpdateId: %d as active order has same orderId and orderUpdateId", order.orderId, order.orderUpdateId);
} else {
console.log("mca: " + new Date().toISOString() + " assigned order %o", headeredOrder);
}
}
catch (error) {
console.error("mca: " + new Date().toISOString() + " invalid order: %s", error.message);
reject(error);
}
});
}
Orders:
Order No.1
{
"orderId": "49263",
"orderUpdateId": 0,
"nodes": [
{
"nodeId": "208",
"sequenceId": 22209,
"released": true,
"actions": []
},
{
"nodeId": "209",
"sequenceId": 22211,
"released": true,
"actions": []
}
],
"edges": [
{
"edgeId": "e_208_209",
"sequenceId": 22210,
"startNodeId": "208",
"endNodeId": "209",
"released": true,
"actions": []
}
],
"timestamp": "2022-01-21T11:00:40.120Z",
"headerId": 345,
"manufacturer": "siemens",
"serialNumber": "simove002",
"version": "1.1.0"
}
Order No.2
{
"orderId": "49264",
"orderUpdateId": 0,
"nodes": [
{
"nodeId": "209",
"sequenceId": 22211,
"released": true,
"actions": []
},
{
"nodeId": "210",
"sequenceId": 22213,
"released": true,
"actions": []
}
],
"edges": [
{
"edgeId": "e_209_210",
"sequenceId": 22212,
"startNodeId": "209",
"endNodeId": "210",
"released": true,
"actions": []
}
],
"timestamp": "2022-01-21T11:00:46.129Z",
"headerId": 346,
"manufacturer": "siemens",
"serialNumber": "simove002",
"version": "1.1.0"
}
Order No.3
{
"orderId": "49265",
"orderUpdateId": 0,
"nodes": [
{
"nodeId": "210",
"sequenceId": 22213,
"released": true,
"actions": []
},
{
"nodeId": "211",
"sequenceId": 22215,
"released": true,
"actions": []
}
],
"edges": [
{
"edgeId": "e_210_211",
"sequenceId": 22214,
"startNodeId": "210",
"endNodeId": "211",
"released": true,
"actions": []
}
],
"timestamp": "2022-01-21T11:00:54.144Z",
"headerId": 347,
"manufacturer": "siemens",
"serialNumber": "simove002",
"version": "1.1.0"
}
Environment:
- Package Version: 1.1.1
- Node.js Version: v16.13.2
- OS: Windows 10/ Ubuntu
Deleted user commented
Your issue is related to stitching orders, i.e. orders that are stitched onto another currently active order. I have just released a patch version 1.1.4 which fixes processing of stitching orders by master control and vehicle plane.