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.
Files changed (91) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +5 -0
  3. data/Gemfile +4 -0
  4. data/LICENSE.txt +674 -0
  5. data/README.md +94 -0
  6. data/Rakefile +1 -0
  7. data/app/assets/images/denver_summit.jpg +0 -0
  8. data/app/assets/images/eppendorf_innova_42.jpg +0 -0
  9. data/app/assets/images/heidolph.jpg +0 -0
  10. data/app/assets/images/ika_ret_control.jpg +0 -0
  11. data/app/assets/images/kern.jpg +0 -0
  12. data/app/assets/images/knf_rc900.jpg +0 -0
  13. data/app/assets/images/knf_sc920.jpg +0 -0
  14. data/app/assets/images/knf_simdos_02.jpg +0 -0
  15. data/app/assets/images/pce_balance.jpg +0 -0
  16. data/app/assets/images/purebeaglebone.jpg +0 -0
  17. data/app/assets/images/weathercape.jpg +0 -0
  18. data/app/assets/javascripts/dial_a_device_node/consolelogger.js +176 -0
  19. data/app/assets/javascripts/dial_a_device_node/deviceconnection.js +225 -0
  20. data/app/assets/javascripts/dial_a_device_node/devices/denver_summit.js +153 -0
  21. data/app/assets/javascripts/dial_a_device_node/devices/denver_summit_SIM.js +111 -0
  22. data/app/assets/javascripts/dial_a_device_node/devices/denver_summit_UI.js +121 -0
  23. data/app/assets/javascripts/dial_a_device_node/devices/eppendorf_innova_42.js +128 -0
  24. data/app/assets/javascripts/dial_a_device_node/devices/eppendorf_innova_42_SIM.js +66 -0
  25. data/app/assets/javascripts/dial_a_device_node/devices/eppendorf_innova_42_UI.js +46 -0
  26. data/app/assets/javascripts/dial_a_device_node/devices/heidolph.js +62 -0
  27. data/app/assets/javascripts/dial_a_device_node/devices/heidolph_SIM.js +24 -0
  28. data/app/assets/javascripts/dial_a_device_node/devices/heidolph_UI.js +17 -0
  29. data/app/assets/javascripts/dial_a_device_node/devices/ika_ret_control.js +192 -0
  30. data/app/assets/javascripts/dial_a_device_node/devices/ika_ret_control_SIM.js +233 -0
  31. data/app/assets/javascripts/dial_a_device_node/devices/ika_ret_control_UI.js +96 -0
  32. data/app/assets/javascripts/dial_a_device_node/devices/kern.js +137 -0
  33. data/app/assets/javascripts/dial_a_device_node/devices/kern_SIM.js +118 -0
  34. data/app/assets/javascripts/dial_a_device_node/devices/kern_UI.js +121 -0
  35. data/app/assets/javascripts/dial_a_device_node/devices/knf_rc900.js +289 -0
  36. data/app/assets/javascripts/dial_a_device_node/devices/knf_rc900_SIM.js +188 -0
  37. data/app/assets/javascripts/dial_a_device_node/devices/knf_rc900_UI.js +179 -0
  38. data/app/assets/javascripts/dial_a_device_node/devices/knf_sc920.js +309 -0
  39. data/app/assets/javascripts/dial_a_device_node/devices/knf_sc920_SIM.js +298 -0
  40. data/app/assets/javascripts/dial_a_device_node/devices/knf_sc920_UI.js +441 -0
  41. data/app/assets/javascripts/dial_a_device_node/devices/knf_simdos_02.js +283 -0
  42. data/app/assets/javascripts/dial_a_device_node/devices/knf_simdos_02_SIM.js +130 -0
  43. data/app/assets/javascripts/dial_a_device_node/devices/knf_simdos_02_UI.js +188 -0
  44. data/app/assets/javascripts/dial_a_device_node/devices/legacy_vnc.js +106 -0
  45. data/app/assets/javascripts/dial_a_device_node/devices/legacy_vnc_SIM.js +32 -0
  46. data/app/assets/javascripts/dial_a_device_node/devices/legacy_vnc_UI.js +26 -0
  47. data/app/assets/javascripts/dial_a_device_node/devices/pce_balance.js +111 -0
  48. data/app/assets/javascripts/dial_a_device_node/devices/pce_balance_SIM.js +80 -0
  49. data/app/assets/javascripts/dial_a_device_node/devices/pce_balance_UI.js +69 -0
  50. data/app/assets/javascripts/dial_a_device_node/devices/purebeaglebone.js +286 -0
  51. data/app/assets/javascripts/dial_a_device_node/devices/purebeaglebone_SIM.js +13 -0
  52. data/app/assets/javascripts/dial_a_device_node/devices/purebeaglebone_UI.js +256 -0
  53. data/app/assets/javascripts/dial_a_device_node/devices/weathercape.js +75 -0
  54. data/app/assets/javascripts/dial_a_device_node/devices/weathercape_SIM.js +33 -0
  55. data/app/assets/javascripts/dial_a_device_node/devices/weathercape_UI.js +42 -0
  56. data/app/assets/javascripts/dial_a_device_node/folderwatcher.js +43 -0
  57. data/app/assets/javascripts/dial_a_device_node/helper/WebSocket-Node-wrapper.js +36 -0
  58. data/app/assets/javascripts/dial_a_device_node/helper/XMLHttpRequest.js +579 -0
  59. data/app/assets/javascripts/dial_a_device_node/helper/agent.js +125 -0
  60. data/app/assets/javascripts/dial_a_device_node/helper/ajax.js +300 -0
  61. data/app/assets/javascripts/dial_a_device_node/helper/type.js +10 -0
  62. data/app/assets/javascripts/dial_a_device_node/php/comport.php +49 -0
  63. data/app/assets/javascripts/dial_a_device_node/php/php_serial.class.php +622 -0
  64. data/app/assets/javascripts/dial_a_device_node/systemstatus.js +124 -0
  65. data/app/assets/javascripts/dial_a_device_node/webconnection.js +197 -0
  66. data/app/assets/javascripts/dial_a_device_node/websocket_rails/abstract_connection.js.coffee +45 -0
  67. data/app/assets/javascripts/dial_a_device_node/websocket_rails/channel.js.coffee +70 -0
  68. data/app/assets/javascripts/dial_a_device_node/websocket_rails/event.js.coffee +42 -0
  69. data/app/assets/javascripts/dial_a_device_node/websocket_rails/http_connection.js.coffee +89 -0
  70. data/app/assets/javascripts/dial_a_device_node/websocket_rails/websocket_connection.js.coffee +37 -0
  71. data/app/assets/javascripts/dial_a_device_node/websocket_rails/websocket_rails.js.coffee +164 -0
  72. data/app/views/devices/ui/_denver_summit.html.erb +52 -0
  73. data/app/views/devices/ui/_eppendorf_innova_42.html.erb +72 -0
  74. data/app/views/devices/ui/_heidolph.html.erb +54 -0
  75. data/app/views/devices/ui/_ika_ret_control.html.erb +81 -0
  76. data/app/views/devices/ui/_kern.html.erb +52 -0
  77. data/app/views/devices/ui/_knf_rc900.html.erb +143 -0
  78. data/app/views/devices/ui/_knf_sc920.html.erb +194 -0
  79. data/app/views/devices/ui/_knf_simdos_02.html.erb +98 -0
  80. data/app/views/devices/ui/_pce_balance.html.erb +37 -0
  81. data/app/views/devices/ui/_purebeaglebone.html.erb +137 -0
  82. data/app/views/devices/ui/_weathercape.html.erb +313 -0
  83. data/beaglebonechip.js +57 -0
  84. data/dial-a-device-web.js +84 -0
  85. data/dial_a_device_node.gemspec +23 -0
  86. data/dial_a_device_node.js +419 -0
  87. data/lib/dial_a_device_node.rb +6 -0
  88. data/lib/dial_a_device_node/version.rb +3 -0
  89. data/package.json +35 -0
  90. data/start.js +40 -0
  91. metadata +161 -0
