I am trying to visualize the simulation of process advancement based on its process definition ID. I use simulation support to perform it, but I have an issue, I guess, with the exclusive gateway. When the process advances in the other flow of the gateway, there is a problem. It does not pursue the right path, but in the console, it renders the correct task that the process executes.
This is the function based on simulation support:
private async startTokenSimulation(): Promise<void> {
if (this.isSimulationStarted) return;
const simulationSupport = this.bpmnJS.get<any>('simulationSupport');
if (!simulationSupport) {
console.error('Simulation support is not available.');
return;
}
simulationSupport.toggleSimulation(true);
this.isSimulationStarted = true;
let firstStartEventProcessed = false;
try {
for (const instance of this.activityInstances) {
console.log('Processing instance:', instance);
if (!firstStartEventProcessed && instance.activityType === 'startEvent') {
simulationSupport.triggerElement(instance.activityId, { ended: !!instance.endTime });
firstStartEventProcessed = true;
console.log('Start Event Processed:', instance.activityId);
} else if (instance.endTime) {
simulationSupport.elementEnter(instance.activityId, { ended: true });
console.log('Element Entered and Ended:', instance.activityId);
} else {
simulationSupport.triggerElement(instance.activityId);
console.log('Element Triggered:', instance.activityId);
}
}
} catch (error) {
console.error('Error during token simulation:', error);
}
}
And this is the video that can explain my issue in more detail: