<body docProcLang="JavaLikeCalc.JavaScript">

<center>
<h1>Average over hour values of ""</h1>
<?dp return "<h1>"+tr("Average over hour values of \"%1\"").replace("%1",title)+"</h1><span>"+SYS.strftime(time-params.repHour*3600-1,"%d %B %Y")+"</span>";?>
</center>

<div width="100%"><div style="margin-left: auto; margin-right: auto; text-align: center; width: fit-content;">
	<?dp if(!enGraph) return "";
		for(iP = 0, srcs = ""; iP < params.length; iP++) {
			pO = params[iP];
			if(!pO.min.isEVal() && !pO.max.isEVal()) srcs += pO.var+":"+pO.min+":"+pO.max+":"+pO.color+":0:2\n";
		}
		return srcs.length ? DAQ.JavaLikeCalc.lib_doc.diagram(time, time-bTime, srcs, 800, 300, arch) : "";
	?>
</div></div>
<br/>

<TABLE class="data" width="100%" export="1">
  <THEAD>
    <TR><TH>Date</TH><TH>Time</TH><TH>Capacity</TH><TH>Aver. pressure diff.</TH><TH>St. pressure</TH><TH>Aver. temp.</TH><TH>Density</TH></TR>
    <TR><TH>&nbsp;</TH><TH>begin&nbsp;&nbsp;end</TH><TH>m3</TH><TH>kgF/m2</TH><TH>kgF/cm</TH><TH>grad.C</TH><TH>kg/m3</TH></TR>
	<?dp
		//Names
		row = ""; hasGrps = false;
		for(iP = 0; iP < params.length && !hasGrps; iP++) {
			pO = params[iP]; pOprv = params[iP-1];
			if(iP && pO.name.parse(1,":").trim().length && pOprv.name.parse(1,":").trim().length && pO.name.parse(0,":").trim() == pOprv.name.parse(0,":").trim())
				hasGrps = true;
			else row += "<TH style='color: "+((enGraph&&!pO.min.isEVal()&&!pO.max.isEVal())?pO.color:"black")+";'>"+SYS.strEncode(hasGrps?pO.name.parse(1,":").trim():pO.name, "HTML")+"</TH>";
		}
		
		if(!hasGrps) rez = "<TR><TH>"+tr("Date")+"</TH><TH>"+tr("Time")+"</TH>"+row+"</TR>";
		// Groups processing
		else {
			for(grpLst = grpLst_ = row = row2 = "", grpCnt = 0, iP = 0; iP <= params.length; iP++, grpLst = grpLst_) {
				pO = params[iP]; pOprv = params[iP-1];
				grpLst_ = (iP < params.length && (tVl=pO.name).parse(1,":").length) ? tVl : "";
				if(grpLst.parse(1,":").trim().length && grpLst.parse(0,":").trim() == grpLst_.parse(0,":").trim()) {
					if(!grpCnt) row2 += "<TH style='color: "+((enGraph&&!pOprv.min.isEVal()&&!pOprv.max.isEVal())?pOprv.color:"black")+";'>"+SYS.strEncode(pOprv.name.parse(1,":").trim(), "HTML")+"</TH>";
					row2 += "<TH style='color: "+((enGraph&&!pO.min.isEVal()&&!pO.max.isEVal())?pO.color:"black")+";'>"+SYS.strEncode(pO.name.parse(1,":").trim(), "HTML")+"</TH>";
					grpCnt++;
				}
				else {
					if(grpCnt) { row += "<TH colspan='"+(grpCnt+1)+"'>"+SYS.strEncode(grpLst.parse(0,":").trim(), "HTML")+"</TH>"; hasGrps = true; }
					if(!grpLst_.parse(1,":").trim().length && iP < params.length)
						row += "<TH rowspan='2' style='color: "+((enGraph&&!pO.min.isEVal()&&!pO.max.isEVal())?pO.color:"black")+";'>"+SYS.strEncode(pO.name, "HTML")+"</TH>";
					grpCnt = 0;
				}
			}
			rez = "<TR><TH rowspan='2'>"+tr("Date")+"</TH><TH rowspan='2'>"+tr("Time")+"</TH>"+row+"</TR><TR>"+row2+"</TR>";
		}

		//Units
		rez += "<TR><TH>&nbsp;</TH><TH>"+tr("begin")+"&nbsp;&nbsp;"+tr("end")+"</TH>";
		for(iP = 0; iP < params.length; iP++) {
			pO = params[iP];
			rez += "<TH>"+((enGraph && pO.min < pO.max)?"["+pO.min+"..."+pO.max+"] ":"")+SYS.strEncode(pO.ed, "HTML")+"</TH>";
		}
		rez += "</TR>";
		return rez; ?>
  </THEAD>
  <TR docRept="3600">
  <?dp using DAQ.JavaLikeCalc.lib_doc;
	if((rTime-rPer) > SYS.time())	return "";
	rez = "<TD style='text-align: center;'>"+SYS.strftime(rTime,"%d %m")+"</TD>"+
		"<TD style='text-align: center;'>"+SYS.strftime(rTime-rPer,"%H:%M")+"&nbsp;&nbsp;"+SYS.strftime(rTime,"%H:%M")+"</TD>";
	for(iP = 0; iP < params.length; iP++) {
		pO = params[iP];
		if(pO.type == "string")
			rez += "<TD style='text-align: center;'>"+getVal(pO.var,rTime-rPer,0,0,arch,false,rTime*1e6)+"</TD>";
		else if(pO.isCntr == true) {
			if(!(V1=getVal(pO.var,rTime-rPer,0,-1,arch,false,rTime*1e6)).isEVal())	V1 = V1.toReal();
			if(!(V2=getVal(pO.var,rTime,0,-1,arch,false,(rTime-rPer)*1e6)).isEVal())	V2 = V2.toReal();
			rez += "<TD style='text-align: center;'>"+((V1.isEVal() || V2.isEVal())?tr("Empty"):abs(V2-V1).toFixed(pO.prec))+"</TD>";
		} else rez += "<TD style='text-align: center;'>"+averVal(pO.var,rTime-rPer,rTime,pO.prec,arch)+"</TD>";
	}
	return rez; ?>
  </TR>
  <TR style="font-weight: bold;">
  <?dp using DAQ.JavaLikeCalc.lib_doc;
	rez = "<TD colspan='2' style='text-align: center;'>"+tr("Summary")+"</TD>";
	for(iP = 0; iP < params.length; iP++)
		if(params[iP].isCntr == true) {
			if(!(V1=getVal(params[iP].var,bTime,0,-1,arch,false,time*1e6)).isEVal())	V1 = V1.toReal();
			if(!(V2=getVal(params[iP].var,time,0,-1,arch,false,bTime*1e6)).isEVal())	V2 = V2.toReal();
			rez += "<TD style='text-align: center;'>"+((V1.isEVal() || V2.isEVal())?tr("Empty"):abs(V2-V1).toFixed(3))+"</TD>";
		} else rez += "<TD/>";
	return rez; ?>
  </TR>
</TABLE>
</body>