-
Notifications
You must be signed in to change notification settings - Fork 1
/
data_simulator.js
79 lines (50 loc) · 1.96 KB
/
data_simulator.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
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
module.exports = function() {
this.Q100 = async function() {
return this.randomize([null, 'AVAILABLE'])
}
this.Q104 = async function() {
return `Q104 \x02MODE, ${this.randomize(['MDI', 'JOG', 'ZERORET'])}\x17 >`
}
this.Q500 = async function() {
status = this.randomize(['PROGRAM', 'STATUS'])
let str = ''
if (status == 'PROGRAM') {
str = `Q500 \x02${status},SIMULACAO,IDLE,PARTS,${this.getRandomInt(0, 10)}\x17 >`
} else {
str = `Q500 \x02${status}, BUSY\x17 >`
}
return str
}
this.Q600_5021 = async function() {
str = `Q600 5021 \x02MACRO, 5021, ${(this.getRandomInt(-600000, 200000)/1000).toFixed(3)}\x17 >`
return str
}
this.Q600_5022 = async function() {
str = `Q600 5022 \x02MACRO, 5022, ${(this.getRandomInt(-300000, 100000)/1000).toFixed(3)}\x17 >`
return str
}
this.Q600_5023 = async function() {
str = `Q600 5023 \x02MACRO, 5023, ${(this.getRandomInt(-250000, 100000)/1000).toFixed(3)}\x17 >`
return str
}
this.Q600_3027 = async function() {
str = `Q600 3027 \x02MACRO, 3027, ${(this.getRandomInt(0, 6000000)/1000).toFixed(3)}\x17 >`
return str
}
this.Q600_1094 = async function() {
str = `Q600 1094 \x02MACRO, 1094, ${(this.getRandomInt(0, 151000000)/1000).toFixed(3)}\x17 >`
return str
}
this.Q600_1098 = async function() {
str = `Q600 1098 \x02MACRO, 1098, ${Math.floor(this.getRandomInt(0, 8192)).toFixed(3)}\x17 >`
return str
}
this.getRandomInt = function(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min)) + min;
}
this.randomize = function(array_of_random_elements) {
return array_of_random_elements[Math.round(Math.random() * (array_of_random_elements.length - 1))]
}
}