<!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>
  <table width="100%">
    <tr>
    <td width="300px" style="text-align: center;"><img src="img/ico-batt.png" style="width: 70%;text-align: center;"></td>
    <td>
    <table width='100%'>
      <tr><td style='border: none'> <h1>无线电池巡检</h1></td></tr>
      <tr><td style='width: 200px;'>基本信息</td><td>SID:<span class='SID1028'></span>&nbsp;&nbsp;&nbsp;编址:<span class='Addr1028'></span>&nbsp;&nbsp;&nbsp;数据端口:<span class='Port1028'></span></td></tr>
      <tr><td style='width: 200px;'>更新时间</td><td><span class='DateUpd1028'></span></td></tr>
      <tr><td style='width: 200px;'>监测项状态</td><td><span class='State1028'></span></td></tr>
    </table>
    <table class="append" width='100%' style='margin-top: 30px'>
    </table>
    </td>
    </tr>
  </table>
</div>
<a href='javascript:history.back()' class='back' style='color: #fff'>返回</a>
<script>
var itype=1028;
var tescape= 5000,time;
  
<% db_Open("/NandFlash/tmp/dbDat0.db3"); %>
var sid=<% write(sid);%>;
var jbase=<% db_QryAdv("select * from tbBatt100 where SID="+sid,0); %>;
var jlist=<% db_QryAdv("select * from tbBattVal 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+"&batval=0",
        dataType:"json",
        success: function(msg){
            listB(msg)
        }
    });
    $.ajax({
        type: "POST",
        url: "omdev/smdat0.asp",
        data: "itype="+itype+"&sid="+sid+"&batval=1",
        dataType:"json",
        success: function(msg){
            list3(msg)
        }
    });
}
listB(jbase);
function listB(data){
    $.each(data.recs,function(i,n){
        $(".SID1028").html(n.SID);
        $(".Addr1028").html(n.Addr);
        $(".Port1028").html(n.Port%256);
        $(".DateUpd1028").html(n.DateUpd);
        $(".State1028").html(window.parent.parseState(n.State));
    });
}
list3(jlist);
function list3(data){
    var q='';
    $.each(data.recs,function(i,n){
        var ist = n.State;
        n.State="";
        if(ist&0x100) n.State+="故障";
        else {
          if(ist&0x80) n.State+="在线 "; else n.State+="未在线 ";
          if(ist&0x40) n.State+="告警 "; else { if(ist&0x80) n.State+="正常 ";}
          if(ist&0x02) n.State+="温度异常 ";
          if(ist&0x01) n.State+="电压异常 ";
        }
        q+="<tr><td><span class='grey'>"+"#"+(i+1)+"</span></td><td style='border-left: none;border-right: none'>状态:<span>"+ n.State+"</span></td><td style='border-left: none;border-right: none'>电压:<span >"+ n.V/10+" V</span></td><td style='border-left: none;border-right: none'>温度:<span >"+ n.T/10+" ℃</span></td></tr>";
    });
    $(".append").html(q)
    $("span:contains('故障'),span:contains('告警'),span:contains('未')").addClass("red").removeClass("ger");
    $("span:contains('正常')").addClass("ger").removeClass("red");
}
</script>
</body>
</html>