-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathActivity.js
More file actions
executable file
·54 lines (45 loc) · 1.47 KB
/
Activity.js
File metadata and controls
executable file
·54 lines (45 loc) · 1.47 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
class Activity {
constructor(n, d, dd) {
this.name = n;
this.dependency = d;
this.duration = dd;
this.num1 = 0;
this.num2 = dd;
this.num3 = 0;
this.num4 = 0;
this.num5 = 0;
this.num6 = 0;
}
familiarize() {
this.connectTo = [];
for (let key in all_activity) {
if (all_activity[key].dependency.indexOf(this.name) != -1)
this.connectTo.push(key);
}
if (this.connectTo.length == 0 && this.name != "end") {
this.connectTo.push("end");
all_activity["end"].dependency.push(this.name);
}
}
calculateTop(parentNeedTime) {
//console.log(this.name +">")
this.num1 = Math.max(this.num1, parentNeedTime);
//this.num2 ok
this.num3 = this.num1 + this.duration;
this.connectTo.forEach((x) => { all_activity[x].calculateTop(this.num3); });
this.calculateBottom();
}
calculateBottom() { //console.log(this.name +"<")
if (this.name == "end") {
this.num6 = this.num3;
} else {
this.num6 = Number.MAX_VALUE;
this.connectTo.forEach((x) => {
console.log(this.name + " | " + this.num6 + " ? " + x + ":" + all_activity[x].num4)
this.num6 = Math.min(this.num6, all_activity[x].num4);
});
}
this.num4 = this.num6 - this.num2;
this.num5 = this.num4 - this.num1;
}
}