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
data/beaglebonechip.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
var util = require('util');
|
|
2
|
+
var os = require('os');
|
|
3
|
+
|
|
4
|
+
(function (exports) {
|
|
5
|
+
|
|
6
|
+
exports.getSerialNumber = function (callback) {
|
|
7
|
+
|
|
8
|
+
var b = require('bonescript');
|
|
9
|
+
|
|
10
|
+
b.getPlatform(interpretPlatform);
|
|
11
|
+
|
|
12
|
+
function interpretPlatform(x) {
|
|
13
|
+
|
|
14
|
+
if (x.serialNumber && x.serialNumber != "") {
|
|
15
|
+
|
|
16
|
+
callback(x.serialNumber);
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
} else {
|
|
20
|
+
|
|
21
|
+
require('getmac').getMac(function (err, macAddress) {
|
|
22
|
+
|
|
23
|
+
if (err) throw err;
|
|
24
|
+
serialnumber = macAddress.replace(/\:/g, "");
|
|
25
|
+
callback(serialnumber);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
exports.getIPAddress = function (callback) {
|
|
35
|
+
|
|
36
|
+
var interfaces = os.networkInterfaces();
|
|
37
|
+
var addresses = [];
|
|
38
|
+
for (k in interfaces) {
|
|
39
|
+
for (k2 in interfaces[k]) {
|
|
40
|
+
var address = interfaces[k][k2];
|
|
41
|
+
if (address.family == "IPv4" && !address.internal) {
|
|
42
|
+
ipaddress = address.address;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (!ipaddress) {
|
|
48
|
+
ipaddress = "127.0.0.1";
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
callback(ipaddress);
|
|
52
|
+
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
})(typeof exports == 'undefined' ? this['beaglebonechip'] = {} : exports);
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
var myhttp = require('http');
|
|
2
|
+
var querystring = require('querystring');
|
|
3
|
+
|
|
4
|
+
(function (exports) {
|
|
5
|
+
|
|
6
|
+
exports.getBBInfo = function (host, myip, myserial, callback, callback_error) {
|
|
7
|
+
|
|
8
|
+
if (host.indexOf(":") > -1) {
|
|
9
|
+
|
|
10
|
+
var hn = host.substr(0, host.indexOf(":"));
|
|
11
|
+
|
|
12
|
+
var port = host.substr(host.indexOf(":") + 1);
|
|
13
|
+
|
|
14
|
+
} else {
|
|
15
|
+
|
|
16
|
+
var hn = host;
|
|
17
|
+
var port = 80;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
var postdata = querystring.stringify({
|
|
21
|
+
|
|
22
|
+
"beaglebone[ipaddress]": myip,
|
|
23
|
+
|
|
24
|
+
"beaglebone[serialnumber]": myserial,
|
|
25
|
+
|
|
26
|
+
commit: "Update Beaglebone"
|
|
27
|
+
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
var options = {
|
|
31
|
+
hostname: hn,
|
|
32
|
+
port: port,
|
|
33
|
+
path: "/connect/" + myserial,
|
|
34
|
+
method: "POST",
|
|
35
|
+
headers: {
|
|
36
|
+
'content-type': 'application/x-www-form-urlencoded'
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
var request = myhttp.request(options, function (res) {
|
|
42
|
+
|
|
43
|
+
var body = "";
|
|
44
|
+
|
|
45
|
+
res.setEncoding("utf8");
|
|
46
|
+
|
|
47
|
+
res.on('data', function (chunk) {
|
|
48
|
+
body += chunk;
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
res.on('end', function () {
|
|
52
|
+
var myResponse = JSON.parse(body);
|
|
53
|
+
|
|
54
|
+
if (myResponse) {
|
|
55
|
+
|
|
56
|
+
if (typeof myResponse.table === "undefined") {
|
|
57
|
+
|
|
58
|
+
callback(myResponse);
|
|
59
|
+
|
|
60
|
+
} else {
|
|
61
|
+
|
|
62
|
+
callback(myResponse.table);
|
|
63
|
+
|
|
64
|
+
}
|
|
65
|
+
} else {
|
|
66
|
+
callback({});
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
}).on('error', function (e) {
|
|
72
|
+
|
|
73
|
+
callback_error(e.message);
|
|
74
|
+
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
request.write(postdata);
|
|
78
|
+
request.end();
|
|
79
|
+
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
})(typeof exports == 'undefined' ? this['dialadeviceweb'] = {} : exports);
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require 'dial_a_device_node/version'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "dial_a_device_node"
|
|
8
|
+
spec.version = DialADeviceNode::VERSION
|
|
9
|
+
spec.authors = ["Dominic Lütjohann"]
|
|
10
|
+
spec.email = ["dominic@luetjohann.com"]
|
|
11
|
+
spec.description = "Description"
|
|
12
|
+
spec.summary = "Summary"
|
|
13
|
+
spec.homepage = ""
|
|
14
|
+
spec.license = "GPLv3"
|
|
15
|
+
|
|
16
|
+
spec.files = `git ls-files`.split($/)
|
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
|
19
|
+
spec.require_paths = ["lib"]
|
|
20
|
+
|
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
|
22
|
+
spec.add_development_dependency "rake"
|
|
23
|
+
end
|
|
@@ -0,0 +1,419 @@
|
|
|
1
|
+
(function (exports) {
|
|
2
|
+
|
|
3
|
+
var consolelogger, simulate, device, device_id, device_library, device_type, deviceconnection, ev, eventbus, heartbeat, http, ser_baud, ser_string, simulation, status, unique_id, url_string, util, webconnection;
|
|
4
|
+
|
|
5
|
+
var serialnumber, ipaddress, server;
|
|
6
|
+
|
|
7
|
+
var bbinfo;
|
|
8
|
+
|
|
9
|
+
var updateBB_loop = false;
|
|
10
|
+
|
|
11
|
+
var dialadevicenode;
|
|
12
|
+
|
|
13
|
+
var heartbeatinterval;
|
|
14
|
+
|
|
15
|
+
var logging = false;
|
|
16
|
+
|
|
17
|
+
var device_fwatcher_root;
|
|
18
|
+
|
|
19
|
+
// default parameters
|
|
20
|
+
ser_port = '/dev/ttyUSB0';
|
|
21
|
+
|
|
22
|
+
ser_string = 'simulation';
|
|
23
|
+
|
|
24
|
+
ser_baud = 115200;
|
|
25
|
+
ser_databit = 8;
|
|
26
|
+
ser_parity = "none";
|
|
27
|
+
ser_stopbit = 1;
|
|
28
|
+
|
|
29
|
+
ser_linebreak = "";
|
|
30
|
+
ser_prefix = "";
|
|
31
|
+
ser_suffix = "";
|
|
32
|
+
|
|
33
|
+
device_id = 0;
|
|
34
|
+
|
|
35
|
+
url_string = '192.168.7.1:3000/websocket';
|
|
36
|
+
|
|
37
|
+
device_type = 'purebeaglebone';
|
|
38
|
+
unique_id = '';
|
|
39
|
+
simulate = false;
|
|
40
|
+
|
|
41
|
+
exports.set_url_string = function (param) {
|
|
42
|
+
url_string = param;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
exports.set_device_type = function (param) {
|
|
46
|
+
device_type = param;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
exports.set_ser_string = function (param) {
|
|
50
|
+
ser_string = param;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
exports.set_ser_port = function (param) {
|
|
54
|
+
ser_port = param;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
exports.set_fwatcher_root = function (param) {
|
|
58
|
+
|
|
59
|
+
if (typeof(param) != "undefined") {
|
|
60
|
+
device_fwatcher_root = param;
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
exports.set_ser_linebreak = function (param) {
|
|
65
|
+
|
|
66
|
+
if (typeof(param) != "undefined") {
|
|
67
|
+
ser_linebreak = param;
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
exports.set_ser_prefix = function (param) {
|
|
72
|
+
|
|
73
|
+
if (typeof(param) != "undefined") {
|
|
74
|
+
ser_prefix = param;
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
exports.set_ser_suffix = function (param) {
|
|
79
|
+
|
|
80
|
+
if (typeof(param) != "undefined") {
|
|
81
|
+
ser_suffix = param;
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
exports.set_ser_databit = function (param) {
|
|
86
|
+
|
|
87
|
+
if (typeof(param) != "undefined") {
|
|
88
|
+
ser_databit = param;
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
exports.set_ser_parity = function (param) {
|
|
93
|
+
if (typeof(param) != "undefined") {
|
|
94
|
+
ser_parity = param;
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
exports.set_ser_stopbit = function (param) {
|
|
99
|
+
if (typeof(param) != "undefined") {
|
|
100
|
+
ser_stopbit = param;
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
exports.set_simulate = function (param) {
|
|
105
|
+
simulate = param;
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
exports.set_device_id = function (param) {
|
|
109
|
+
device_id = param;
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
exports.set_unique_id = function (param) {
|
|
113
|
+
unique_id = param;
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
exports.set_ser_baud = function (param) {
|
|
117
|
+
ser_baud = param;
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
function getBBInfo(interval, action) {
|
|
122
|
+
|
|
123
|
+
if (typeof interval === "undefined") {
|
|
124
|
+
interval = 1000
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
if (typeof action === "undefined") {
|
|
128
|
+
action = "start"
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
var intervalIDcheck = setInterval(function () {
|
|
133
|
+
|
|
134
|
+
if (bbinfo && action != "heartbeat") {
|
|
135
|
+
clearInterval(intervalIDcheck);
|
|
136
|
+
|
|
137
|
+
bbinfo.ipaddress = ipaddress;
|
|
138
|
+
|
|
139
|
+
if (bbinfo.id > 0) {
|
|
140
|
+
|
|
141
|
+
if (action == "start") {
|
|
142
|
+
|
|
143
|
+
run_dial_a_device();
|
|
144
|
+
|
|
145
|
+
} else if (action == "heartbeat") {
|
|
146
|
+
|
|
147
|
+
getBBInfo(10000, "heartbeat");
|
|
148
|
+
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
} else {
|
|
152
|
+
|
|
153
|
+
// console.log("beaglebone not registered");
|
|
154
|
+
|
|
155
|
+
if (typeof dialadevicenode === "undefined") {
|
|
156
|
+
process.exit(1);
|
|
157
|
+
} else {
|
|
158
|
+
dialadevicenode.halt();
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
}
|
|
163
|
+
} else {
|
|
164
|
+
|
|
165
|
+
var dialadeviceweb = require('./dial-a-device-web.js');
|
|
166
|
+
|
|
167
|
+
dialadeviceweb.getBBInfo(server, ipaddress, serialnumber, function (message) {
|
|
168
|
+
|
|
169
|
+
bbinfo = message;
|
|
170
|
+
|
|
171
|
+
}, function (message) {
|
|
172
|
+
clearInterval(intervalIDcheck);
|
|
173
|
+
// console.log("beaglebone registration failed (" + message + ")");
|
|
174
|
+
|
|
175
|
+
var exec = require('child_process').exec;
|
|
176
|
+
|
|
177
|
+
exec('udhcpc -i eth0', function (error, stdout, stderr) {
|
|
178
|
+
|
|
179
|
+
// console.log("resetting DHCP on eth0...");
|
|
180
|
+
|
|
181
|
+
bbinfo = undefined;
|
|
182
|
+
|
|
183
|
+
getBBInfo(8000, "start");
|
|
184
|
+
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
if (typeof dialadevicenode === "undefined") {
|
|
188
|
+
process.exit(1);
|
|
189
|
+
} else {
|
|
190
|
+
dialadevicenode.halt();
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
}, interval);
|
|
201
|
+
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
exports.run_beaglebone = function (host, overridelogging) {
|
|
206
|
+
|
|
207
|
+
server = host;
|
|
208
|
+
|
|
209
|
+
if (typeof overridelogging != 'undefined') {
|
|
210
|
+
logging = overridelogging;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
if (logging == true) {
|
|
214
|
+
|
|
215
|
+
console.log("connecting to " + host);
|
|
216
|
+
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
var beaglebonechip = require('./beaglebonechip.js');
|
|
220
|
+
|
|
221
|
+
beaglebonechip.getSerialNumber(function (ser) {
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
if (logging == true) {
|
|
225
|
+
|
|
226
|
+
console.log("serialnumber " + ser);
|
|
227
|
+
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
serialnumber = ser;
|
|
231
|
+
|
|
232
|
+
beaglebonechip.getIPAddress(function (ip) {
|
|
233
|
+
|
|
234
|
+
ipaddress = ip;
|
|
235
|
+
|
|
236
|
+
getBBInfo(2000, "start");
|
|
237
|
+
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
function run_dial_a_device() {
|
|
246
|
+
|
|
247
|
+
if (!bbinfo.device) {
|
|
248
|
+
|
|
249
|
+
// console.log("no device registered for this beaglebone");
|
|
250
|
+
|
|
251
|
+
getBBInfo(5000);
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
} else {
|
|
255
|
+
|
|
256
|
+
getBBInfo(10000, "heartbeat");
|
|
257
|
+
|
|
258
|
+
// successfully connected
|
|
259
|
+
|
|
260
|
+
dialadevicenode = require('./dial_a_device_node.js');
|
|
261
|
+
|
|
262
|
+
dialadevicenode.set_ser_string(bbinfo.devicetype.porttype);
|
|
263
|
+
|
|
264
|
+
dialadevicenode.set_ser_port(bbinfo.devicetype.portname);
|
|
265
|
+
|
|
266
|
+
dialadevicenode.set_ser_baud(parseInt(bbinfo.devicetype.portbaud));
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
dialadevicenode.set_ser_parity(bbinfo.devicetype.portparity);
|
|
270
|
+
|
|
271
|
+
dialadevicenode.set_ser_databit(bbinfo.devicetype.portdatabits);
|
|
272
|
+
|
|
273
|
+
dialadevicenode.set_ser_stopbit(bbinfo.devicetype.portstopbits);
|
|
274
|
+
|
|
275
|
+
dialadevicenode.set_ser_linebreak(bbinfo.devicetype.portlinebreak);
|
|
276
|
+
dialadevicenode.set_ser_prefix(bbinfo.devicetype.portprefix);
|
|
277
|
+
dialadevicenode.set_ser_suffix(bbinfo.devicetype.portsuffix);
|
|
278
|
+
|
|
279
|
+
|
|
280
|
+
dialadevicenode.set_fwatcher_root(bbinfo.device.fwroot);
|
|
281
|
+
|
|
282
|
+
|
|
283
|
+
dialadevicenode.set_device_id(bbinfo.device.id);
|
|
284
|
+
|
|
285
|
+
dialadevicenode.set_url_string(server + '/websocket');
|
|
286
|
+
|
|
287
|
+
dialadevicenode.set_device_type(bbinfo.devicetype.name);
|
|
288
|
+
|
|
289
|
+
dialadevicenode.set_unique_id(serialnumber);
|
|
290
|
+
|
|
291
|
+
dialadevicenode.set_simulate(false);
|
|
292
|
+
|
|
293
|
+
dialadevicenode.run();
|
|
294
|
+
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
|
|
298
|
+
};
|
|
299
|
+
|
|
300
|
+
|
|
301
|
+
exports.halt = function (eventbus) {
|
|
302
|
+
|
|
303
|
+
webconnection.halt;
|
|
304
|
+
|
|
305
|
+
clearInterval(heartbeatinterval);
|
|
306
|
+
|
|
307
|
+
process.exit(1);
|
|
308
|
+
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
exports.run = function (eventbus) {
|
|
312
|
+
|
|
313
|
+
require('coffee-script/register');
|
|
314
|
+
|
|
315
|
+
require('./app/assets/javascripts/dial_a_device_node/websocket_rails/websocket_rails.js.coffee');
|
|
316
|
+
|
|
317
|
+
require('./app/assets/javascripts/dial_a_device_node/websocket_rails/event.js.coffee');
|
|
318
|
+
|
|
319
|
+
require('./app/assets/javascripts/dial_a_device_node/websocket_rails/abstract_connection.js.coffee');
|
|
320
|
+
|
|
321
|
+
require('./app/assets/javascripts/dial_a_device_node/websocket_rails/http_connection.js.coffee');
|
|
322
|
+
|
|
323
|
+
require('./app/assets/javascripts/dial_a_device_node/websocket_rails/websocket_connection.js.coffee');
|
|
324
|
+
|
|
325
|
+
require('./app/assets/javascripts/dial_a_device_node/websocket_rails/channel.js.coffee');
|
|
326
|
+
|
|
327
|
+
util = require('util');
|
|
328
|
+
|
|
329
|
+
ev = require('events');
|
|
330
|
+
|
|
331
|
+
http = require('http');
|
|
332
|
+
|
|
333
|
+
device_library = './app/assets/javascripts/dial_a_device_node/devices/' + device_type + '.js';
|
|
334
|
+
|
|
335
|
+
device = require(device_library);
|
|
336
|
+
|
|
337
|
+
simulation = require('./app/assets/javascripts/dial_a_device_node/devices/' + device_type + '_SIM.js');
|
|
338
|
+
|
|
339
|
+
deviceconnection = require('./app/assets/javascripts/dial_a_device_node/deviceconnection.js');
|
|
340
|
+
|
|
341
|
+
webconnection = require('./app/assets/javascripts/dial_a_device_node/webconnection.js');
|
|
342
|
+
|
|
343
|
+
consolelogger = require('./app/assets/javascripts/dial_a_device_node/consolelogger.js');
|
|
344
|
+
|
|
345
|
+
status = require('./app/assets/javascripts/dial_a_device_node/systemstatus.js');
|
|
346
|
+
|
|
347
|
+
folderwatcher = require('./app/assets/javascripts/dial_a_device_node/folderwatcher.js');
|
|
348
|
+
|
|
349
|
+
eventbus = new ev.EventEmitter;
|
|
350
|
+
|
|
351
|
+
status.init(eventbus);
|
|
352
|
+
|
|
353
|
+
webconnection.init(eventbus, true);
|
|
354
|
+
|
|
355
|
+
webconnection.initsubscribe;
|
|
356
|
+
|
|
357
|
+
device.init(eventbus);
|
|
358
|
+
|
|
359
|
+
|
|
360
|
+
eventbus.emit("device.announce.deviceid", device_id);
|
|
361
|
+
|
|
362
|
+
eventbus.emit("device.announce.devicetype", device_type);
|
|
363
|
+
|
|
364
|
+
|
|
365
|
+
|
|
366
|
+
if (logging == true) {
|
|
367
|
+
|
|
368
|
+
consolelogger.init(eventbus);
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
deviceconnection.init(eventbus);
|
|
372
|
+
|
|
373
|
+
eventbus.emit("serial.set.baud", ser_baud);
|
|
374
|
+
|
|
375
|
+
eventbus.emit("serial.set.databit", ser_databit);
|
|
376
|
+
eventbus.emit("serial.set.parity", ser_parity);
|
|
377
|
+
eventbus.emit("serial.set.stopbit", ser_stopbit);
|
|
378
|
+
|
|
379
|
+
eventbus.emit("serial.set.linebreak", ser_linebreak);
|
|
380
|
+
eventbus.emit("serial.set.prefix", ser_prefix);
|
|
381
|
+
eventbus.emit("serial.set.suffix", ser_suffix);
|
|
382
|
+
|
|
383
|
+
eventbus.emit("serial.set.port", ser_port);
|
|
384
|
+
|
|
385
|
+
if (ser_string == "serial") {
|
|
386
|
+
|
|
387
|
+
eventbus.emit("serial.connect");
|
|
388
|
+
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
eventbus.emit("webconnection.set.channelname", 'channel_dev_' + device_id);
|
|
392
|
+
|
|
393
|
+
eventbus.emit("webconnection.set.url", url_string);
|
|
394
|
+
|
|
395
|
+
eventbus.emit("webconnection.set.deviceendpoint", true);
|
|
396
|
+
|
|
397
|
+
eventbus.emit("webconnection.connect");
|
|
398
|
+
|
|
399
|
+
if (simulate) {
|
|
400
|
+
simulation.init(eventbus);
|
|
401
|
+
} else {
|
|
402
|
+
|
|
403
|
+
folderwatcher.init(eventbus);
|
|
404
|
+
|
|
405
|
+
eventbus.emit("folderwatcher.set_root", device_fwatcher_root);
|
|
406
|
+
|
|
407
|
+
eventbus.emit("device.folderwatcher_initialized");
|
|
408
|
+
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
heartbeat = function () {
|
|
412
|
+
return eventbus.emit("device.heartbeat");
|
|
413
|
+
};
|
|
414
|
+
|
|
415
|
+
heartbeatinterval = setInterval(heartbeat, 1000);
|
|
416
|
+
|
|
417
|
+
};
|
|
418
|
+
|
|
419
|
+
})(typeof exports == 'undefined' ? this['dialadevicenode'] = {} : exports);
|