From 1bce4de22888eb4b37b17f3a118065012331267e Mon Sep 17 00:00:00 2001 From: Georgios Andreadis Date: Thu, 26 Jan 2017 22:04:26 +0100 Subject: Set first tick to be 1 instead of 0 --- src/scripts/controllers/simulationcontroller.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/scripts/controllers/simulationcontroller.ts') diff --git a/src/scripts/controllers/simulationcontroller.ts b/src/scripts/controllers/simulationcontroller.ts index 8d9553e9..418b5437 100644 --- a/src/scripts/controllers/simulationcontroller.ts +++ b/src/scripts/controllers/simulationcontroller.ts @@ -72,7 +72,7 @@ export class SimulationController { this.experimentSelectionMode = true; this.sectionIndex = 0; - this.currentTick = 0; + this.currentTick = 1; this.playing = false; this.stateCache = new StateCache(this); this.colorRepresentation = ColorRepresentation.LOAD; @@ -340,7 +340,7 @@ export class SimulationController { this.currentPath = this.getPathById(this.currentExperiment.pathId); this.sections = this.currentPath.sections; this.sectionIndex = 0; - this.currentTick = 0; + this.currentTick = 1; this.playing = false; this.stateCache = new StateCache(this); this.colorRepresentation = ColorRepresentation.LOAD; -- cgit v1.2.3 From 50a54370e426c48164dcf10edd8857aa92747696 Mon Sep 17 00:00:00 2001 From: Georgios Andreadis Date: Thu, 26 Jan 2017 22:16:04 +0100 Subject: Fetch states for all ticks at once All experiment states are now fetched in one go. Additionally, the experiments are now expected to start at tick 1 (this was wrongly assumed to be 0, before). --- src/scripts/controllers/simulationcontroller.ts | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/scripts/controllers/simulationcontroller.ts') diff --git a/src/scripts/controllers/simulationcontroller.ts b/src/scripts/controllers/simulationcontroller.ts index 418b5437..baab21bf 100644 --- a/src/scripts/controllers/simulationcontroller.ts +++ b/src/scripts/controllers/simulationcontroller.ts @@ -504,8 +504,6 @@ export class SimulationController { return; } - console.log(this.stateCache); - let html; let container = $(".building-stats-list"); -- cgit v1.2.3 From fd6005292dbbee09a8b3f3d63f22a7c4e95faa1d Mon Sep 17 00:00:00 2001 From: Georgios Andreadis Date: Thu, 26 Jan 2017 22:59:22 +0100 Subject: Fix task state generation --- src/scripts/controllers/simulationcontroller.ts | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'src/scripts/controllers/simulationcontroller.ts') diff --git a/src/scripts/controllers/simulationcontroller.ts b/src/scripts/controllers/simulationcontroller.ts index baab21bf..9f06df97 100644 --- a/src/scripts/controllers/simulationcontroller.ts +++ b/src/scripts/controllers/simulationcontroller.ts @@ -284,9 +284,9 @@ export class SimulationController { $(".experiment-list .list-body").on("click", ".remove-experiment", (event: JQueryEventObject) => { event.stopPropagation(); - let affectedRow = $(event.target).closest(".experiment-row"); - let index = affectedRow.index(); - let affectedExperiment = this.experiments[index]; + const affectedRow = $(event.target).closest(".experiment-row"); + const index = affectedRow.index(); + const affectedExperiment = this.experiments[index]; MapController.showConfirmDeleteDialog("experiment", () => { this.mapController.api.deleteExperiment(affectedExperiment.simulationId, affectedExperiment.id) @@ -361,9 +361,9 @@ export class SimulationController { } private populateDropdowns(): void { - let pathDropdown = $("#new-experiment-path-select"); - let traceDropdown = $("#new-experiment-trace-select"); - let schedulerDropdown = $("#new-experiment-scheduler-select"); + const pathDropdown = $("#new-experiment-path-select"); + const traceDropdown = $("#new-experiment-trace-select"); + const schedulerDropdown = $("#new-experiment-scheduler-select"); pathDropdown.empty(); for (let i = 0; i < this.simulation.paths.length; i++) { @@ -504,14 +504,13 @@ export class SimulationController { return; } - let html; - let container = $(".building-stats-list"); + const container = $(".building-stats-list"); container.children().remove("div"); this.stateCache.stateList[this.currentTick].roomStates.forEach((roomState: IRoomState) => { if (this.colorRepresentation === ColorRepresentation.LOAD && roomState.room !== undefined) { - html = '
' + + const html = '
' + '

' + roomState.room.name + '

' + '

Load: ' + Math.round(roomState.loadFraction * 100) + '%

' + '
'; @@ -532,7 +531,6 @@ export class SimulationController { $("#room-name-field").text(this.mapController.roomModeController.currentRoom.name); $("#room-type-field").text(this.mapController.roomModeController.currentRoom.roomType); - let html; let container = $(".room-stats-list"); container.children().remove("div"); @@ -542,7 +540,7 @@ export class SimulationController { return; } if (this.colorRepresentation === ColorRepresentation.LOAD) { - html = '
' + + const html = '
' + '

' + rackState.rack.name + '

' + '

Load: ' + Math.round(rackState.loadFraction * 100) + '%

' + '
'; -- cgit v1.2.3 From 027b379cf9d53a12782781e586f79051461ab661 Mon Sep 17 00:00:00 2001 From: Georgios Andreadis Date: Thu, 26 Jan 2017 23:11:29 +0100 Subject: Refactor controllers to use 'const' when possible --- src/scripts/controllers/simulationcontroller.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/scripts/controllers/simulationcontroller.ts') diff --git a/src/scripts/controllers/simulationcontroller.ts b/src/scripts/controllers/simulationcontroller.ts index 9f06df97..bb46575c 100644 --- a/src/scripts/controllers/simulationcontroller.ts +++ b/src/scripts/controllers/simulationcontroller.ts @@ -278,7 +278,7 @@ export class SimulationController { return; } - let row = $(event.target).closest(".experiment-row"); + const row = $(event.target).closest(".experiment-row"); this.prepareAndLaunchExperiment(this.experiments[row.index()]); }); @@ -298,7 +298,7 @@ export class SimulationController { }); $("#new-experiment-btn").click(() => { - let nameInput = $("#new-experiment-name-input"); + const nameInput = $("#new-experiment-name-input"); if (nameInput.val() === "") { $(".experiment-name-alert").show(); return; @@ -306,7 +306,7 @@ export class SimulationController { $(".experiment-name-alert").hide(); } - let newExperiment: IExperiment = { + const newExperiment: IExperiment = { id: -1, name: nameInput.val(), pathId: parseInt($("#new-experiment-path-select").val()), @@ -394,7 +394,7 @@ export class SimulationController { * Populates the list of experiments. */ private populateExperimentsList(): void { - let table = $(".experiment-list .list-body"); + const table = $(".experiment-list .list-body"); table.empty(); console.log("EXPERIMENT", this.experiments); @@ -531,7 +531,7 @@ export class SimulationController { $("#room-name-field").text(this.mapController.roomModeController.currentRoom.name); $("#room-type-field").text(this.mapController.roomModeController.currentRoom.roomType); - let container = $(".room-stats-list"); + const container = $(".room-stats-list"); container.children().remove("div"); @@ -550,13 +550,13 @@ export class SimulationController { } private setupColorMenu(): void { - let html = + const html = ''; - let indicator = $(".color-indicator"); + const indicator = $(".color-indicator"); indicator["popover"]({ animation: true, content: html, @@ -572,7 +572,7 @@ export class SimulationController { } else { indicator["popover"]("show"); - let selectElement = $("#color-representation-select"); + const selectElement = $("#color-representation-select"); selectElement.change(() => { console.log(selectElement.val()); }); -- cgit v1.2.3