<!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='type1280 empty' style=' margin: 10px;'>
  <table width="100%">
    <tr>
    <td width="300px" style="text-align: center;"><img src="img/ico-elec.png" style="width: 70%;text-align: center;"></td>
    <td>
    <table width='100%'>
        <tr><td style='border: none'> <h1>HC-311A单相导轨式电表</h1></td></tr>
        <tr><td style='width: 200px;'>基本信息</td><td>SID:<span class='SIDHC311A'> </span>&nbsp;&nbsp;&nbsp;编址:<span class='AddrHC311A'> </span>&nbsp;&nbsp;&nbsp;数据端口:<span class='PortHC311A'> </span></td></tr>
        <tr><td style='width: 200px;'>更新时间</td><td><span class='DateUpdHC311A'> </span></td></tr>
        <tr><td style='width: 200px;'>监测项状态</td><td><span class='StateHC311A'> </span></td></tr>
    </table>
    <table width='100%' style='margin-top: 30px'>
        <tr><td style='border: none'> <h1>各项基本信息</h1></td></tr>
        <tr><td width='50%'>机器类型Type: <span class='TypeHC311A'></span></td><td width='50%'>SnapID: <span class='SnapHC311A'></span></td></tr>
		<tr><td width='50%'>电压: <span class='VoltageHC311A'></span></td><td width='50%'>电流: <span class='CurrentHC311A'></span></td></tr>
		<tr><td width='50%'>有功功率: <span class='ygglHC311A'></span></td><td width='50%'>无功功率: <span class='wgglHC311A'></span></td></tr>
		 <tr><td width='50%'>视在功率: <span class='szglHC311A'></span></td><td width='50%'>功率因素: <span class='glysHC311A'></span></td></tr>
		<tr><td width='50%'>频率: <span class='HZHC311A'></span></td><td width='50%'>模块内温度: <span class='mknwdHC311A'></span></td></tr>
		
		<tr><td width='50%'>正向有功电度: <span class='zxygddHC311A'></span></td><td width='50%'>反向有功电度: <span class='fxygddHC311A'></span></td></tr>
		<tr><td width='50%'>感性无功电度: <span class='gxwgddHC311A'></span></td><td width='50%'>容性无功电度: <span class='rxwgddHC311A'></span></td></tr>
		 <tr><td width='50%'>和有功电度: <span class='jdzhygddHC311A'></span></td><td width='50%'>和无功电度: <span class='jdzhwgddHC311A'></span></td></tr>
		<tr><td width='50%'>净有功电度: <span class='jygddHC311A'></span></td><td width='50%'>净无功电度: <span class='jwgddHC311A'></span></td></tr>
		
    </table>
    <table width='100%' style='margin-top: 30px' class="ofBTN">
        <tr><td style='border: none'> <h1>继电器</h1></td></tr>
        <tr><td width='50%'>继电器状态: <span class='m_uRelayState'></span></td><td width='50%'> <span class='xx'></span></td></tr>
		<tr><td width='50%'> <a  href='javascript:relayctrl(1)' id='relayctrlon' class='gray'>闭合</a><a href='javascript:relayctrl(0)' id='relayctrloff' class='gray'>断开</a></td></tr>
    </table>
    </td>
    </tr>
  </table>
    
    <a href='javascript:history.back()' class='back' style='color: #fff'>返回</a>
</div>
<script>
var itype=262;
var tescape= 5000,time;
  
<% db_Open("/NandFlash/tmp/dbDat0.db3"); %>
var sid=<% write(sid);%>;
var json=<% db_QryAdv("select * from tbHC311A 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); 
			
        }
    });
}
var monitorStatus = ["正常","告警","故障"];

list3(json);
function list3(data){
    $.each(data.recs,function(i,n){
        $(".SIDHC311A").html(n.SID);
        $(".AddrHC311A").html(n.Addr);
        $(".PortHC311A").html(n.Port%256);
        $(".DateUpdHC311A").html(n.DateUpd);
        $(".StateHC311A").html(monitorStatus[n.State%3]);
        $(".TypeHC311A").html(n.Type+"A");
        $(".SnapHC311A").html(n.SnapID);

        $(".VoltageHC311A").html(n.m_uiAU/10+"V");
		$(".CurrentHC311A").html(n.m_uiAI/10+"A");
		$(".ygglHC311A").html(n.m_iP/1000+"KW");
		$(".wgglHC311A").html(n.m_iQ/1000+"KVar");
		$(".szglHC311A").html(n.m_uiS/1000+"KVA");
        $(".glysHC311A").html(n.m_iPF/1000);
		$(".HZHC311A").html(n.m_uiFR/100+"HZ");
		$(".mknwdHC311A").html(n.m_iTemp/10+"°C");
		$(".m_uRelayState").html(n.m_uRelayState ? "吸合" : "断开");
		if (n.m_uRelayState)
		{
            $("#relayctrlon").attr("class","redd");
            $("#relayctrloff").attr("class","gray");
		}
		else
		{
            $("#relayctrlon").attr("class","gray");
            $("#relayctrloff").attr("class","redd");
		}
		
		//正向有功电度,反向有功电度,感性无功电度,容性无功电度
	//DWORD m_iEpPH,m_iEpNH,m_iEqPH,m_iEqNH;

	//绝对值和有功电度,净有功电度,绝对值和无功电度,净无功电度
	//DWORD m_iEp_total,m_iEp_net,m_iEq_total,m_iEq_net;
		$(".zxygddHC311A").html(n.m_iEpPH/1000+"度");
		$(".fxygddHC311A").html(n.m_iEpNH/1000+"度");
		$(".gxwgddHC311A").html(n.m_iEqPH/1000+"度");
		$(".rxwgddHC311A").html(n.m_iEqNH/1000+"度");
		$(".jdzhygddHC311A").html(n.m_iEp_total/1000+"度");
        $(".jdzhwgddHC311A").html(n.m_iEq_total/1000+"度");
		$(".jygddHC311A").html(n.m_iEp_net/1000+"度");
		$(".jwgddHC311A").html(n.m_iEq_net/1000+"度");
    })
	$("span:contains('故障'),span:contains('告警'),span:contains('闭合'),span:contains('关闭')").addClass("red").removeClass("ger");
        $("span:contains('正常')").addClass("ger").removeClass("red");
    
}

function relayctrl(state)
{
	var wParam = 0x0f0000; //[32:16]功能码，[15:0]寄存器地址
	var lParam = (sid << 16) | (state & 0xFFFF)//[32:16]SID，[15:0]控制值
    $.ajax({
        type: "POST",
        url: "action/doctrl",
        data: "op="+wParam+"&value="+lParam+"",
        dataType: "json",
        success: function(msg){
            alert("ok!");
        }
    });
}

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