var VarValue=[];function Cmd(CmdStr){var a;try{eval("a = "+CmdStr+";")}catch(e){a=0;alert("表达式错误: "+CmdStr+"\n请在组态程序中修正后重新发布!")}return a}ht.Chart=function(e,t,a){var i=this,n=i._view=document.createElement("div");n.style.width=t+"px";n.style.height=a+"px";n.style.position="absolute";n.style.setProperty("box-sizing","border-box",null);i._option=e;i._chart=echarts.init(i.getView());if(e)i._chart.setOption(e);i._FIRST=true};function getDateString(e){var t=e.getDate();var a=e.getMonth()+1;var i=e.getFullYear();var n=e.getHours();var s=e.getMinutes();var r=e.getSeconds();var o=i+"/"+a+"/"+t+" "+n+":"+s+":"+r;return o}function GetDital(e,t){if(e==null||e==undefined)return 0;else{var a=e;if(isNaN(a))return 0;else return a.toFixed(t)}}ht.Default.def("ht.Chart",Object,{ms_v:1,ms_fire:1,ms_ac:["chart","option","isFirst","view"],validateImpl:function(){var e=this,t=e._chart;t.resize();if(e._FIRST){e._FIRST=false}},setSize:function(e,t){var a=this._view;a.style.width=e+"px";a.style.height=t+"px"}});ht.DataModel.prototype.isAutoAdjustIndex=function(){return false};function submitAddSingle(e,t,a){var i={TagName:e,Time:a,Value:t};if(i.Time===""){var n=new Date;var s=n.getDate();var r=n.getMonth()+1;var o=n.getFullYear();var l=n.getHours();var d=n.getMinutes();var u=n.getSeconds();var h=o+"/"+r+"/"+s+" "+l+":"+d+":"+u;i.Time=h}var c=JSON.stringify(i);$.ajax({url:"http://"+webServiceIP+":"+webServicePort+"/api/Snapshot/?isSingleData=True",type:"POST",data:c,contentType:"application/json; charset=utf-8",success:function(e){if(typeof e=="string"&&e.constructor==String){if(e!=="True")alert(e)}else{var t=e.ErrorList;if(t!=null&&t.length>0){alert(t[0].ErrorMsg)}}},error:function(e){if(e.responseText==="")alert("网络链接错误");else alert(e.responseText)}})}function getHisData(option,cmdStr,callBack){str="http://"+webServiceIP+":"+webServicePort+"/api/History?tagName="+cmdStr;str=encodeURI(str);$.ajax({url:str,type:"GET",dataType:"json",cache:false,success:function(data){if(data===null)return;var hisValues=eval(data);var k=0;var date=[];var test_data={};if(hisValues!=null){for(tag in hisValues){test_data[tag]=[];option.series[k]={};option.series[k].name=tag;option.series[k].type="line";option.series[k].showSymbol=false;option.series[k].sampling="average";option.legend.data.push(tag);for(var i=0;i=0&&index2e4){newOption.series[index].data.splice(0,newOption.series[index].data.length-2e4)}}}}if(dataChanged){chart.setOption(newOption)}}},complete:function(e,t){e=null}})}function getDivText(e){return $(e).text()}function creatTree(e,t,a){var i=new ht.Data;i.setName(e.name);t.add(i);if(a!==undefined)i.setParent(a);if(e.child!==undefined){for(var n=0;n