//Use datatype real with format 00.00functionread(){schedule.DefaultValue="0";for(varn=0;n<nbrOnOff;n++){for(vari=1;i<=7;i++){varday=i+n*10;varon=tagValue(prefix+"_CT"+day).Replace(":","").Replace(",","").Replace(".","");varoff=tagValue(prefix+"_CF"+day).Replace(":","").Replace(",","").Replace(".","");//var off = "1700";on=pad(on,4);off=pad(off,4);if(on=="0000"&&off=="0000"){// do nothing}elseif(off=="2400")schedule.AddEvent("1",on+"-0000:"+i);elseschedule.AddEvent("1",on+"-"+off+":"+i);}}returntrue;}functionwrite(){vardays=[0,0,0,0,0,0,0,0,0];varday=0;for(vari=0;i<schedule.Events.Count;i++){if(schedule.Events[i].Value!=schedule.DefaultValue&&schedule.Events[i].Time.Length==11){day=schedule.Events[i].Time.Substring(10);vard=day-1;day+=days[d]*10;days[d]++;varon=schedule.Events[i].Time.Substring(0,4);varoff=schedule.Events[i].Time.Substring(5,4);if(off=="0000")off="2400";tagWrite(prefix+"_CT"+day,(parseFloat(on)/100).toFixed(2));tagWrite(prefix+"_CF"+day,(parseFloat(off)/100).toFixed(2));}}for(vari=1;i<=7;i++){for(varn=days[i-1];n<=nbrOnOff;n++){day=i+n*10;tagWrite(prefix+"_CT"+day,"0000");tagWrite(prefix+"_CF"+day,"0000");}}returntrue;}functionpad(n,width){varresult='';for(vari=n.length;i<width;i++){result+='0';}result+=n;returnresult;}
Comments (0)
HTTPSSSH
You can clone a snippet to your computer for local editing.
Learn more.