iso_detail.html 9.79 KB
<!-- Styles -->
		<script src="assets/plugins/jquery/jquery-2.2.0.min.js"></script>
<style>
	label{
		font-size:16px;
		color:#000000;
		font-weight: bold;
	}
</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.1)."}";
				$data2[] = "{x: new Date('".$label."'), y: ".($max_3*0.1)."}";
			}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)."]}"; 
		
	
?>
		
<main class="mn-inner">
	<div class="row">
		<div class="col s12">
			<div class="page-title" style="font-size:20px">ISO 2631 Report</div>
		</div>
		<div class="row" >
			<form class="col s12">
			<div class="card">
                <div class="card-content">
				<div class="row">
					<h5><?=Display_unit?></h5>
					<div class="col s3">
						<input type="radio" name="Axis" id="r1" value="1" <?php echo ($_GET['Axis'] == 1 or $_GET['Axis'] == "") ? 'checked':"";?>>
						<label class="" for="r1">dB</label>
					</div>
					<div class="col s3">
						<input type="radio" name="Axis" id="r2" value="2" <?php echo ($_GET['Axis'] == 2) ? 'checked':"";?>>
						<label class="" for="r2">Gal</label>
					</div>
				</div>
				<div class="row">
					<h5><?=build_type?></h5>
					<div class="col s2">
						<input type="radio" name="rules" id="a1" value="1" <?php echo ($_GET['rules'] == 1) ? 'checked':"";?>>
						<label class="" for="a1"><?=build_1?></label>
					</div>
					<div class="col s2">
						<input type="radio" name="rules" id="a2" value="2" <?php echo ($_GET['rules'] == 2 or $_GET['rules'] == '') ? 'checked':"";?>>
						<label class="" for="a2"><?=build_2?> - 07:00~22:00</label>
					</div>
					<div class="col s2">
						<input type="radio" name="rules" id="a3" value="3" <?php echo ($_GET['rules'] == 3) ? 'checked':"";?>>
						<label class="" for="a3"><?=build_3?> - 22:00~07:00</label>
					</div>
					<div class="col s2">
						<input type="radio" name="rules" id="a5" value="4" <?php echo ($_GET['rules'] == 4) ? 'checked':"";?>>
						<label class="" for="a5"><?=build_4?></label>
					</div>
					<div class="col s2">
						<input type="radio" name="rules" id="a6" value="5" <?php echo ($_GET['rules'] == 5) ? 'checked':"";?>>
						<label class="" for="a6"><?=build_5?></label>
					</div>
				</div>
				<div class="row">
					<h5>Interval (unit:Seconds)</h5>
					<div class="col s2">
						<input type="text" name="duration" id="d1" value="<?php echo ($_GET['duration'] !='') ? $_GET['duration']:"60";?>" >
					</div>
				</div>
					<a class="waves-effect waves-light btn green m-b-xs confirm-save"><?=query;?></a>
					<a class="waves-effect waves-light btn green m-b-xs confirm-print"><?=print_report;?></a>
				</div>
			</div>
			</form>
		</div>
		<?
			$str = explode("_",$_GET['details']);
			$datetime = date("Y-m-d",strtotime($str['1']));
			$id = explode('.',$str['2']);
		?>
		<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>
					<button id="exportChart" class="waves-effect waves-light btn green m-b-xs"><?=export;?></button>
					<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>
					<button id="exportChart2" class="waves-effect waves-light btn green m-b-xs"><?=export;?></button>
					<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() {
				setTimeout(function(){
					$('body').addClass('loaded');
				}, 1000);
				setTimeout(function(){
					$('.loader').fadeOut('400');
				}, 600);
				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();
				document.getElementById("exportChart").addEventListener("click",function(){
					chart.exportChart({format: "jpg"});
				});
			
				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();
				document.getElementById("exportChart2").addEventListener("click",function(){
					chart.exportChart({format: "jpg"});
				});
				
			}
			
			$(".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>
    </body>
</html>