<!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='empty' style=' margin: 10px;'>
  <table width="100%">
    <tr>
    <td width="300px" style="text-align: center;"><img src="img/ico-elecsw.png" style="width: 110%;text-align: center;"></td>
    <td>
    <table width='100%'>
        <tr><td style='border: none'> <h1>UPS配电空开监测</h1></td></tr>
        <tr><td style='width: 200px;'>基本信息</td><td>SID:<span class='BaseSID'> </span>&nbsp;&nbsp;&nbsp;编址:<span class='BaseAddr'> </span>&nbsp;&nbsp;&nbsp;数据端口:<span class='BasePort'> </span></td></tr>
        <tr><td style='width: 200px;'>更新时间</td><td><span class='BaseDateUpd'> </span></td></tr>
        <tr><td style='width: 200px;'>监测状态</td><td><span class='BaseState'> </span></td></tr>
    </table>
    
		    <table width='100%' style='margin-top: 30px'>
      <tr><td style='border: none'> <h1>运行信息</h1></td></tr>
			<tr><td width='25%'>空开状态一:<span id='KK1'></span></td>
		    	<td width='25%'>空开状态二:<span id='KK2'></span></td>
		    	<td width='25%'>空开状态三:<span id='KK3'></span></td>
		    	<td width='25%'>空开状态四:<span id='KK4'></span></td>
		  </tr>
			<tr><td width='25%'>空开状态五:<span id='KK5'></span></td>
		    	<td width='25%'>空开状态六:<span id='KK6'></span></td>
		    	<td width='25%'>空开状态七:<span id='KK7'></span></td>
		    	<td width='25%'>空开状态八:<span id='KK8'></span></td>
		  </tr>
    </table>

    </td>
    </tr>
  </table>
    <a href='javascript:history.back()' class='back' style='color: #fff'>返回</a>
</div>
<script>
var itype=4150;
var tescape= 5000,time;
  
<% db_Open("/NandFlash/tmp/dbDat0.db3"); %>
var sid=<% write(sid);%>;
var json0=<% db_QryAdv("select * from tbSnmp where SID="+sid,0);%>;
var json=<% db_QryAdv("select * from tbSnmpDat where SID="+sid,0);%>;
<% db_Close(); %>
	
$(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); 
        }
    });
}

list0(json0);
function list0(data){ // ?九渲眯畔?
    $.each(data.recs,function(i,n){
        $(".BaseSID").html(n.SID);
        $(".BaseAddr").html(n.Addr);
        $(".BasePort").html(n.Port%256);
        $(".BaseDateUpd").html(n.DateUpd);
        $(".BaseState").html(parseState(n.State));
    });
}

list3(json);
function list3(data){ // 展示数据
    var iv;
    $.each(data.recs,function(i,n){
				
        switch(n.Fld)
        {
					case "KK1":
					case "KK2":
					case "KK3":
					case "KK4":
					case "KK5":
					case "KK6":
					case "KK7":
					case "KK8":
					{
						iv = n.Val?"断开":"闭合"; 
					}break;
        }
        $("#"+n.Fld).html(iv);

    })

	$("span:contains('故障'),span:contains('告警'),span:contains('闭合'),span:contains('断开')").addClass("red").removeClass("ger");
    $("span:contains('正常'),span:contains('闭合')").addClass("ger").removeClass("red");
}

function parseAlm(istate){
    if(istate==0) return "正常";
    else   if(istate==1) return "告警";
    else return "无效";
}
function parseState(istate){
    if(istate==0) return "正常";
    else   if(istate==1) return "告警";
    else return "故障";
}

</script>

</body>
</html>