some patches to moveonedge to trigger a callback rather than using forward tables

This commit is contained in:
2025-09-08 12:46:17 -05:00
parent a7ea3ed49e
commit 5714564bd5
2 changed files with 52 additions and 3 deletions
+11 -3
View File
@@ -13,6 +13,7 @@ class CompleteNodeOnEdgeEngine {
this.edges = edges;
this.dotNodes = dotNodes;
this.forwTable = forwTable;
this.onArrival = null;
this.linksByEdges = {};
@@ -30,6 +31,10 @@ class CompleteNodeOnEdgeEngine {
this.targetInterval = this.time_delay;
}
setArrivalCallback(callback) {
this.onArrival = callback;
}
/**
* Initializes the movement of the nodes on edges.
*/
@@ -143,9 +148,9 @@ class CompleteNodeOnEdgeEngine {
this.maxTime = Math.max(this.maxTime, this.currentTime);
}
document.getElementById("currenttime").innerHTML = this.currentTime/1000;
/*document.getElementById("currenttime").innerHTML = this.currentTime/1000;
document.getElementById("ratio_inc").innerHTML = this.ratio_inc/100;
document.getElementById("maxtime").innerHTML = this.maxTime/1000;
document.getElementById("maxtime").innerHTML = this.maxTime/1000;*/
}
/**
@@ -186,7 +191,10 @@ class CompleteNodeOnEdgeEngine {
dotNode.ratio += current_ratio;
if (dotNode.ratio > 100) {
this.traces_table[dotNode.id].push(dotNode.target);
if (!this.updateDotNode(dotNode, dotNode.target, this.forwTable[dotNode.target][dotNode.source], dotNode.ratio - 100)) {
if (typeof this.onArrival === 'function') {
try {
this.onArrival({ from: dotNode.source, to: dotNode.target, dot: dotNode });
} catch (e) {}
this.dotNodes.remove(dotNode, time);
return;
}