<!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='type802 empty' style=' margin: 10px;'>
  <table width="100%">
    <tr>
    <td width="300px" style="text-align: center;"><img src="img/ico-ups.png" style="width: 50%;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='SID802'> </span>&nbsp;&nbsp;&nbsp;编址:<span class='Addr802'> </span>&nbsp;&nbsp;&nbsp;数据端口:<span class='Port802'> </span></td></tr>
        <tr><td style='width: 200px;'>更新时间</td><td><span class='DateUpd802'> </span></td></tr>
        <tr><td style='width: 200px;'>监测项状态</td><td><span class='State802'> </span></td></tr>
    </table>

    <table width='100%' style='margin-top: 30px'>
        <tr><td style='border: none'> <h1>运行参数</h1></td></tr>
        <tr>
			<td id='Vin' >输入电压:<span class='VinA802'> </span>&nbsp;<span class='VinB802'> </span>&nbsp;<span class='VinC802'> </span></td>
			<td id='Vout'>输出电压:<span class='VoutA802'> </span>&nbsp;<span class='VoutB802'> </span>&nbsp;<span class='VoutC802'> </span></td>
			<td id='Vba' >旁路电压:<span class='VBA802'> </span>&nbsp;<span class='VBB802'> </span>&nbsp;<span class='VBC802'> </span></td>
		</tr>
		<tr>
			<td id='Fin' >输入频率:<span class='FinA802'> </span></td>
			<td id='Fout'>输出频率:<span class='FoutA802'> </span></td>
			<td id='Fba' >旁路频率:<span class='FBA802'> </span></td>
		</tr>
		<tr>
			<td id='Iin' >输入电流:<span class='IinA802'> </span>&nbsp;<span class='IinB802'> </span>&nbsp;<span class='IinC802'> </span></td>
			<td id='Iout'>输出电流:<span class='IoutA802'> </span>&nbsp;<span class='IoutB802'> </span>&nbsp;<span class='IoutC802'> </span></td>
			<td id='Iba' >旁路电流:<span class='IBA802'> </span>&nbsp;<span class='IBB802'> </span>&nbsp;<span class='IBC802'> </span></td>
		</tr>
        <tr>
			<td id='Vbat'>电池电压:<span class='Vbatt802'> </span></td>
			<td id='Tem' >电池容量:<span class='Pbatt802'> </span></td>
			<td id='Mbat'>电池剩余时间:<span class='Mbatt802'> </span></td>
		</tr>
		<tr>
			<td id='Tem' >环境温度:<span class='Tem802'> </span></td>
			<td id='xx'><span class='v1802'> </span></td>
			<td id='xxx'><span class='xx802'> </span></td>
		</tr>
    </table>
    <table width='100%' style='margin-top: 30px'>
        <tr><td style='border: none'> <h1>工作状态</h1></td></tr>
        <tr>             
			<td id='b0' >输入状态:<span class='b0802'> </span></td>
			<td id='b1' >电池状态:<span class='b1802'> </span></td>
			<td id='b2' >电池低压:<span class='b2802'> </span></td>
			<td id='b3' >电池充电:<span class='b3802'> </span></td>
		</tr>
        <tr>             
			<td id='b4' >UPS 状态:<span class='b4802'> </span></td>
			<td id='b5' >UPS 高温:<span class='b5802'> </span></td>
			<td id='b6' >旁路状态:<span class='b6802'> </span></td>
			<td id='b7' >输出频率:<span class='b7802'> </span></td>
		</tr>            
		<tr>             
			<td id='b8' >输出状态1:<span class='b8802'> </span></td>
			<td id='b9' >输出状态2:<span class='b9802'> </span></td>
			<td id='b10'>输出状态3:<span class='b10802'> </span></td>
			<td id='b11'>整 流 器:<span class='b11802'> </span></td>
		</tr>            
        <tr>
			<td id='b12'>逆 变 器:<span class='b12802'> </span></td>
			<td id='b13'>逆变过载:<span class='b13802'> </span></td>
			<td id='b14'>逆变高温:<span class='b14802'> </span></td>
			<td id='b15'><span class='b15802'> </span></td>
		</tr>            
    </table>
    </td>
    </tr>
  </table>
    <a href='javascript:history.back()' class='back' style='color: #fff'>返回</a>
    </div>
<script>
var itype=802;
var tescape= 5000,time;

