Blame view

print_iso.php 9.31 KB
cf76164e6   Ting Chan   20190709
1
2
3
4
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
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
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
  <?php
  session_start();
  	
  		if($_GET['lang'] != ""){
  			$_SESSION['languge'] = $_GET['lang'];
  			include('lang/'.$_SESSION['languge'].".php");
  		}elseif($_SESSION['languge'] == ''){
  			$_SESSION['languge'] = "tn";
  			include("lang/tn.php");
  		}else{
  			include('lang/'.$_SESSION['languge'].".php");
  		}
  
  
  ?>
  <!DOCTYPE html>
  <meta charset="UTF-8" />
  <link rel="icon" type="image/png" href="images/logo.png">
  <!-- Styles -->
  		<script src="assets/plugins/jquery/jquery-2.2.0.min.js"></script>
  <style>
  	table {  
  		color: #333; /* Lighten up font color */
  		font-family: Helvetica, Arial, sans-serif; /* Nicer font */
  		width: 100%; 
  		border-collapse: 
  		collapse; border-spacing: 0; 
  	}
  
  	td, th { border: 1px solid #CCC; height: 30px; } /* Make cells a bit taller */
  
  	th {  
  		background: #F3F3F3; /* Light grey background */
  		font-weight: bold; /* Make sure they're bold */
  	}
  
  	td {  
  		background: #FAFAFA; /* Lighter grey background */
  		text-align: center; /* Center our text */
  	}
  </style>
  <?php 
  	$path = "/home/pi/Desktop/vAlert/rec/".$_GET['details'];
  	$datetime = substr($_GET['details'],12,2)." ".substr($_GET['details'],14,2)." ".substr($_GET['details'],8,4);
  	
  	
  	//水平、垂直最大限值rms to db
  	$db_1 = array('77.147','80');
  	$db_2 = array('82.923','86.021');
  	$db_3 = array('80','82.923');
  	$db_4 = array('88.943','92.041');
  	$db_5 = array('95.269','98.062');
  	
  	$db_1_a = array('73.979','71.126');
  	$db_2_a = array('80','77.025');
  	$db_3_a = array('76.901','73.979');
  	$db_4_a = array('86.020','82.922');
  	$db_5_a = array('92.041','89.247');
  	
  	//水平、垂直最大限值gal
  	$gal_1 = array('0.072','0.10');
  	$gal_2 = array('0.14','0.20');
  	$gal_3 = array('0.10','0.14');
  	$gal_4 = array('0.28','0.40');
  	$gal_5 = array('0.58','0.80');
  	
  	$gal_1_a = array('0.050','0.036');
  	$gal_2_a = array('0.100','0.071');
  	$gal_3_a = array('0.070','0.050');
  	$gal_4_a = array('0.200','0.140');
  	$gal_5_a = array('0.400','0.290');
  	
  	
  
  	if($_GET['rules'] != ""){
  		if($_GET['Axis'] == 1){
  			$text = 'db_'.$_GET['rules'];
  			$text1 = 'db_'.$_GET['rules']."_a";
  			$rules = $$text;
  			$rules1 = $$text1;
  		}else{
  			$text = 'gal_'.$_GET['rules'];
  			$text1 = 'gal_'.$_GET['rules']."_a";
  			$rules = $$text;
  			$rules1 = $$text1;
  		}
  	}else{
  		$rules = $db_2;
  		$rules1 = $db_2_a;
  	}
  	
  	$max_1 = 0;
  	$max_2 = 0;
  	$max_3 = 0;
  	$max_4 = 0;
  	if (($handle = fopen($path, "r")) !== FALSE) {
  		$i = 0;
  		$interval = ($_GET['duration'] == "") ? "60":$_GET['duration'];
  		if ($handle) {
  			while (!feof($handle)) {
  					$buffer[] = fgets($handle, 4096);
  			}
  			fclose($handle);
  		}
  	}	
  	$j=0;
  	for($i=1;$i<=count($buffer);$i++){
  		$data = explode(",",$buffer[$i]);
  
  		if($data[1] >= $max_1){
  			$max_1 = $data[1];
  			$label = $datetime." ".$data[0];
  		}
  		
  		if($data[2] >= $max_2){
  			$max_2 = $data[2];
  		}
  		if($data[3] >= $max_3){
  			$max_3 = $data[3];
  			$label = $datetime." ".$data[0];
  		}
  		if($data[4] >= $max_4){
  			$max_4 = $data[4];
  		}
  		
  		
  		$num = $j % $interval;
  		if($num == 0){	
  			if($_GET["Axis"] == 2){
  			//GAL
  				$data1[] = "{x: new Date('".$label."'), y: ".($max_1*0.01)."}";
  				$data2[] = "{x: new Date('".$label."'), y: ".($max_3*0.01)."}";
  			}else{
  			//DB
  				$data1[] = "{x: new Date('".$label."'), y: ".$max_2."}";
  				$data2[] = "{x: new Date('".$label."'), y: ".$max_4."}";
  			}
  			$max_1 = 0;
  			$max_2 = 0;
  			$max_3 = 0;
  			$max_4 = 0;
  		}
  		$j++;
  	
  	}
  	
  	$value = "{type: 'spline', 
          showInLegend: true,
          name: 'Horizontal',
          markerSize: 0,  
  		xValueFormatString:'H:m:s',
          dataPoints: [".implode(",",$data1)."]}";
  
  	$value2 = "{type: 'spline', 
          showInLegend: true,
          name: 'Vertical',
          markerSize: 0,  
  		xValueFormatString:'H:m:s',
          dataPoints: [".implode(",",$data2)."]}"; 
  		
  	
  ?>
  		<?
  			$str = explode("_",$_GET['details']);
  			$datetime = date("Y-m-d",strtotime($str['1']));
  			$id = explode('.',$str['2']);
  		?>
  <body>
  <main class="mn-inner">
  	<div class="row">
  		<div class="col s12">
  			<div class="page-title" style="font-size:40px;text-align:center;">ISO 2631 Report</div>
  			
  		</div>
  		<div class="row" >
  			<form class="col s12">
  			<div class="card">
                  <div class="card-content">
  				<div class="row" >
  					<img src="images/sanlien.png"/ style="float:right;margin-top: -70px;margin-bottom: 10px;">
  					<span class="card-title" style="font-size:16px"><?=Monitoring_Day?>:<?php echo $datetime;?></span><br>
  					<span class="card-title" style="font-size:16px"><?=sequence?>:<?php echo $id[0];?></span>
  					
  					<table>
  					<thead>
  						<th><?=Display_unit?></th>
  						<th><?=build_type?></th>
  						<th><?=Duration?></th>
  					</thead>
  					<tbody>
  						<tr>
  							<td>
  								<?php echo ($_GET['Axis'] == "" or $_GET['Axis'] == "1") ? "dB":"Gal";?>
  							</td>
  							<td>
  								<?php echo ($_GET['rules'] == 1) ? build_1:"";?>
  								<?php echo ($_GET['rules'] == 2 or $_GET['rules'] == "") ? build_2." - 07:00~22:00":"";?>
  								<?php echo ($_GET['rules'] == 3) ? build_3." - 22:00~07:00":"";?>
  								<?php echo ($_GET['rules'] == 4)  ? build_4:"";?>
  								<?php echo ($_GET['rules'] == 5) ? build_5:"";?>
  							</td>
  							<td>
  								<?php echo ( $_GET['duration'] == "") ? '60 seconds':$_GET['duration']." minutes";?>
  							</td>
  						</tr>
  					</tbody>
  					</table>
  				</div>
  
  				</div>
  			</div>
  			</form>
  		</div>
  		<br><br>
  		<div class="col s12 m12 l12">
              <div class="card">
                  <div class="card-content">
                      <span class="card-title" style="font-size:16px">Sequence Number:<?php echo $id[0];?></span>
  					<div id="chartContainer" style="height: 300px; width: 100%;"> </div>
                  </div>
              </div>
  		</div>
  		<div class="col s12 m12 l12">
              <div class="card">
                  <div class="card-content">
                      <span class="card-title" style="font-size:16px">Sequence Number:<?php echo $id[0];?></span>
  					<div id="chartContainer2" style="height: 300px; width: 100%;"> </div>
                  </div>
              </div>
  		</div>
  		
  	</div>
  </main>
  	</div>
          <div class="left-sidebar-hover"></div>
          
  		<!--<script src="js/dataTables.bootstrap.min.js"></script>-->
          <script src="assets/plugins/materialize/js/materialize.min.js"></script>
          <script src="assets/plugins/material-preloader/js/materialPreloader.min.js"></script>
  		<script src="assets/js/pages/form_elements.js"></script>
          <script src="assets/js/alpha.js"></script>
  		<script src="assets/js/pages/form_elements.js"></script>
  		<script type="text/javascript" src="js/canvasjs.min.js"></script>
  		<script type="text/javascript">
  			window.onload = function() {
  				var chart = new CanvasJS.Chart("chartContainer",
  					{      
  					  title:{
  						text: "ISO 2631 - Horizontal"
  					  },
  					  zoomEnabled: true,
  					  axisX :{
  						valueFormatString: "H:m:s" ,
  						title:"<?=$datetime?>",
  						interval: 1000,
  					  },
  					  axisY :{
  						includeZero: false,
  						title:"<?php echo ($_GET['Axis'] == 2) ? 'Gal':'dB';?>",
  						//maximum: <?php echo ($_GET['Axis'] == 2) ? ($rules[0]+0.03):($rules[0]+10);?>,
  						stripLines:[{
  							showOnTop: true,
  							color:"#FF0000",
  							value:<?php echo $rules[0];?>,
  							label : "Action: <?php echo $rules[0];?>"
  						},{
  							showOnTop: true,
  							color:"#BBBB00",
  							value:<?php echo $rules1[0];?>,
  							label : "Warring: <?php echo $rules1[0];?>"
  						}]
  					  },
  					  toolTip: {
  						shared: "true"
  					  },
  					  data: [<?php echo $value; ?>]
  					});
  				chart.render();
  			
  				var chart2 = new CanvasJS.Chart("chartContainer2",
  					{      
  					  title:{
  						text: "ISO 2631 - Vertical"
  					  },
  					  zoomEnabled: true,
  					  axisX :{
  						valueFormatString: "H:m:s" ,
  						title:"<?=$datetime?>",
  						interval: 1000,
  						
  					  },
  					  axisY :{
  						includeZero: false,
  						title:"<?php echo ($_GET['Axis'] == 2) ? 'Gal':'dB';?>",
  						//maximum: <?php echo ($_GET['Axis'] == 2) ? ($rules[1]+0.03):($rules[1]+10);?>,
  						stripLines:[{
  							showOnTop: true,
  							color:"#FF0000",
  							value:<?php echo $rules[1];?>,
  							label : "Action: <?php echo $rules[1];?>"
  						},{
  							showOnTop: true,
  							color:"#BBBB00",
  							value:<?php echo $rules1[1];?>,
  							label : "Warring: <?php echo $rules1[1];?>"
  						}]
  					  },
  					  toolTip: {
  						shared: "true"
  					  },
  					  data: [<?php echo $value2; ?>]
  					});
  
  				chart2.render();
  				
  				window.print();
  				
  			}
  			
  			
  			$(".confirm-save").click(function(){
  				alert("<?=data_update?>");
  				location.href="?item=iso&details=<?php echo $_GET['details'];?>&Axis="+$("input[name='Axis']:checked").val()+"&rules="+$("input[name='rules']:checked").val()+"&duration="+$("#d1").val();
  				
  			})
  			$(".confirm-print").click(function(){
  				 window.open("print_iso.php?item=iso&details=<?php echo $_GET['details'];?>&Axis="+$("input[name='Axis']:checked").val()+"&rules="+$("input[name='rules']:checked").val()+"&duration="+$("#d1").val(),'_blank');
  				
  			});
  			
  		  </script>
  		<div id="chartContainer" style="height: 300px; width: 100%;"></div>
      </body>
  </html>