<!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='empty' style=' margin: 10px;'>
  <table width="100%">
    <tr>
    <td width="300px" style="text-align: center;"><img src="img/ico-elecsw.png" style="width: 60%;text-align: center;"></td>
    <td>
    <table width='100%'>
        <tr><td style='border: none'> <h1 class='smName'></h1></td></tr>
        <tr><td style='width: 200px;'>基本信息</td><td>SID:<span class='BaseSID'> </span>&nbsp;&nbsp;&nbsp;编址:<span class='BaseAddr'> </span>&nbsp;&nbsp;&nbsp;数据端口:<span class='BasePort'> </span></td></tr>
        <tr><td style='width: 200px;'>更新时间</td><td><span class='DateUpd'> </span></td></tr>
        <tr><td style='width: 200px;'>监测状态</td><td><span class='State'> </span></td></tr>
    </table>
    <table width='100%' style='margin-top: 10px'>
        <tr><td style='border: none'> <h1>空调监测量</h1></td></tr>
		<tr><td>水温：<span class='watertemp'> </span>&nbsp;</td>
			<td>回风温度：<span class='airtempR'> </span>&nbsp;</td>
			<td>送风温度：<span class='airtempS'> </span>&nbsp;</td>
			<td>回风湿度：<span class='airhumR'> </span>&nbsp;</td></tr>
		<tr><td>送风湿度：<span class='airhumS'> </span>&nbsp;</td>
			<td>室外温度：<span class='airtempO'> </span>&nbsp;</td>
			<td>室外湿度：<span class='airhumO'> </span>&nbsp;</td>
			<td>温度设定偏移：<span class='tempsetS'> </span>&nbsp;</td></tr>
		<tr><td>湿度设定偏移：<span class='humsetS'> </span>&nbsp;</td>
			<td>模块1数字输出状态1：<span class='m1do1'> </span>&nbsp;</td>
			<td>模块1数字输出状态2：<span class='m1do2'> </span>&nbsp;</td>
			<td>模块1数字输入状态1：<span class='m1di1'> </span>&nbsp;</td></tr>
		<tr><td>模块1数字输入状态2：<span class='m1di2'> </span>&nbsp;</td>
			<td>设定温度：<span class='tempset'> </span>&nbsp;</td>
			<td>设定湿度：<span class='humset'> </span>&nbsp;</td>
			<td>最高回风温度：<span class='airtempRH'> </span>&nbsp;</td></tr>
		<tr><td>最高送风温度：<span class='airtempSH'> </span>&nbsp;</td>
			<td>最低回风温度：<span class='airtempRL'> </span>&nbsp;</td>
			<td>最低送风温度：<span class='airtempSL'> </span>&nbsp;</td>
			<td>最高水温：<span class='watertempH'> </span>&nbsp;</td></tr>
		<tr><td>最低水温：<span class='watertempL'> </span>&nbsp;</td>
			<td>最高回风湿度：<span class='airhumRH'> </span>&nbsp;</td>
			<td>最高送风湿度：<span class='airhumSH'> </span>&nbsp;</td>
			<td>最低回风湿度：<span class='airhumRL'> </span>&nbsp;</td></tr>
		<tr><td>最低送风湿度：<span class='airhumSL'> </span>&nbsp;</td>
			<td>干冷器开始温度：<span class='drycooltempS'> </span>&nbsp;</td>
			<td>干冷器开启温度：<span class='drycooltempE'> </span>&nbsp;</td>
			<td>泵开始温度：<span class='pumptemp'> </span>&nbsp;</td></tr>
		<tr><td>GE/CW阀关闭温度：<span class='gecwtemp'> </span>&nbsp;</td>
			<td>除湿开始湿度：<span class='dehumtemp'> </span>&nbsp;</td>
			<td>除湿湿滞：<span class='dehumband'> </span>&nbsp;</td>
			<td>加湿开始湿度：<span class='humtemp'> </span>&nbsp;</td></tr>
		<tr><td>加湿湿滞：<span class='humband'> </span>&nbsp;</td>
			<td>通用状态：<span class='status'> </span>&nbsp;</td>
			<td><span class=''> </span>&nbsp;</td>
			<td><span class=''> </span>&nbsp;</td></tr>
	</table>
	
    </td>
    </tr>
  </table>
    <a href='javascript:history.back()' class='back' style='color: #fff'>返回</a>
</div>
<script>
var itype=2108;
var tescape= 5000,time;
  
<% db_Open("/NandFlash/tmp/dbDat0.db3"); %>
var sid=<% write(sid);%>;
var json0=<% db_QryAdv("select * from tbCyberStulzC where SID="+sid,0);%>;
var jname = <% db_QryAdv("select Name from tbSM where SID="+sid,0); %>
<% db_Close(); %>
	
$(".smName").html(jname.recs[0].Name);

	
$(function(){
  time=setInterval(ajax,tescape)
  ajax();
});

