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,98 @@
1
+
2
+ <span class="btn-group inline">
3
+
4
+ <button id="stop" name="stop" class=" btn btn-warning btn-large" onclick="ui.toggleStop();"><span id="stopicon" name="stopicon" class="glyphicon glyphicon-stop"></span></button>
5
+
6
+ <button id="start" name="start" class=" btn btn-success btn-large" onclick="ui.toggleStart();" data-toggle="button"><span id="starticon" name="starticon" class="glyphicon glyphicon-play"></span></button>
7
+ <button id="pause" name="pause" class=" btn btn-success btn-large" onclick="ui.togglePause();" data-toggle="button"><span id="pauseicon" name="pauseicon" class="glyphicon glyphicon-pause"></span></button>
8
+
9
+
10
+ <button id="primedrain" name="primedrain" class=" btn btn-default btn-large" onclick="ui.togglePrimeDrain();">Prime/Drain</button>
11
+
12
+ </span>
13
+
14
+ <span class="btn-group inline">
15
+ <button id="runmodebutton" name="runmodebutton" class=" btn btn-info btn-large dropdown-toggle" data-toggle="dropdown"><span id="runmode">Run Mode</span>&nbsp;<span class="caret"></span></button>
16
+ <ul class="dropdown-menu">
17
+ <li><a href="#" onclick="ui.setRunmode(0);">Run Mode</a></li>
18
+ <li><a href="#" onclick="ui.setRunmode(1);">Dispense Mode (volume)</a></li>
19
+ <li><a href="#" onclick="ui.setRunmode(2);">Dispense Mode (flow rate)</a></li>
20
+ </ul>
21
+
22
+ </span>
23
+
24
+
25
+ <div class="row-fluid" style="margin-top:20px;">
26
+ <div class="span6">
27
+ <div class="well" style="text-align: center";>
28
+ <label><span id="timecounter" style="font-size: 20px;"></span></label>
29
+
30
+ </div>
31
+ </div>
32
+
33
+ <div class="span6">
34
+ <div class="well" style="text-align: center";>
35
+ <label><span id="amountcounter" style="font-size: 20px;"></span></label>
36
+
37
+ </div>
38
+ </div>
39
+ </div>
40
+
41
+
42
+
43
+ <div class="row-fluid clearfix" style="height: 160px;">
44
+
45
+
46
+ <div id="tflowrate" class="well" style="display:none;">
47
+
48
+
49
+ <div class="inline" id="flowrate"> </div>
50
+
51
+ <script type="text/javascript">
52
+
53
+ smartinput ("flowrate", function(val) {
54
+ ui.setFlowrate(val);
55
+ }, "Set (&micro;l/min)");
56
+ </script>
57
+
58
+
59
+
60
+ </div>
61
+
62
+ <div id="tamount" class="well" style="display:none;">
63
+
64
+
65
+
66
+
67
+
68
+ <div class="inline" id="amount"> </div>
69
+
70
+ <script type="text/javascript">
71
+
72
+ smartinput ("amount", function(val) {
73
+ ui.setAmount(val);
74
+ }, "Set (&micro;l)");
75
+ </script>
76
+
77
+
78
+
79
+
80
+ </div>
81
+
82
+
83
+ <div id="ttime"class="well" style="display:none;">
84
+
85
+
86
+ <div class="inline" id="time"> </div>
87
+
88
+ <script type="text/javascript">
89
+
90
+ smartinput ("time", function(val) {
91
+ ui.setTimeSeconds(val);
92
+ }, "Set (s)");
93
+ </script>
94
+
95
+
96
+ </div>
97
+
98
+ </div>
@@ -0,0 +1,37 @@
1
+ <div class="row-fluid" style="margin-top:20px;">
2
+ <div class="span12">
3
+ <div id="tab2" name="tab2" class="well" style="text-align: center";>
4
+ <label id="Display" name="Display" ><span id="iDisplay" style="font-size: 20px;"></span></label>
5
+
6
+ </div>
7
+ </div>
8
+ </div>
9
+
10
+
11
+ <div class="row-fluid">
12
+ <div class="span12">
13
+
14
+ <span class="btn-group">
15
+ <button id="powerbutton" name="powerbutton" class="btn btn-warning btn-large" onclick="ui.togglepower(); "><span id="power">Power</span></button>
16
+ </span>
17
+
18
+
19
+ <span class="btn-group">
20
+
21
+ <button id="tare" name="TARE" class="btn btn-danger btn-large " onclick="ui.tare();" >Tare</button>
22
+ </span>
23
+
24
+ <span class="btn-group">
25
+ <button id="print" name="PRINT" class=" btn btn-success btn-large" onclick="ui.print(); " >Print</button>
26
+ </span>
27
+
28
+
29
+
30
+ </div>
31
+
32
+ <script type="text/javascript">
33
+ if (connectiontype == "simulation") {
34
+ //ev.emit("device.set.print");
35
+ }
36
+ </script>
37
+ </div>
@@ -0,0 +1,137 @@
1
+ <div class="row-fluid">
2
+ <div class="span12">
3
+
4
+ <ul class="nav nav-tabs">
5
+
6
+ <li class="active"><a href="#leds" data-toggle="tab">LEDs</a></li>
7
+ <li><a href="#serial" data-toggle="tab">Serial Console</a></li>
8
+ <!--<li><a href="#designer" data-toggle="tab">Device Designer</a></li> -->
9
+ <li><a href="#customui" data-toggle="tab">Custom UI</a></li>
10
+ </ul>
11
+
12
+
13
+ <div class="tab-content">
14
+
15
+ <div class="tab-pane active" id="leds">
16
+ <span class="btn-group inline">
17
+ <button id="usrled0button" name="usrled0button" class=" btn btn-success btn-large" onclick="ui.toggleusrled0();" data-toggle="button"><span id="usrled0">USR LED 0</span></button>
18
+ </span>
19
+
20
+ <span class="btn-group inline">
21
+ <button id="usrled1button" name="usrled1button" class=" btn btn-success btn-large" onclick="ui.toggleusrled1();" data-toggle="button"><span id="usrled0">USR LED 1</span></button>
22
+ </span>
23
+
24
+ <span class="btn-group inline">
25
+ <button id="usrled2button" name="usrled2button" class=" btn btn-success btn-large" onclick="ui.toggleusrled2();" data-toggle="button"><span id="usrled0">USR LED 2</span></button>
26
+ </span>
27
+
28
+ <span class="btn-group inline">
29
+ <button id="usrled3button" name="usrled3button" class=" btn btn-success btn-large" onclick="ui.toggleusrled3();" data-toggle="button"><span id="usrled0">USR LED 3</span></button>
30
+ </span>
31
+
32
+
33
+ </div>
34
+
35
+ <div class="tab-pane" id="serial">
36
+
37
+ <span id="serialconnect">
38
+
39
+ <h4>External serial port&nbsp;<input type="button" class="btn btn-success btn-xs" value="Open" onClick="ui.serialsetport(); ui.serialsetbaud(); ui.serialsetlinebreak(); ui.serialsetprefix(); ui.serialsetsuffix(); ui.serialsetdatabit(); ui.serialsetparity(); ui.serialsetstopbit(); ui.serialopen();" /></h4>
40
+
41
+ <form class="form-horizontal" role="form">
42
+
43
+ <div class="form-group">
44
+ <label for="serialport" class="col-sm2 control-label">Port</label>
45
+ <input type="text" class="form-control" id="serialport" value="/dev/ttyUSB0" placeholder="/dev/tty..."/>
46
+ </div>
47
+
48
+ <div class="form-group">
49
+ <label for="serialbaud" class="col-sm2 control-label">Baud rate</label>
50
+ <input type="text" class="form-control" id="serialbaud" value="9600" placeholder="Baud rate"/>
51
+ </div>
52
+
53
+ <div class="form-group">
54
+ <label for="serialdatabit" class="col-sm2 control-label">Data bits</label>
55
+ <input type="text" class="form-control" id="serialdatabit" value="8" placeholder="Data bits"/>
56
+ </div>
57
+
58
+ <div class="form-group">
59
+ <label for="serialparity" class="col-sm2 control-label">Parity</label>
60
+ <input type="text" class="form-control" id="serialparity" value="none" placeholder="Parity"/>
61
+ </div>
62
+
63
+ <div class="form-group">
64
+ <label for="serialstopbit" class="col-sm2 control-label">Stop bits</label>
65
+ <input type="text" class="form-control" id="serialstopbit" value="1" placeholder="Stop bits"/>
66
+ </div>
67
+
68
+ <hr>
69
+
70
+ <div class="form-group">
71
+ <label for="seriallinebreak" class="col-sm2 control-label">Parser line break (hex)</label>
72
+ <input type="text" class="form-control" id="seriallinebreak" value="0D" placeholder="Line Break (hex)"/>
73
+ <span class="help-block">Leave blank for raw input interpreation.</span>
74
+ </div>
75
+
76
+ <div class="form-group">
77
+ <label for="serialprefix" class="col-sm2 control-label">Prefix (hex)</label>
78
+ <input type="text" class="form-control" id="serialprefix" value="" placeholder="Prefix (hex)"/>
79
+ <span class="help-block">Send this hex code as prefix for every command.</span>
80
+ </div>
81
+
82
+ <div class="form-group">
83
+ <label for="serialsuffix" class="col-sm2 control-label">Suffix (hex)</label>
84
+ <input type="text" class="form-control" id="serialsuffix" value="" placeholder="Suffix (hex)"/>
85
+ <span class="help-block">Send this hex code as suffix for every command.</span>
86
+ </div>
87
+
88
+ </form>
89
+
90
+ </span>
91
+
92
+ <span id="serialdisconnect" style="display:none;">
93
+
94
+ <h4>External serial port&nbsp;
95
+ <input type="button" class="btn btn-xs btn-warning" value="Close" onClick="ui.serialclose();" />
96
+
97
+ &nbsp;<span id="serialstatus"></span></h4>
98
+
99
+ <textarea rows="10" cols="80" id="serialconsole"></textarea>
100
+
101
+ <br/>
102
+
103
+ <input type="text" id="sendserial" /> <input type="button" class="btn btn-success" value="Send" onClick="ui.sendserial();" />
104
+
105
+ <br>
106
+
107
+ <input type="text" id="sendraw" /> <input type="button" class="btn btn-warning" value="Send raw hex" onClick="ui.sendraw();" />
108
+
109
+ </span>
110
+
111
+ </div>
112
+
113
+ <script type="text/javascript">
114
+
115
+ $('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
116
+ e.target // activated tab
117
+
118
+ if ($(e.target).attr("href") == "#customui") {
119
+
120
+ ui.retrieveCustomUI();
121
+
122
+ }
123
+
124
+ })
125
+
126
+ </script>
127
+
128
+ <div class="tab-pane" id="customui">
129
+
130
+ <p>Loading...</p>
131
+
132
+ </div>
133
+
134
+ </div>
135
+
136
+ </div>
137
+ </div>
@@ -0,0 +1,313 @@
1
+ <script src="/assets/external/processing-1.3.6.min.js"></script>
2
+
3
+
4
+ <div class="row-fluid">
5
+ <div class="span12">
6
+
7
+ <div id="animateTest"><canvas id="barometerCanvas"></canvas><canvas id="thermometerCanvas"></canvas><canvas id="lightCanvas"></canvas></div>
8
+
9
+ <small><p>Temperature: <span id="temperature"></span> °C</p>
10
+ <p>Pressure: <span id="pressure"></span> mbar</p>
11
+ <p>Humidity: <span id="humidity"></span> %</p>
12
+ <p>Lux: <span id="lux"></span></p></small>
13
+
14
+ </div>
15
+ </div>
16
+
17
+
18
+
19
+
20
+ <script type="text/javascript">
21
+
22
+ // global vars
23
+ var PI = 3.14;
24
+ var HALF_PI = 1.57;
25
+ var TWO_PI = 6.28;
26
+
27
+ // set defaults
28
+ var pressure = 950;
29
+ var pmax = 1050;
30
+ var pmin = 950;
31
+ var punit = " mbar";
32
+
33
+ var temp = -25;
34
+ var tmax = 80;
35
+ var tmin = -30;
36
+ var tunit = " °C";
37
+
38
+ var humidity = 50;
39
+ var hmax = 100;
40
+ var hmin = 0;
41
+ var hunit = " %";
42
+
43
+ var lux = 0;
44
+ var lmax = 2000;
45
+ var lmin = 0;
46
+ var lunit = " lux";
47
+
48
+ var barometerWidth;
49
+ var barometerHeight;
50
+ var thermometerWidth;
51
+ var lightWidth;
52
+
53
+
54
+ var setWidth = function() {
55
+
56
+ var canvasWidth = window.innerWidth * 0.4;
57
+
58
+ if ( canvasWidth > (1.8 * window.innerHeight)) {
59
+ canvasWidth = 1.8 * window.innerHeight;
60
+
61
+ }
62
+
63
+ barometerWidth = canvasWidth*0.5;
64
+ barometerHeight = barometerWidth;
65
+ thermometerWidth = canvasWidth*0.25;
66
+ lightWidth = canvasWidth*0.25;
67
+ };
68
+
69
+ setWidth();
70
+
71
+ var barometerSketchProc = function(p) {
72
+ p.size(barometerWidth, barometerWidth);
73
+ p.draw = function() {
74
+ p.size(barometerWidth, barometerWidth);
75
+ barometerWidth=p.width;
76
+ p.background(0,0);
77
+
78
+ // barometer
79
+ p.fill(220);
80
+ p.noStroke();
81
+ // Angles for sin() and cos() start at 3 o'clock;
82
+ // subtract HALF_PI to make them start at the top
83
+ p.ellipse(barometerWidth/2, barometerWidth/2, barometerWidth*0.8, barometerWidth*0.8);
84
+
85
+ var angle = -HALF_PI + HALF_PI / 3;
86
+ var inc = TWO_PI / 12;
87
+ p.stroke(0);
88
+ p.strokeWeight(barometerWidth*0.015);
89
+ p.arc(barometerWidth/2, barometerWidth/2, barometerWidth*0.8, barometerWidth*0.8, -(4/3)*PI, PI/3);
90
+
91
+ // we want a range from ±950 - ±1050 milibar
92
+ // 1-5=1010-1050, 7-12=950-1000
93
+ p.textSize(Math.round(barometerWidth*0.04));
94
+ for ( i = 1; i <= 12; i++, angle += inc ) {
95
+ if(i!=6) {
96
+ p.line(barometerWidth/2 + Math.cos(angle) * barometerWidth*0.35,barometerWidth/2 + Math.sin(angle) * barometerWidth*.35,barometerWidth/2 + Math.cos(angle) * barometerWidth*0.4,barometerWidth/2 + Math.sin(angle) * barometerWidth*.4);
97
+ if (i < 6) {
98
+ myText = 1000 + 10*i;
99
+ } else {
100
+ myText = 880 + 10*i;
101
+ }
102
+ myWidth = p.textWidth(myText);
103
+ p.fill(0, 102, 153);
104
+ p.text(myText, Math.round(barometerWidth/2 + Math.cos(angle) * barometerWidth*0.3 - myWidth/2),Math.round(barometerWidth/2 + Math.sin(angle) * barometerWidth*0.3));
105
+ } else {
106
+ myText = punit;
107
+ myWidth = p.textWidth(myText);
108
+ p.fill(0, 102, 153);
109
+ p.text(myText, Math.round(barometerWidth/2 + Math.cos(angle) * barometerWidth*0.3 - myWidth/2),Math.round(barometerWidth/2 + Math.sin(angle) * barometerWidth*0.3));
110
+ }
111
+ }
112
+
113
+
114
+ // RH scale
115
+ p.fill(220);
116
+ p.stroke(0);
117
+ p.strokeWeight(barometerWidth*0.005);
118
+ p.arc(barometerWidth/2, barometerWidth/2, barometerWidth*0.4, barometerWidth*0.4, -(4/3)*PI, PI/3);
119
+
120
+ // we want a range from 0 - 100%
121
+ // 1-5=60-100, 7-12=0-50
122
+ p.textSize(Math.round(barometerWidth*0.02));
123
+ for ( i = 1; i <= 12; i++, angle += inc ) {
124
+ if(i!=6) {
125
+ p.line(barometerWidth/2 + Math.cos(angle) * barometerWidth*0.18,barometerWidth/2 + Math.sin(angle) * barometerWidth*.18,barometerWidth/2 + Math.cos(angle) * barometerWidth*0.2,barometerWidth/2 + Math.sin(angle) * barometerWidth*.2);
126
+ if (i < 6) {
127
+ myText = 50 +10*i;
128
+ } else {
129
+ myText = 10*i - 70;
130
+ }
131
+ myWidth = p.textWidth(myText);
132
+ p.fill(0, 102, 153);
133
+ p.text(myText, Math.round(barometerWidth/2 + Math.cos(angle) * barometerWidth*0.16 - myWidth/2),Math.round(barometerWidth/2 + Math.sin(angle) * barometerWidth*0.16));
134
+ } else {
135
+ myText = hunit;
136
+ myWidth = p.textWidth(myText);
137
+ p.fill(0, 102, 153);
138
+ p.text(myText, Math.round(barometerWidth/2 + Math.cos(angle) * barometerWidth*0.12 - myWidth/2),Math.round(barometerWidth/2 + Math.sin(angle) * barometerWidth*0.12));
139
+ }
140
+ }
141
+
142
+ //humidity needle
143
+ p.stroke(60);
144
+ p.strokeWeight(barometerWidth*0.005);
145
+ p.line(-Math.cos(humidity) * barometerWidth*0.05 + barometerWidth/2, -Math.sin(humidity) * barometerWidth*0.05 + barometerWidth/2, Math.cos(humidity) * barometerWidth*0.15 + barometerWidth/2, Math.sin(humidity) * barometerWidth*0.15 + barometerWidth/2);
146
+ //p.ellipse(barometerWidth/2, barometerWidth/2, barometerWidth/20, barometerWidth/20);
147
+
148
+ // pressure needle
149
+ p.stroke(60);
150
+ p.strokeWeight(barometerWidth*0.015);
151
+ p.line(-Math.cos(pressure) * barometerWidth*0.05 + barometerWidth/2, -Math.sin(pressure) * barometerWidth*0.05 + barometerWidth/2, Math.cos(pressure) * barometerWidth*0.35 + barometerWidth/2, Math.sin(pressure) * barometerWidth*0.35 + barometerWidth/2);
152
+ p.ellipse(barometerWidth/2, barometerWidth/2, barometerWidth/20, barometerWidth/20);
153
+
154
+ };
155
+ p.noLoop();
156
+ }
157
+
158
+ var thermometerSketchProc = function(p) {
159
+ p.size(thermometerWidth, barometerHeight);
160
+ p.draw = function() {
161
+ p.size(thermometerWidth, barometerHeight);
162
+ thermometerWidth=p.width;
163
+ p.background(0,0);
164
+
165
+ // thermometer
166
+ // contour
167
+ p.stroke(0);
168
+ p.strokeWeight(thermometerWidth*0.27);
169
+ p.line(thermometerWidth/2,thermometerWidth*1.75,thermometerWidth/2,thermometerWidth/4);
170
+ p.ellipse(thermometerWidth/2, thermometerWidth*1.75, thermometerWidth/5, thermometerWidth/5);
171
+
172
+ p.strokeWeight(thermometerWidth*0.22);
173
+ p.stroke(255);
174
+ p.line(thermometerWidth/2,thermometerWidth*1.75,thermometerWidth/2,thermometerWidth/4);
175
+ // mercury bubble
176
+ if(temp > 0) {
177
+ p.stroke(255,0,0);
178
+ } else {
179
+ p.stroke(0,0,255)
180
+ }
181
+ p.ellipse(thermometerWidth/2, thermometerWidth*1.75, thermometerWidth/5, thermometerWidth/5);
182
+ // temperature line
183
+ if (temp < 44) {
184
+ p.strokeCap("butt");
185
+ } else {
186
+ // don't exceed thermometer bounds.
187
+ temp = 44;
188
+ p.strokeCap("round");
189
+ }
190
+ p.line(thermometerWidth/2,thermometerWidth*1.75,thermometerWidth/2,thermometerWidth*1.1 - (thermometerWidth/50) * temp);
191
+ // scale
192
+ p.strokeCap("round");
193
+ p.stroke(0);
194
+ p.strokeWeight(thermometerWidth*0.03);
195
+ var theight = thermometerWidth*1.5;
196
+ var inc = thermometerWidth/5;
197
+
198
+ p.textSize(Math.round(thermometerWidth*0.06));
199
+
200
+ for ( i = 1; i <= 7; i++, theight -= inc ) {
201
+ // longer bar at zero degrees C
202
+ if(i==3) {
203
+ extra = thermometerWidth/10;
204
+ } else {
205
+ extra = thermometerWidth/20;
206
+ }
207
+ p.line((thermometerWidth/2) - thermometerWidth/8,theight,(thermometerWidth/2) - thermometerWidth/8 + extra, theight );
208
+
209
+ myText = -30 + i*10;
210
+ p.fill(0, 0, 0);
211
+ p.text(myText, (thermometerWidth/2) - thermometerWidth*0.09 + extra, theight + 4);
212
+
213
+ // min/max marks
214
+ p.strokeWeight(thermometerWidth*0.01);
215
+ p.line((thermometerWidth/2) + thermometerWidth/8,thermometerWidth*1.1 - (thermometerWidth/50) * tmin,(thermometerWidth/2) + thermometerWidth/8 - thermometerWidth/20, thermometerWidth*1.1 - (thermometerWidth/50) * tmin );
216
+ p.line((thermometerWidth/2) + thermometerWidth/8,thermometerWidth*1.1 - (thermometerWidth/50) * tmax,(thermometerWidth/2) + thermometerWidth/8 - thermometerWidth/20, thermometerWidth*1.1 - (thermometerWidth/50) * tmax );
217
+ p.strokeWeight(thermometerWidth*0.03);
218
+ }
219
+ myText = temp + tunit;
220
+ p.fill(0, 0, 0);
221
+ p.textSize(Math.round(thermometerWidth*0.09));
222
+ myWidth = p.textWidth(myText);
223
+ p.text(myText, thermometerWidth/2 - myWidth/2, thermometerWidth*1.75 + thermometerWidth*0.045);
224
+ };
225
+ p.noLoop();
226
+ }
227
+
228
+
229
+ var lightSketchProc = function(p) {
230
+ p.size(lightWidth, barometerHeight);
231
+ p.draw = function() {
232
+ p.size(lightWidth, barometerHeight);
233
+ lightWidth=p.width;
234
+ p.background(0,0);
235
+
236
+ // contour
237
+ p.stroke(0);
238
+ p.strokeWeight(lightWidth*0.01);
239
+ if(lux > (3*255))
240
+ lux = (3*255 - 10);
241
+ p.fill(lux/3 + 10);
242
+ p.ellipse(lightWidth/2,lightWidth,lightWidth/2,lightWidth/2);
243
+
244
+ myText = lux + lunit;
245
+ p.fill(0, 0, 0);
246
+ p.textSize(Math.round(lightWidth*0.09));
247
+ myWidth = p.textWidth(myText);
248
+ p.text(myText, lightWidth/2 - myWidth/2, lightWidth*1.4 + lightWidth*0.045);
249
+ };
250
+ p.noLoop();
251
+ }
252
+
253
+ var canvas = document.getElementById("barometerCanvas");
254
+ var thermometerCanvas = document.getElementById("thermometerCanvas");
255
+ var lightCanvas = document.getElementById("lightCanvas");
256
+ var barometer = new Processing(canvas, barometerSketchProc);
257
+ var thermometer = new Processing(thermometerCanvas, thermometerSketchProc);
258
+ var light = new Processing(lightCanvas, lightSketchProc);
259
+
260
+ var setPressure = function(data) {
261
+ var myData = parseFloat(data);
262
+ // Angles for sin() and cos() start at 3 o'clock;
263
+ // subtract HALF_PI to make them start at the top
264
+ // 30miliBar = HALF_PI
265
+ pressure = (myData - 1000) * (TWO_PI / 120) - HALF_PI;
266
+
267
+ if (myData > pmax) pmax = myData;
268
+ if (myData < pmin) pmin = myData;
269
+
270
+ barometer.redraw();
271
+ }
272
+
273
+
274
+ var setHumidity = function(data) {
275
+ var myData = parseFloat(data);
276
+ // Angles for sin() and cos() start at 3 o'clock;
277
+ // subtract HALF_PI to make them start at the top
278
+ // 30% = HALF_PI
279
+ humidity = (myData - 50) * (TWO_PI / 120) - HALF_PI;
280
+
281
+ if (myData > hmax) hmax = myData;
282
+ if (myData < hmin) hmin = myData;
283
+
284
+ barometer.redraw();
285
+ }
286
+
287
+ var setTemperature = function(data) {
288
+ var myData = parseFloat(data);
289
+ temp = myData;
290
+ if (myData > tmax) tmax = myData;
291
+ if (myData < tmin) tmin = myData;
292
+ thermometer.redraw();
293
+ }
294
+
295
+ var setLux = function(data) {
296
+ var myData = parseFloat(data);
297
+ lux = myData;
298
+ light.redraw();
299
+
300
+ }
301
+
302
+
303
+ window.onresize=resizeHandler;
304
+ function resizeHandler(){
305
+ setWidth();
306
+ barometer.redraw();
307
+ thermometer.redraw();
308
+ light.redraw();
309
+ }
310
+
311
+
312
+
313
+ </script>