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,124 @@
1
+ (function (exports) {
2
+
3
+ var status_model = {
4
+
5
+ deviceconnection: false,
6
+ devicesimulation: false,
7
+ devicewebconnection: false,
8
+ webconnection: false,
9
+ webchannel: ""
10
+
11
+ }
12
+
13
+ var deviceendpoint = false;
14
+
15
+ exports.init = function (eventbus) {
16
+ localeventbus = eventbus;
17
+
18
+ localeventbus.on("status.deviceendpoint", function (data) {
19
+
20
+ deviceendpoint = data;
21
+
22
+ });
23
+
24
+
25
+ localeventbus.on("status.incoming", function (data) {
26
+
27
+ status_model_device = data;
28
+
29
+ status_model.devicewebconnection = status_model_device.devicewebconnection;
30
+ status_model.deviceconnection = status_model_device.deviceconnection;
31
+ status_model.devicesimulation = status_model_device.devicesimulation;
32
+
33
+ localeventbus.emit("ui.status", status_model);
34
+ });
35
+
36
+ localeventbus.on("serial.portopened", function () {
37
+
38
+ status_model.deviceconnection = true;
39
+ localeventbus.emit("ui.status", status_model);
40
+ });
41
+
42
+ localeventbus.on("device.assumeconnected", function () {
43
+
44
+ status_model.deviceconnection = true;
45
+ localeventbus.emit("ui.status", status_model);
46
+
47
+ });
48
+
49
+ localeventbus.on("serial.simulation", function () {
50
+
51
+ status_model.devicesimulation = true;
52
+
53
+ localeventbus.emit("ui.status", status_model);
54
+ });
55
+
56
+ localeventbus.on("serial.openfailed", function () {
57
+
58
+ status_model.deviceconnection = false;
59
+ localeventbus.emit("ui.status", status_model);
60
+
61
+ setTimeout(function () {
62
+ localeventbus.emit("serial.connect");
63
+ }, 1000);
64
+
65
+ });
66
+
67
+
68
+ localeventbus.on("webconnection.connected", function (url) {
69
+
70
+ if (deviceendpoint) {
71
+ status_model.devicewebconnection = true;
72
+ } else {
73
+ status_model.webconnection = true;
74
+ }
75
+ status_model.webchannel = "";
76
+ localeventbus.emit("ui.status", status_model);
77
+
78
+ });
79
+
80
+ localeventbus.on("webconnection.closed", function () {
81
+
82
+ if (deviceendpoint) {
83
+ status_model.devicewebconnection = false;
84
+ } else {
85
+ status_model.webconnection = false;
86
+ }
87
+ status_model.webchannel = "";
88
+ localeventbus.emit("ui.status", status_model);
89
+
90
+ setTimeout(function () {
91
+ localeventbus.emit("webconnection.connect");
92
+ }, 1000);
93
+ });
94
+
95
+ localeventbus.on("channel.subscription", function (channelname, channel) {
96
+
97
+ status_model.webchannel = channelname;
98
+
99
+ if (deviceendpoint) {
100
+ status_model.devicewebconnection = true;
101
+ } else {
102
+ status_model.webconnection = true;
103
+ }
104
+
105
+ localeventbus.emit("ui.status", status_model);
106
+ });
107
+
108
+ localeventbus.on("channel.dev_disconnected", function () {
109
+
110
+ if (deviceendpoint) {
111
+ status_model.devicewebconnection = false;
112
+ status_model.deviceconnection = false;
113
+ } else {
114
+ status_model.devicewebconnection = false;
115
+ status_model.deviceconnection = false;
116
+ }
117
+
118
+ localeventbus.emit("ui.status", status_model);
119
+ });
120
+
121
+ localeventbus.emit("status.initialized");
122
+ };
123
+
124
+ })(typeof exports == 'undefined' ? this['systemstatus'] = {} : exports);
@@ -0,0 +1,197 @@
1
+ (function (exports) {
2
+
3
+ var websockets;
4
+
5
+ var localeventbus;
6
+
7
+ var channel;
8
+
9
+ var deviceendpoint = false;
10
+
11
+ var simulation = false;
12
+
13
+ var device_info = {
14
+
15
+ deviceid: "",
16
+ operationid: "",
17
+ devicetype: ""
18
+
19
+ }
20
+
21
+ var channelname = "";
22
+ var url = "";
23
+
24
+
25
+ exports.websockets = websockets;
26
+
27
+ exports.halt = function () {
28
+
29
+ if (!(typeof websockets === "undefined")) {
30
+ websockets.close();
31
+ }
32
+
33
+ }
34
+
35
+ exports.init = function (eventbus, de) {
36
+ localeventbus = eventbus;
37
+
38
+ deviceendpoint = de;
39
+
40
+
41
+
42
+ localeventbus.emit("initialized");
43
+
44
+ localeventbus.emit("status.deviceendpoint", deviceendpoint);
45
+
46
+ localeventbus.on("serial.simulation", function () {
47
+
48
+ simulation = true;
49
+
50
+ });
51
+
52
+ localeventbus.on("device.announce.deviceid", function (data) {
53
+ device_info.deviceid = data;
54
+ });
55
+
56
+ localeventbus.on("device.announce.operationid", function (data) {
57
+ device_info.operationid = data;
58
+ });
59
+
60
+ localeventbus.on("device.announce.devicetype", function (data) {
61
+ device_info.devicetype = data;
62
+ });
63
+
64
+ localeventbus.on("webconnection.set.channelname", function (data) {
65
+ channelname = data;
66
+ });
67
+
68
+ localeventbus.on("webconnection.set.url", function (data) {
69
+ url = data;
70
+ });
71
+
72
+ localeventbus.on("webconnection.set.deviceendpoint", function (data) {
73
+ (typeof data == 'object' ? deviceendpoint = data[0] : deviceendpoint = data);
74
+ });
75
+
76
+ localeventbus.on("webconnection.connect", function (data) {
77
+
78
+ localeventbus.emit('connecting', url);
79
+
80
+ websockets = new WebSocketRails(url, true);
81
+
82
+ websockets.bind("connection_closed", function (data) {
83
+ localeventbus.emit('webconnection.closed');
84
+ });
85
+
86
+ websockets.bind("connection_error", function (data) {
87
+ localeventbus.emit('webconnection.closed');
88
+ });
89
+
90
+
91
+ localeventbus.on("device.snapshot", function (model) {
92
+
93
+ websockets.trigger("device.log", {
94
+
95
+ "device_info": device_info,
96
+ "model": model
97
+
98
+ });
99
+ });
100
+
101
+ websockets.on_open = function (data) {
102
+ localeventbus.emit('webconnection.connected', url);
103
+
104
+ localeventbus.emit('channel.subscribing', channelname);
105
+
106
+ channel = websockets.subscribe(channelname);
107
+
108
+ if (simulation) {
109
+
110
+ // create a local loop for ui updates
111
+
112
+ localeventbus.on("ui.command", function (data) {
113
+
114
+ localeventbus.emit("device.command", data);
115
+
116
+ });
117
+
118
+ }
119
+
120
+
121
+ if (deviceendpoint) {
122
+
123
+ localeventbus.on("ui.status", function (data) {
124
+ channel.trigger("device.status", data);
125
+ });
126
+
127
+ // device-local loop
128
+
129
+ localeventbus.on("device.requestheartbeat", function (data) {
130
+ localeventbus.emit("device.heartbeat");
131
+ });
132
+
133
+
134
+ // new commands
135
+
136
+ localeventbus.on("ui.update", function (data) {
137
+ channel.trigger("ui.update", data);
138
+ });
139
+
140
+ channel.bind('subscriber_join', function (data) {
141
+ localeventbus.emit("channel.ui_connected", data);
142
+ });
143
+
144
+ channel.bind('subscriber_part', function (data) {
145
+ localeventbus.emit("channel.ui_disconnected", data);
146
+ });
147
+
148
+ channel.bind('device.command', function (data) {
149
+ localeventbus.emit("device.command", data);
150
+ });
151
+
152
+
153
+ } else {
154
+
155
+ channel.bind("device.status", function (data) {
156
+ localeventbus.emit("status.incoming", data);
157
+ });
158
+
159
+ // new commands
160
+
161
+ channel.bind("ui.update", function (data) {
162
+ localeventbus.emit("ui.update", data);
163
+ });
164
+
165
+ channel.bind("ui.status", function (data) {
166
+ localeventbus.emit("status.incoming", data);
167
+ });
168
+
169
+ localeventbus.on("ui.command", function (data) {
170
+ channel.trigger("device.command", data);
171
+ });
172
+
173
+ channel.bind('subscriber_join', function (data) {
174
+ localeventbus.emit("channel.dev_connected", data);
175
+ });
176
+
177
+ channel.bind('subscriber_part', function (data) {
178
+ localeventbus.emit("channel.dev_disconnected", data);
179
+ });
180
+
181
+ }
182
+
183
+ localeventbus.emit('channel.subscription', channelname, channel);
184
+ }
185
+
186
+ });
187
+
188
+ };
189
+
190
+ exports.webconnect = function (url) {
191
+
192
+
193
+ };
194
+
195
+
196
+
197
+ })(typeof exports == 'undefined' ? this['webconnection'] = {} : exports);
@@ -0,0 +1,45 @@
1
+ ###
2
+ Abstract Interface for the WebSocketRails client.
3
+ ###
4
+ class WebSocketRails.AbstractConnection
5
+
6
+ constructor: (url, @dispatcher) ->
7
+ @message_queue = []
8
+
9
+ close: ->
10
+
11
+ trigger: (event) ->
12
+ if @dispatcher.state != 'connected'
13
+ @message_queue.push event
14
+ else
15
+ @send_event event
16
+
17
+ send_event: (event) ->
18
+ # Events queued before connecting do not have the correct
19
+ # connection_id set yet. We need to update it before dispatching.
20
+ event.connection_id = @connection_id if @connection_id?
21
+
22
+ # ...
23
+
24
+ on_close: (event) ->
25
+ if @dispatcher && @dispatcher._conn == @
26
+ close_event = new WebSocketRails.Event(['connection_closed', event])
27
+ @dispatcher.state = 'disconnected'
28
+ @dispatcher.dispatch close_event
29
+
30
+ on_error: (event) ->
31
+ if @dispatcher && @dispatcher._conn == @
32
+ error_event = new WebSocketRails.Event(['connection_error', event])
33
+ @dispatcher.state = 'disconnected'
34
+ @dispatcher.dispatch error_event
35
+
36
+ on_message: (event_data) ->
37
+ if @dispatcher && @dispatcher._conn == @
38
+ @dispatcher.new_message event_data
39
+
40
+ setConnectionId: (@connection_id) ->
41
+
42
+ flush_queue: ->
43
+ for event in @message_queue
44
+ @trigger event
45
+ @message_queue = []
@@ -0,0 +1,70 @@
1
+ ###
2
+ The channel object is returned when you subscribe to a channel.
3
+
4
+ For instance:
5
+ var dispatcher = new WebSocketRails('localhost:3000/websocket');
6
+ var awesome_channel = dispatcher.subscribe('awesome_channel');
7
+ awesome_channel.bind('event', function(data) { console.log('channel event!'); });
8
+ awesome_channel.trigger('awesome_event', awesome_object);
9
+
10
+ If you want to unbind an event, you can use the unbind function :
11
+ awesome_channel.unbind('event')
12
+ ###
13
+ class WebSocketRails.Channel
14
+
15
+ constructor: (@name, @_dispatcher, @is_private = false, @on_success, @on_failure) ->
16
+ @_callbacks = {}
17
+ @_token = undefined
18
+ @_queue = []
19
+ if @is_private
20
+ event_name = 'websocket_rails.subscribe_private'
21
+ else
22
+ event_name = 'websocket_rails.subscribe'
23
+
24
+ @connection_id = @_dispatcher._conn?.connection_id
25
+ event = new WebSocketRails.Event( [event_name, {data: {channel: @name}}, @connection_id], @_success_launcher, @_failure_launcher)
26
+ @_dispatcher.trigger_event event
27
+
28
+ destroy: ->
29
+ if @connection_id == @_dispatcher._conn?.connection_id
30
+ event_name = 'websocket_rails.unsubscribe'
31
+ event = new WebSocketRails.Event( [event_name, {data: {channel: @name}}, @connection_id] )
32
+ @_dispatcher.trigger_event event
33
+ @_callbacks = {}
34
+
35
+ bind: (event_name, callback) ->
36
+ @_callbacks[event_name] ?= []
37
+ @_callbacks[event_name].push callback
38
+
39
+ unbind: (event_name) ->
40
+ delete @_callbacks[event_name]
41
+
42
+ trigger: (event_name, message) ->
43
+ event = new WebSocketRails.Event( [event_name, {channel: @name, data: message, token: @_token}, @connection_id] )
44
+ if !@_token
45
+ @_queue.push event
46
+ else
47
+ @_dispatcher.trigger_event event
48
+
49
+ dispatch: (event_name, message) ->
50
+ if event_name == 'websocket_rails.channel_token'
51
+ @connection_id = @_dispatcher._conn?.connection_id
52
+ @_token = message['token']
53
+ @flush_queue()
54
+ else
55
+ return unless @_callbacks[event_name]?
56
+ for callback in @_callbacks[event_name]
57
+ callback message
58
+
59
+ # using this method because @on_success will not be defined when the constructor is executed
60
+ _success_launcher: (data) =>
61
+ @on_success(data) if @on_success?
62
+
63
+ # using this method because @on_failure will not be defined when the constructor is executed
64
+ _failure_launcher: (data) =>
65
+ @on_failure(data) if @on_failure?
66
+
67
+ flush_queue: ->
68
+ for event in @_queue
69
+ @_dispatcher.trigger_event event
70
+ @_queue = []
@@ -0,0 +1,42 @@
1
+ ###
2
+ The Event object stores all the relevant event information.
3
+ ###
4
+
5
+ class WebSocketRails.Event
6
+
7
+ constructor: (data, @success_callback, @failure_callback) ->
8
+ @name = data[0]
9
+ attr = data[1]
10
+ if attr?
11
+ @id = if attr['id']? then attr['id'] else (((1+Math.random())*0x10000)|0)
12
+ @channel = if attr.channel? then attr.channel
13
+ @data = if attr.data? then attr.data else attr
14
+ @token = if attr.token? then attr.token
15
+ @connection_id = data[2]
16
+ if attr.success?
17
+ @result = true
18
+ @success = attr.success
19
+
20
+ is_channel: ->
21
+ @channel?
22
+
23
+ is_result: ->
24
+ typeof @result != 'undefined'
25
+
26
+ is_ping: ->
27
+ @name == 'websocket_rails.ping'
28
+
29
+ serialize: ->
30
+ JSON.stringify [@name, @attributes()]
31
+
32
+ attributes: ->
33
+ id: @id,
34
+ channel: @channel,
35
+ data: @data
36
+ token: @token
37
+
38
+ run_callbacks: (@success, @result) ->
39
+ if @success == true
40
+ @success_callback?(@result)
41
+ else
42
+ @failure_callback?(@result)