function ajax(){
    $.ajax({
        type: "POST",
        url: "omdev/smdat0.asp",
        data: "itype="+itype+"&sid="+sid,
        dataType:"json",
        success: function(msg){
            list3(msg); 
        }
    });
}

list0(json0);
function list0(data){ // 基本配置信息
    $.each(data.recs,function(i,n){
        $(".BaseSID").html(n.SID);
        $(".BaseAddr").html(n.Addr);
        $(".BasePort").html(n.Port%256);
        $(".DateUpd").html(n.DateUpd);
        $(".State").html(parseState(n.State));
    });
}

//list3(json);

var mtConfig = new Map([
["watertemp",10],
["airtempR",1],
["airtempS",10],
["airhumR",10],
["airhumS",10],
["airtempO",10],
["airhumO",1],
["tempsetS",10],
["humsetS",10],
["m1do1",-2],
["m1do2",-3],
["m1di1",-4],
["m1di2",-5],
["tempset",10],
["humset",1],
["airtempRH",1],
["airtempSH",1],
["airtempRL",10],
["airtempSL",10],
["watertempH",1],
["watertempL",10],
["airhumRH",10],
["airhumSH",10],
["airhumRL",10],
["airhumSL",10],
["drycooltempS",10],
["drycooltempE",10],
["pumptemp",10],
["gecwtemp",10],
["dehumtemp",10],
["dehumband",10],
["humtemp",10],
["humband",10],
["status",-1],
]); 
function list3(data){ // 展示数据
    //var ifactor = 10;//系数
    $.each(data.recs,function(i,n){
		for (var prop in n)
		{
			//console.log("jsonObj[" + prop + "]=" + n[prop]+". Config:"+mtConfig.get(prop));
			if (prop == "DateUpd")
				$("."+prop).html(n[prop]);
			else if (prop == "State")
				$(".State").html(parseState(n[prop]));
			else if (typeof(mtConfig.get(prop)) == "undefined")
				$("."+prop).html(n[prop]);
			else if (mtConfig.get(prop) > 0)
				$("."+prop).html(n[prop] / mtConfig.get(prop));
			else if (mtConfig.get(prop) == -1)
				$(".State").html(parseState(n[prop]));
			else if (mtConfig.get(prop) == -2)
				$(".State").html(parsem1do1(n[prop]));
			else if (mtConfig.get(prop) == -3)
				$(".State").html(parsem1do2(n[prop]));
			else if (mtConfig.get(prop) == -4)
				$(".State").html(parsem1di1(n[prop]));
			else if (mtConfig.get(prop) == -5)
				$(".State").html(parsem1di2(n[prop]));
			else
				$("."+prop).html(n[prop]);
		}
    })

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

function parseAlm(istate){
    if(istate==0) return "正常";
    else   if(istate==1) return "告警";
    else return "无效";
}
function parsem1do1(istate){
       
    if(istate==0) return "正常";
    else   if(istate==1) return "加热";
    else   if(istate==2) return "压缩机";
    else   if(istate==3) return "加湿";
    else   if(istate==4) return "除湿";
    else   if(istate==5) return "风机";
    else   if(istate==6) return "干冷器";
    else   if(istate==7) return "报警1关";
    else   if(istate==8) return "热风再热";
    else return "无效";
}      
function parsem1do2(istate){
       
    if(istate==0) return "ud";
    else   if(istate==1) return "加热";
    else   if(istate==2) return "风阀";
    else   if(istate==3) return "报警2关";
    else   if(istate==4) return "报警3关";
    else   if(istate==5) return "报警4关";
    else   if(istate==6) return "报警5关";
    else   if(istate==7) return "报警1关";
    else   if(istate==8) return "乙二醇泵1/2";
    else return "无效";
}
function parsem1di1(istate){
       
    if(istate==0) return "正常";
    else   if(istate==1) return "压缩机低压";
    else   if(istate==2) return "压缩机高压";
    else   if(istate==3) return "再热1故障";
    else   if(istate==4) return "加湿故障";
    else   if(istate==5) return "风机故障";
    else   if(istate==6) return "过滤阻塞";
    else   if(istate==7) return "报警1";
    else   if(istate==8) return "再热2故障";
    else return "无效";
}
function parsem1di2(istate){
       
    if(istate==0) return "正常";
    else   if(istate==1) return "导热率过高";
    else   if(istate==2) return "超声波加湿故障";
    else   if(istate==3) return "乙二醇泵1故障";
    else   if(istate==4) return "乙二醇泵2故障";
    else   if(istate==5) return "干冷器故障";
    else   if(istate==6) return "有水检测";
    else   if(istate==7) return "报警2";
    else   if(istate==8) return "报警3";
    else return "无效";
}
function parseState(istate){
    if(istate==0) return "正常";
    else   if(istate==1) return "告警";
    else return "故障";
}

</script>

</body>
</html>