Sat, 04 May 2019 21:18:51 +0200
Websocket interface is working for the main screen and manual mode.
0 | 1 | document.getElementById("test").innerHTML = "WebSocket is not connected"; |
2 | ||
3 | var websocket = new WebSocket('ws://'+location.hostname+'/ws'); | |
40
71e06f6d80fd
Work on web interface using websockets.
Michiel Broek <mbroek@mbse.eu>
parents:
11
diff
changeset
|
4 | //var slider = document.getElementById("myRange"); |
0 | 5 | |
6 | ||
7 | var BBScreen={ | |
8 | ||
40
71e06f6d80fd
Work on web interface using websockets.
Michiel Broek <mbroek@mbse.eu>
parents:
11
diff
changeset
|
9 | Screen: -1, |
71e06f6d80fd
Work on web interface using websockets.
Michiel Broek <mbroek@mbse.eu>
parents:
11
diff
changeset
|
10 | setScreen: function(s){ |
41
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
11 | Screen = parseInt(s,10); |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
12 | console.log("Screen:"+Screen); |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
13 | switch (Screen) { |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
14 | case 0: $("#mltline").show(); |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
15 | $("#mlt_table").show(); |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
16 | $("#but00").text('Hand'); |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
17 | $("#but20").text('Auto'); |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
18 | $("#mlt00").show(); |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
19 | $("#mlt20").show(); |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
20 | $("#mlt01").hide(); |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
21 | $("#mlt21").hide(); |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
22 | $("#midline").show(); |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
23 | $("#mid00").hide(); |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
24 | $("#mid20").hide(); |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
25 | $("#hltline").show(); |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
26 | $("#hlt_table").show(); |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
27 | $("#hlt00").hide(); |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
28 | $("#hlt20").hide(); |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
29 | $("#hlt01").show(); |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
30 | $("#hlt21").show(); |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
31 | $("#hlt01").css("background-color", "#e7e7e7"); |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
32 | $("#hlt01").css("color", "black"); |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
33 | $("#but04").text('Info'); |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
34 | $("#but24").text('Tools'); |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
35 | $("#row_info").hide(); |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
36 | $("#prompt").hide(); |
40
71e06f6d80fd
Work on web interface using websockets.
Michiel Broek <mbroek@mbse.eu>
parents:
11
diff
changeset
|
37 | break; |
41
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
38 | case 2: $("#mltline").hide(); |
40
71e06f6d80fd
Work on web interface using websockets.
Michiel Broek <mbroek@mbse.eu>
parents:
11
diff
changeset
|
39 | $("#midline").hide(); |
71e06f6d80fd
Work on web interface using websockets.
Michiel Broek <mbroek@mbse.eu>
parents:
11
diff
changeset
|
40 | $("#hltline").hide(); |
71e06f6d80fd
Work on web interface using websockets.
Michiel Broek <mbroek@mbse.eu>
parents:
11
diff
changeset
|
41 | $("#row_info").show(); |
41
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
42 | $("#prompt").hide(); |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
43 | break; |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
44 | // case 21: Automaat show recipe and Stop / Start |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
45 | // Prompt |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
46 | // Prompt |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
47 | case 100: |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
48 | case 101: |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
49 | case 102: |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
50 | case 103: |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
51 | case 104: |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
52 | case 105: |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
53 | case 106: |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
54 | case 107: $("#mltline").show(); |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
55 | $("#but00").text('+sp'); |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
56 | $("#but20").text('-sp'); |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
57 | $("#midline").show(); |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
58 | $("#hltline").show(); |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
59 | $("#hlt01").hide(); |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
60 | $("#hlt21").hide(); |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
61 | $("#row_info").hide(); |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
62 | $("#prompt").hide(); |
40
71e06f6d80fd
Work on web interface using websockets.
Michiel Broek <mbroek@mbse.eu>
parents:
11
diff
changeset
|
63 | break; |
41
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
64 | case 108: $("#mltline").show(); // to boil |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
65 | $("#midline").hide(); |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
66 | $("#hltline").hide(); |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
67 | $("#prompt").hide(); |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
68 | break; |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
69 | case 109: $("#mltline").show(); // boil |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
70 | $("#midline").show(); |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
71 | $("#hltline").hide(); |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
72 | $("#prompt").hide(); |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
73 | break; |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
74 | case 200: $("#mltline").hide(); |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
75 | $("#midline").hide(); |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
76 | $("#hltline").hide(); |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
77 | $("#row_info").hide(); |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
78 | $("#prompt").show(); |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
79 | break; |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
80 | case 201: $("#mltline").show(); |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
81 | $("#mlt00").hide(); |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
82 | $("#mlt20").hide(); |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
83 | $("#mlt01").hide(); |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
84 | $("#mlt21").hide(); |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
85 | $("#mlt_table").hide(); |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
86 | $("#but00").text('+sp'); |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
87 | $("#but20").text('-sp'); |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
88 | $("#but01").text('Pomp'); |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
89 | $("#but21").text('Aan'); |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
90 | $("#midline").show(); |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
91 | $("#mid00").hide(); |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
92 | $("#mid20").hide(); |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
93 | $("#hltline").show(); |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
94 | $("#hlt00").hide(); |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
95 | $("#hlt20").hide(); |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
96 | $("#hlt21").hide(); |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
97 | $("#hlt_table").hide(); |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
98 | $("#but03").text('+sp'); |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
99 | $("#but23").text('-sp'); |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
100 | $("#but04").text('Stop'); |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
101 | $("#but24").text('Aan'); |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
102 | $("#hlt01").css("background-color", "#575757"); |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
103 | $("#hlt01").css("color", "white"); |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
104 | $("#row_info").hide(); |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
105 | $("#prompt").hide(); |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
106 | break; |
40
71e06f6d80fd
Work on web interface using websockets.
Michiel Broek <mbroek@mbse.eu>
parents:
11
diff
changeset
|
107 | default: $("#mltline").hide(); |
71e06f6d80fd
Work on web interface using websockets.
Michiel Broek <mbroek@mbse.eu>
parents:
11
diff
changeset
|
108 | $("#midline").hide(); |
71e06f6d80fd
Work on web interface using websockets.
Michiel Broek <mbroek@mbse.eu>
parents:
11
diff
changeset
|
109 | $("#hltline").hide(); |
41
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
110 | $("#prompt").hide(); |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
111 | console.log("this is default screen "+Screen); |
40
71e06f6d80fd
Work on web interface using websockets.
Michiel Broek <mbroek@mbse.eu>
parents:
11
diff
changeset
|
112 | break; |
71e06f6d80fd
Work on web interface using websockets.
Michiel Broek <mbroek@mbse.eu>
parents:
11
diff
changeset
|
113 | } |
71e06f6d80fd
Work on web interface using websockets.
Michiel Broek <mbroek@mbse.eu>
parents:
11
diff
changeset
|
114 | }, |
0 | 115 | MLT_pv: function(s) { |
116 | $("#mlt_pv").text(s); | |
117 | }, | |
118 | MLT_sp: function(s) { | |
119 | $("#mlt_sp").text(s); | |
41
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
120 | if (Screen == 201) { |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
121 | if (s != "") { |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
122 | $("#mlt00").show(); |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
123 | $("#mlt20").show(); |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
124 | $("#mlt01").show(); |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
125 | $("#mlt21").show(); |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
126 | $("#mlt_table").show(); |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
127 | } |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
128 | } |
0 | 129 | }, |
130 | MLT_power: function(s) { | |
131 | $("#mlt_power").text(s); | |
132 | }, | |
133 | MLT_led: function(s) { | |
134 | if (s == 0) | |
135 | $("#mlt_led").css("background-color", "#270"); | |
136 | else | |
137 | $("#mlt_led").css("background-color", "#5E0"); | |
138 | }, | |
139 | Pump_led: function(s) { | |
140 | if (s == 0) | |
141 | $("#pump_led").css("background-color", "#820"); | |
142 | else | |
143 | $("#pump_led").css("background-color", "#F40"); | |
144 | }, | |
145 | HLT_pv: function(s) { | |
146 | $("#hlt_pv").text(s); | |
147 | }, | |
148 | HLT_sp: function(s) { | |
149 | $("#hlt_sp").text(s); | |
41
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
150 | if (Screen == 201) { |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
151 | if (s != "") { |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
152 | $("#hlt00").show(); |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
153 | $("#hlt20").show(); |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
154 | $("#hlt21").show(); |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
155 | $("#hlt_table").show(); |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
156 | } |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
157 | } |
0 | 158 | }, |
159 | HLT_power: function(s) { | |
160 | $("#hlt_power").text(s); | |
161 | }, | |
162 | HLT_led: function(s) { | |
163 | if (s == 0) | |
164 | $("#hlt_led").css("background-color", "#270"); | |
165 | else | |
166 | $("#hlt_led").css("background-color", "#5E0"); | |
167 | }, | |
168 | Topmessage: function(s) { | |
169 | $("#top_msg").text(s); | |
170 | }, | |
171 | Timer: function(s) { | |
172 | $("#timer").text(s); | |
173 | }, | |
174 | }; | |
175 | ||
176 | var BrewBoard = { | |
177 | ||
178 | p_msg:function(e){ | |
179 | var b=this; | |
180 | var a=JSON.parse(e); | |
181 | var c={ | |
40
71e06f6d80fd
Work on web interface using websockets.
Michiel Broek <mbroek@mbse.eu>
parents:
11
diff
changeset
|
182 | main: function(v){ |
71e06f6d80fd
Work on web interface using websockets.
Michiel Broek <mbroek@mbse.eu>
parents:
11
diff
changeset
|
183 | BBScreen.setScreen(v) |
71e06f6d80fd
Work on web interface using websockets.
Michiel Broek <mbroek@mbse.eu>
parents:
11
diff
changeset
|
184 | }, |
0 | 185 | mlt_pv:function(v){ |
186 | BBScreen.MLT_pv(v) | |
187 | }, | |
188 | mlt_sp:function(v){ | |
189 | BBScreen.MLT_sp(v) | |
190 | }, | |
191 | mlt_power:function(v){ | |
192 | BBScreen.MLT_power(v) | |
193 | }, | |
194 | mlt_led:function(v){ | |
195 | BBScreen.MLT_led(v) | |
196 | }, | |
197 | pump_led:function(v){ | |
198 | BBScreen.Pump_led(v) | |
199 | }, | |
200 | hlt_pv:function(v){ | |
201 | BBScreen.HLT_pv(v) | |
202 | }, | |
203 | hlt_sp:function(v){ | |
204 | BBScreen.HLT_sp(v) | |
205 | }, | |
206 | hlt_power:function(v){ | |
207 | BBScreen.HLT_power(v) | |
208 | }, | |
209 | hlt_led:function(v){ | |
210 | BBScreen.HLT_led(v) | |
211 | }, | |
212 | top_msg:function(v){ | |
213 | BBScreen.Topmessage(v) | |
214 | }, | |
215 | timer:function(v){ | |
216 | BBScreen.Timer(v) | |
217 | }, | |
218 | }; | |
219 | console.log(e); | |
220 | $.each(a,function(k,v){ | |
221 | if (typeof(c[k])!="undefined"){ | |
222 | c[k](v) | |
223 | } | |
224 | }); | |
225 | } | |
226 | }; | |
227 | ||
228 | ||
40
71e06f6d80fd
Work on web interface using websockets.
Michiel Broek <mbroek@mbse.eu>
parents:
11
diff
changeset
|
229 | function sendTouch(x, y) { |
41
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
230 | websocket.send('{"touch":{"x":'+x+',"y":'+y+'}}'); |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
231 | console.log('Sent {"touch":{"x":'+x+',"y":'+y+'}}'); |
0 | 232 | } |
233 | ||
234 | ||
40
71e06f6d80fd
Work on web interface using websockets.
Michiel Broek <mbroek@mbse.eu>
parents:
11
diff
changeset
|
235 | /* Define keys in the screens and their actions. */ |
71e06f6d80fd
Work on web interface using websockets.
Michiel Broek <mbroek@mbse.eu>
parents:
11
diff
changeset
|
236 | $("#ok_info").click( function() { sendTouch(160,220); }); |
41
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
237 | $("#mlt00").click( function() { sendTouch( 35, 46); }); |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
238 | $("#mlt20").click( function() { sendTouch(285, 46); }); |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
239 | $("#mlt01").click( function() { sendTouch( 35, 96); }); |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
240 | $("#mlt21").click( function() { sendTouch(285, 96); }); |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
241 | $("#mid00").click( function() { sendTouch( 35,140); }); |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
242 | $("#mid20").click( function() { sendTouch(285,140); }); |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
243 | $("#hlt00").click( function() { sendTouch( 35,170); }); |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
244 | $("#hlt20").click( function() { sendTouch(285,170); }); |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
245 | $("#hlt01").click( function() { sendTouch( 35,220); }); |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
246 | $("#hlt21").click( function() { sendTouch(285,220); }); |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
247 | $("#button_ja").click( function() { sendTouch( 80,120); }); |
7639cfa6aec0
Websocket interface is working for the main screen and manual mode.
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
248 | $("#button_nee").click( function() { sendTouch(240,120); }); |
40
71e06f6d80fd
Work on web interface using websockets.
Michiel Broek <mbroek@mbse.eu>
parents:
11
diff
changeset
|
249 | |
71e06f6d80fd
Work on web interface using websockets.
Michiel Broek <mbroek@mbse.eu>
parents:
11
diff
changeset
|
250 | |
0 | 251 | websocket.onopen = function(evt) { |
252 | console.log('WebSocket connection opened'); | |
253 | document.getElementById("test").innerHTML = "WebSocket is connected!"; | |
254 | } | |
255 | ||
256 | /* | |
257 | * Process received websocket messages. | |
258 | */ | |
259 | websocket.onmessage = function(evt) { | |
260 | var msg = evt.data; | |
261 | var value; | |
262 | switch (msg.charAt(0)) { | |
263 | case '{': | |
264 | BrewBoard.p_msg(evt.data); | |
265 | break; | |
266 | default: | |
267 | document.getElementById("output").innerHTML = evt.data; | |
268 | break; | |
269 | } | |
270 | } | |
271 | ||
272 | websocket.onclose = function(evt) { | |
273 | console.log('Websocket connection closed'); | |
274 | document.getElementById("test").innerHTML = "WebSocket closed"; | |
275 | } | |
276 | ||
277 | websocket.onerror = function(evt) { | |
278 | console.log('Websocket error: ' + evt); | |
279 | document.getElementById("test").innerHTML = "WebSocket error????!!!1!!"; | |
280 | } | |
281 | ||
282 |