<!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>
    <script src="js/omara.js"></script>

</head>
<body style="background: #F3F3F3">
<div class='type2080 empty' style=' margin: 10px;'>
  <table width="100%">
    <tr>
    <td width="300px" style="text-align: center;"><img src="img/ico-cyber.png" style="width: 60%;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='SID2080'> </span>&nbsp;&nbsp;&nbsp;编址:<span class='Addr2080'> </span>&nbsp;&nbsp;&nbsp;数据端口:<span class='Port2080'> </span></td></tr>
        <tr><td style='width: 200px;'>更新时间</td><td><span class='DateUpd2080'> </span></td></tr>
        <tr><td style='width: 200px;'>监测项状态</td><td><span class='State2080'> </span></td></tr>
    </table>
    <table width='100%' style='margin-top: 30px'>
        <tr><td style='border: none'> <h1>基本信息</h1></td></tr>
		<tr><td width='50%'>温度实时值:<span class='TemReal2080'></span></td>
		    <td width='50%'>湿度实时值:<span class='HumReal2080'></span></td></tr>
		<tr><td width='50%'>湿度设定值:<span class='HumSet2080'></span></td>
		    <td width='50%'>温度设定值:<span class='TemSet2080'></span></td></tr>
		<tr><td width='50%'>温度回差值:<span class='TemBack2080'></span></td>
		    <td width='50%'>湿度回差值:<span class='HumBack2080'></span></td></tr>
    </table>
    <table width='100%' style='margin-top: 30px'>
        <tr><td style='border: none'> <h1>运行状态</h1></td></tr>
		<tr><td width='50%'>机组状态:<span class='StUnitStatus2080'></span></td>
		    <td width='50%'>机组故障:<span class='StUnitFault2080'></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,1)' id='relayctrlon' class='gray'>开启</a><a href='javascript:relayctrl(2,1)' 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=2080;
var tescape= 5000,time;
  
<% db_Open("/NandFlash/tmp/dbDat0.db3"); %>
var sid=<% write(sid);%>;
var json=<% db_QryAdv("select * from tbCyberCSHH 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){
        $(".SID2080").html(n.SID);
        $(".Addr2080").html(n.Addr);
        $(".Port2080").html(n.Port%256);
        $(".DateUpd2080").html(n.DateUpd);
        $(".State2080").html(parseState(n.State));
		
		$(".TemReal2080").html((n.TemReal/100) + "℃");
		$(".TemSet2080").html((n.TemSet/100) + "℃");
		$(".TemBack2080").html((n.TemBack/100) + "℃");
		$(".HumReal2080").html((n.HumReal/100) + "％");
		$(".HumSet2080").html((n.HumSet/100) + "％");
		$(".HumBack2080").html((n.HumBack/100) + "％");
		$(".StUnitStatus2080").html((n.StUnitStatus) ? "开启" : "停止");
		$(".StUnitFault2080").html((n.StUnitFault) ? "告警" : "正常");
		
		if (n.StUnitStatus)
		{
            $("#relayctrlon").attr("class","redd");
            $("#relayctrloff").attr("class","gray");
		}
		else
		{
            $("#relayctrlon").attr("class","gray");
            $("#relayctrloff").attr("class","redd");
		}
    })

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

function parseAlm(istate){
    if(istate==0) return "正常";
    else   if(istate==1) return "告警";
    else return "无效";
}

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

function relayctrl(reg,state)
{
	var wParam = 0x0f0000 | reg; //[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>