-
Notifications
You must be signed in to change notification settings - Fork 8
/
Switch.js
42 lines (36 loc) · 1.16 KB
/
Switch.js
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
export var C_switch = 1;
export var list_switches = [];
list_switches.push(-1);
export class Switch
{
constructor()
{
this.ports = ["-1", "-1", "-1", "-1", "-1", "-1", "-1","-1", "-1", "-1", "-1", "-1", "-1", "-1"];
this.table = ["-1", "-1", "-1", "-1", "-1", "-1", "-1","-1", "-1", "-1", "-1", "-1", "-1", "-1"];
this.serial = C_switch + 999;
this.left_table = ["-1", "-1", "-1", "-1", "-1", "-1"];
this.right_table = ["-1", "-1", "-1", "-1", "-1", "-1"];
C_switch ++;
}
is_port_vacant()
{
for(var i = 0; i < this.ports.length; i++)
{
if(this.ports[i] == "-1")
{
return 1;
}
}
return 0;
}
}
export function create_switch()
{
let s = new Switch();
list_switches.push(s);
}
export function reset_switches()
{
list_switches = ["-1"];
C_switch = 1;
}