");}
function RefSimpTimers(){
function refresh(){
if (this.status == 200) {
r=JSON.parse(this.responseText);
for(i=1;i<4;++i){
var rc=(r.tmr2[i-1]).split("%",3);
tt=parseInt(rc[0],10);t=TimeToStrSec(tt);
if(rc[2]=="1" || trpend[i-1]==1){
document.getElementById("stbgn"+i).value=t;
document.getElementById("slact"+i).value=rc[1];
bt=document.getElementById("simt"+i);
if(rc[2]=="1"){bt.innerHTML="Стоп";bt.style.backgroundColor="#99CC00";}
else{bt.innerHTML="Пуск";bt.style.backgroundColor="#FF6633";}
if(tt<5&&tt!=0&&rc[2]=="1") trpend[i-1]=1;
else trpend[i-1]=0;
}}}};
var xhr=new XMLHttpRequest();
xhr.onload = refresh;
xhr.open('GET','/tmr2.json',true);
xhr.send();
}
function GenCntInter(N,curN,pp,tt,unt,tw,tz,ttr){
var T=parseFloat(ttr),P=0;
document.write("
Счетчик:
№"+N+"
");
document.write("
Начало учета:
?
");
document.write("
Конец учета:
?
");
document.write("
Действующий тариф:
?
");
document.write("
");
document.write("
Тариф:
Пиковый
");
document.write("
Потребление:
? кВт*ч
");
document.write("
Стоимость:
?
");
document.write("
Тариф:
Полупиковый
");
document.write("
Потребление:
? кВт*ч
");
document.write("
Стоимость:
?
");
document.write("
Тариф:
Ночной
");
document.write("
Потребление:
? кВт*ч
");
document.write("
Стоимость:
?
");
document.write("
");
document.write("
Общее потребление:
? кВт*ч
");
document.write("
Общая стоимость:
?
");
document.write("
");
document.getElementById('curt').innerHTML=tds[curN];
for(i=1;i<4;++i){
var px = FloatToString(pp[i])*sc;
document.getElementById("pp"+N+i).innerHTML=parseFloat(px).toFixed(4);
document.getElementById("prs"+N+i).innerHTML=(px*T).toFixed(2)+' '+unt;
P+=px;}
document.getElementById("pp"+N).innerHTML=parseFloat(P).toFixed(4);
document.getElementById("tt"+N).innerHTML=UnixToStr(tt,tz,10);
document.getElementById("prs"+N).innerHTML=(P*T).toFixed(2)+' '+unt;
document.getElementsByName('tnow')[0].innerHTML=UnixToStr(tw,tz,10);}
function configIPBoxes(){e=document.forms.conf;
var ap=document.getElementsByName('netm');
st=e.dhcp.checked;
function apmode(m){e.wfiap.disabled=m;e.wfpap.disabled=m;e.ipaap.disabled=m;}
function clnmode(m){e.wfi.disabled=m;e.wfp.disabled=m;e.ipa.disabled=m;e.mas.disabled=m;e.gte.disabled=m;}
if(ap[0].checked){apmode(true);clnmode(false);
e.ipa.disabled=st;e.mas.disabled=st;e.gte.disabled=st;}
if(ap[1].checked){apmode(false);clnmode(true);}
}
function sendtime() {var ut=Date.parse(new Date( Date.parse(document.getElementById('curdt').value)))/1000;
var d='timenow='+ut;
PostData(d,'index23_3.html',false,'Время установлено',false);}
function WriteChart(log,z){
var val=[],tst=[],vf=[],scl;
for(i=0;i<32;++i){
var r=log[i];
var t=r.substr(0,8);
if (t!='00000000') tst[i]=UnixToStr(t,z,16,0);
else tst[i]=0;
val[i]=FloatToString(r.substr(8,8));
vf[i]=parseFloat((val[i]*sc).toFixed(4));}
scl=Math.max.apply(null, vf);
document.write("
");}
function setprm(p) {
document.getElementById("vmin").value=Math.round(p[0]*Ku);
document.getElementById("vmax").value=Math.round(p[1]*Ku);
document.getElementById("imin").value=(p[2]*Ki).toFixed(1);
document.getElementById("imax").value=(p[3]*Ki).toFixed(1);}
function sld(){document.getElementById("vn").innerHTML=document.getElementById("vmin").value+' В';
document.getElementById("vx").innerHTML=document.getElementById("vmax").value+' В';
document.getElementById("in").innerHTML=document.getElementById("imin").value+' A';
document.getElementById("ix").innerHTML=document.getElementById("imax").value+' A';}
function sendprm(){var d='umin='+Math.round( parseFloat(document.getElementById("vmin").value,10)/Ku);
d+='&umax='+Math.round( parseFloat(document.getElementById("vmax").value,10)/Ku);
d+='&imin='+Math.round( parseFloat(document.getElementById("imin").value,10)/Ki);
d+='&imax='+Math.round( parseFloat(document.getElementById("imax").value,10)/Ki);
d+='&pten='+((document.getElementsByName('pten')[0].checked) ? '1':'0').toString();
d+='&rstt='+document.getElementById('rstt').value;
d+='&rstn='+document.getElementById('rstn').value;
d+='&sav=prs';
PostData(d,'index41.html',false,'Параметры установлены',true);}
function GenTzSel(zn) {
document.write('
Time zone:
');
document.getElementById('tz').value = zn;}
function PrintIPInput(title,name,value){document.write("
"+title+"
");}
function PrintMACInput(title,name,value){document.write("
MAC:
");}
function PrintTextInput(title,name,value,min,max){document.write("
"+title+"
");}
function PrintTextInputNoReg(title,name,value,min,max){document.write("
"+title+"
");}
function PrintLabel(title,value){document.write("
"+title+"
"+value+"
");}
function PrintCheckBox(title,name,checked,action){document.write("
"+title+"
");}
function PrintInt(title,name,value,min,max){document.write("
"+title+"
");}
function PrintIntId(title,id,value,min,max){document.write("
"+title+"
");}
function PrintSep(){document.write("
");}
function PrintTar(title,name,value){document.write("
"+title+"
");}
function PrintSaveBtn(){document.write("");}
function PrintSaveFail(isfail){document.write("
Ошибка формата данных!
");}
function PrintMenu(){
document.write("");}
function saveFile(fileName,urlFile){
let a = document.createElement("a");
a.style = "display: none";
document.body.appendChild(a);
a.href = urlFile;
var D = new Date();
a.download ='WS10_'+fileName+'_'+((D).toISOString()).substr(0,19)+'.dat';
a.click();
window.URL.revokeObjectURL(urlFile);
a.remove();
}
function ReadEEPR(v5m,v1h,v1d,z){
document.getElementById('tmr').innerHTML=0;
var str=document.location.toString();
var ref=str.substring(0,str.lastIndexOf('/savehist.html'));
let data = {bufm:[],bufh:[],bufd:[],adr:0x1006,isReady:true};
function PrcdData(){
function Iter(item){
if(item.substr(0,8)!='00000000')
prnt+=UnixToStr(item.substr(0,8),z,16,0)+' '+(FloatToString(item.substr(8,8))*sc).toFixed(4)+' кВт*ч\r\n'}
data.bufm.sort();data.bufh.sort();data.bufd.sort();
var prnt='5 минут\r\n';data.bufm.forEach(Iter);
prnt+='1 час\r\n';data.bufh.forEach(Iter);
prnt+='1 день\r\n';data.bufd.forEach(Iter);
let blobData = new Blob([prnt], {type: "text/plain"});
let url = window.URL.createObjectURL(blobData);
saveFile('measures',url);
window.location=ref+'/index23.html';
}
function ReadChunk(){
if (this.readyState==4 && this.status==200) {
for(i=0;i<8;++i){
r=(this.response.mem[i]).substr(5,32);
r1=r.substr(6,2)+r.substr(4,2)+r.substr(2,2)+r.substr(0,2)+r.substr(8,8);
r2=r.substr(22,2)+r.substr(20,2)+r.substr(18,2)+r.substr(16,2)+r.substr(24,8);
if(data.adr<0x1906){data.bufm.push(r1);data.bufm.push(r2);}
else if (data.adr<0x1f06){data.bufh.push(r1);data.bufh.push(r2);}
else{data.bufd.push(r1);data.bufd.push(r2);}}
data.adr+=0x80;data.isReady=true;
document.getElementById('tmr').innerHTML=Math.round((data.adr-0x1006)/(0x2B06-0x1006)*100);
if(data.adr==0x2B06) {clearInterval(timerId);
PrcdData();
}}else{alert(xhr.status+': '+xhr.statusText);window.location=ref+'/index23.html'}}
let timerId = setInterval(function(){
if(data.isReady){
data.isReady=false;
var xhr=new XMLHttpRequest();
xhr.open('POST',ref+'/mem.json', true);
xhr.responseType='json';
xhr.onreadystatechange=ReadChunk;
xhr.send('base='+data.adr.toString(16));}},5);
}
function ReadConf(){
document.getElementById('tmr').innerHTML=0;
var str=document.location.toString();
var ref=str.substring(0,str.lastIndexOf('/saveconf.html'));
let data = {buf:[],adr:0x0000,isReady:true};
function PrcdData(){
function Iter(item){prnt+=item+'\r\n';}
var prnt='';data.buf.forEach(Iter);
let blobData = new Blob([prnt], {type: "text/plain"});
let url = window.URL.createObjectURL(blobData);
saveFile('config',url);
window.location=ref+'/index23.html';
}
function ReadChunk(){
if (this.readyState==4 && this.status==200) {
for(i=0;i<8;++i){
r=(this.response.mem[i]).substr(5,32);
data.buf.push(r);}
data.adr+=0x80;data.isReady=true;
document.getElementById('tmr').innerHTML=Math.round((data.adr-0x0000)/(0x0800-0x0000)*100);
if(data.adr==0x0800) {clearInterval(timerId);
PrcdData();
}}else{alert(xhr.status+': '+xhr.statusText);window.location=ref+'/index23.html'}}
let timerId = setInterval(function(){
if(data.isReady){
data.isReady=false;
var xhr=new XMLHttpRequest();
xhr.open('POST',ref+'/mem.json', true);
xhr.responseType='json';
xhr.onreadystatechange=ReadChunk;
xhr.send('base='+data.adr.toString(16));}},5);
}
function WriteConf(input){
document.getElementById('tmr').innerHTML=0;
var str=document.location.toString();
var ref=str.substring(0,str.lastIndexOf('/restconf.html'));
let data = {buf:[],adr:0x0000,isReady:true};
let file = input.files[0];
let reader = new FileReader();
reader.readAsText(file);
reader.onload = function() {
data.buf = reader.result.split('\r\n');
function ReadChunk(){
if (this.readyState==4 && this.status==200) {
data.adr+=0x40;data.isReady=true;
document.getElementById('tmr').innerHTML=Math.round((data.adr-0x0000)/(0x0800-0x0000)*100);
if(data.adr==0x0800) {
clearInterval(timerId);
window.location=ref+'/reboot.html';
}}else{alert(xhr.status+': '+xhr.statusText);window.location=ref+'/index23.html'}}
let timerId = setInterval(function(){
if(data.isReady){
data.isReady=false;
var ind=data.adr/0x10;
var dt='write='+data.adr.toString(16);
dt+='&dt1='+data.buf[ind];
dt+='&dt2='+data.buf[ind+1];
dt+='&dt3='+data.buf[ind+2];
dt+='&dt4='+data.buf[ind+3];
var xhr=new XMLHttpRequest();
xhr.open('POST',ref+'/mem.json', true);
xhr.responseType='json';
xhr.onreadystatechange=ReadChunk;
xhr.send(dt);}},5);
};
reader.onerror = function() {};
}