<!DOCTYPE html>
<% language=javascript %>

<html>
<head lang="en">
    <meta charset="GB2312">
    <title></title>
    <link href="css/style.css" title="style" rel="stylesheet" type="text/css" />
    <script src="js/jquery-1.6.3.min.js"></script>

</head>
<body style="background: #F3F3F3">
<div class='1301 empty' style=' margin: 10px;'>
  <table width="100%">
    <tr>
    <td width="300px" style="text-align: center;"><img src="img/ico-envir.png" style="width: 70%;text-align: center;"></td>
    <td>
    <table width='100%'>
        <tr><td style='border: none'> <h1 class='smName'></h1></td></tr>
        <tr><td style='width: 200px;'>基本信息</td><td>SID:<span class='SID_XF'> </span>&nbsp;&nbsp;&nbsp;编址:<span class='Addr_XF'> </span>&nbsp;&nbsp;&nbsp;数据端口:<span class='Port_XF'></span></td></tr>
        <tr><td style='width: 200px;'>更新时间</td><td><span class='DateUpd_XF'> </span></td></tr>
        <tr><td style='width: 200px;'>监测项状态</td><td><span class='State_XF'> </span></td></tr>
    </table>

    <table width='100%' style='margin-top:10px'>
        <tr><td style='border: none'> <h1>监测数据</h1></td> </tr>
        <tr> <td style='width: 200px'>传感器测量通道1</td><td> 数值:<span class='XCH1_Data'></span> <span class='XCH1_Pcs'> </tr>
        <tr> <td style='width: 200px'>传感器测量通道2</td><td> 数值:<span class='XCH2_Data'></span> <span class='XCH2_Pcs'> </tr>
        	
        <tr> <td style='width: 200px'>温度</td><td> 数据:<span class='XTem_Data'> </span>&nbsp;&nbsp;°C </tr>
        <tr> <td style='width: 200px'>湿度</td><td> 数据:<span class='XHum_Data'> </span>&nbsp;&nbsp;% </tr>
        <tr> <td style='width: 200px'>AD采集通道1</td><td> 数值:<span class='XCH1_Ad'> </tr>
        <tr> <td style='width: 200px'>AD采集通道2</td><td> 数值:<span class='XCH2_Ad'>  </tr>
        		
        <tr> <td style='width: 200px'>系统状态</td><td> 温度:<span class='XTem_Alarm'> </span>,&nbsp;&nbsp;湿度:<span class='XHum_Alarm'> </span>,&nbsp;&nbsp;寿命:<span class='XAge_Alarm'> </tr>
        
    </table>
    </td>
    </tr>
  </table>
    <a href='javascript:history.back()' class='back' style='color: #fff'>返回</a>
</div>
<script>
    var itype=1301; //对应"omdev/smXF.asp"里面的类型
    var tescape= 3000,time;
	
<% db_Open("/NandFlash/tmp/dbDat0.db3"); %>
var sid=<% write(sid);%>;
var json=<% db_QryAdv("select * from tbXF where SID="+sid,0); %>;
var jname = <% db_QryAdv("select Name from tbSM where SID="+sid,0); %>
<% db_Close(); %>
	
$(".smName").html(jname.recs[0].Name);


    $(function(){
        time=setInterval(ajax,tescape)
    });
    function ajax(){
        $.ajax({
            type: "POST",
            url: "omdev/smdat0.asp",
            data: "itype="+itype+"&sid="+sid,
            dataType:"json",
            success: function(msg){
                list3(msg)
            }
        });
    }
   list3(json);
    function list3(data){
        $.each(data.recs,function(i,n){

            $(".SID_XF").html(n.SID);
            $(".Addr_XF").html(n.Addr);
            $(".Port_XF").html(n.Port);
            $(".DateUpd_XF").html(n.DateUpd);
            //$(".State_XF").html(window.parent.parseState(n.State));
            $(".State_XF").html(SensorState(n.State));
            
            
            if(n.XFCH1_Dot)
            {
            	$(".XCH1_Data").html(n.XFCH1_Data/10);
            }
            else
            {
            	$(".XCH1_Data").html(n.XFCH1_Data);
            }
            $(".XCH1_Pcs").html(DataPcs(n.XFCH1_Pcs));
            
            if(n.XFCH2_Dot)
            {
            	$(".XCH2_Data").html(n.XFCH2_Data/10);
            }
            else
            {
            	$(".XCH2_Data").html(n.XFCH2_Data);
            }
            $(".XCH2_Pcs").html(DataPcs(n.XFCH2_Pcs));
            
            
            if(n.XFTem_Dot)//显示温度值
            {
            	$(".XTem_Data").html(n.XFTem_Data/10);
            }
            else
            {
            		$(".XTem_Data").html(n.XFTem_Data);
            }
            if(n.XFHum_Dot) //显示湿度值
            {
            	$(".XHum_Data").html(n.XFHum_Data/10);
            }
            else
            {
            		$(".XHum_Data").html(n.XFHum_Data);
            }
            
            $(".XCH1_Ad").html(n.XFCH1_Ad);
            $(".XCH2_Ad").html(n.XFCH2_Ad);
            
						if (0 == n.XFSYS_Status)
						{
							$(".XTem_Alarm").html("正常");
							$(".XHum_Alarm").html("正常");
							$(".XAge_Alarm").html("正常");
						}
						else
						{
							if(n.XFSYS_Status&0x40)
							{
								$(".XTem_Alarm").html("超温");
							}
							if(n.XFSYS_Status&0x20)
							{
								$(".XHum_Alarm").html("潮湿");
							}
							if(n.XFSYS_Status&0x08)
							{
								$(".XAge_Alarm").html("超寿命");	
							}
						}
        
        });
        $("span:contains('故障'),span:contains('告警'),span:contains('关闭'),span:contains('超温'),span:contains('潮湿')").addClass("red").removeClass("ger");
        $("span:contains('正常'),span:contains('关机')").addClass("ger").removeClass("red");
    }
	
	function SensorState(st)
	{
		var str;
		if (0 == st)
			str = "正常";
		else
			str = "故障";
		return str;
	}
	
	function DataPcs(pcs)
	{
		var str;
		
		switch(pcs)
		{
			case 0: str = "PPM"; break;
			case 1: str = "%LEL"; break;
			case 2: str = "%VOL"; break;
			case 3: str = "mg/m3"; break;
			default: str = "PPM"; break;
		}
			
		return str;
	}
	
	
</script>
</body>
</html>