物联网平台 +Web 组态
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

176 lines
4.8 KiB

<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ page import="com.lp.cfg.ProConfig"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<!DOCTYPE html>
<html>
<head>
<%@ include file="/WEB-INF/oss/iot/common/variable.jsp"%>
<%@ include file="/WEB-INF/oss/iot/common/variable_js.jsp"%>
<%@ include file="/WEB-INF/oss/iot/common/resource_lib.jsp"%>
<style type="text/css">
.btn-span{
border:1px solid #3499da;
padding: 1px 10px;
color:#3499da ;
margin:-3px 10px;
border-radius: 4px;
cursor: pointer;
display: inline-block;
}
.self-input{
display: inline;
width: 50%;
}
.self-sapn{
display: inline-block;
width: 40%;
text-overflow: ellipsis;
white-space: nowrap;overflow: hidden;
line-height: 13px;
}
.float-left.width-50{
margin-bottom: 8px;
}
</style>
</head>
<body>
<div id="container" style="padding: 10px 20px;">
</div>
<div id="template" class="hide">
<div class="panel mt-10" >
<div class="panel-head ">
<strong>{name}</strong>
<!-- <span class="float-right btn-span" onclick="sensor_param_read({id},this);" >参数读取</span> -->
<span class="float-right btn-span" onclick="sensor_param_down({id},this);" >参数下发</span>
<span class="pr-10 float-right">( 更新时间:<span>[mtime])</span></span>
</div>
<div class="panel-body clearfloat">
{body}
</div>
</div>
</div>
<div id="template3" class="hide">
<div class="float-left width-50">
<span class="self-sapn" style="display: none;" >{0}:</span>
<select class="input input-small input-select self-input params">
{1}
</select>
</div>
</div>
<div id="template2" class="hide">
<div class="float-left ">
<span class="self-sapn" style="display: none;">{0}:</span>
<input class="input self-input {5}-value" readonly="readonly" style="width: 25%;" tag="{4}" value="{1}" >
<input class="input self-input params" placeholder="数据下发" style="width: 28%;" tag="{4}" >
<span style="margin-left: 15px;">{2}</span>
<p style="padding-top: 5px;">
备注: {3}
</p>
</div>
</div>
</body>
<script type="text/javascript">
// 参数读取
function sensor_param_read( id ,obj){
commonAjax('PUT', localUrl+'/sensor/param/read.json' , {id:id},function(data){
if(isOK(data)){
tip("读指令下发成功,请稍后...");
// setTimeout(function() {
// getSensorSetting(GetQueryString("id"));
// }, 3000);
}else{
tip(data.statusMsg) ;
}
});
}
// 参数下发
function sensor_param_down( id, obj ){
var inputs = $(obj).parent().parent().find('input.params,select.params');
var str_sdata = inputs.eq(0).val() ;
if( inputs.eq(0).attr("tag") != null && inputs.eq(0).attr("tag") != '' ){
var info_data = eval ("("+ inputs.eq(0).attr("tag") + ")") ;
if(info_data.max != null && info_data.max != '' ){
if( str_sdata >= info_data.max ){
showTip("参数大于最大值");
return ;
}
}
if(info_data.min != null && info_data.min != '' ){
if( str_sdata <= info_data.min ){
showTip("参数小于最大值");
return ;
}
}
}
if(inputs.length >0){
commonAjax('PUT',localUrl+'/sensor/param/down.json', {sdata :str_sdata ,id:id },function(data){
if(isOK(data)){
tip("写指令下发成功,请稍后...");
setTimeout(function() {
// 更新
udpSensorSetting(GetQueryString("id"));
inputs.eq(0).val('') ;
}, 2000);
}else{
tip(data.statusMsg) ;
}
});
}else{
tip("暂无指令下发");
}
}
setInterval(function(){
udpSensorSetting(GetQueryString("id"));
}, 3500);
// 更新数据
function udpSensorSetting(nid){
postAjax(localUrl+"/page/sensor.json?pageSize=300&paged=1", { node_id : nid , data_type:1 },function(data){
if(isOK(data)){
var dataT = data.data.data ;
for(var i=0 ; i<dataT.length; i++){
$("."+dataT[i].id + "-value").val( dataT[i].sdata ) ;
}
}
});
}
getSensorSetting(GetQueryString("id"));
function getSensorSetting(nid){
postAjax(localUrl+"/page/sensor.json?pageSize=300&paged=1", { node_id : nid , data_type:1 },function(data){
if(isOK(data)){
var dataT = data.data.data ;
$("#container").empty();
for(var i=0 ; i<dataT.length; i++){
dataT[i].body = getBodyContent( dataT[i].infos , dataT[i].sdata , dataT[i].param_config , dataT[i].param_names , dataT[i].infos.replace(/"/g,"'"), dataT[i].id );
$("#container").append( $("#template").html().format(dataT[i]) );
}
}else{
$("#container").append( "<p style='color:#666;text-align:center;'>暂无参数配置</p>");
}
});
}
function getBodyContent(as,bs,cs , d,f,j){
return $("#template2").html().format( as ,gdv(bs,0), cs ,d ,f , j);
}
</script>
</html>