Skip to content

Commit

Permalink
Various changes for hotfix 1.0.1
Browse files Browse the repository at this point in the history
• Nuked Dark mode
• Fixed tests inclusion in graphCore.js
• Fixed a couple idle zone variable related bugs in graphHelper.js
• Deleted obsolete functions (addNode, listNetwork) from graphHelper.js and getZoneCount from heatGeneration.js
• Renamed tickSpeed to tickDuration for clarity
• Fixed active orders stat not updated at closing time
• Updated comments across the board
  • Loading branch information
Mikkel committed May 19, 2021
1 parent be487eb commit 2909a9c
Show file tree
Hide file tree
Showing 11 changed files with 79 additions and 193 deletions.
1 change: 1 addition & 0 deletions node/PublicResources/js/cytoStylesheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export { CytoStyle, TestCytoStyle };
* Applies the stylesheet to the cytoscape graph
* @param {string} containerId The id of the given graph
* @param {string} graphSize The size of the graph, either "small" or "large", that the stylesheet is to be applied to
* @param {boolean} headless Whether the graph should be rendered or not
* @returns The finished graph object
*/
function CytoStyle(containerId, graphSize, headless) {
Expand Down
78 changes: 0 additions & 78 deletions node/PublicResources/js/darkMode.js

This file was deleted.

2 changes: 1 addition & 1 deletion node/PublicResources/js/dijkstra.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { initializeSingleSource, relax } from "../js/pathModules.js";

/**
* Dijkstra's algorithm will find the shortest path between all nodes in a weighted graph.
* @param {Object} cyGraph The graph nodes will be updated with new distances
* @param {Class} cyGraph The graph nodes will be updated with new distances
* and parents in terms of the new starting point.
* @param {Object} startNode The starting point node. Also called source.
*/
Expand Down
2 changes: 0 additions & 2 deletions node/PublicResources/js/dynamicPageGeneration.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ const generateVisualizationHTML = (graphs) => {
<img class="legend disable-select" src="../html/legend.png" alt="Graph legend reference" title="Graph legend reference">
<!-- Load application code at the end to ensure DOM is loaded -->
<script src="../js/graphCore.js" type="module"></script>
<script src="../js/darkMode.js" type="module"></script>
</body>
</html>
`;
Expand Down Expand Up @@ -366,7 +365,6 @@ const generateHeadlessHTML = (graph, infoDiv) => {
${infoDiv}
<!-- Load application code at the end to ensure DOM is loaded -->
<script src="../js/graphCore.js" type="module"></script>
<script src="../js/darkMode.js" type="module"></script>
</body>
</html>
`;
Expand Down
26 changes: 13 additions & 13 deletions node/PublicResources/js/graphCore.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,24 @@ import { CyGraph } from "./graphHelper.js";
import { CytoStyle } from "./cytoStylesheet.js";
import { dijkstra } from "./dijkstra.js";
import { aStar } from "./aStar.js";
import { addDarkBtn } from "./darkMode.js";
import { greedyBestFirstSearch } from "./greedyBestFirstSearch.js";
import { startSimulation } from "./orderGeneration.js";
import * as tests from "./tests.js";
import { runAllTests } from "./tests.js";

export { SetupGraph, simulationTest, getAlgorithm, startSim };

/**
* Performs setup and initialization of the input Cytoscape graph
* @param {CyGraph} cyGraph The CyGraph class to set up
* @param {Class} cyGraph The CyGraph class to set up
* @param {File} presetFile The graph preset file to load
* @param {Function} startSimulationCallback Callback function which starts the simulation
* @param {Number} tickDuration the desired miliseconds per simulation tick
*/
function SetupGraph(
cyGraph,
presetFile = null,
startSimulationCallback,
tickSpeed
tickDuration
) {
if (presetFile === null) {
startSimulation(cyGraph);
Expand All @@ -35,16 +35,18 @@ function SetupGraph(
cyGraph.initializeNodes();
cyGraph.graph.fit(cyGraph.graph.elements());
// then call the given start simulation function for this graph
startSimulationCallback(cyGraph, tickSpeed);
startSimulationCallback(cyGraph, tickDuration);
});
}

/**
* Callback function which starts the simulation once the graph is initialized
* @param {CyGraph} cyGraph The graph to perform the simulation on
* @param {Class} cyGraph The graph to perform the simulation on
* @param {Number} tickDuration the desired miliseconds per simulation tick
*/
function simulationTest(cyGraph, tickSpeed) {
startSimulation(cyGraph, tickSpeed);
function simulationTest(cyGraph, tickDuration) {
startSimulation(cyGraph, tickDuration);
runAllTests();
console.log(`[${cyGraph.name}] Started simulation`);
}

Expand Down Expand Up @@ -87,7 +89,7 @@ async function startSim() {
: graphSettings["graph-size"] === "large"
? BIG_GRAPH_PRESET_FILE
: AALBORG_GRAPH;
let tickSpeed = 1000 / graphSettings["ticks-per-second"];
let tickDuration = 1000 / graphSettings["ticks-per-second"];

for (let i = 0; i < graphSettings["number-of-graphs"]; i++) {
let cytoStyle = new CytoStyle(
Expand All @@ -105,11 +107,11 @@ async function startSim() {
graphSettings["idle-zones"], // use idle zones
graphDivs[i].classList.contains("headless"), // headless traversal
graphSettings["courier-frequency"], // max number of couriers
tickSpeed, // ms per tick
tickDuration, // ms per tick
graphSettings["obstruction-level"]
);
graphArray.push(cyGraph);
SetupGraph(cyGraph, graphSize, simulationTest, tickSpeed);
SetupGraph(cyGraph, graphSize, simulationTest, tickDuration);
}
}

Expand All @@ -122,5 +124,3 @@ const DISTANCE_PER_TICK = 300; // 300 units per tick -> meters per minute -> 18
let graphArray = [];

startSim();

addDarkBtn(graphArray);
Loading

0 comments on commit 2909a9c

Please sign in to comment.