This repository was archived by the owner on Sep 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp.js
More file actions
116 lines (97 loc) · 3.39 KB
/
app.js
File metadata and controls
116 lines (97 loc) · 3.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
let simulator = angular.module('Simulator', ['ngMaterial', 'md.data.table', 'angularResizable']);
const { settingsStore } = require('./src/common/store');
simulator.config(function($mdThemingProvider) {
$mdThemingProvider.theme('docs-dark')
.primaryPalette('blue')
.accentPalette('blue-grey')
.dark();
$mdThemingProvider.theme('docs-light')
.primaryPalette('blue')
.accentPalette('blue-grey');
});
simulator.controller('IndexController', ['$scope', IndexController]);
/*
* The IndexController is the "root" in our application's controller hierarchy. It is responsible
* for changing the view between the main display and the cache details page, as well as storing
* the cacheInfo variable that is used across the entire application.
*/
function IndexController($scope) {
let ctrl = this;
// These are the tabs that appear on the navigation bar at the top of the display
$scope.navs = [{
buttonTitle: 'Overview',
active: true
},
{
buttonTitle: 'L1',
active: true
}
];
// This is where all the info is stored about the cache configuration
ctrl.cacheInfo = {
policy: 'FIFO',
blockSize: 32,
fileName: '',
B: 5,
policySet: true,
blockSizeSet: false,
disableDeleteCache: true,
policies: ['FIFO', 'LRU', 'LFU'],
blockSizes: [],
cacheSizes: [],
caches: [{
title: 'L1',
cacheSize: 'Not Set',
associativity: 'Not Set',
C: 10,
S: 0,
active: true
}]
};
this.$onInit = () => {
settingsStore.updateLocalFromStore(ctrl.cacheInfo);
ctrl.cacheInfo.blockSize = Math.pow(2, ctrl.cacheInfo.B);
};
$scope.hideParamLabels = true;
$scope.initialCacheInfo = ctrl.cacheInfo; // this is necessary for initializing the application
$scope.changeView = function(index) {
for (let i = 0; i < $scope.navs.length; i++) {
if (index === i) {
$scope.navs[i].active = true;
//Broadcast sends an event to child controllers/components
$scope.$broadcast('updatedNavs', $scope.navs[i], index-1);
} else {
$scope.navs[i].active = false;
}
}
//Pass the updated cache list to cacheDetail template to change its model
};
// Triggered by the cacheInput controller each time the cache config changes
$scope.$on('updateCacheInfo', function(event, data) {
$scope.navs = [{
buttonTitle: 'Overview',
active: true
}];
ctrl.cacheInfo = data;
let i = 1;
for (let cache of ctrl.cacheInfo.caches) {
$scope.navs[i] = {
buttonTitle: cache.title
};
i++;
}
$scope.$broadcast('cacheInfoUpdated', ctrl.cacheInfo); // send updated info back to children controllers
});
$scope.$on('updateParamLabels', function(event, data) {
$scope.hideParamLabels = data;
});
$scope.$on('inputUpdateCanvas', function(event, data) {
$scope.$broadcast('displayUpdateCanvas');
});
$scope.$on('step', (event, data) => {
$scope.$broadcast('updateModals', data);
});
$scope.$on('currentInstruction', (event, data) => {
$scope.$broadcast('breakdown', data);
});
}