@@ -0,0 +1,283 @@
1
+ (function (exports) {
2
+
3
+ var device_model = {
4
+
5
+ amount: 0,
6
+ time: 0,
7
+ timecounter: 0,
8
+ amountcounter: 0,
9
+ flowrate: 0.0,
10
+ runmode: 0,
11
+ runfunction: 0,
12
+ cyclenumber: 1,
13
+ actualcyclenumber: 1
14
+
15
+ };
16
+
17
+ exports.init = function (eventbus) {
18
+
19
+ if (typeof String.prototype.startsWith != 'function') {
20
+ String.prototype.startsWith = function (str) {
21
+ return this.indexOf(str) == 0;
22
+ };
23
+ }
24
+
25
+
26
+ function pad(n, width, z) {
27
+ z = z || '0';
28
+ n = n + '';
29
+ return n.length >= width ? n : new Array(width - n.length + 1).join(z) + n;
30
+ }
31
+
32
+ function toknftime(datetime) {
33
+
34
+ var d = new Date(datetime);
35
+
36
+ return pad(d.getUTCHours(), 2) + pad(d.getUTCMinutes(), 2) + pad(d.getUTCSeconds(), 2) + "00";
37
+
38
+ }
39
+
40
+ function fromknftime(str) {
41
+
42
+ var d = new Date();
43
+
44
+ d.setTime(parseInt(str.substr(0, 2))*60*60 * 1000 + parseInt(str.substr(2, 2))*60 * 1000 + parseInt(str.substr(4, 2)) * 1000 + parseInt(str.substr(6, 2)) * 10 );
45
+
46
+ return d.getTime();
47
+
48
+ }
49
+
50
+ eventbus.on("device.initialized", function () {
51
+
52
+ });
53
+
54
+
55
+ eventbus.on("device.heartbeat", function () {
56
+
57
+ localeventbus.emit("device.command", {
58
+ "command": "get_amount"
59
+ });
60
+
61
+ localeventbus.emit("device.command", {
62
+ "command": "get_timecounter"
63
+ });
64
+
65
+ localeventbus.emit("device.command", {
66
+ "command": "get_amountcounter"
67
+ });
68
+
69
+ localeventbus.emit("device.command", {
70
+ "command": "get_flowrate"
71
+ });
72
+
73
+ localeventbus.emit("device.command", {
74
+ "command": "get_time"
75
+ });
76
+
77
+ localeventbus.emit("device.command", {
78
+ "command": "get_runmode"
79
+ });
80
+
81
+ localeventbus.emit("device.command", {
82
+ "command": "get_operationstatus"
83
+ });
84
+
85
+ localeventbus.emit("device.command", {
86
+ "command": "get_runmodestatus"
87
+ });
88
+
89
+ localeventbus.emit("device.command", {
90
+ "command": "get_dispensemodestatus"
91
+ });
92
+
93
+ eventbus.emit('ui.update', {
94
+ "component": "all",
95
+ "model": device_model
96
+ });
97
+
98
+ eventbus.emit('device.snapshot', device_model);
99
+
100
+ });
101
+
102
+
103
+ eventbus.on("device.command", function (data) {
104
+
105
+ if (data.command == "get_amount") {
106
+
107
+ eventbus.emit("serial.command", "?DV");
108
+
109
+ }
110
+
111
+ if (data.command == "set_amount") {
112
+
113
+ eventbus.emit("serial.immediatecommand", "DV"+pad(data.value, 8));
114
+
115
+ }
116
+
117
+ if (data.command == "get_timecounter") {
118
+
119
+ eventbus.emit("serial.command", "?TT");
120
+
121
+ }
122
+
123
+ if (data.command == "get_amountcounter") {
124
+
125
+ eventbus.emit("serial.command", "?TV");
126
+
127
+ }
128
+
129
+
130
+ if (data.command == "get_flowrate") {
131
+
132
+ eventbus.emit("serial.command", "?RV");
133
+
134
+ }
135
+
136
+ if (data.command == "set_flowrate") {
137
+
138
+ eventbus.emit("serial.immediatecommand", "RV"+pad(data.value, 8));
139
+
140
+ }
141
+
142
+
143
+ if (data.command == "get_time") {
144
+
145
+ eventbus.emit("serial.command", "?DT");
146
+
147
+ }
148
+
149
+ if (data.command == "set_time") {
150
+
151
+ eventbus.emit("serial.immediatecommand", "DT"+toknftime(data.value));
152
+
153
+ }
154
+
155
+ if (data.command == "get_runmode") {
156
+
157
+ eventbus.emit("serial.command", "?MS");
158
+
159
+ }
160
+
161
+ if (data.command == "get_operationstatus") {
162
+
163
+ eventbus.emit("serial.command", "?SS1");
164
+
165
+ }
166
+
167
+ if (data.command == "get_runmodestatus") {
168
+
169
+ eventbus.emit("serial.command", "?SS3");
170
+
171
+ }
172
+
173
+ if (data.command == "get_dispensemodestatus") {
174
+
175
+ eventbus.emit("serial.command", "?SS4");
176
+
177
+ }
178
+
179
+ if (data.command == "set_runmode") {
180
+
181
+ eventbus.emit("serial.immediatecommand", "MS"+data.value);
182
+
183
+ }
184
+
185
+ if (data.command == "set_function") {
186
+
187
+ eventbus.emit("serial.immediatecommand", "KY"+data.value);
188
+
189
+ device_model.runfunction = data.value;
190
+
191
+ }
192
+
193
+
194
+
195
+ });
196
+
197
+
198
+ eventbus.on("device.reply", function (lastmessage, data) {
199
+
200
+
201
+ if (lastmessage.startsWith('?DV')) {
202
+
203
+ device_model.amount = parseFloat(data);
204
+
205
+ eventbus.emit('device.assumeconnected');
206
+
207
+ }
208
+
209
+ if (lastmessage.startsWith('?TT')) {
210
+
211
+ device_model.timecounter = fromknftime(data);
212
+
213
+ }
214
+
215
+ if (lastmessage.startsWith('?DT')) {
216
+
217
+ device_model.time = fromknftime(data);
218
+
219
+ }
220
+
221
+ if (lastmessage.startsWith('?TV')) {
222
+
223
+ device_model.amountcounter = parseFloat(data);
224
+
225
+ }
226
+
227
+ if (lastmessage.startsWith('?RV')) {
228
+
229
+ device_model.flowrate = parseFloat(data);
230
+
231
+ }
232
+
233
+ if (lastmessage.startsWith('?MS')) {
234
+
235
+ device_model.runmode = parseInt(data);
236
+
237
+ }
238
+
239
+ if (lastmessage.startsWith('?SS1')) {
240
+
241
+ if (parseInt(data) == 1) {
242
+
243
+ device_model.runfunction = 1;
244
+
245
+ } else {
246
+
247
+
248
+ device_model.runfunction = 0;
249
+ }
250
+
251
+ }
252
+
253
+ if (lastmessage.startsWith('?SS3')) {
254
+
255
+ if (parseInt(data) == 1) {
256
+
257
+ device_model.runmode = 0;
258
+ device_model.runfunction = 1;
259
+
260
+ }
261
+
262
+ }
263
+
264
+ if (lastmessage.startsWith('?SS4')) {
265
+
266
+ if (parseInt(data) == 1) {
267
+
268
+ device_model.runfunction = 1;
269
+
270
+ }
271
+
272
+ }
273
+
274
+
275
+ });
276
+
277
+
278
+ eventbus.emit("device.initialized");
279
+
280
+ };
281
+
282
+
283
+ })(typeof exports == 'undefined' ? this['device'] = {} : exports);
@@ -0,0 +1,130 @@
1
+ (function (exports) {
2
+
3
+ var device_model_simulation = {
4
+
5
+ amount: 400,
6
+ time: 1000,
7
+ timecounter: 0,
8
+ amountcounter: 0,
9
+ flowrate: 400.0,
10
+ runmode: 0,
11
+ runfunction: 0,
12
+ cyclenumber: 1,
13
+ actualcyclenumber: 1
14
+
15
+ };
16
+
17
+ exports.init = function (eventbus) {
18
+
19
+ setInterval(function () {
20
+
21
+
22
+ if (device_model_simulation.runfunction == 1) {
23
+
24
+ device_model_simulation.timecounter = device_model_simulation.timecounter + 1000;
25
+
26
+
27
+ if (device_model_simulation.runmode == 0) {
28
+
29
+
30
+ device_model_simulation.amountcounter = device_model_simulation.amountcounter + Math.round(device_model_simulation.flowrate / 60);
31
+
32
+ if (device_model_simulation.amountcounter >= device_model_simulation.amount) {
33
+
34
+ device_model_simulation.runfunction = 0;
35
+ }
36
+
37
+ }
38
+
39
+ if (device_model_simulation.runmode == 1) {
40
+
41
+
42
+ device_model_simulation.amountcounter = device_model_simulation.amountcounter + Math.round((device_model_simulation.amount / (device_model_simulation.time/1000)));
43
+
44
+ if (device_model_simulation.timecounter >= device_model_simulation.time) {
45
+
46
+ device_model_simulation.runfunction = 0;
47
+ }
48
+
49
+ }
50
+
51
+ if (device_model_simulation.runmode == 2) {
52
+
53
+
54
+ device_model_simulation.amountcounter = device_model_simulation.amountcounter + Math.round(device_model_simulation.flowrate / 60);
55
+
56
+ if (device_model_simulation.timecounter >= device_model_simulation.time) {
57
+
58
+ device_model_simulation.runfunction = 0;
59
+ }
60
+
61
+ }
62
+
63
+ }
64
+
65
+ if (device_model_simulation.runfunction == 2) {
66
+
67
+ device_model_simulation.timecounter = 2000;
68
+ device_model_simulation.runfunction = 0;
69
+ device_model_simulation.amountcounter = 175;
70
+
71
+ }
72
+
73
+ eventbus.emit('ui.update', {
74
+ "component": "all",
75
+ "model": device_model_simulation
76
+ });
77
+
78
+ eventbus.emit('device.snapshot', device_model_simulation);
79
+
80
+
81
+ }, 1000);
82
+
83
+ eventbus.emit("serial.simulation");
84
+ eventbus.emit("serial.portopened");
85
+
86
+ eventbus.on("device.command", function (data) {
87
+
88
+ if (data.command == "set_amount") {
89
+
90
+ device_model_simulation.amount = data.value;
91
+
92
+ }
93
+
94
+ if (data.command == "set_flowrate") {
95
+
96
+ device_model_simulation.flowrate = data.value;
97
+
98
+ }
99
+
100
+ if (data.command == "set_time") {
101
+
102
+ device_model_simulation.time = data.value;
103
+
104
+ }
105
+
106
+ if (data.command == "set_runmode") {
107
+
108
+ device_model_simulation.runmode = data.value;
109
+
110
+ }
111
+
112
+ if (data.command == "set_function") {
113
+
114
+ if (device_model_simulation.runfunction == 0 && data.value > 0) {
115
+
116
+ device_model_simulation.timecounter = 0;
117
+ device_model_simulation.amountcounter = 0;
118
+
119
+
120
+ }
121
+
122
+ device_model_simulation.runfunction = data.value;
123
+
124
+ }
125
+
126
+ });
127
+
128
+ };
129
+
130
+ })(typeof exports == 'undefined' ? this['simulator'] = {} : exports);
@@ -0,0 +1,188 @@
1
+ (function (exports) {
2
+
3
+
4
+ function pad(n, width, z) {
5
+ z = z || '0';
6
+ n = n + '';
7
+ return n.length >= width ? n : new Array(width - n.length + 1).join(z) + n;
8
+ }
9
+
10
+
11
+
12
+ exports.init = function (eventbus) {
13
+
14
+ eventbus.on("ui.update", function (data) {
15
+
16
+
17
+ document.getElementById("amountcounter").innerHTML = data.model.amountcounter + " µl";
18
+
19
+ var d = new Date();
20
+
21
+ d.setTime(data.model.timecounter);
22
+
23
+ document.getElementById("timecounter").innerHTML = pad(d.getUTCHours(), 2)+':'+pad(d.getUTCMinutes(), 2)+':'+pad(d.getUTCSeconds(), 2);
24
+
25
+ switch (parseInt(data.model.runfunction)) {
26
+ case 0:
27
+
28
+ // STOP
29
+
30
+ $('#start').removeClass('active');
31
+ $('#pause').removeClass('active');
32
+
33
+ $('#stop').addClass('active');
34
+
35
+ break;
36
+
37
+ case 1:
38
+
39
+ // START
40
+
41
+ $('#start').addClass('active');
42
+ $('#pause').removeClass('active');
43
+
44
+ $('#stop').removeClass('active');
45
+
46
+ break;
47
+
48
+ case 3:
49
+
50
+ // PAUSE
51
+ $('#start').removeClass('active');
52
+ $('#pause').addClass('active');
53
+
54
+ $('#stop').removeClass('active');
55
+ break;
56
+ }
57
+
58
+ switch ((data.model.runmode)) {
59
+ case 0:
60
+ $('#runmode').text('Run Mode');
61
+
62
+ $("#tflowrate").show();
63
+ $("#tamount").hide();
64
+ $("#ttime").hide();
65
+
66
+ break;
67
+ case 1:
68
+ $('#runmode').text('Dispense Mode (volume)');
69
+
70
+ $("#tflowrate").hide();
71
+ $("#tamount").show();
72
+ $("#ttime").show();
73
+ break;
74
+ case 2:
75
+ $('#runmode').text('Dispense Mode (flow rate)');
76
+
77
+ $("#tflowrate").show();
78
+ $("#tamount").hide();
79
+ $("#ttime").show();
80
+ break;
81
+
82
+ }
83
+
84
+ if (!$('#amount_input').hasClass("dontupdate")) {
85
+ $('#amount_input').val(data.model.amount);
86
+ }
87
+
88
+ if (!$('#flowrate_input').hasClass("dontupdate")) {
89
+ $('#flowrate_input').val(data.model.flowrate);
90
+ }
91
+
92
+ var d2 = new Date(data.model.time);
93
+
94
+ if (!$('#time_input').hasClass("dontupdate")) {
95
+ $('#time_input').val(d2.getUTCSeconds() + d2.getUTCMinutes()*60 + d2.getUTCHours() * 60 * 60);
96
+ }
97
+
98
+
99
+ });
100
+
101
+ };
102
+
103
+ exports.setRunmode = function setRunmode(data) {
104
+
105
+ localeventbus.emit("ui.command", {
106
+ "command": "set_runmode",
107
+ "value": data
108
+ });
109
+ };
110
+
111
+ exports.toggleStart = function toggleStartPause() {
112
+
113
+ localeventbus.emit("ui.command", {
114
+ "command": "set_function",
115
+ "value": 1
116
+ });
117
+
118
+ };
119
+
120
+ exports.togglePause = function toggleStartPause() {
121
+
122
+ localeventbus.emit("ui.command", {
123
+ "command": "set_function",
124
+ "value": 3
125
+ });
126
+
127
+ };
128
+
129
+ exports.toggleStop = function toggleStop() {
130
+
131
+ localeventbus.emit("ui.command", {
132
+ "command": "set_function",
133
+ "value": 0
134
+ });
135
+
136
+ };
137
+
138
+ exports.togglePrimeDrain = function togglePrimeDrain() {
139
+
140
+ localeventbus.emit("ui.command", {
141
+ "command": "set_function",
142
+ "value": 2
143
+ });
144
+
145
+ };
146
+
147
+ exports.setFlowrate = function setFlowrate(data) {
148
+
149
+ localeventbus.emit("ui.command", {
150
+ "command": "set_flowrate",
151
+ "value": data
152
+ });
153
+
154
+ };
155
+
156
+ exports.setAmount = function setAmount(data) {
157
+
158
+ localeventbus.emit("ui.command", {
159
+ "command": "set_amount",
160
+ "value": data
161
+ });
162
+
163
+ };
164
+
165
+
166
+ exports.setTime = function setTime(data) {
167
+
168
+ localeventbus.emit("ui.command", {
169
+ "command": "set_time",
170
+ "value": data
171
+ });
172
+
173
+ };
174
+
175
+ exports.setTimeSeconds = function setTimeSeconds(data) {
176
+
177
+ var d = new Date();
178
+
179
+ d.setTime(data*1000);
180
+
181
+ localeventbus.emit("ui.command", {
182
+ "command": "set_time",
183
+ "value": d.getTime()
184
+ });
185
+
186
+ };
187
+
188
+ })(typeof exports == 'undefined' ? this['ui'] = {} : exports);