<% db_Open("/NandFlash/tmp/dbDat0.db3"); %>
var sid=<% write(sid);%>;
var tag1=<% write(db_QryInt("select Tag1 from tbSM where SID="+sid,1));%>;
var json=<% db_QryAdv("select * from tbUpsEx 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)
        }
    });
}
list3(json);
function list3(data){
    $.each(data.recs,function(i,n){
        $(".SID802").html(n.SID);
        $(".Addr802").html(n.Addr);
        $(".Port802").html(n.Port%256);
        $(".DateUpd802").html(n.DateUpd);
        $(".State802").html(parseState(n.State));

		{
			if ((n.Vin1==0) && (n.Vin2==0) && (n.Vin3==0))
			{
					$(".VinA802").html("N/A");
					$(".VinB802").html("N/A");
					$(".VinC802").html("N/A");
			}
			else
			{
				$(".VinA802").html(n.Vin1/10+"V");
				$(".VinB802").html(n.Vin2/10+"V");
				$(".VinC802").html(n.Vin3/10+"V");
			}
			
			if ((n.Vout1==0) && (n.Vout2==0) && (n.Vout3==0))
			{
				$(".VoutA802").html("N/A");
				$(".VoutB802").html("N/A");
				$(".VoutC802").html("N/A");
			}
			else
			{
				$(".VoutA802").html(n.Vout1/10+"V");
				$(".VoutB802").html(n.Vout2/10+"V");
				$(".VoutC802").html(n.Vout3/10+"V");
			}
			
			if ((n.VB1==0) && (n.VB2==0) && (n.VB3==0))
			{
				$(".VBA802").html("N/A");
				$(".VBB802").html("N/A");
				$(".VBC802").html("N/A");
			}
			else
			{
				$(".VBA802").html(n.VB1/10+"V");
				$(".VBB802").html(n.VB2/10+"V");
				$(".VBC802").html(n.VB3/10+"V");
			}
			
			if ((n.Iin1==0) && (n.Iin2==0) && (n.Iin3==0))
			{
				$(".IinA802").html("N/A");
				$(".IinB802").html("N/A");
				$(".IinC802").html("N/A");
			}
			else
			{
				$(".IinA802").html(n.Iin1/10+"A");
			    $(".IinB802").html(n.Iin2/10+"A");
			    $(".IinC802").html(n.Iin3/10+"A");
			}
			
			if ((n.Iout1==0) && (n.Iout2==0) && (n.Iout3==0))
			{
				$(".IoutA802").html("N/A");
				$(".IoutB802").html("N/A");
				$(".IoutC802").html("N/A");
			}
			else
			{
				$(".IoutA802").html(n.Iout1/10+"A");
				$(".IoutB802").html(n.Iout2/10+"A");
				$(".IoutC802").html(n.Iout3/10+"A");
			}
			
			if ((n.IB1==0) && (n.IB2==0) && (n.IB3==0))
			{
				$(".IBA802").html("N/A");
				$(".IBB802").html("N/A");
				$(".IBC802").html("N/A");
			}
			else
			{
				$(".IBA802").html(n.IB1/10+"A");
				$(".IBB802").html(n.IB2/10+"A");
				$(".IBC802").html(n.IB3/10+"A");
			}
			
			$(".FinA802").html(n.Fin1/10+" Hz");
			$(".FoutA802").html(n.Fout1+" Hz");
			$(".FBA802").html(n.FB1/10+" Hz");
			
			$(".Vbatt802").html(n.Vbatt/10+"V"); 
			$(".Pbatt802").html(n.Pbatt+"%");
			$(".Mbatt802").html(n.Mbatt+" s");  
			$(".Tem802").html(n.Tem/10+"℃");  
			
            var sst = "";
			if (n.b0 == 1) sst = "AC异常"; else sst="AC正常";
			$(".b0802").html(sst);
			if (n.b1 == 1) sst = "异常"; else sst="正常";
			$(".b1802").html(sst);
			if (n.b2 == 1) sst = "异常(低压)"; else sst="无";
			$(".b2802").html(sst);
			if (n.b3 == 1) sst = "正常(充电)"; else sst="无";
			$(".b3802").html(sst);
			if (n.b4 == 1) sst = "异常"; else sst="正常";
			$(".b4802").html(sst);
			if (n.b5 == 1) sst = "异常(高温)"; else sst="正常";
			$(".b5802").html(sst);
			if (n.b6 == 1) sst = "异常"; else sst="正常";
			$(".b6802").html(sst);
			if (n.b7 == 1) sst = "异常"; else sst="正常";
			$(".b7802").html(sst);

			if (n.b8 == 1) sst = "异常(过载)"; else sst="正常";
			$(".b8802").html(sst);
			if (n.b9 == 1) sst = "异常(过载)"; else sst="正常";
			$(".b9802").html(sst);
			if (n.b10 == 1) sst = "异常(过载)"; else sst="正常";
			$(".b10802").html(sst);
			if (n.b11 == 1) sst = "异常"; else sst="正常";
			$(".b11802").html(sst);
			if (n.b12 == 1) sst = "异常(过载)"; else sst="无";
			$(".b12802").html(sst);
			if (n.b13 == 1) sst = "异常(高温)"; else sst="无";
			$(".b13802").html(sst);
		}

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

function parseState(istate){
    if(istate==0) return "正常";
    else   if(istate==1) return "告警";
    else return "故障";
}
</script>
</body>
</html>