<!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='type1292 empty' style=' margin: 10px;'>
  <table width="100%">
    <tr>
    <td width="300px" style="text-align: center;"><img src="img/ico-envir.png" style="width: 50%;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='SID1292'> </span>&nbsp;&nbsp;&nbsp;编址:<span class='Addr1292'> </span>&nbsp;&nbsp;&nbsp;数据端口:<span class='Port1292'> </span></td></tr>
        <tr><td style='width: 200px;'>更新时间</td><td><span class='DateUpd1292'> </span></td></tr>
        <tr><td style='width: 200px;'>监测项状态</td><td><span class='State1292'> </span></td></tr>
    </table>
    <table width='100%' style='margin-top: 30px'>
        <tr><td style='border: none'> <h1>监测量</h1></td></tr>
        <tr><td >A相温度：<span class='TemA1292'></span></td><td>状态:<span class='iTemA1292'></span></td></tr>
        <tr><td >B相温度：<span class='TemB1292'></span></td><td>状态:<span class='iTemB1292'></span></td></tr>
        <tr><td >C相温度：<span class='TemC1292'></span></td><td>状态:<span class='iTemC1292'></span></td></tr>
        <tr><td >历史最高温度：<span class='TemH1292'></span></td><td><span class='iTemH1292'></span></td></tr>
    </table>
    <table width='100%' style='margin-top: 30px'>
        <tr><td style='border: none'> <h1>状态量</h1></td></tr>
        <tr><td >下位机已经跳闸:<span class='iSw1292'></span></td><td>下位机发生故障:<span class='iErr1292'></span></td></tr>
        <tr><td >下位机已经超温:<span class='iTh1292'></span></td><td>下位机已经启动风机:<span class='iFan1292'></span></td></tr>
    </table>
    </td>
    </tr>
  </table>
    <a href='javascript:history.back()' class='back' style='color: #fff'>返回</a>
</div>
<script>
var itype=1292;
var tescape= 5000,time;
  
<% db_Open("/NandFlash/tmp/dbDat0.db3"); %>
var sid=<% write(sid);%>;
var json=<% db_QryAdv("select * from tbEnvirBWDK3208E 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){
        if(n.iPm==0){n.iPm="正常";}
        if(n.iPm==1){n.iPm="告警";}
        if(n.iPm<0||n.iPm>1){n.iPm="故障";}
        $(".SID1292").html(n.SID);
        $(".Addr1292").html(n.Addr);
        $(".Port1292").html(n.Port%256);
        $(".DateUpd1292").html(n.DateUpd);
        $(".State1292").html(parseState(n.State));

        $(".TemA1292").html(n.TemA/10+"℃");
        $(".iTemA1292").html(parseState(n.iTemA));
        $(".TemB1292").html(n.TemB/10+"℃");
        $(".iTemB1292").html(parseState(n.iTemB));
        $(".TemC1292").html(n.TemC/10+"℃");
        $(".iTemC1292").html(parseState(n.iTemC));
        $(".TemH1292").html(n.TemH/10+"℃");
        $(".iSw1292").html(n.iSw?"是":"否");
        $(".iErr1292").html(n.iErr?"是":"否");
        $(".iTh1292").html(n.iTh?"是":"否");
        $(".iFan1292").html(n.iFan?"是":"否");
    })
    $("span:contains('故障'),span:contains('告警'),span:contains('闭合'),span:contains('是')").addClass("red").removeClass("ger");
    $("span:contains('正常'),span:contains('否')").addClass("ger").removeClass("red");
}

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

</script>
</body>
</html>