eda79839
Antoine Duquenoy
Upload des sources
|
1
2
3
|
<!DOCTYPE html>
<html lang="en">
<head>
|
7c7f4b04
Antoine Duquenoy
Corrections ortho...
|
4
|
<title>Pot connecté</title>
|
eda79839
Antoine Duquenoy
Upload des sources
|
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
|
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<style>
a:link {
text-decoration: none;
}
a:visited {
text-decoration: none;
}
</style>
<script type="text/javascript">
var consigne_temp_inf = 0;
var consigne_temp_sup = 0;
var consigne_moisture = 0;
window.WebSocket=(window.WebSocket||window.MozWebSocket);
var websocket=new WebSocket('ws://localhost:9000','myprotocol');
websocket.onopen=function(){
document.getElementById("onoff").innerHTML = "Connecté";
document.getElementById("onoff").className = "label label-success";
};
websocket.onerror=function(){
document.getElementById("onoff").innerHTML = "Non connecté";
document.getElementById("onoff").className = "label label-danger";
};
websocket.onmessage=function(message){
console.log(message.data);
if((message.data)[0] == 'N')
{
if((message.data).length == 1){return;}
var value = parseInt((message.data).substring(1));
if(value < 200)
{
document.getElementById("water_alert").style.background = "#F2DEDE";
document.getElementById("water").innerHTML = "Il est temps de rajouter de l'eau";
document.getElementById("niv_ok").className = "glyphicon glyphicon-remove";
}
else
{
document.getElementById("water_alert").style.background = "#DFF0D8";
document.getElementById("water").innerHTML = "Niveau d'eau correct";
document.getElementById("niv_ok").className = "glyphicon glyphicon-ok";
}
}
if((message.data)[0] == 'T')
{
if((message.data).length <= 2){return;}
var value = (message.data).substring(1) * (5.0 / 1023.0 * 100.0);
value = Math.round(value*100)/100;
document.getElementById("temp").innerHTML = value;
document.getElementById("temp_lvl").style.width = value +"%";
if(value < consigne_temp_inf || value > consigne_temp_sup)
{
document.getElementById("temp_ok").className = "glyphicon glyphicon-remove";
document.getElementById("temp_lvl").style.backgroundColor = "#e74c3c";
}
else
{
document.getElementById("temp_ok").className = "glyphicon glyphicon-ok";
document.getElementById("temp_lvl").style.backgroundColor = "#2ecc71";
}
}
if((message.data)[0] == 'H')
{
if((message.data).length == 1){return;}
var value = (message.data).substring(1);
document.getElementById("moisture").innerHTML = value;
document.getElementById("moisture_lvl").style.width = value +"%";
if(parseInt(value) < consigne_moisture )
{
document.getElementById("hum_ok").className = "glyphicon glyphicon-remove";
}
else
{
document.getElementById("hum_ok").className = "glyphicon glyphicon-ok";
}
}
if((message.data)[0] == 'M')
{
var value = (message.data).substring(1);
consigne_moisture = parseInt(value);
document.getElementById("consigne_moisture").innerHTML = value+"%";
}
};
function sendMoisture()
{
var consigne = document.getElementById("consigne_moisture_change").value;
if(consigne == ""){return;}
document.getElementById("consigne_moisture_change").value = '';
if (parseInt(consigne) > 100)
{
consigne = "100";
}
websocket.send("M"+consigne);
}
function sendTemp()
{
var consigne1 = document.getElementById("consigne1_temp_change").value;
var consigne2 = document.getElementById("consigne2_temp_change").value;
if(consigne1 == "" || consigne2 == ""){return;}
var temp_bornes = [parseInt(consigne1),parseInt(consigne2)];
consigne_temp_inf = Math.min.apply(Math, temp_bornes);
consigne_temp_sup = Math.max.apply(Math, temp_bornes);
document.getElementById("consigne_temp").innerHTML = consigne_temp_inf+"-"+consigne_temp_sup+"°C";
}
</script>
</head>
<body>
<div class="container">
|
7c7f4b04
Antoine Duquenoy
Corrections ortho...
|
142
|
<h1><a style="text-decoration:none;color:#212121;cursor:pointer;" btn-lg" data-toggle="modal" data-target="#myModal">Pot de fleurs connecté</a></h1>
|
eda79839
Antoine Duquenoy
Upload des sources
|
143
144
145
146
147
148
149
150
151
152
153
154
|
<!- ----------------------------------------------------------------------------------------- -!>
<div id="myModal" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
|
7c7f4b04
Antoine Duquenoy
Corrections ortho...
|
155
|
<h4 class="modal-title">Pot de fleurs connecté</h4>
|
eda79839
Antoine Duquenoy
Upload des sources
|
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
|
</div>
<div class="modal-body">
<p>Projet réalisé en 2017 dans le cadre du projet "Systèmes Communicants" en IMA3.</p>
<p><a href="http://projets-ima.plil.net/mediawiki/index.php?title=Projet_IMA3_P1,_2016/2017,_TD1">Lien du wiki</a> / <a href="https://archives.plil.fr/aduqueno/2017_TD1_1.git">Projet GIT</a></p>
<p><i>Antoine Duquenoy, Clément Froissart, Amine El Messaoudi et Antoine Gosse</i></p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<!- ----------------------------------------------------------------------------------------- -!>
<span id="onoff" class="label label-danger">Non connecté</span>
<hr/>
</br>
<div class="panel panel-default">
<div class="panel-heading">
<h3><span id="hum_ok" class="glyphicon glyphicon-refresh" style="margin-right:10px;font-size: 0.8em;"></span>Taux d'humidité <span id="consigne_moisture" class="badge">Consigne</span></h3>
</div>
<div class="panel-body">
<div class="progress" style="background-color:#34495e">
<div id="moisture_lvl" class="progress-bar" role="progressbar" aria-valuenow="70" aria-valuemin="0" aria-valuemax="100" style="width:100%;background-color:#3498db">
<div id="moisture">Chargement</div>
</div>
</div>
<form onkeypress="return event.keyCode != 13" class="form-inline">
<div class="form-group">
<label for="lvl">Taux d'humidité souhaité</label>
<input type="name" class="form-control" id="consigne_moisture_change">
</div>
<button type="button" class="btn btn-default" onclick="sendMoisture();">Envoyer</button>
</form>
</div>
</div>
</br>
<div class="panel panel-default">
<div class="panel-heading">
<h3><span id="niv_ok" class="glyphicon glyphicon-refresh" style="margin-right:10px;font-size: 0.8em;"></span>Niveau d'eau</h3>
</div>
<div id="water_alert" class="panel-body" style="background-color:#FCF8E3;">
<div id="water">
Chargement
</div>
</div>
</div>
</br>
<div class="panel panel-default">
<div class="panel-heading">
<h3><span id="temp_ok" class="glyphicon glyphicon-refresh" style="margin-right:10px;font-size: 0.8em;"></span>Température <span id="consigne_temp" class="badge">Consigne</span></h3>
</div>
<div class="panel-body">
<div class="progress" style="background-color:#34495e">
<div id="temp_lvl" class="progress-bar" role="progressbar" aria-valuenow="70" aria-valuemin="0" aria-valuemax="100" style="width:100%;background-color:#e74c3c">
<div id="temp">Chargement</div>
</div>
</div>
<form onkeypress="return event.keyCode != 13" class="form-inline">
<div class="form-group">
<label for="lvl">Température souhaitée entre</label>
<input type="number" value="0" min="0" max="64" class="form-control" id="consigne1_temp_change">
et
<input type="number" value="40" min="0" max="64" class="form-control" id="consigne2_temp_change">
</div>
<button type="button" class="btn btn-default" onclick="sendTemp();">Envoyer</button>
</form>
</div>
</div>
</div>
</body>
|
7c7f4b04
Antoine Duquenoy
Corrections ortho...
|
250
|
</html>
|