dial_a_device_node 0.0.153
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +5 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +674 -0
- data/README.md +94 -0
- data/Rakefile +1 -0
- data/app/assets/images/denver_summit.jpg +0 -0
- data/app/assets/images/eppendorf_innova_42.jpg +0 -0
- data/app/assets/images/heidolph.jpg +0 -0
- data/app/assets/images/ika_ret_control.jpg +0 -0
- data/app/assets/images/kern.jpg +0 -0
- data/app/assets/images/knf_rc900.jpg +0 -0
- data/app/assets/images/knf_sc920.jpg +0 -0
- data/app/assets/images/knf_simdos_02.jpg +0 -0
- data/app/assets/images/pce_balance.jpg +0 -0
- data/app/assets/images/purebeaglebone.jpg +0 -0
- data/app/assets/images/weathercape.jpg +0 -0
- data/app/assets/javascripts/dial_a_device_node/consolelogger.js +176 -0
- data/app/assets/javascripts/dial_a_device_node/deviceconnection.js +225 -0
- data/app/assets/javascripts/dial_a_device_node/devices/denver_summit.js +153 -0
- data/app/assets/javascripts/dial_a_device_node/devices/denver_summit_SIM.js +111 -0
- data/app/assets/javascripts/dial_a_device_node/devices/denver_summit_UI.js +121 -0
- data/app/assets/javascripts/dial_a_device_node/devices/eppendorf_innova_42.js +128 -0
- data/app/assets/javascripts/dial_a_device_node/devices/eppendorf_innova_42_SIM.js +66 -0
- data/app/assets/javascripts/dial_a_device_node/devices/eppendorf_innova_42_UI.js +46 -0
- data/app/assets/javascripts/dial_a_device_node/devices/heidolph.js +62 -0
- data/app/assets/javascripts/dial_a_device_node/devices/heidolph_SIM.js +24 -0
- data/app/assets/javascripts/dial_a_device_node/devices/heidolph_UI.js +17 -0
- data/app/assets/javascripts/dial_a_device_node/devices/ika_ret_control.js +192 -0
- data/app/assets/javascripts/dial_a_device_node/devices/ika_ret_control_SIM.js +233 -0
- data/app/assets/javascripts/dial_a_device_node/devices/ika_ret_control_UI.js +96 -0
- data/app/assets/javascripts/dial_a_device_node/devices/kern.js +137 -0
- data/app/assets/javascripts/dial_a_device_node/devices/kern_SIM.js +118 -0
- data/app/assets/javascripts/dial_a_device_node/devices/kern_UI.js +121 -0
- data/app/assets/javascripts/dial_a_device_node/devices/knf_rc900.js +289 -0
- data/app/assets/javascripts/dial_a_device_node/devices/knf_rc900_SIM.js +188 -0
- data/app/assets/javascripts/dial_a_device_node/devices/knf_rc900_UI.js +179 -0
- data/app/assets/javascripts/dial_a_device_node/devices/knf_sc920.js +309 -0
- data/app/assets/javascripts/dial_a_device_node/devices/knf_sc920_SIM.js +298 -0
- data/app/assets/javascripts/dial_a_device_node/devices/knf_sc920_UI.js +441 -0
- data/app/assets/javascripts/dial_a_device_node/devices/knf_simdos_02.js +283 -0
- data/app/assets/javascripts/dial_a_device_node/devices/knf_simdos_02_SIM.js +130 -0
- data/app/assets/javascripts/dial_a_device_node/devices/knf_simdos_02_UI.js +188 -0
- data/app/assets/javascripts/dial_a_device_node/devices/legacy_vnc.js +106 -0
- data/app/assets/javascripts/dial_a_device_node/devices/legacy_vnc_SIM.js +32 -0
- data/app/assets/javascripts/dial_a_device_node/devices/legacy_vnc_UI.js +26 -0
- data/app/assets/javascripts/dial_a_device_node/devices/pce_balance.js +111 -0
- data/app/assets/javascripts/dial_a_device_node/devices/pce_balance_SIM.js +80 -0
- data/app/assets/javascripts/dial_a_device_node/devices/pce_balance_UI.js +69 -0
- data/app/assets/javascripts/dial_a_device_node/devices/purebeaglebone.js +286 -0
- data/app/assets/javascripts/dial_a_device_node/devices/purebeaglebone_SIM.js +13 -0
- data/app/assets/javascripts/dial_a_device_node/devices/purebeaglebone_UI.js +256 -0
- data/app/assets/javascripts/dial_a_device_node/devices/weathercape.js +75 -0
- data/app/assets/javascripts/dial_a_device_node/devices/weathercape_SIM.js +33 -0
- data/app/assets/javascripts/dial_a_device_node/devices/weathercape_UI.js +42 -0
- data/app/assets/javascripts/dial_a_device_node/folderwatcher.js +43 -0
- data/app/assets/javascripts/dial_a_device_node/helper/WebSocket-Node-wrapper.js +36 -0
- data/app/assets/javascripts/dial_a_device_node/helper/XMLHttpRequest.js +579 -0
- data/app/assets/javascripts/dial_a_device_node/helper/agent.js +125 -0
- data/app/assets/javascripts/dial_a_device_node/helper/ajax.js +300 -0
- data/app/assets/javascripts/dial_a_device_node/helper/type.js +10 -0
- data/app/assets/javascripts/dial_a_device_node/php/comport.php +49 -0
- data/app/assets/javascripts/dial_a_device_node/php/php_serial.class.php +622 -0
- data/app/assets/javascripts/dial_a_device_node/systemstatus.js +124 -0
- data/app/assets/javascripts/dial_a_device_node/webconnection.js +197 -0
- data/app/assets/javascripts/dial_a_device_node/websocket_rails/abstract_connection.js.coffee +45 -0
- data/app/assets/javascripts/dial_a_device_node/websocket_rails/channel.js.coffee +70 -0
- data/app/assets/javascripts/dial_a_device_node/websocket_rails/event.js.coffee +42 -0
- data/app/assets/javascripts/dial_a_device_node/websocket_rails/http_connection.js.coffee +89 -0
- data/app/assets/javascripts/dial_a_device_node/websocket_rails/websocket_connection.js.coffee +37 -0
- data/app/assets/javascripts/dial_a_device_node/websocket_rails/websocket_rails.js.coffee +164 -0
- data/app/views/devices/ui/_denver_summit.html.erb +52 -0
- data/app/views/devices/ui/_eppendorf_innova_42.html.erb +72 -0
- data/app/views/devices/ui/_heidolph.html.erb +54 -0
- data/app/views/devices/ui/_ika_ret_control.html.erb +81 -0
- data/app/views/devices/ui/_kern.html.erb +52 -0
- data/app/views/devices/ui/_knf_rc900.html.erb +143 -0
- data/app/views/devices/ui/_knf_sc920.html.erb +194 -0
- data/app/views/devices/ui/_knf_simdos_02.html.erb +98 -0
- data/app/views/devices/ui/_pce_balance.html.erb +37 -0
- data/app/views/devices/ui/_purebeaglebone.html.erb +137 -0
- data/app/views/devices/ui/_weathercape.html.erb +313 -0
- data/beaglebonechip.js +57 -0
- data/dial-a-device-web.js +84 -0
- data/dial_a_device_node.gemspec +23 -0
- data/dial_a_device_node.js +419 -0
- data/lib/dial_a_device_node.rb +6 -0
- data/lib/dial_a_device_node/version.rb +3 -0
- data/package.json +35 -0
- data/start.js +40 -0
- metadata +161 -0
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
(function (exports) {
|
|
2
|
+
|
|
3
|
+
var device_model_simulation = {
|
|
4
|
+
|
|
5
|
+
temperature: 21.0,
|
|
6
|
+
temperature_setpoint: 37,
|
|
7
|
+
|
|
8
|
+
rotation: 0,
|
|
9
|
+
rotation_setpoint: 500
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
exports.init = function (eventbus) {
|
|
15
|
+
|
|
16
|
+
setInterval(function () {
|
|
17
|
+
|
|
18
|
+
eventbus.emit('ui.update', {
|
|
19
|
+
"component": "all",
|
|
20
|
+
"model": device_model_simulation
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
eventbus.emit('device.snapshot', device_model_simulation);
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
}, 1000);
|
|
27
|
+
|
|
28
|
+
setInterval(function () {
|
|
29
|
+
|
|
30
|
+
device_model_simulation.temperature = device_model_simulation.temperature_setpoint;
|
|
31
|
+
device_model_simulation.rotation = device_model_simulation.rotation_setpoint;
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
}, 500);
|
|
35
|
+
|
|
36
|
+
eventbus.emit("serial.simulation");
|
|
37
|
+
eventbus.emit("serial.portopened");
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
if (typeof String.prototype.startsWith != 'function') {
|
|
41
|
+
String.prototype.startsWith = function (str) {
|
|
42
|
+
return this.indexOf(str) == 0;
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
eventbus.on("device.command", function (data) {
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
if (data.command == "set_temperature_setpoint") {
|
|
50
|
+
|
|
51
|
+
device_model_simulation.temperature_setpoint = data.value;
|
|
52
|
+
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (data.command == "set_rotation_setpoint") {
|
|
56
|
+
|
|
57
|
+
device_model_simulation.rotation_setpoint = data.value;
|
|
58
|
+
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
})(typeof exports == 'undefined' ? this['simulator'] = {} : exports);
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
(function (exports) {
|
|
2
|
+
|
|
3
|
+
exports.init = function (eventbus) {
|
|
4
|
+
|
|
5
|
+
eventbus.on("ui.update", function (data) {
|
|
6
|
+
|
|
7
|
+
g1.refresh(data.model.temperature);
|
|
8
|
+
|
|
9
|
+
g2.refresh(data.model.rotation);
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
if (!$('#temperature_setpoint_input').hasClass("dontupdate")) {
|
|
13
|
+
$('#temperature_setpoint_input').val(data.model.temperature_setpoint);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
if (!$('#rotation_setpoint_input').hasClass("dontupdate")) {
|
|
17
|
+
$('#rotation_setpoint_input').val(data.model.rotation_setpoint);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
exports.setTemperatureSetpoint = function setTemperatureSetpoint(val) {
|
|
29
|
+
|
|
30
|
+
localeventbus.emit("ui.command", {
|
|
31
|
+
"command": "set_temperature_setpoint",
|
|
32
|
+
"value": parseFloat(val)
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
exports.setRotationSetpoint = function setRotationSetpoint(val) {
|
|
38
|
+
|
|
39
|
+
localeventbus.emit("ui.command", {
|
|
40
|
+
"command": "set_rotation_setpoint",
|
|
41
|
+
"value": parseFloat(val)
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
})(typeof exports == 'undefined' ? this['ui'] = {} : exports);
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
(function (exports) {
|
|
2
|
+
|
|
3
|
+
var device_model = {
|
|
4
|
+
|
|
5
|
+
temperature: '0',
|
|
6
|
+
exttemperature: '0',
|
|
7
|
+
rotation: '0',
|
|
8
|
+
vacuum: '0'
|
|
9
|
+
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
exports.init = function (eventbus) {
|
|
13
|
+
|
|
14
|
+
if (typeof String.prototype.startsWith != 'function') {
|
|
15
|
+
String.prototype.startsWith = function (str) {
|
|
16
|
+
return this.indexOf(str) == 0;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
eventbus.on("device.initialized", function () {
|
|
21
|
+
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
eventbus.on("device.requestheartbeat", function () {
|
|
25
|
+
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
eventbus.on("device.reply", function (lastmessage, data) {
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
if (lastmessage.startsWith('heartbeat')) {
|
|
33
|
+
|
|
34
|
+
eventbus.emit('device.assumeconnected');
|
|
35
|
+
|
|
36
|
+
var re = data.split(';');
|
|
37
|
+
|
|
38
|
+
if (re.length == 4) {
|
|
39
|
+
|
|
40
|
+
device_model.rotation = re[0].trim();
|
|
41
|
+
device_model.temperature = re[1].trim();
|
|
42
|
+
device_model.exttemperature = re[2].trim();
|
|
43
|
+
device_model.vacuum = re[3].trim();
|
|
44
|
+
|
|
45
|
+
eventbus.emit('ui.update', {
|
|
46
|
+
"component": "all",
|
|
47
|
+
"model": device_model
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
eventbus.emit('device.snapshot', device_model);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
eventbus.emit("device.initialized");
|
|
58
|
+
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
})(typeof exports == 'undefined' ? this['device'] = {} : exports);
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
(function (exports) {
|
|
2
|
+
|
|
3
|
+
var device_model_simulation = {
|
|
4
|
+
|
|
5
|
+
temperature: '31.4',
|
|
6
|
+
exttemperature: '25.3',
|
|
7
|
+
rotation: '20',
|
|
8
|
+
vacuum: '976'
|
|
9
|
+
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
exports.init = function (eventbus) {
|
|
13
|
+
|
|
14
|
+
setInterval(function () {
|
|
15
|
+
mystring = device_model_simulation.rotation + ";" + device_model_simulation.temperature + ";" + device_model_simulation.exttemperature + ";" + device_model_simulation.vacuum;
|
|
16
|
+
eventbus.emit("device.reply", "heartbeat", mystring);
|
|
17
|
+
}, 1000);
|
|
18
|
+
|
|
19
|
+
eventbus.emit("serial.simulation");
|
|
20
|
+
eventbus.emit("serial.portopened");
|
|
21
|
+
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
})(typeof exports == 'undefined' ? this['simulator'] = {} : exports);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
(function (exports) {
|
|
2
|
+
|
|
3
|
+
exports.init = function (eventbus) {
|
|
4
|
+
|
|
5
|
+
eventbus.on("ui.update", function (data) {
|
|
6
|
+
|
|
7
|
+
g1.refresh(data.model.rotation);
|
|
8
|
+
g2.refresh(data.model.temperature);
|
|
9
|
+
g3.refresh(data.model.exttemperature);
|
|
10
|
+
g4.refresh(data.model.vacuum);
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
})(typeof exports == 'undefined' ? this['ui'] = {} : exports);
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
(function (exports) {
|
|
2
|
+
|
|
3
|
+
var device_model = {
|
|
4
|
+
|
|
5
|
+
temperature: 0,
|
|
6
|
+
temperature_setpoint: 0,
|
|
7
|
+
heater_status: 0,
|
|
8
|
+
rotation: 0,
|
|
9
|
+
rotation_setpoint: 0,
|
|
10
|
+
stirrer_status: 0
|
|
11
|
+
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
exports.init = function (eventbus) {
|
|
15
|
+
|
|
16
|
+
if (typeof String.prototype.startsWith != 'function') {
|
|
17
|
+
String.prototype.startsWith = function (str) {
|
|
18
|
+
return this.indexOf(str) == 0;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
eventbus.on("device.initialized", function () {
|
|
23
|
+
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
eventbus.on("device.heartbeat", function () {
|
|
28
|
+
|
|
29
|
+
localeventbus.emit("device.command", {
|
|
30
|
+
"command": "get_temperature"
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
localeventbus.emit("device.command", {
|
|
34
|
+
"command": "get_rotation"
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
localeventbus.emit("device.command", {
|
|
38
|
+
"command": "get_temperature_setpoint"
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
localeventbus.emit("device.command", {
|
|
42
|
+
"command": "get_rotation_setpoint"
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
localeventbus.emit("device.command", {
|
|
46
|
+
"command": "get_heater_status"
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
localeventbus.emit("device.command", {
|
|
50
|
+
"command": "get_stirrer_status"
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
eventbus.emit('ui.update', {
|
|
54
|
+
"component": "all",
|
|
55
|
+
"model": device_model
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
eventbus.emit('device.snapshot', device_model);
|
|
59
|
+
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
eventbus.on("device.command", function (data) {
|
|
64
|
+
|
|
65
|
+
if (data.command == "get_temperature") {
|
|
66
|
+
|
|
67
|
+
eventbus.emit("serial.command", "IN_PV_1");
|
|
68
|
+
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (data.command == "get_rotation") {
|
|
72
|
+
|
|
73
|
+
eventbus.emit("serial.command", "IN_PV_4");
|
|
74
|
+
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (data.command == "get_temperature_setpoint") {
|
|
78
|
+
|
|
79
|
+
eventbus.emit("serial.command", "IN_SP_1");
|
|
80
|
+
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (data.command == "get_rotation_setpoint") {
|
|
84
|
+
|
|
85
|
+
eventbus.emit("serial.command", "IN_SP_4");
|
|
86
|
+
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (data.command == "set_temperature_setpoint") {
|
|
90
|
+
|
|
91
|
+
eventbus.emit("serial.immediatecommand", "OUT_SP_1 "+data.value);
|
|
92
|
+
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (data.command == "set_rotation_setpoint") {
|
|
96
|
+
|
|
97
|
+
eventbus.emit("serial.immediatecommand", "OUT_SP_4 "+data.value);
|
|
98
|
+
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (data.command == "get_heater_status") {
|
|
102
|
+
|
|
103
|
+
eventbus.emit("serial.command", "STATUS_1");
|
|
104
|
+
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (data.command == "get_stirrer_status") {
|
|
108
|
+
|
|
109
|
+
eventbus.emit("serial.command", "STATUS_4");
|
|
110
|
+
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
if (data.command == "start_heater") {
|
|
114
|
+
|
|
115
|
+
eventbus.emit("serial.immediatecommand", "START_1");
|
|
116
|
+
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if (data.command == "stop_heater") {
|
|
120
|
+
|
|
121
|
+
eventbus.emit("serial.immediatecommand", "STOP_1");
|
|
122
|
+
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
if (data.command == "start_stirrer") {
|
|
126
|
+
|
|
127
|
+
eventbus.emit("serial.immediatecommand", "START_4");
|
|
128
|
+
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
if (data.command == "stop_stirrer") {
|
|
132
|
+
|
|
133
|
+
eventbus.emit("serial.immediatecommand", "STOP_4");
|
|
134
|
+
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
eventbus.on("device.reply", function (lastmessage, data) {
|
|
141
|
+
|
|
142
|
+
if (lastmessage.startsWith('IN_PV_1')) {
|
|
143
|
+
|
|
144
|
+
device_model.temperature = parseFloat(data.split(" ")[0]);
|
|
145
|
+
|
|
146
|
+
eventbus.emit('device.assumeconnected');
|
|
147
|
+
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
if (lastmessage.startsWith('IN_PV_4')) {
|
|
151
|
+
|
|
152
|
+
device_model.rotation = parseFloat(data.split(" ")[0]);
|
|
153
|
+
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
if (lastmessage.startsWith('IN_SP_1')) {
|
|
157
|
+
|
|
158
|
+
device_model.temperature_setpoint = parseFloat(data.split(" ")[0]);
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
if (lastmessage.startsWith('IN_SP_4')) {
|
|
164
|
+
|
|
165
|
+
device_model.rotation_setpoint = parseFloat(data.split(" ")[0]);
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
if (lastmessage.startsWith('STATUS_1')) {
|
|
171
|
+
|
|
172
|
+
device_model.heater_status = parseFloat(data.split(" ")[0][1]);
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
if (lastmessage.startsWith('STATUS_4')) {
|
|
178
|
+
|
|
179
|
+
device_model.stirrer_status = parseFloat(data.split(" ")[0][1]);
|
|
180
|
+
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
eventbus.emit("device.initialized");
|
|
188
|
+
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
})(typeof exports == 'undefined' ? this['device'] = {} : exports);
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
(function (exports) {
|
|
2
|
+
|
|
3
|
+
var device_model_simulation = {
|
|
4
|
+
|
|
5
|
+
temperature: 21.0,
|
|
6
|
+
temperature_setpoint: 100,
|
|
7
|
+
heater_status: 0,
|
|
8
|
+
rotation: 0,
|
|
9
|
+
rotation_setpoint: 500,
|
|
10
|
+
stirrer_status: 0
|
|
11
|
+
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
exports.init = function (eventbus) {
|
|
15
|
+
|
|
16
|
+
setInterval(function () {
|
|
17
|
+
|
|
18
|
+
eventbus.emit('ui.update', {
|
|
19
|
+
"component": "all",
|
|
20
|
+
"model": device_model_simulation
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
eventbus.emit('device.snapshot', device_model_simulation);
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
}, 1000);
|
|
27
|
+
|
|
28
|
+
setInterval(function () {
|
|
29
|
+
|
|
30
|
+
if (device_model_simulation.heater_status == 1) {
|
|
31
|
+
|
|
32
|
+
var oldtemperature = device_model_simulation.temperature;
|
|
33
|
+
|
|
34
|
+
var newtemperature = oldtemperature;
|
|
35
|
+
|
|
36
|
+
if (oldtemperature < device_model_simulation.temperature_setpoint) {
|
|
37
|
+
newtemperature = newtemperature + 5;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (oldtemperature > device_model_simulation.temperature_setpoint) {
|
|
41
|
+
newtemperature = newtemperature - 3;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (Math.abs(oldtemperature - newtemperature) < 5) {
|
|
45
|
+
newtemperature = device_model_simulation.temperature_setpoint;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
device_model_simulation.temperature = newtemperature;
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
} else {
|
|
52
|
+
|
|
53
|
+
var oldtemperature = device_model_simulation.temperature;
|
|
54
|
+
var newtemperature = oldtemperature - 3;
|
|
55
|
+
|
|
56
|
+
if (newtemperature < 22) {
|
|
57
|
+
newtemperature = 22;
|
|
58
|
+
}
|
|
59
|
+
device_model_simulation.temperature = newtemperature;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
if (device_model_simulation.stirrer_status == 1) {
|
|
65
|
+
|
|
66
|
+
var oldrotation = device_model_simulation.rotation;
|
|
67
|
+
|
|
68
|
+
var newrotation = oldrotation;
|
|
69
|
+
|
|
70
|
+
if (oldrotation < device_model_simulation.rotation_setpoint) {
|
|
71
|
+
newrotation = newrotation + 50;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (oldrotation > device_model_simulation.rotation_setpoint) {
|
|
75
|
+
newrotation = newrotation - 70;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (Math.abs(oldrotation - newrotation) < 70) {
|
|
79
|
+
newrotation = device_model_simulation.rotation_setpoint;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
device_model_simulation.rotation = newrotation;
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
} else {
|
|
86
|
+
|
|
87
|
+
var oldrotation = device_model_simulation.rotation;
|
|
88
|
+
var newrotation = oldrotation - 50;
|
|
89
|
+
|
|
90
|
+
if (newrotation < 0) {
|
|
91
|
+
newrotation = 0;
|
|
92
|
+
}
|
|
93
|
+
device_model_simulation.rotation = newrotation;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
}, 500);
|
|
97
|
+
|
|
98
|
+
eventbus.emit("serial.simulation");
|
|
99
|
+
eventbus.emit("serial.portopened");
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
if (typeof String.prototype.startsWith != 'function') {
|
|
103
|
+
String.prototype.startsWith = function (str) {
|
|
104
|
+
return this.indexOf(str) == 0;
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
eventbus.on("serial.immediatecommand", function (message) {
|
|
109
|
+
|
|
110
|
+
if (message.startsWith('START')) {
|
|
111
|
+
|
|
112
|
+
dev = message.split("_")[1]
|
|
113
|
+
|
|
114
|
+
switch (dev) {
|
|
115
|
+
|
|
116
|
+
case '1':
|
|
117
|
+
device_model_simulation.heater_status = 1;
|
|
118
|
+
|
|
119
|
+
break;
|
|
120
|
+
case '4':
|
|
121
|
+
device_model_simulation.stirrer_status = 1;
|
|
122
|
+
break;
|
|
123
|
+
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
if (message.startsWith('STOP')) {
|
|
129
|
+
|
|
130
|
+
dev = message.split("_")[1]
|
|
131
|
+
|
|
132
|
+
switch (dev) {
|
|
133
|
+
|
|
134
|
+
case '1':
|
|
135
|
+
device_model_simulation.heater_status = 2;
|
|
136
|
+
|
|
137
|
+
break;
|
|
138
|
+
case '4':
|
|
139
|
+
device_model_simulation.stirrer_status = 2;
|
|
140
|
+
break;
|
|
141
|
+
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
if (message.startsWith('OUT_SP')) {
|
|
147
|
+
|
|
148
|
+
dev = message.split(" ")[0].split("_")[2]
|
|
149
|
+
|
|
150
|
+
data = message.split(" ")[1]
|
|
151
|
+
|
|
152
|
+
switch (dev) {
|
|
153
|
+
|
|
154
|
+
case '1':
|
|
155
|
+
device_model_simulation.temperature_setpoint = parseFloat(data);
|
|
156
|
+
|
|
157
|
+
break;
|
|
158
|
+
case '4':
|
|
159
|
+
device_model_simulation.rotation_setpoint = parseFloat(data);
|
|
160
|
+
break;
|
|
161
|
+
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
eventbus.on("serial.command", function (message) {
|
|
170
|
+
|
|
171
|
+
var value = "OK";
|
|
172
|
+
|
|
173
|
+
if (message.startsWith('STATUS')) {
|
|
174
|
+
|
|
175
|
+
dev = message.split("_")[1]
|
|
176
|
+
|
|
177
|
+
switch (dev) {
|
|
178
|
+
|
|
179
|
+
case '1':
|
|
180
|
+
value = device_model_simulation.heater_status;
|
|
181
|
+
|
|
182
|
+
break;
|
|
183
|
+
case '4':
|
|
184
|
+
value = device_model_simulation.stirrer_status;
|
|
185
|
+
break;
|
|
186
|
+
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
if (message.startsWith('IN_PV')) {
|
|
192
|
+
|
|
193
|
+
dev = message.split(" ")[0].split("_")[2]
|
|
194
|
+
|
|
195
|
+
switch (dev) {
|
|
196
|
+
|
|
197
|
+
case '1':
|
|
198
|
+
value = device_model_simulation.temperature;
|
|
199
|
+
|
|
200
|
+
break;
|
|
201
|
+
case '4':
|
|
202
|
+
value = device_model_simulation.rotation;
|
|
203
|
+
break;
|
|
204
|
+
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
if (message.startsWith('IN_SP')) {
|
|
210
|
+
|
|
211
|
+
dev = message.split(" ")[0].split("_")[2]
|
|
212
|
+
|
|
213
|
+
switch (dev) {
|
|
214
|
+
|
|
215
|
+
case '1':
|
|
216
|
+
value = device_model_simulation.temperature_setpoint;
|
|
217
|
+
|
|
218
|
+
break;
|
|
219
|
+
case '4':
|
|
220
|
+
value = device_model_simulation.rotation_setpoint;
|
|
221
|
+
break;
|
|
222
|
+
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
eventbus.emit("device.reply", message, value);
|
|
228
|
+
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
})(typeof exports == 'undefined' ? this['simulator'] = {} : exports);
|