<!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='type2067 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='SID2067'> </span>&nbsp;&nbsp;&nbsp;编址:<span class='Addr2067'> </span>&nbsp;&nbsp;&nbsp;数据端口:<span class='Port2067'> </span></td></tr>
        <tr><td style='width: 200px;'>更新时间</td><td><span class='DateUpd2067'> </span></td></tr>
        <tr><td style='width: 200px;'>监测项状态</td><td><span class='State2067'> </span></td></tr>
    </table>
    <table width='100%' style='margin-top: 30px'>
        <tr><td style='border: none'> <h1>各项基本信息</h1></td></tr>
		<tr><td class='temon' width='50%'>开机温度: <span class='temon2067'></span></td><td class='temoff' width='50%'>关机温度: <span class='temoff2067'></span></td></tr>
		<tr><td class='temhigh' width='50%'>回风温度上限: <span class='temhigh2067'></span></td><td class='temlow' width='50%'>回风温度下限: <span class='temlow2067'></span></td></tr>
		<tr><td class='humhigh' width='50%'>回风湿度上限: <span class='humhigh2067'></span></td><td class='humlow' width='50%'>回风湿度下限: <span class='humlow2067'></span></td></tr>
		<tr><td class='temret' width='50%'>回风温度: <span class='temret2067'></span></td><td class='almtemr' width='50%'>回风温度警报状态: <span class='almtemr2067'></span></td></tr>
    </table>
	<table width='100%' style='margin-top: 30px'>
        <tr><td style='border: none'> <h1>系统状态</h1></td></tr>
        <tr>
			<td class='onoff'>空调开关状态: <span class='onoff2067'></span></td>
			<td class='stjs'>加湿器状态: <span class='stjs2067'></span></td>
			<td class='stjy'>加热器状态: <span class='stjy2067'></span></td>
		</tr>
		<tr>
			<td class='stfj'>风扇状态: <span class='stfj2067'></span></td>
			<td class='stys'>压缩机状态: <span class='stys2067'></span></td>
			<td class='stlw'>过滤网状态: <span class='stlw2067'></span></td>
		</tr>
		<tr>
			<td class='stcs'>注意报状态: <span class='stcs2067'></span></td>
			<td class='stbj'>警报状态: <span class='stbj2067'></span></td>
			<td class='stexp'>异常状态: <span class='stexp2067'></span></td>
		</tr>
		<tr>
			<td class='stmode'>运转状态: <span class='stmode2067'></span></td>
			<td>&nbsp; <span class='xxx2067'></span></td>
			<td>&nbsp; <span class='xxxxx2067'></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=2067;
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 tbCyberDaiKin 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){
        $(".SID2067").html(n.SID);
        $(".Addr2067").html(n.Addr);
        $(".Port2067").html(n.Port%256);
        $(".DateUpd2067").html(n.DateUpd);
        $(".State2067").html(window.parent.parseState(n.State));
		
		if (tag1 == 1)
		{
			$(".temon").html("设定温度: <span class='temon2067'>"+n.temon+"℃</span>");
			$(".temoff").html("关机温度: <span class='temoff2067'>N/A</span>");
			$(".temhigh").html("制冷温度上限: <span class='temhigh2067'>"+n.temhigh+"℃</span>");
			$(".temlow").html("制冷温度下限: <span class='temlow2067'>"+n.temlow+"℃</span>");
			$(".humhigh").html("制热温度上限: <span class='humhigh2067'>"+n.humhigh+"%RH</span>");
			$(".humlow").html("制热温度下限: <span class='humlow2067'>"+n.humlow+"%RH</span>");
			$(".temret").html("回风温度: <span class='temret2067'>"+n.temret+"℃</span>");
			$(".almtemr").html("回风温度警报状态: <span class='almtemr2067'>N/A</span>");
		
			$(".onoff2067").html(n.onoff ? "运转" : "停止");
			$(".stjs2067").html("N/A");
			$(".stjy2067").html("N/A");
			$(".stfj2067").html(n.stfj + "(1~5：1：低风…5：强风)");
			$(".stys").html("扫风状态: <span class='stys2067'>"+n.stys+"(1~7:  <=4:停扫…<=7:扫风)</span>");
			$(".stlw2067").html("N/A");
			$(".stcs2067").html("N/A");
			$(".stbj2067").html("N/A");
			$(".stexp2067").html("N/A");
			
			var stmode = "未知";
			if (n.stmode == 0x60)
				stmode = "送风";
			else if (n.stmode == 0x61)
				stmode = "制热";
			else if (n.stmode == 0x62)
				stmode = "制冷";
			else if (n.stmode == 0x63)
				stmode = "自动";
			else if (n.stmode == 0x67)
				stmode = "除湿";
			$(".stmode2067").html(stmode);
		}
		else
		{
			$(".temon2067").html(n.temon+"℃");
			$(".temoff2067").html(n.temoff+"℃");
			$(".temhigh2067").html(n.temhigh+"℃");
			$(".temlow2067").html(n.temlow+"℃");
			$(".humhigh2067").html(n.humhigh+"%RH");
			$(".humlow2067").html(n.humlow+"%RH");
			$(".temret2067").html(n.temret/100+"℃");
			var almtemr = "故障";
			if (n.almtemr == 0)
				almtemr = "正常";
			else if (n.almtemr == 1)
				almtemr = "下限以下";
			else if (n.almtemr == 2)
				almtemr = "上限以上";
			$(".almtemr2067").html(almtemr);
			
			$(".onoff2067").html(n.onoff ? "运转" : "停止");
			$(".stjs2067").html(n.stjs ? "运转" : "停止");
			$(".stjy2067").html(n.stjy ? "运转" : "停止");
			$(".stfj2067").html(n.stfj ? "运转" : "停止");
			$(".stys2067").html(n.stys ? "运转" : "停止");
			$(".stlw2067").html(n.stlw ? "开" : "关");
			$(".stcs2067").html(n.stcs ? "开" : "关");
			$(".stbj2067").html(n.stbj ? "开" : "关");
			$(".stexp2067").html(n.stexp ? "异常" : "正常");
			
			var stmode = "未知";
			if (n.stmode == 0)
				stmode = "送风";
			else if (n.stmode == 1)
				stmode = "制热";
			else if (n.stmode == 2)
				stmode = "制冷";
			$(".stmode2067").html(stmode);
			
			if (n.onoff)
			{
				$("#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 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>