<!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='type512 empty' style=' margin: 10px;'>
  <table width="100%">
    <tr>
    <td width="300px" style="text-align: center;"><img src="img/ico-elecsw.png" style="width: 80%;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='SID512'> </span>&nbsp;&nbsp;&nbsp;编址:<span class='Addr512'> </span>&nbsp;&nbsp;&nbsp;数据端口:<span class='Port512'> </span></td></tr>
        <tr><td style='width: 200px;'>更新时间</td><td><span class='DateUpd512'> </span></td></tr>
        <tr><td style='width: 200px;'>监测项状态</td><td><span class='State512'> </span></td></tr>
		<tr><td style='width: 200px;' id='asd1'>开关1</td><td><span class='sd1512'> </span></td></tr>
		<tr><td style='width: 200px;' id='asd2'>开关2</td><td><span class='sd2512'> </span></td></tr>
		<tr><td style='width: 200px;' id='asd3'>开关3</td><td><span class='sd3512'> </span></td></tr>
		<tr><td style='width: 200px;' id='asd4'>开关4</td><td><span class='sd4512'> </span></td></tr>
		<tr><td style='width: 200px;' id='asd5'>开关5</td><td><span class='sd5512'> </span></td></tr>
		<tr><td style='width: 200px;' id='asd6'>开关6</td><td><span class='sd6512'> </span></td></tr>
    </table>
    </td>
    </tr>
  </table>
    <a href='javascript:history.back()' class='back' style='color: #fff'>返回</a>
</div>
<script>
var itype=512;
var tescape= 5000,time;

<% db_Open("/NandFlash/tmp/dbDat0.db3"); %>
var sid=<% write(sid);%>;
var json=<% db_QryAdv("select * from tbOnoff where SID="+sid,0); %>;
var jdefv=<% db_QryAdv("select ANote from tbSMDefVal where SID="+sid,0); %>;
<% db_Close(); %>
	
$(function(){
  time=setInterval(ajax,tescape)
  if(jdefv.reccnt>0){
    var snote="";
    $.each(jdefv.recs, function(i, n) {
      snote="配电开关"+(i+1)+" ";
      if(n.ANote!="")
        snote+=n.ANote;
      $("#asd"+(i+1)).html(snote);
    });
  }
});

  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.sd1 == 0) {
        n.sd1 = "正常";
      } else {
        n.sd1 = "断开";
      }
      if (n.sd2 == 0) {
        n.sd2 = "正常";
      } else {
        n.sd2 = "断开";
      }
      if (n.sd3 == 0) {
        n.sd3 = "正常";
      } else {
        n.sd3 = "断开";
      }
      if (n.sd4 == 0) {
        n.sd4 = "正常";
      } else {
        n.sd4 = "断开";
      }
      if (n.sd5 == 0) {
        n.sd5 = "正常";
      } else {
        n.sd5 = "断开";
      }
      if (n.sd6 == 0) {
        n.sd6 = "正常";
      } else {
        n.sd6 = "断开";
      }
      $(".SID512").html(n.SID);
      $(".Addr512").html(n.Addr);
      $(".Port512").html(n.Port % 256);
      $(".DateUpd512").html(n.DateUpd);
      $(".State512").html(window.parent.parseState(n.State));
      $(".sd1512").html(n.sd1);
      $(".sd2512").html(n.sd2);
      $(".sd3512").html(n.sd3);
      $(".sd4512").html(n.sd4);
      $(".sd5512").html(n.sd5);
      $(".sd6512").html(n.sd6);
    })
    $("span:contains('故障'),span:contains('告警'),span:contains('闭合'),span:contains('关闭')").addClass("red").removeClass("ger");
    $("span:contains('正常')").addClass("ger").removeClass("red");
  }
</script>
</body>
</html>