import $ from 'jquery'; const CORS= 'http://localhost:8080/LD_9/'; // 开启跨域请求(调试时开启) // const CORS=''; // 关闭跨域请求(发布时开启) //定义计时器 function Interval() { this.timer = null; this.time = ''; this.callback = ''; } // 开启计时器并添加 Interval.prototype.start = function(callback, time) { // 先关闭计时器 this.stop(); // 配置执行函数 if(typeof callback == 'function' && typeof time == 'number') { this.callback = callback; this.time = time; callback(); this.timer = setInterval(callback, time); }else { console.warn('未完整配置参数!'); } }; // 开启计时器 Interval.prototype.open = function() { var callback = this.callback; var time = this.time; this.start(callback, time); }; // 关闭计时器 Interval.prototype.stop = function() { clearInterval(this.timer); }; // 延时计时器 function Timeout() { this.timer = null; this.time = ''; this.callback = ''; } // 开启计时器并添加 Timeout.prototype.start = function(callback, time, exe) { // 先关闭计时器 this.stop(); // 配置执行函数 if(typeof callback == 'function' && typeof time == 'number') { this.callback = callback; this.time = time; if(exe != 'exe') { callback(); } this.timer = setTimeout(callback, time); }else { console.warn('未完整配置参数!'); } }; // 开启计时器 Timeout.prototype.open = function() { var callback = this.callback; var time = this.time; this.start(callback, time, 'exe'); }; // 关闭计时器 Timeout.prototype.stop = function() { clearTimeout(this.timer); }; /*从多维数组中获取最大值*/ function getMaxFromArr(arr) { var newArray = arr.join(",").split(","); return Math.max.apply({},newArray); } /*从多维数组中获取最小值*/ function getMinFromArr (arr) { var newArray = arr.join(",").split(","); return Math.min.apply({},newArray); } /*从多维数组中获取和*/ function getSumFromArr (arr) { var newArray = arr.join(",").split(","); var sum =0; for(var i=0; i 0){ }else{ value = 0; } var theTime = parseInt(value);// 秒 var theTime1 = 0;// 分 var theTime2 = 0;// 小时 // alert(theTime); if(theTime >= 60) { theTime1 = parseInt(theTime/60); theTime = parseInt(theTime%60); //alert(theTime1+"-"+theTime); if(theTime1 >= 60) { theTime2 = parseInt(theTime1/60); theTime1 = parseInt(theTime1%60); } } var result = (theTime<10?"0":"")+parseInt(theTime); if(theTime1 >= 0) { result =(theTime1<10?"0":"")+parseInt(theTime1)+":"+result; } if(theTime2 >= 0) { result =(theTime2<10?"0":"")+parseInt(theTime2)+":"+result; } //console.info(result); return result; } // 设置后备时间(续航时间) function sethoubeiTime(value){ value = Math.abs(value); var str = ""; if(value>0){ var hour = parseInt(value); var min = parseInt((parseFloat(value) - hour)*60); if(hour<10){ str = "0"; } str+=hour+"H"; if(min<10){ str+="0"; } str+=min+"M"; }else{ str = "00H00M"; } return str; } // 格式化时间 Date.prototype.format =function(format) { var o = { "M+" : this.getMonth()+1, //month "d+" : this.getDate(), //day "h+" : this.getHours(), //hour "m+" : this.getMinutes(), //minute "s+" : this.getSeconds(), //second "q+" : Math.floor((this.getMonth()+3)/3), //quarter "S" : this.getMilliseconds() //millisecond }; if(/(y+)/.test(format)) format=format.replace(RegExp.$1, (this.getFullYear()+"").substr(4- RegExp.$1.length)); for(var k in o)if(new RegExp("("+ k +")").test(format)) format = format.replace(RegExp.$1, RegExp.$1.length==1? o[k] : ("00"+ o[k]).substr((""+ o[k]).length)); return format; }; function Title(){ this.min=0; //最小值 this.max=0; //最大值 this.avg=0; //平均值 this.sum=0; //总和 this.ahight=0; //高告警阀值 this.alow=0; //低告警阀值 this.clow=0; //次低更换阀值 this.lc=0; //低告警单体数 this.lp=0; //低告警百分比 } function createTitle(){ var obj=new Object(); obj.min=0; obj.max=0; obj.avg=0; obj.sum=0; obj.ahight=0; obj.alow=0; obj.clow=0; obj.lc=0; obj.lp=0; return obj; } Title.prototype.setMin=function(min){ this.min=min; }; Title.prototype.getMin=function(){ return this.min; }; Title.prototype.setMax=function(max){ this.max=max; }; Title.prototype.getMax=function(){ return this.max; }; Title.prototype.setAvg=function(avg){ this.avg=avg; }; Title.prototype.getAvg=function(){ return this.avg; }; Title.prototype.setSum=function(sum){ this.sum=sum; }; Title.prototype.getSum=function(){ return this.sum; }; Title.prototype.setAhight=function(ahight){ this.ahight=ahight; }; Title.prototype.getAhight=function(){ return this.ahight; }; Title.prototype.setAlow=function(alow){ this.alow=alow; }; Title.prototype.getAlow=function(){ return this.alow; }; Title.prototype.setClow=function(clow){ this.clow=clow; }; Title.prototype.getClow=function(){ return this.clow; }; Title.prototype.setLc=function(lc){ this.lc=lc; }; Title.prototype.getLc=function(){ return this.lc; }; Title.prototype.setLp=function(lp){ this.lp=lp; }; Title.prototype.getLp=function(){ return lp; }; Title.prototype.getAllTile=function(lname){ //alert(this.avg); var title=""; var maxText='最大值'; //最大值 var minText='最小值'; //最小值 var avgText='平均值'; //平均值 var lowText='落后值'; //落后值 var lcText='落后数量'; //落后数量 var lpText='落后数量比'; //落后数量比 if("Voltage"==lname){ //title=maxText+"="+(parseFloat(this.max).toFixed(3))+"V;"+minText+"="+(parseFloat(this.min).toFixed(3))+"V;"+avgText+"="+(parseFloat(this.avg).toFixed(3))+"V;"+lowText+"="+this.alow+"V;"+lcText+"="+this.lc+";"+lpText+"="+this.lp+"%"; title=maxText+"="+(parseFloat(this.max).toFixed(3))+"V;"+minText+"="+(parseFloat(this.min).toFixed(3))+"V;"+avgText+"="+(parseFloat(this.avg).toFixed(3))+"V;累加和="+(parseFloat(this.sum).toFixed(3))+"V"; }else if("Resistance"==lname){ //title=maxText+"="+(parseFloat(this.max).toFixed(3))+"mΩ;"+minText+"="+(parseFloat(this.min).toFixed(3))+"mΩ;"+avgText+"="+(parseFloat(this.avg).toFixed(3))+"mΩ;"+lowText+"="+this.alow+"mΩ;"+lcText+"="+this.lc+";"+lpText+"="+this.lp+"%"; title=maxText+"="+(parseFloat(this.max).toFixed(3))+"mΩ;"+minText+"="+(parseFloat(this.min).toFixed(3))+"mΩ;"+avgText+"="+(parseFloat(this.avg).toFixed(3))+"mΩ"; }else if("Temperature"==lname){ //title=maxText+"="+(parseFloat(this.max).toFixed(1))+"℃;"+minText+"="+(parseFloat(this.min).toFixed(1))+"℃;"+avgText+"="+(parseFloat(this.avg).toFixed(1))+"℃;"+lowText+"="+this.alow+"℃;"+lcText+"="+this.lc+";"+lpText+"="+this.lp+"%"; title=maxText+"="+(parseFloat(this.max).toFixed(1))+"℃;"+minText+"="+(parseFloat(this.min).toFixed(1))+"℃;"+avgText+"="+(parseFloat(this.avg).toFixed(1))+"℃"; }else if("Conductance"==lname){ //title=maxText+"="+(parseFloat(this.max).toFixed(0))+";"+minText+"="+(parseFloat(this.min).toFixed(0))+";"+avgText+"="+(parseFloat(this.avg).toFixed(0))+";"+lowText+"="+this.alow+";"+lcText+"="+this.lc+";"+lpText+"="+this.lp+"%"; title=maxText+"="+(parseFloat(this.max).toFixed(0))+";"+minText+"="+(parseFloat(this.min).toFixed(0))+";"+avgText+"="+(parseFloat(this.avg).toFixed(0)); }else if("MonJHCurr"==lname){ //title=maxText+"="+(parseFloat(this.max).toFixed(3))+"V;"+minText+"="+(parseFloat(this.min).toFixed(3))+"V;"+avgText+"="+(parseFloat(this.avg).toFixed(3))+"V;"+lowText+"="+this.alow+"V;"+lcText+"="+this.lc+";"+lpText+"="+this.lp+"%"; title=maxText+"="+(parseFloat(this.max).toFixed(3))+"mA;"+minText+"="+(parseFloat(this.min).toFixed(3))+"mA;"+avgText+"="+(parseFloat(this.avg).toFixed(3))+"mA"; }else if("Serpercent"==lname || "Percent_total_capacity" == lname){ //title=maxText+"="+this.max+"%;"+minText+"="+this.min+"%;"+avgText+"="+this.avg+"%;"+lowText+"="+this.alow+"%;"+lcText+"="+this.lc+";"+lpText+"="+this.lp+"%"; title=maxText+"="+this.max+"%;"+minText+"="+this.min+"%;"+avgText+"="+this.avg+"%"; }else if("Actual_capacity"==lname || "Residual_capacity" == lname){ //title=maxText+"="+(parseFloat(this.max).toFixed(0))+"AH;"+minText+"="+(parseFloat(this.min).toFixed(0))+"AH;"+avgText+"="+(parseFloat(this.avg).toFixed(0))+"AH;"+lowText+"="+this.alow+"AH;"+lcText+"="+this.lc+";"+lpText+"="+this.lp+"%"; title=maxText+"="+(parseFloat(this.max).toFixed(0))+"AH;"+minText+"="+(parseFloat(this.min).toFixed(0))+"AH;"+avgText+"="+(parseFloat(this.avg).toFixed(0))+"AH"; } return title; }; var CapType_Rest = 0; //当查询剩余容量时传递 var CapType_Real = 1; //当查询实际容量时传递 var STDAH; //标纯容量 var MonomerVolType; //电池电压类型 // 获取标纯电流 function GetFDCurrent(stdcap,hourrate) { var res = 0.055; switch(hourrate) { case 1: res = 0.514; break; case 2: res = 0.306; break; case 3: res = 0.250; break; case 4: res = 0.200; break; case 5: res = 0.166; break; case 6: res = 0.146; break; case 7: res = 0.131; break; case 8: res = 0.118; break; case 9: res = 0.108; break; case 10: res = 0.100; break; case 20: res = 0.055; break; default: res = 0.055; break; } return (stdcap * res); } // 获取放电小时率 stdah:标纯容量 current:当前电流 function GetHourRate(stdah,current) { var index = 0; var value=[5.14, 3.06, 2.50, 2.00, 1.66, 1.46, 1.31, 1.18, 1.08, 1.00, 0.55, 0.40]; var res; current = Math.abs(current); res = current/(stdah/10); if(res >= 5.14) return 1; else if(res <= 0.55) return 20; else { for(var index=0; index<10; index++) { if((res<=value[index]) && (res>value[index+1])) break; else continue; } if((value[index]-res) < (res-value[index+1])) { return (index+1); } else { if(index+2 > 10) return (20); else return (index+2); } } } function N_TO_10H(n_H) { switch(n_H) { case 1 : return(1/0.55); case 2 : return(1/0.61); case 3 : return(1/0.75); case 4 : return(1/0.79); case 5 : return(1/0.833); case 6 : return(1/0.876); case 7 : return(1/0.917); case 8 : return(1/0.944); case 9 : return(1/0.974); case 10: return(1/1); case 20: return(1/1.1); } return 1.0; } //获取剩余容量 STDAH:标称容量 HourRate:放电小时率 SumAH:测试容量 MaxMonomerVol:最大电池电压 MonomerVol:当前电池组的最低单体电压 //MonomerVolType:电池标称电压 CapType:容量类型(定值是常量) function GetMonomerCap(STDAH, HourRate, SumAH, MaxMonomerVol, MonomerVol, MonomerVolType,CapType) { if((MaxMonomerVol - MonomerVolType*0.9) <= 0) return 0; if(SumAH < 0) SumAH *= (-1); var tmp_cap; tmp_cap = MonomerVol - MonomerVolType * 0.9; tmp_cap *= (STDAH - SumAH * N_TO_10H(HourRate)); var dt_vol = MaxMonomerVol - MonomerVolType*0.9; if(dt_vol < 0.01) dt_vol = 0.01; tmp_cap = tmp_cap/dt_vol; if(tmp_cap < 0) tmp_cap = 0; if(CapType == CapType_Rest) return tmp_cap; else if(CapType == CapType_Real) return (tmp_cap + SumAH * N_TO_10H(HourRate)); else return ((tmp_cap + SumAH * N_TO_10H(HourRate))*100 / STDAH); } //将秒转化成00M00H类型 function formatTime1(value) { var theTime = parseInt(value);// 秒 var theTime1 = 0;// 分 var theTime2 = 0;// 小时 if(theTime >= 60) { theTime1 = parseInt(theTime/60); theTime = parseInt(theTime%60); // alert(theTime1+"-"+theTime); if(theTime1 >= 60) { theTime2 = parseInt(theTime1/60); theTime1 = parseInt(theTime1%60); } } var result = ""; if(theTime1 >= 0) { result =(theTime1<10?"0":"")+parseInt(theTime1)+"M"+result; } if(theTime2 >= 0) { result =(theTime2<10?"0":"")+parseInt(theTime2)+"H"+result; } return result; } //省-市-区县联动 function LinkagePlus() { this.data=[]; this.provinces = []; } LinkagePlus.prototype.setData = function(data) { this.data = data; this._setProvinces(data); }; // 设置所有的省 LinkagePlus.prototype._setProvinces = function(data) { var result = []; Object.keys(data).forEach(function(key){ var temp = {}; temp.key = key; temp.name = data[key].name; result.push(temp); }); this.provinces = result; }; // 获取指定省的编号 LinkagePlus.prototype._getProvinceKey = function(province) { var result = { code: 0, province: province, key: 0, msg: '未查询到"'+province+'"的编号' }; var provinces = this.provinces; for(var i=0; i