summaryrefslogtreecommitdiff
path: root/src/scripts/controllers/simulation
diff options
context:
space:
mode:
authorGeorgios Andreadis <g.andreadis@student.tudelft.nl>2017-01-26 23:11:29 +0100
committerGeorgios Andreadis <g.andreadis@student.tudelft.nl>2017-01-26 23:11:29 +0100
commit027b379cf9d53a12782781e586f79051461ab661 (patch)
tree2a7601dce3b02b8e6984a9206849b97770ae585d /src/scripts/controllers/simulation
parent45a1bdae27115974568fe8cfaff7c190d1963e28 (diff)
Refactor controllers to use 'const' when possible
Diffstat (limited to 'src/scripts/controllers/simulation')
-rw-r--r--src/scripts/controllers/simulation/chart.ts12
-rw-r--r--src/scripts/controllers/simulation/statecache.ts8
-rw-r--r--src/scripts/controllers/simulation/timeline.ts8
3 files changed, 14 insertions, 14 deletions
diff --git a/src/scripts/controllers/simulation/chart.ts b/src/scripts/controllers/simulation/chart.ts
index 84009622..5f94f412 100644
--- a/src/scripts/controllers/simulation/chart.ts
+++ b/src/scripts/controllers/simulation/chart.ts
@@ -52,7 +52,7 @@ export class ChartController {
room.tiles.forEach((tile: ITile) => {
if (tile.object !== undefined && tile.objectType === "RACK" && this.rackSeries[tile.objectId] === undefined) {
- let objectName = (<IRack>tile.object).name;
+ const objectName = (<IRack>tile.object).name;
this.names["ra" + tile.objectId] = objectName === "" || objectName === undefined ?
"Unnamed rack" : objectName;
@@ -177,7 +177,7 @@ export class ChartController {
machineId = this.mapController.nodeModeController.currentMachine.id;
}
- let unloads: string[] = [];
+ const unloads: string[] = [];
for (let id in this.names) {
if (this.names.hasOwnProperty(id)) {
if (machineId === -1) {
@@ -211,17 +211,17 @@ export class ChartController {
}
public tickUpdated(tick: number): void {
- let roomStates: IRoomState[] = this.simulationController.stateCache.stateList[tick].roomStates;
+ const roomStates: IRoomState[] = this.simulationController.stateCache.stateList[tick].roomStates;
roomStates.forEach((roomState: IRoomState) => {
ChartController.insertAtIndex(this.roomSeries[roomState.roomId].loadFractions, tick + 1, roomState.loadFraction);
});
- let rackStates: IRackState[] = this.simulationController.stateCache.stateList[tick].rackStates;
+ const rackStates: IRackState[] = this.simulationController.stateCache.stateList[tick].rackStates;
rackStates.forEach((rackState: IRackState) => {
ChartController.insertAtIndex(this.rackSeries[rackState.rackId].loadFractions, tick + 1, rackState.loadFraction);
});
- let machineStates: IMachineState[] = this.simulationController.stateCache.stateList[tick].machineStates;
+ const machineStates: IMachineState[] = this.simulationController.stateCache.stateList[tick].machineStates;
machineStates.forEach((machineState: IMachineState) => {
ChartController.insertAtIndex(this.machineSeries[machineState.machineId].loadFractions, tick + 1, machineState.loadFraction);
});
@@ -238,4 +238,4 @@ export class ChartController {
list[index] = data;
}
-} \ No newline at end of file
+}
diff --git a/src/scripts/controllers/simulation/statecache.ts b/src/scripts/controllers/simulation/statecache.ts
index 06dbd424..19fe0d8f 100644
--- a/src/scripts/controllers/simulation/statecache.ts
+++ b/src/scripts/controllers/simulation/statecache.ts
@@ -73,7 +73,7 @@ export class StateCache {
}
private cache(): void {
- let tick = this.lastCachedTick + 1;
+ const tick = this.lastCachedTick + 1;
this.updateLastTick().then(() => {
// Check if end of simulated region has been reached
@@ -85,7 +85,7 @@ export class StateCache {
this.stateList = data;
// Determine last cached tick
- let ticks = Object.keys(this.stateList).sort((a, b) => {
+ const ticks = Object.keys(this.stateList).sort((a, b) => {
return parseInt(a) - parseInt(b);
});
if (ticks.length > 0) {
@@ -209,7 +209,7 @@ export class StateCache {
);
return Promise.all(promises).then(() => {
- let tickStates: {[key: number]: ITickState} = {};
+ const tickStates: {[key: number]: ITickState} = {};
machineStates.forEach((machineState: IMachineState) => {
if (tickStates[machineState.tick] === undefined) {
@@ -269,7 +269,7 @@ export class StateCache {
}
private fetchAllStatesOfTick(tick: number): Promise<ITickState> {
- let tickState: ITickState = {
+ const tickState: ITickState = {
tick,
machineStates: [],
rackStates: [],
diff --git a/src/scripts/controllers/simulation/timeline.ts b/src/scripts/controllers/simulation/timeline.ts
index 950973a9..ec3d8cb4 100644
--- a/src/scripts/controllers/simulation/timeline.ts
+++ b/src/scripts/controllers/simulation/timeline.ts
@@ -45,8 +45,8 @@ export class TimelineController {
});
$(".timeline-container .timeline").on("click", (event: JQueryEventObject) => {
- let parentOffset = $(event.target).closest(".timeline").offset();
- let clickX = event.pageX - parentOffset.left;
+ const parentOffset = $(event.target).closest(".timeline").offset();
+ const clickX = event.pageX - parentOffset.left;
let newTick = Math.round(clickX / (this.timelineWidth * this.timeUnitFraction));
@@ -111,7 +111,7 @@ export class TimelineController {
private updateTaskIndicators(): void {
$(".task-indicator").remove();
- let tickStateTypes = {
+ const tickStateTypes = {
"queueEntryTick": "task-queued",
"startTick": "task-started",
"finishedTick": "task-finished"
@@ -121,7 +121,7 @@ export class TimelineController {
return;
}
- let indicatorCountList = new Array(this.simulationController.stateCache.lastCachedTick);
+ const indicatorCountList = new Array(this.simulationController.stateCache.lastCachedTick);
let indicator;
this.simulationController.currentExperiment.trace.tasks.forEach((task: ITask) => {
for (let tickStateType in tickStateTypes) {