# wlb_Main

ID: ElCadr
PARENT: /wlb_originals/wdg_Box
ATTRS: path;name;dscr;active;geomW;geomH;evProc;backColor;bordWidth;bordColor;
ICO:
  iVBORw0KGgoAAAANSUhEUgAAABcAAABACAIAAAB+w3u4AAAACXBIWXMAAA06AAANOgEDIh6FAAAE
  z0lEQVRYhdWX32/TVhTHv7Zv7NhO08RpcBLaauqPTcC0PYAQQkKTGJrGwx54QPsD2Z/AH8CkFiak
  DkY7UWgLbYdaorqO7diOf8S+e4hhxrHTUqZpnKfknOOPv9f33HvuZe7d+0XXdXyCybJMdF3X9eO0
  d3Nzk+d5lmUBCILgeR7P8/1+XxAEnucZhul0OhkQO84mhFBKXdeNoiiKItu2WZallA4GA8dxKKU5
  j4y7lpaW0n9nZ2cBtNvtCYPK0XIGIwC0GY0MSc2ojYf71T435AI+iLhI8IWKXSmkcBFHmZzRAghL
  YVAKYjYeiAM2LhROANSNelG4rtcBgAEoGDCTKHing1IqSVJRatpcdzAz0wTQ71sJpRt2a6QmMMK1
  a9fm5uaWl5efP38uy/K5c+eq1Wou5cmTjbdve6urv9669eP6+m8EQIxYH+rtUhvA/v5+HMf7+/uE
  ENM0L1++nEsxTYMQ9saN79682U20CIxQ4ZKPv7y8LIqiIAjlcrnZbBaNaHq6dnCgPX788ObNH3q9
  twSAQpRRbGdnp1QqvU/d2toqomxtvarX1YWFpfX13xMtfUACOEDTtJWVlXR2CEQAD4RADIipULd7
  MPqhKA0CYAdQgPmxFx4Be0AdkAALiICvAC5PGgGgAFN5sQqgAhxQAqYBvwCRUMZVjEwE5gpCGUuK
  OgKCDwOUpQEfjJdrhChClE/5C9j4MGDUDLNmRlz2AXNo7ng7GWeyv1SQfavgC+JAZGhWDAWtcdnV
  n1BmgJkPA5KTv6AapDHuzNnr0jYcDi3LCoKAUkoIkSRJluWPpgA4PDwcFTTLssfHx4uLi+n6zlIs
  y8qsYMdxLMtaXFz0fZ9SKsvy0dERx+UUzT8U27bHKc1mkxBSLpffO0cdJmP/zu79f6KcPEemaYZh
  yHFcvV64yZ+gpdvt6rq+vb3tuu7Ztaiq6nleo9FgmMI2cjIFQKWS3w/T9tnNURAEHMcpinJGSrfb
  dV3XsqxWq3V2LaqqBkHQbrdzj1CnpQA4Tf9Pvu4WsJry2lP2s2+fvfzyZSZ7EA/uG/dX+6sZf0I5
  BF6kvF7Z253fPegcZLJDGq7Za5veZsZ/8oiCIDAMgxDySXPkeZ6maaOT5hkpqqpyHNfpdKIo25g+
  ggKAYRhRFCfnfF7ryDCMwWDA83yjkdMVT6Wl2+3Gcazruud5Z9eiqqpt27Ozs4RMyjx5RLVazv0g
  Y//VHFFK9/b24jj+JEocx47j+L4/ISf5LheAZqppVa3qlbUrkR1pmtZqtRYWFkYN/3zj/F3mrshm
  SzmhNIFmqsx5n+8cdACgBQDvzwxT0tRFXMzXIstTp5mItAVByPMlAIbRSyjXr39v2870dG1+/gsA
  DIM4juOY2ralKDO5lF5Pr9cVAC9e/Pn06UMCYDgc7u6+Yll2Y+OPft/iOM7zPMexFaVx587PBVqC
  R49WVlYe3L79U6IlDMOrV6+HYRgEQaVSGQ6HruvEcVytTnuezzCgFJk27fv+pUvfXLjw9evX2wll
  fX2tVitcabnmed7ok/d6GiEgAExTM01tPNV1XUqpKIqO41QqlaJjQ3KzKTJN03RdF0XRNM12uz03
  V3i3mESRJIllWUmSqtXq1FTu5ecdRZblogPOhG0pbSzL/Q2YovM7l7aYfgAAAABJRU5ErkJggg==

PROC:
  JavaLikeCalc.JavaScript
  function setActMess(mess) {
  	if(prmErr.isEVal())	SYS.messNote("OP:"+this.ownerSess().user()+":"+prmShifr, "'"+prmShifr+"'."+mess);
  	else SYS.nodeAt(prmErr).nodePrev().messSet("'"+prmShifr+"'."+mess, 2, "OP", this.ownerSess().user());
  }

  ev_wrk = ev_rez = "";
  if(f_start) cntr = prevCntr = holdCntr = 0, toFastCalc = toFastCalc_ = false;
  cntr++;

  toFastCalc = false;

  if(!prmColor.isEVal()) { bordColor = prmColor; bordWidth = 2; }
  else { bordColor = "black"; bordWidth = 1; }

  //Disable all mutable widgets
  info_ed_en = info_var_en = info_sp_en = info_out_en = spToVar_en = up_en = upm_en = upMax_en = down_en = downm_en = downMin_en = lev_out_en = lev_var_en = lev_sp_en = mode_en = modMan_en = modAuto_en =
  	modCasc_en = pnl_pid_en = greed_text_en = greed_text1_en = greed_text2_en = greed_text3_en = greed_text4_en = greed_text5_en = 
  	com_open_en = com_stop_en = com_close_en = com_text_en = st_open_en = st_close_en = st_text_en = Ramka_en = moveUp_en = moveDwn_en = false;

  info_name_text = prmShifr.isEVal() ? "" : prmShifr;

  //Impulse processing
  if(!prmAnalog.isEVal() && prmAnalog == false) {
  	lev_out_en = info_out_en = false; 
  	moveUp_en = moveDwn_en = true; 
  	moveUp_fillColor = (!prmImpQupTm.isEVal() && prmImpQupTm) ? "cyan" : "black-0"; 
  	moveDwn_fillColor = (!prmImpQdwnTm.isEVal() && prmImpQdwnTm) ? "cyan" : "black-0"; 
  }

  //Check for analog
  if(!prmVar.isEVal() || !prmVarIn.isEVal()) {
  	info_ed_en = info_var_en = lev_var_en = greed_text_en = greed_text1_en = greed_text2_en = greed_text3_en = greed_text4_en = greed_text5_en = true;
  	info_ed_text = prmDemention.isEVal() ? "" : prmDemention;
  	pVar = prmVar.isEVal() ? prmVarIn : prmVar;
  	if(prmVarIn.isEVal()) info_var_bordWidth = 0;
  	if(info_var_clearCnt <= 0) { info_var_arg0val = pVar; info_var_backColor = ""; } else { info_var_clearCnt--; toFastCalc = true; }
  	lev_var_p1y = max(0,min(140,140*(1-(pVar-min)/(max-min))));
  	if(prmPrec.isEVal())	info_var_arg0cfg = "10;f;2";
  	else if(prmPrec >= 0)	info_var_arg0cfg = "10;f;"+prmPrec;
  	else	info_var_arg0cfg = "10;g;"+abs(prmPrec);

  	info_var_color = lev_var_c3 = "#3EFF3E";
  	//Warning borders process
  	if(!prmWMin.isEVal() && !prmWMax.isEVal() && prmWMax > prmWMin) {
  		lev_var_c2 = "yellow";
  		lev_var_p6y = lev_var_p7y = 140*(1-(prmWMax-min)/(max-min));
  		lev_var_p8y = lev_var_p9y = 140*(1-(prmWMin-min)/(max-min));
  		if(pVar >= prmWMax || pVar <= prmWMin) info_var_color = lev_var_c3 = "yellow";
  	}
  	else lev_var_c2 = "black-0";
  	//Alarm borders process
  	if(!prmAMin.isEVal() && !prmAMax.isEVal() && prmAMax > prmAMin) {
  		lev_var_c1 = "red";
  		lev_var_p2y = lev_var_p3y = 140*(1-(prmAMax-min)/(max-min));
  		lev_var_p4y = lev_var_p5y = 140*(1-(prmAMin-min)/(max-min));
  		if( pVar >= prmAMax || pVar <= prmAMin ) info_var_color = lev_var_c3 = "red";
  	}
  	else lev_var_c1 = "black-0";

  	//EVAL
  	if(pVar > max || pVar < min) info_var_color = lev_var_c3 = "lightgray";

  	// Check an process PID regulator
  	if(!prmVar.isEVal() && !prmSp.isEVal()) {
  		lev_out_en = info_out_en = !prmOut.isEVal() && (prmAnalog.isEVal() || prmAnalog == true);
  		info_sp_en = lev_sp_en = mode_en = modMan_en = modAuto_en = pnl_pid_en = true;

  		modCasc_en = !prmCasc.isEVal();
  		spToVar_en = up_en = upm_en = upMax_en = down_en = downm_en = downMin_en = (prmCasc != true);
  		lev_out_p1y = 140*(1-prmOut/100);
  		lev_sp_p1y = max(0,min(140,140*(1-(prmSp-min)/(max-min))));
  		if(info_sp_clearCnt <= 0) { info_sp_arg0val = prmSp; info_sp_backColor = ""; } else { info_sp_clearCnt--; toFastCalc = true; }
  		if(prmPrec.isEVal())	info_sp_arg0cfg = "10;f;2";
  		else if(prmPrec >= 0)	info_sp_arg0cfg = "10;f;"+prmPrec;
  		else info_sp_arg0cfg = "10;g;"+abs(prmPrec);

  		if(info_out_clearCnt <= 0) { info_out_arg0val = prmOut; info_out_backColor = ""; } else { info_out_clearCnt--; toFastCalc = true; }
  		appToVl = 0;

  		//Event process
  		for(off = 0; (ev_wrk=event.parse(0,"\n",off)).length; ) {
  			prevMode = prmAuto ? ((prmCasc==true)?tr("Cascade"):tr("Automate")) : tr("Manual");      
  			if(ev_wrk == "ws_BtPress:/modMan" && prmAuto) {  
  				prmAuto = false; if(prmCasc==true) prmCasc = false;
  				setActMess(tr("Mode")+" : "+(prmDescr.isEVal()?"":prmDescr)+" : "+prevMode+" : "+tr("Manual"));
  			}
  			else if(ev_wrk == "ws_BtPress:/modAuto" && (!prmAuto || prmCasc)) {  
  				prmAuto = true; if(prmCasc==true) prmCasc = false;
  				setActMess(tr("Mode")+" : "+(prmDescr.isEVal()?"":prmDescr)+" : "+prevMode+" : "+tr("Automate"));
  			}
  			else if(ev_wrk == "ws_BtPress:/modCasc" && !prmCasc) {  
  				prmAuto = prmCasc = true;
  				setActMess(tr("Mode")+" : "+(prmDescr.isEVal()?"":prmDescr)+" : "+prevMode+" : "+tr("Cascade"));
  			}
  			else if(ev_wrk == "key_mousePresLeft:/info_sp") {
  				setActMess(tr("Setpoint")+" : "+(prmDescr.isEVal()?"":prmDescr)+" : "+prmSp.toFixed(abs(prmPrec))+" : "+info_sp_arg0val.toFixed(abs(prmPrec)));
  				prmSp = info_sp_arg0val; info_sp_backColor = ""; info_sp_clearCnt = 0;
  			}
  			else if(ev_wrk == "key_mousePresLeft:/info_out") {
  				setActMess(tr("Output")+" : "+(prmDescr.isEVal()?"":prmDescr)+" : "+prmManIn.toFixed(1)+" : "+info_out_arg0val.toFixed(1));
  				prmManIn = info_out_arg0val; info_out_backColor = ""; info_out_clearCnt = 0;
  			}
  			else if(ev_wrk == "ws_BtPress:/spToVar") {
  				info_sp_arg0val = info_var_arg0val;
  				info_sp_backColor = "darkslategray";
  				info_sp_clearCnt = 25;
  				toCalcCycles = 1;
  			}
  			else if(ev_wrk == "ws_BtPress:/up")			appToVl = 1;
  			else if(ev_wrk == "ws_BtPress:/upm")		appToVl = 10;
  			else if(ev_wrk == "ws_BtPress:/upMax")		appToVl = 1e300;
  			else if(ev_wrk == "ws_BtPress:/down")		appToVl = -1;
  			else if(ev_wrk == "ws_BtPress:/downm")		appToVl = -10;
  			else if(ev_wrk == "ws_BtPress:/downMin")	appToVl = -1e300;
  			else if(ev_wrk == "ws_BtPress:/pnl_pid") {
  				sessNm = path.parsePath(0);
  				pidPg = "/"+sessNm + "/pg_so/"+vcaAttrGet("/"+sessNm+"/pg_so/wdg_pgCont/a_pgOpenSrc").parsePath(2)+"/pg_greg/pg_"+prmId;
  				if(vcaNodePresent(pidPg)) vcaAttrSet(pidPg+"/a_pgOpen",1);
  				else ev_rez += "usr_PidCntrCall\n"; 
  			} 
  			else ev_rez += ev_wrk+"\n";
  		}
  		event = ev_rez;

  		if(appToVl && (prmAuto || prmOut.isEVal())) {
  			if(prmPrec.isEVal())	newVl = ((info_sp_arg0val-min)/(max-min)+appToVl/100)*(max-min)+min;
  			else {
  				if((cntr-prevCntr)/f_frq > 0.2)	{ holdCntr = cntr; levUp = 0; }
  				prevCntr = cntr;
  				if((cntr-holdCntr)/f_frq > 3)	{ holdCntr = cntr; levUp++; }
  				decMult = max(2,floor(lg((max-min)/pow(10,-prmPrec))));
  				newVl = info_sp_arg0val + sign(appToVl) *										//direction
  														pow(abs(appToVl),floor(decMult/2)) *	//half for two buttons level
  														pow(10,min(levUp,ceil(decMult/2)-1)) *	//levelUp on hold any 3 seconds
  														pow(10,-prmPrec);								//precision base
  			}
  			newVl = max(min,min(max,newVl));
  			if(!prmAMin.isEVal() && !prmAMax.isEVal() && prmAMax > prmAMin ) newVl = max(prmAMin,min(prmAMax,newVl));
  			info_sp_arg0val = newVl; info_sp_backColor = "darkslategray"; info_sp_clearCnt = 25;
  			toCalcCycles = 1;
  		}
     	else if(appToVl && !prmAuto) {
  			if(prmAnalog==false) {
  				prmManIn = 50+2.5*appToVl;
  				if(appToVl == -1)		setActMess(tr("Output")+": "+(prmDescr.isEVal()?"":prmDescr)+" :: "+tr("Close")+" ( < )");
  				else if(appToVl == 1)	setActMess(tr("Output")+": "+(prmDescr.isEVal()?"":prmDescr)+" :: "+tr("Open")+" ( > )");
  				else if(appToVl == -10) setActMess(tr("Output")+": "+(prmDescr.isEVal()?"":prmDescr)+" :: "+tr("Close")+" ( << )");
  				else if(appToVl == 10)	setActMess(tr("Output")+": "+(prmDescr.isEVal()?"":prmDescr)+" :: "+tr("Open")+" ( >> )");
  			}
  			else {
  				newVl = max(0,min(100,info_out_arg0val+appToVl));
  				info_out_arg0val = newVl; info_out_backColor = "darkslategray"; info_out_clearCnt = 25;
  				toCalcCycles = 1;
  			}
  		}

  		if(prmAuto && prmCasc) { mode_text = tr("Cascade"); info_sp_bordWidth = info_out_bordWidth = 0; }
  		else if(prmAuto) {
  			mode_text = tr("Automate");
  			info_sp_bordWidth = 1; info_out_bordWidth = 0;
  		}
  		else {
  			mode_text = tr("Manual");
  			info_out_bordWidth = 1; info_sp_bordWidth = prmOut.isEVal() ? 1 : 0;
  		}
  	}
  	// Manual variable input
  	else if(!prmVarIn.isEVal()) {
  		up_en = upm_en = upMax_en = down_en = downm_en = downMin_en = true;
  		info_var_bordWidth = 1;
  		appToVl = 0;

  		//Event process
  		for(off = 0; (ev_wrk=event.parse(0,"\n",off)).length; ) {
  			if(ev_wrk == "key_mousePresLeft:/info_var") {
  				setActMess(tr("Variable")+" : "+(prmDescr.isEVal()?"":prmDescr)+" : "+prmVarIn.toFixed(abs(prmPrec))+" : "+info_var_arg0val.toFixed(abs(prmPrec)));
  				prmVarIn = info_var_arg0val; info_var_backColor = ""; info_var_clearCnt = 0;
  			}
  			else if(ev_wrk == "ws_BtPress:/up")			appToVl = 1;
  			else if(ev_wrk == "ws_BtPress:/upm")		appToVl = 10;
  			else if(ev_wrk == "ws_BtPress:/upMax")		appToVl = 1e300;
  			else if(ev_wrk == "ws_BtPress:/down")		appToVl = -1;
  			else if(ev_wrk == "ws_BtPress:/downm")		appToVl = -10;
  			else if(ev_wrk == "ws_BtPress:/downMin")	appToVl = -1e300;
  			else ev_rez += ev_wrk + "\n";
  		}
  		event = ev_rez;

  		if(appToVl) {
  			if(prmPrec.isEVal()) newVl = ((info_var_arg0val-min)/(max-min)+appToVl/100)*(max-min)+min;
  			else {
  				if((cntr-prevCntr)/f_frq > 0.2)	{ holdCntr = cntr; levUp = 0; }
  				prevCntr = cntr;
  				if((cntr-holdCntr)/f_frq > 3)	{ holdCntr = cntr; levUp++; }
  				decMult = max(2,floor(lg((max-min)/pow(10,-prmPrec))));
  				newVl = info_var_arg0val +	sign(appToVl) *										//direction
  															pow(abs(appToVl),floor(decMult/2)) *	//half for two buttons level
  															pow(10,min(levUp,ceil(decMult/2)-1)) *	//levelUp on hold any 3 seconds
  															pow(10,-prmPrec);								//precision base
  			}
  			newVl = max(min,min(max,newVl));
  			if(!prmAMin.isEVal() && !prmAMax.isEVal() && prmAMax > prmAMin) newVl = max(prmAMin,min(prmAMax,newVl));
  			info_var_arg0val = newVl; info_var_backColor = "darkslategray"; info_var_clearCnt = 25;
  			toCalcCycles = 1;
  		}
  	}
  }
  else if(!prmCom.isEVal() || !prmClose.isEVal() || !prmOpenSt.isEVal() || !prmCloseSt.isEVal()) {
  	Ramka_en = true;
  	com_open_en = com_close_en = (!prmCom.isEVal() || !prmClose.isEVal());
  	st_open_en = st_close_en = (!prmOpenSt.isEVal() || !prmCloseSt.isEVal());
  	com_stop_en = !prmStop.isEVal();

  	if(com_open_en) {
  		com_open_name = !digComs.isEVal() ? digComs.parse(0,";").parse(0,"-") : tr("OPEN");
  		com_open_color = (digComs.parse(0,";").parse(1,"-") != "") ? digComs.parse(0,";").parse(1,"-") : "green";
  		com_open_tipTool = !digComs.isEVal() ? tr("Command")+" "+digComs.parse(0,";").parse(0,"-") : tr("Command")+" "+tr("OPEN");
  		com_open_tipStatus = !digComs.isEVal() ? tr("Press for")+" "+digComs.parse(0,";").parse(0,"-") : tr("Press for")+" "+tr("OPEN");
  		com_open_en = com_open_name.length;
  	}
  	if(com_close_en) {
  		com_close_name = !digComs.isEVal() ? digComs.parse(1,";").parse(0,"-") : tr("CLOSE");
  		com_close_color = (digComs.parse(1,";").parse(1,"-") != "") ? digComs.parse(1,";").parse(1,"-") : "red";
  		com_close_tipTool = !digComs.isEVal() ? tr("Command")+" "+digComs.parse(1,";").parse(0,"-") : tr("Command")+" "+tr("CLOSE");
  		com_close_tipStatus = !digComs.isEVal() ? tr("Press for")+" "+digComs.parse(1,";").parse(0,"-") : tr("Press for")+" "+tr("CLOSE");
  		com_close_en = com_close_name.length;
  	}
  	if(com_stop_en) { 
  		com_stop_name = !digComs.isEVal() ? digComs.parse(2,";").parse(0,"-") : tr("STOP");
  		com_stop_color = (digComs.parse(2,";").parse(1,"-") != "") ? digComs.parse(2,";").parse(1,"-") : "yellow";
  		com_stop_tipTool = !digComs.isEVal() ? tr("Command")+" "+digComs.parse(2,";").parse(0,"-") : tr("Command")+" "+tr("STOP");
  		com_stop_tipStatus = !digComs.isEVal() ? tr("Press for")+" "+digComs.parse(2,";").parse(0,"-") : tr("Press for")+" "+tr("STOP");
  		com_stop_en = com_stop_name.length;
  	}
  	if(st_open_en) {
  		st_open_text = !digStts.isEVal() ? digStts.parse(0,";").parse(0,"-") : tr("OPEN");
  		st_open_color = (digStts.parse(0,";").parse(1,"-") != "") ? digStts.parse(0,";").parse(1,"-") : "green";
  		st_open_tipTool = !digStts.isEVal() ? digStts.parse(0,";").parse(0,"-") : tr("OPEN");
  		st_open_tipStatus = !digStts.isEVal() ? tr("State")+" "+digStts.parse(0,";").parse(0,"-") : tr("State")+" "+tr("OPEN");
  	}
  	if(st_close_en) {
  		st_close_text = !digStts.isEVal() ? digStts.parse(1,";").parse(0,"-") : tr("CLOSE");
  		st_close_color = (digStts.parse(1,";").parse(1,"-") != "") ? digStts.parse(1,";").parse(1,"-") : "red";
  		st_close_tipTool = !digStts.isEVal() ? digStts.parse(1,";").parse(0,"-") : tr("CLOSE");
  		st_close_tipStatus = !digStts.isEVal() ? tr("State")+" "+digStts.parse(1,";").parse(0,"-") : tr("State")+" "+tr("CLOSE");
  	}

  	//Event process
  	for(off = 0; (ev_wrk=event.parse(0,"\n",off)).length; ) {
  		if(ev_wrk == "ws_BtPress:/com_open") {
  			if(!prmCom.isEVal()) prmCom = true; prmClose = false;
  			setActMess(tr("Command")+" : "+(prmDescr.isEVal()?"":prmDescr)+" : : "+com_open_name);
  		}
  		else if(ev_wrk == "ws_BtPress:/com_close") {
  			if(!prmClose.isEVal()) prmClose = true; prmCom = false;
  			setActMess(tr("Command")+" : "+(prmDescr.isEVal()?"":prmDescr)+" : : "+com_close_name);
  		}
  		else if(ev_wrk == "ws_BtPress:/com_stop") {
  			prmStop = true;
  			setActMess(tr("Command")+" : "+(prmDescr.isEVal()?"":prmDescr)+" : : "+com_stop_name);
  		}
  		else ev_rez+=ev_wrk+"\n";
  	}
  	event = ev_rez;

  	if(st_open_en) st_open_color = !prmOpenSt.isEVal() ? (prmOpenSt ?
  		((digStts.parse(0,";").parse(1,"-") != "") ? digStts.parse(0,";").parse(1,"-") : "green") : "gray") :
  			(prmCloseSt ? "gray" : ((digStts.parse(0,";").parse(1,"-") != "") ? digStts.parse(0,";").parse(1,"-") : "green"));

  	if(st_close_en) st_close_color = !prmCloseSt.isEVal() ? (prmCloseSt ?
  		((digStts.parse(1,";").parse(1,"-") != "") ? digStts.parse(1,";").parse(1,"-") : "red") : "gray") :
  			(prmOpenSt ? "gray" : ((digStts.parse(1,";").parse(1,"-") != "") ? digStts.parse(1,";").parse(1,"-") : "red"));
  }
  else if(!prmComText.isEVal() || !prmStText.isEVal()) {
  	Ramka_en = true;
  	com_text_en = !prmComText.isEVal();
  	st_text_en = !prmStText.isEVal();

  	//Event process
  	for(off = 0; (ev_wrk=event.parse(0,"\n",off)).length; ) {
  		if(ev_wrk == "ws_CombChange:/com_text") {
  			prmComText = com_text_value;
  			setActMess(tr("Command")+" : "+(prmDescr.isEVal()?"":prmDescr)+" : : "+prmComText);
  			com_text_value = "";
  		}
  		else ev_rez += ev_wrk+"\n";
  	}
  	event = ev_rez;

  	if(com_text_en) {
  		com_text_items = "";
  		for(off = 0; !digComs.isEVal() && (vIt=digComs.parse(0,";",off)).length; ) com_text_items += vIt + "\n";
  		com_text_tipTool = !digComs.isEVal() ? tr("Select command") : "";
  		com_text_tipStatus = !digComs.isEVal() ? tr("Press for command select") : "";
  		com_text_en = com_text_items.length;
  	}
  	if(st_text_en) {
  		st_text_text = !prmStText.isEVal() ? prmStText.parse(0,":") : "";
  		if(com_text_en) com_text_value = st_text_text;
  		st_text_color = (prmStText.parse(1,":") != "") ? prmStText.parse(1,":") : "green";
  		st_text_tipTool = !prmStText.isEVal() ? prmStText.parse(0,":") : "";
  		st_text_tipStatus = !prmStText.isEVal() ? tr("State")+" "+prmStText.parse(0,":") : "";
  		st_text_en = st_text_text.length;
  		if(st_text_en && com_text_items.indexOf(st_text_text) != -1) com_text_value = st_text_text;
  	}
  }

  //Updating cycles processing for big processing periods of that page 
  if(toCalcCycles > 0.1) {
  	this.attrSet("event", this.attr("event")+"usr_calc\n");	//!!!! Just to calc in the next session cycle for update
  	toCalcCycles = max(0, toCalcCycles-1);
  }
  if(toFastCalc != toFastCalc_)	{ toFastCalc_ = toFastCalc; this.calcPer(toFastCalc?500:-3); }


ID: grpGraph
PARENT: /wlb_originals/wdg_Box
ATTRS: name;dscr;geomW;geomH;evProc;backColor;bordWidth;bordColor;
ICO:
  iVBORw0KGgoAAAANSUhEUgAAAEAAAAAqCAIAAACMZMq1AAAACXBIWXMAAAx1AAAMdQEteJR1AAAE
  xklEQVRYhdVYTW/bRhCd2S8uRVESJbOCZCSAgThBTknR3Jrmnj+R/5Kf2EvgwEacOkod24q+SIHk
  krvbA22akW0ILQSknNO+p/cWXM2sZih8//69ylSSJo7jGGPiOG6327ooALHlulEcE0IAQCmVJAn8
  z6LVarFotQp6vXbbm83n0nGEEEGvt16vXSkBEQEKrV3X/fLly3q9/tkPfE+w828XRx8/1qnj42MA
  sNYi4l3Dv+KttQBwL4+IlFLGWJ03xpQJ34iHeMdxmFSOF4/RYuZnmZ9Vn3XtZH+PM2ImUXeWtir+
  7Kwv5TDP3TD8KM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KSFULUh6cNuFWwW3tZQg/ZhRCMMSaEuLq6qosadomXy2XVBKCBl5j4/g9NYCPjG3Cr
  YLf2u9N4XZBlWVEURAgRBEF6E0+fPkXECo7H48FgUEEhhOd5Fcyy7ODgQClVMWEYlv+Al7G3t1ff
  3Pf90WhUQWPM4eFhlmUV8+jRI8dx6rt1u90Kep43Ho/TNGWMPX78uN1uD4dDfPny18+fT6E50W63
  R6MRAPR6vW63y968+ePVq99+9lP9x3Bd9x9FY7XqUFOtUwAAAABJRU5ErkJggg==

PROC:
  JavaLikeCalc.JavaScript
  if(f_start) {
  	//Parameter selection enable
  	if(allowSelLst.length)
  		for(i_el = 0; i_el < 8; i_el++) {
  			cEl = this["el"+(i_el+1)];
  			cEl.attrSet("enForce",1);
  			if(cEl.attr("contextMenu").search(":select$") < 0)
  				cEl.attrSet("contextMenu",cEl.attr("contextMenu")+tr("Select")+":select\n");
  		}
  	cnt = 0;
  	toCalcCycles = cnt_ = max(3, 2000/this.ownerSess().period());
  }
  cnt++;
  if(cnt == cnt_)	event = "ws_FocusIn:/trnd1";

  curTm = SYS.time();
  if(!trnd1_tSek)	trnd1_tSek = curTm;
  if(trnd1_curSek > (trnd1_tSek+trnd1_tSize/10) || trnd1_curSek < (trnd1_tSek-trnd1_tSize))
  	trnd1_curSek = trnd1_tSek;
  selSingle = 0;
  selAll = false;

  //Events process
  for(evRez = "", off = 0; (ev_cur=event.parse(0,"\n",off)).length; ) {
  	if(ev_cur == "key_presComma:/trnd1")			trnd1_tSek -= trnd1_tSize/2;
  	else if(ev_cur == "key_presPeriod:/trnd1")	trnd1_tSek += trnd1_tSize/2;
  	else if(ev_cur == "ws_SliderChange:/arh")		trnd1_tSek = arh_value*trnd1_tSize;
  	else if(ev_cur.search("usr_single:/el") == 0) selSingle = ev_cur.slice(14).toInt();
  	else if(ev_cur.search("usr_all:/el") == 0)	selAll = true;
  	else evRez += (ev_cur+"\n");
  	//SYS.messDebug("Trend","Event: "+ev_cur);
  }
  event = evRez;

  //Trend time control
  if(trnd1_tSek < curTm) trnd1_trcPer = 0;
  else trnd1_trcPer = max(1, (this.calcPer()==-2)?10:this.calcPer()/1000), trnd1_tSek = 0;

  //Generic
  name_arg0val = this.attr("name");

  //Scale
  typeXY = (trnd1_type==2);
  cntrAct = cntrLog = xCntrAct = xCntrLog = 0;
  for(i_el = 0; i_el < 10; i_el++) {
  	cEl = this["el"+(i_el+1)];
  	if(!cEl.attr("en")) continue;
  	if(!typeXY || !(i_el%2)) {
  		cntrAct++;
  		if(cEl.attr("log") == true)	cntrLog++;
  	}
  	else {
  		xCntrAct++;
  		if(cEl.attr("log") == true)	xCntrLog++;
  	}
  }
  trnd1_sclVer = (cntrLog > cntrAct/2) ? trnd1_sclVer|0x4 : trnd1_sclVer&(~0x4);
  trnd1_sclHor = (xCntrLog > xCntrAct/2) ? trnd1_sclHor|0x4 : trnd1_sclHor&(~0x4);

  //Trends
  arh_beg = 1e30, arh_end = 0;
  for(i_el = 0; i_el < 8; i_el++) {
  	cEl = this["el"+(i_el+1)];
  	if(selAll)	cEl.attrSet("bordStyle",3);
  	if(selSingle) cEl.attrSet("bordStyle",((i_el+1)==selSingle)?3:1);
  	cTr = this["trnd1"];
  	cTrPrm = "prm"+i_el;
  	if(!cEl.attr("en")) cTr.attrSet(cTrPrm+"addr","");
  	else {
  		cTr.attrSet(cTrPrm+"addr",cEl.attr("addr"));
  		cTr.attrSet(cTrPrm+"bordL",cEl.attr("min"));
  		cTr.attrSet(cTrPrm+"bordU",cEl.attr("max"));
  		cTr.attrSet(cTrPrm+"color",cEl.attr("color"));
  		cTr.attrSet(cTrPrm+"width",cEl.attr("bordWidth")*2);
  		cEl.attrSet("varEl",cTr.attr(cTrPrm+"val"));
  		//Enable/disable of the mode's indication in the regulators ???
  		cEl.attrSet("enMode",((curTm-trnd1_curSek) <= 2));
  		//Archive depth calculate
  		if(cEl.attr("bordStyle") == 3) {
  			arh_tmp = cTr.attr(cTrPrm+"prop");
  			if((arh_vl=arh_tmp.parse(0,":").toReal())) arh_beg = min(arh_beg,arh_vl);
  			if((arh_vl=arh_tmp.parse(1,":").toReal())) arh_end = min(curTm,max(arh_end,arh_vl));
  		}
  		if(!typeXY || !(i_el%2)) {
  			if((cEl.attr("log")==true) == (cntrLog > cntrAct/2) && cEl.attr("bordWidth") == 1) cTr.attrSet(cTrPrm+"scl",0);
  			else cTr.attrSet(cTrPrm+"scl",(cEl.attr("log")==true)?6:2);
  		}
  		else {
  			if((cEl.attr("log")==true) == (xCntrLog > xCntrAct/2)) cTr.attrSet(cTrPrm+"scl",0);
  			else cTr.attrSet(cTrPrm+"scl",(cEl.attr("log")==true)?6:2);
  		}
  	}
  }
  //Set archive scroll
  if(arh_end && ((arh_end-arh_beg)/trnd1_tSize > 2)) {
  	arh_cfg = "0:"+floor(arh_beg/trnd1_tSize+1)+":"+floor(arh_end/trnd1_tSize+1)+":1:5";
  	arh_value = (trnd1_tSek?trnd1_tSek:curTm)/trnd1_tSize;
  	arh_tipTool = tr("Archive space")+": ["+SYS.strftime(arh_beg)+" ... "+SYS.strftime(arh_end)+"]";
  	arh_active = true;
  	if(selSingle) trnd1_tSek = arh_end;
  } else arh_active = false, arh_tipTool = "";

  //Updating cycles processing for big processing periods of that page 
  if(toCalcCycles > 0.1) {
  	this.attrSet("event", this.attr("event")+"usr_calc\n");	//!!!! Just to calc in the next session cycle for update
  	toCalcCycles = max(0, toCalcCycles-1);
  }


ID: graphSelPrm
PARENT: /wlb_originals/wdg_Box
ATTRS: name;dscr;geomW;geomH;pgOpenSrc;pgGrp;backColor;bordWidth;
ICO:
  iVBORw0KGgoAAAANSUhEUgAAAEAAAAAqCAIAAACMZMq1AAAAA3NCSVQICAjb4U/gAAAACXBIWXMA
  AA7EAAAOxAGVKw4bAAAD/klEQVRYhe2Z224bRRiA57gHr8/H2MEpLSCRovYGiXsE4qJ9gEq8RR+A
  23LDg0TiFSJ6Ty8hvSEJJSRqnMb2endnZ2dPPxdxTZq6jllMlkr+rmakmX//z/96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XFDiOffCM9hXfkjylL6377w8m2Y9vFUlkFEmFC
  MKq0Nm5bqHa8d2fv6c/3vj0YqcD3dcPwPaGZBYohjpOuRbMU8cGDZVUXczJ0LLsSUXWXfqGoxAh8
  ITgnKlCWVXDGQzBrcLB/7Nbw/hH69DPGtUBKyghGEIYhpTSJFN7Z2Wk251TnBgijyBFywYBywXCF
  D5hgAMBzXuxAeH8BRzfEXu80U30AAAAASUVORK5CYII=

PROC:
  JavaLikeCalc.JavaScript
  if(f_start) {
  	apply_active = false;
  	name_active = val_min_active = val_max_active = dim_active = log_active = false;
  	prm_items = prm_value = name_value = dim_value = "", log_value = false, val_min_value = val_max_value = 0;
  	//Connect to linked widget 
  	if(pgOpenSrc.length) lWdg = this.wdgAt(pgOpenSrc, true);
  	if(lWdg) {
  		//Get allowed graphic's sources for the selection
  		tmplLst = "";
  		prm_items = "<Clear>\n";
  		if(lWdg.attrPresent("allowSelLst")) tmplLst = lWdg.attr("allowSelLst");
  		else if(lWdg.ownerWdg(true).attrPresent("allowSelLst")) tmplLst = lWdg.ownerWdg(true).attr("allowSelLst");
  		for(off = 0; (pIt=tmplLst.parse(0,"\n",off)).length; )
  			// Archives list template process
  			//t1 = "123";//SYS.messInfo("SEL", "TEST 00");	//!!!! After uncomment it next line will not work. Observe further
  			if(pIt == "<varhs>") {
  				aLs = SYS.Archive.nodeList("va_");
  				for(i_a = 0; i_a < aLs.length; i_a++) {
  					itNm = SYS.Archive[aLs[i_a]].cfg("NAME");
  					if(!itNm.length) itNm = SYS.Archive[aLs[i_a]].cfg("Source");
  					prm_items += tr("Archive")+" '"+itNm+"' (/Archive/"+aLs[i_a]+")\n";
  				}
  			}
  			// Direct items list process by form "{path}:{name}:{min}:{max}:{dim}"
  			else if(pIt.search("/(sub_|)Archive/") >= 0) {
  				if(!(itObj=SYS.nodeAt(pIt.parse(0,":")))) continue;
  				prm_items += tr("Archive")+" '"+pIt.parse(1,":")+"' ("+(pIt.parse(0,":")+":"+pIt.parse(2,":")+":"+pIt.parse(3,":")+":"+pIt.parse(4,":")).replace(new RegExp(":*$"),"")+")\n";
  			}
  			else {
  				pathAbs = pIt.search("/(sub_|)DAQ/") >= 0;
  				itObj = pathAbs ? SYS.nodeAt(pIt.parse(0,":")) : SYS.DAQ.nodeAt(pIt.parse(0,":"));
  				if(!itObj) continue;
  				itNm = pIt.parse(1,":");
  				if(!itNm.length && typeof(itObj).search("TCntrNode:TValue[:$]") == 0) itNm = itObj.cntr().cfg("NAME") + " > " + itObj.NAME.get();
  				prm_items += "DAQ '"+itNm+(pathAbs?"' (":"' (/DAQ")+(pIt.parse(0,":")+":"+pIt.parse(2,":")+":"+pIt.parse(3,":")+":"+pIt.parse(4,":")).replace(new RegExp(":*$"),"")+")\n";
  			}

  		//Current value processing
  		itAddr = lWdg.link("addr").match("(prm|arh):([^ ]+) \\(\\+\\)");
  		if(itAddr.length == 3) {
  			//Get Name
  			if(lWdg.link("name").search("prm:[^ ]+ \\(\\+\\)") >= 0) name_value = lWdg.attr("name");
  			else if((itTmp=lWdg.link("name").match("val:(.+$)")).length == 2) name_value = itTmp[1];
  			else name_value = tr("Empty");
  			//Get Min and Max
  			if(lWdg.link("min").search("prm:[^ ]+ \\(\\+\\)") >= 0) val_min_value = lWdg.attr("min");
  			else if((itTmp=lWdg.link("min").match("val:(.+$)")).length == 2) val_min_value = itTmp[1];
  			if(lWdg.link("max").search("prm:[^ ]+ \\(\\+\\)") >= 0) val_max_value = lWdg.attr("max");
  			else if((itTmp=lWdg.link("max").match("val:(.+$)")).length == 2) val_max_value = itTmp[1];
  			//Logarithmic scale
  			if(lWdg.link("log").search("prm:[^ ]+ \\(\\+\\)") >= 0) log_value = lWdg.attr("log");
  			else if((itTmp=lWdg.link("log").match("val:(.+$)")).length == 2) log_value = itTmp[1];
  			//Dimension
  			if(lWdg.link("ed").search("prm:[^ ]+ \\(\\+\\)") >= 0) dim_value = lWdg.attr("ed");
  			else if((itTmp=lWdg.link("ed").match("val:(.+$)")).length == 2) dim_value = itTmp[1];
  			//Current prm name
  			if(itAddr[1] == "prm") {
  				for(tAddr = "", off = 0, pos = 0; (tAddrEl=itAddr[2].parsePath(0,off)).length; pos++)
  					if(pos >= 3 && off < itAddr[2].length)	tAddr += "/prm_"+tAddrEl;
  					else if(tAddrEl == "var" && off >= itAddr[2].length)	continue;
  					else tAddr += "/"+tAddrEl;
  				prm_value = "DAQ '"+name_value+"' (/DAQ"+(tAddr+":"+val_min_value.toPrecision()+":"+val_max_value.toPrecision()+":"+dim_value).replace(new RegExp(":*$"),"")+")";
  				//prm_value = "DAQ '"+name_value+"' (/DAQ"+(itAddr[2].replace(new RegExp("/var$"),"")+":"+val_min_value.toPrecision()+":"+val_max_value.toPrecision()+":"+dim_value).replace(new RegExp(":*$"),"")+")";
  			}
  			else if(itAddr[1] == "arh") prm_value = tr("Archive")+" '"+name_value+"' (/Archive/va_"+(itAddr[2]+":"+val_min_value.toPrecision()+":"+val_max_value.toPrecision()+":"+dim_value).replace(new RegExp(":*$"),"")+")";
  			if(prm_value.length) name_active = val_min_active = val_max_active = log_active = dim_active = true;
  		}

  		//Load current properties
  		color_value = lWdg.attr("color");
  		if(color_value == lWdg.attr("colorDef"))	color_value = "";

  		//Load the colors list
  		color_cfg = "";
  		parLs = lWdg.nodePrev().nodeList("wdg_");
  		for(iLs = 0; iLs < parLs.length; iLs++)
  			 if((tVl=lWdg.nodePrev()[parLs[iLs]].attr("colorDef")).length)
  				color_cfg += tVl+"\n";
  	}
  }

  colorBox_backColor = (color_value.length?color_value:lWdg.attr("colorDef")).parse(0,"-");

  //Events for commands process
  for(evRez = "", off = 0; (evCur=event.parse(0,"\n",off)).length; ) {
  	//this.messInfo("Event: "+evCur);
  	if(evCur == "ws_ListChange:/prm") {	//Parameter selected
  		//Set properties
  		itTmp = prm_value.match(".+'(.*)' \\((.+?)\\)");
  		if(itTmp.length == 3) {
  			if(itTmp[1].length)	name_value = itTmp[1];
  			off1 = 0;
  			itVal = itTmp[2].parse(0,":",off1);	//Path
  			//Connect to source and get main values for parameter
  			if(itVal.parsePath(0) == "DAQ" && typeof(itObj=SYS.nodeAt(itVal)).search("TCntrNode:TValue[:$]") == 0) {
  				val_min_value = itObj.min.get();
  				val_max_value = itObj.max.get();
  				log_value = itObj.log.get();
  				dim_value = itObj.ed.get();
  			}
  			
  			//Set direct values
  			if((itVal=itTmp[2].parse(0,":",off1)).length) val_min_value = itVal;
  			if((itVal=itTmp[2].parse(0,":",off1)).length) val_max_value = itVal;
  			if((itVal=itTmp[2].parse(0,":",off1)).length) dim_value = itVal;
  		}
  		else name_value = dim_value = "", val_min_value = val_max_value = 0, log_value = false;
  		apply_active = name_active = val_min_active = val_max_active = log_active = dim_active = true;
  		//prmSearch_value = "";
  	}
  	else if(evCur == "key_relsReturn:/prmSearch" && prmSearch_value.length) {
  		sPos = (((sPos=prm_items.indexOf(prm_value))<0)?0:sPos) + prm_value.length;
  		if(((sPos=prm_items.indexOf(prmSearch_value,sPos)) >= 0 || (sPos=prm_items.indexOf(prmSearch_value,0)) >= 0)) {
  			sPos = ((sPos=prm_items.lastIndexOf("\n",sPos)) < 0) ?	0 : sPos+1;
  			prm_value = ((sPos_=prm_items.indexOf("\n",sPos)) >= 0) ? prm_items.slice(sPos,sPos_) : prm_items.slice(sPos);
  			event += "ws_ListChange:/prm\n";
  		}
  	}
  	else if(evCur == "ws_LnAccept:/name" || evCur == "ws_LnAccept:/val_min" || evCur == "ws_LnAccept:/val_max" ||
  				evCur == "ws_LnAccept:/dim" || evCur == "ws_LnAccept:/color" || evCur == "ws_ChkChange:/log")	apply_active = true;
  	else if(evCur == "ws_BtPress:/apply") {
  		//Link addr set
  		itTmp = prm_value.match(".+\\((.+?)[:\\)]");
  		if(itTmp.length != 2)	lWdg.linkSet("addr", "", true);		//Clear
  		else {	//Set
  			off1 = 0;
  			firstEl = itTmp[1].parsePath(0,off1);
  			if(firstEl == "Archive") {
  				lWdg.linkSet("addr", "", true);	//Clear all othet values
  				lWdg.linkSet("addr", "arh:"+itTmp[1].slice(off1+4));		lWdg.linkSet("name", "val:"+name_value);	lWdg.linkSet("ed", "val:"+dim_value);
  				lWdg.linkSet("min", "val:"+val_min_value);						lWdg.linkSet("max", "val:"+val_max_value);
  				lWdg.linkSet("log", "val:"+log_value);
  			}
  			else if(firstEl == "DAQ") {
  				itObj = SYS.nodeAt(itTmp[1]);
  				isPrm = (typeof(itObj).search("TCntrNode:TValue[:$]") == 0);
  				lWdg.linkSet("addr", "", true);	//Clear all othet values
  				lWdg.linkSet("addr", "prm:"+itTmp[1].slice(off1).replace("/prm_","/"), isPrm);
  				if(!isPrm || name_value != itObj.NAME.get())		lWdg.linkSet("name", "val:"+name_value);
  				if(!isPrm || val_min_value != itObj.min.get())	lWdg.linkSet("min","val:"+val_min_value);
  				if(!isPrm || val_max_value != itObj.max.get())	lWdg.linkSet("max","val:"+val_max_value);
  				if(!isPrm || log_value != itObj.log.get())			lWdg.linkSet("log","val:"+log_value);
  				if(!isPrm || dim_value != itObj.ed.get())			lWdg.linkSet("ed","val:"+dim_value);
  			}
  		}
  		lWdg.attrSet("color", color_value);
  		lWdg.attrSet("event", lWdg.attr("event")+"usr_set\n");

  		this.attrSet("pgOpen", false);
  	}
  	else if(evCur == "ws_BtPress:/cancel")	this.attrSet("pgOpen", false);
  	else evRez += evCur+"\n";
  }
  event = evRez;


ID: RootPgSo
PARENT: /wlb_originals/wdg_Box
ATTRS: path;name;dscr;active;geomW;geomH;evProc;backColor;
ICO:
  iVBORw0KGgoAAAANSUhEUgAAAEAAAAApCAIAAAAK8LgbAAAAA3NCSVQICAjb4U/gAAAACXBIWXMA
  AA7EAAAOxAGVKw4bAAADVklEQVRYhe2XS28jRRRGbz366U77ETu2Q6QomwCDDBIsZsFi/gISINbJ
  L4QtC1giQLCZSKMZMa9A7JkYP9vVXd1VdYtF24AEEoFN05LPrj7p072nVepWk4uLC6WU7GSA1F96
  lFJERMfIZuGkjpPyMtGhks08mkQAUCayLQHAX/jlEagV3czJuJu420qgZSdrTA4Ibit5WyKBYL6r
  AIiB4Bn3Vtu5xtdZWwazkBW0TLLDVIUm/vmAUmq4G3XOwbt+9eSmkBrQxvEBG41GWmtFNcmBFAQA
  jDFoUTNNMgIKykQTg9bQlJWDjTGaKdRA5bZiEBXXNP2jYog2gFRQi3ZboRpyIPluCqLiikjye2LA
  ICBNiTW7CleQE5ZSAPCH9wVOj0+j12LjOBEPA7/R4FprrfViuHATN05iREREGUnRFcE0DNOgTJLW
  WrsGM+tu3DKZDxc842zRKo9FnIuW4I57MI7KZHOU5HGBqfWSbWXZX9CCt9bNbSUq0kaKse381C6T
  rC3SjgwwDGe7uc1Etor+tI+IfdUSr06vbr4P8/dPhkGSkO7BhlxeXhZFATsYY8YY+BP/mPy3CiJa
  a+9e4ZyP3n2gcgCw1gIlxBggXPBerxcEAfzvEUKQo7YLYK01iIwxakzya0qrXuyuWGvPupC8fOaZ
  5MFbJ4NwIyfjuMF41Yv9C7I0WS9v/djT2mZpOpv+0qKHtRGglD693rTeOM0NfPHVl9kiAQrCbGpz
  hRARw+Drbz7vnb3ZG5xt8OUMnnFo1kYAAPqDo48/+lTMHhtTTATI183QXdXmCjHGWJY6pLXJE3Dp
  /fMPA9/LlKiNABCiGyQ3BVlrq0gY+L3Dw9WyVm+h8cOnnuPRRjNodozKV5oWhNdGgAB8+8OPFuDt
  0QdtJGit47hisayNAAB0G5EFsJt5TjQBosBSNLUR0Fp/9sl7ESu+W9w7OR5OXjyatqeNZVAbAULI
  47Fj09sVvVXJPF/P1dV1fP5ObQS01vPnLwAA4FEKAAC+w2+eXNVGwFrr+/5fwzp9if+WvUDV7AWq
  Zi9QNXuBqtkLVM1eoGr2AlWzF6iavUDV1F6gNj/13PWY62WFZo5LyPa5M+JwAJBSVrrbneB+OBge
  rzW9GU+cIKAEVKHCOP4NrQkgmJreob8AAAAASUVORK5CYII=

PROC:
  JavaLikeCalc.JavaScript
  var reqUser_; var reqLang_; var toCompleteUpd = false;
  if(this.ownerSess().reqUser() != reqUser_ || this.ownerSess().reqLang() != reqLang_)
  	toCompleteUpd = true, reqUser_ = this.ownerSess().reqUser(), reqLang_ = this.ownerSess().reqLang();

  calcCnt++;

  if(f_start || toCompleteUpd) {
  	play_en = demoPlayProc.length;
  	if(!play_en)	this.infoW.attrSet("geomH",this.play.attr("geomY")+this.play.attr("geomH")-this.infoW.attr("geomY"));
  	//Checking the signal object's presenting and creating needed
  	soLst = this.nodeList("pg_"); soLstS = new Object();
  	for(i = 0; i < soLst.length; i++)
  		if((curSO=soLst[i].slice(3).toInt())) {
  			soNm = this["pg_"+curSO].attr("name");
  			for(soNmSz = 0, off = 0; off < soNm.length; soNmSz++)
  				soNm.charAt(off, "UTF-8");
  			soLstS[curSO.toString(10,2)] = tVl = new Object();
  			tVl.nm = soNm;
  			tVl.nmSz = soNmSz;
  		}
  	//Init views
  	viewGrps = new Array(new Object(), new Object(), new Object());
  	v = viewGrps[0]; v.cnt = 0, v.first = 1, v.last = 2;
  	v = viewGrps[1]; v.cnt = 0, v.first = 3, v.last = 5;
  	v = viewGrps[2]; v.cnt = 0, v.first = 6, v.last = 6, v.global = true;	//Only one item currently
  	oldViewLs = new Array("mn", "ggraph", "gcadr", "gview", "doc", "rg");

  	//Processing SO and views
  	logoR = this.logo.attr("geomX") > this.so1.attr("geomX");
  	soInterSpecX = logoR ? this.so1.attr("geomX") : (this.logo.attr("en")?this.so1.attr("geomX")-this.logo.attr("geomX")-this.logo.attr("geomW"):2);
  	soX = logoR ? soInterSpecX : this.so1.attr("geomX");
  	soWdth =	logoR ?	((this.logo.attr("en")?this.logo.attr("geomX"):this.attr("geomW"))-soX) : (this.attr("geomW") - soX);
  	soSymbSz = this.so1.attr("font").parse(1," ").toReal()*0.75;

  	soInterSpecY = this.so1.attr("geomY");
  	soY = this.so1.attr("geomY");
  	soY2 = soY + this.so1.attr("geomH") + soInterSpecY;
  	row1 = 0, row2 = 0, row1w = 0, row2w = 0;
  	oldViews = false;
  	for(var iSO in soLstS) {
  		if(!(curSO=iSO.toInt()))	continue;
  		soNmSz = soLstS[iSO].nmSz*soSymbSz + soInterSpecX;
  		if(!row2 && (row1w+soNmSz) < soWdth)		row1w += soNmSz, row1++;
  		else if((row2w+soNmSz) < soWdth)			row2w += soNmSz, row2++;
  		else continue;	//Too many and long SO
  		if(curSO != 1)	this.wdgAdd("so"+curSO, soLstS[iSO].nm, this.attr("parent")+"/wdg_so1");

  		soW = this["wdg_so"+curSO];
  		soW.attrSet("name", soLstS[iSO].nm)
  			.attrSet("color", backColorButton)
  			.attrSet("colorText", labColorGood)
  			.attrSet("tipTool", tr("Signal object")+" "+curSO+((curSO<=9)?" (CtrlAlt+"+curSO+")":""))
  			.attrSet("tipStatus", tr("Press for select signal object")+" "+curSO+((curSO<=9)?" (CtrlAlt+"+curSO+")":""));

  		soDscr = this["pg_"+curSO].attr("dscr");
  		if(soDscr.length) soW.attrSet("tipTool", soDscr);
  		soW.attrSet("en", 1);

  		// Appending the events and hotkey processing
  		evProc += "ws_BtPress:/so"+curSO+":open:/pg_so/"+curSO+"/*/*\n";
  		if(curSO <= 9)	evProc += "key_presCtrlAlt"+curSO+":*:open:/pg_so/"+curSO+"/*/*\n";

  		for(iV = viewGrps[0].first; iV <= viewGrps[2].last; iV++) {
  			viewGrp = viewGrps[0];
  			if(iV >= viewGrps[2].first)	viewGrp = viewGrps[2];
  			else if(iV >= viewGrps[1].first)	viewGrp = viewGrps[1];
  			if(viewGrp[iV].isEVal()) {
  				vNm = "";
  				isG = (viewGrp.global == true);
  				if(this.nodeList("pg_","/pg_"+(isG?"view"+iV:curSO)+"/pg_view"+iV).length)	vNm = "view"+iV;
  				else if(this.nodeList("pg_","/pg_"+(isG?oldViewLs[iV-1]:curSO)+"/pg_"+oldViewLs[iV-1]).length)	vNm = oldViewLs[iV-1];
  				if(vNm.length) {
  					viewGrp[iV] = true, viewGrp.cnt++;
  					// Appending the events processing
  					evProc += "ws_BtPress:/go_view"+iV+":open:/pg_so/"+(isG?vNm:"*")+"/"+vNm+"/*\n";
  					// Append for the processing events of the hotkeys
  					vO = this["wdg_go_view"+iV];
  					if((tVl=vO.attr("tipTool").match("\\(CtrlAlt\\+(.)\\)")).length)
  						evProc += "key_presCtrlAlt"+tVl[1]+":*:open:/pg_so/"+(isG?vNm:"*")+"/"+vNm+"/*\n"; 
  				}
  			}
  		}
  	}

  	soWdthAdd = (soWdth-row1w)/row1;
  	soOff = soX, i = 0;
  	for(var iSO in soLstS) {
  		if(!(curSO=iSO.toInt()))	continue;
  		if(i > (row1+row2))	break;
  		soW = this["so"+curSO];
  		soNm = soW.attr("name");
  		soNmSz = soLstS[iSO].nmSz*soSymbSz + soInterSpecX;
  		soOffY = soY2;
  		if(i < row1)	soNmSz += soWdthAdd, soOffY = soY;
  		else if(i == row1)	soOff = soX;
  		soW.attrSet("geomX",soOff).attrSet("geomY",soOffY).attrSet("geomW",soNmSz-soInterSpecX);
  		soOff += soNmSz;
  		i++;
  	}
  	if(row1 == 1)		soOff = soY;
  	else if(!row2)	soOff = soY2 - soInterSpecY;
  	else soOff = soY2 + this.so1.attr("geomH");
  	this.pgCont.attrSet("geomY",soOff).attrSet("geomH",(alarms_en?alarms_geomY:geomH)-soOff);

  	//Unused views concealment
  	for(iVG = 0; iVG < viewGrps.length; iVG++) {
  		viewGrp = viewGrps[iVG];
  		viewOff = this["wdg_go_view"+viewGrp.first].attr("geomX");
  		viewWdth = this["wdg_go_view"+viewGrp.last].attr("geomX") + this["wdg_go_view"+viewGrp.last].attr("geomW") - viewOff;
  		for(iV = viewGrp.first; viewGrp.cnt < (viewGrp.last-viewGrp.first)+1 && iV <= viewGrp.last; iV++) {
  			vO = this["wdg_go_view"+iV];
  			if(viewGrp[iV].isEVal()) vO.attrSet("en", false);
  			else {
  				vO.attrSet("geomX", viewOff).attrSet("geomW", viewWdth/viewGrp.cnt);
  				viewOff += viewWdth/viewGrp.cnt;
  			}
  		}
  	}

  	toCalcCycles = -max(1, 10000/this.ownerSess().period());
  	if(f_start)	toFastCalc = toFastCalc_ = false;
  }

  toChangeCnt = "";
  if(pgCont_pgOpenSrc != lastView || toCompleteUpd) {
  	//Checking for SO selection change
  	curSO = pgCont_pgOpenSrc.parsePath(2).slice(3);
  	lastSO = lastView.parsePath(2).slice(3);
  	if(curSO != lastSO) {
  		if(lastSO.length) this["wdg_so"+lastSO].attrSet("color", backColorButton);
  		if(curSO.length) {
  			this["wdg_so"+curSO].attrSet("color", backColorButtonSel);
  			// Check for view modes active
  			for(iV = viewGrps[0].first; iV <= viewGrps[2].last; iV++) {
  				viewGrp = viewGrps[0];
  				if(iV >= viewGrps[2].first)		viewGrp = viewGrps[2];
  				else if(iV >= viewGrps[1].first)	viewGrp = viewGrps[1];
  				if(viewGrp[iV] == true) {
  					vNm = "";
  					isG = (viewGrp.global == true);
  					if(this.nodeList("pg_","/pg_"+(isG?"view"+iV:curSO)+"/pg_view"+iV).length)	vNm = "view"+iV;
  					else if(this.nodeList("pg_","/pg_"+(isG?oldViewLs[iV-1]:curSO)+"/pg_"+oldViewLs[iV-1]).length)	vNm = oldViewLs[iV-1];
  					this["wdg_go_view"+iV].attrSet("active", vNm.length);
  				}
  			}
  		}
  	}
  	//Checking for view selection change
  	curMode = pgCont_pgOpenSrc.parsePath(3).slice(3);
  	lastMode = lastView.parsePath(3).slice(3);
  	if(curMode != lastMode) {
  		if(lastMode.length)
  			this["wdg_go_"+(((tVl=oldViewLs.indexOf(lastMode)) >= 0)?"view"+(tVl.toInt()+1):lastMode)].attrSet("color","");
  		if(curMode.length)
  			this["wdg_go_"+(((tVl=oldViewLs.indexOf(curMode)) >= 0)?"view"+(tVl.toInt()+1):curMode)].attrSet("color", backColorButtonSel);
  	}

  	//Pages counter display
  	if(pgCont_pgOpenSrc.length && curMode.length) {
  		elLst = this["pg_"+curSO]["pg_"+curMode].nodeList("pg_");
  		curEl = pgCont_pgOpenSrc.parsePath(4);
  		pgSel_items = "";
  		for(iEl = 0, iM = -1; iEl < elLst.length; iEl++) {
  			oEl = this["pg_"+curSO]["pg_"+curMode][elLst[iEl]];
  			if(!(elNm=oEl.attr("name")).length)
  				elNm = oEl.ownerPage().attr("name") + " " + iEl;
  			elNm += " ("+elLst[iEl].slice(3)+")";
  			pgSel_items += (pgSel_items.length?"\n":"") + elNm;
  			if(iM < 0 && elLst[iEl] == curEl) { pgSel_value = elNm; iM = iEl; }
  			delete oEl;
  		}
  		pgCntr_text = ""+(iM+1)+"\n("+elLst.length+")";
  		prev_active = next_active = pgSel_active = (elLst.length>1);
  	}
  	else { pgCntr_text = "-"; prev_active = next_active = pgSel_active = false; }

  	lastView = pgCont_pgOpenSrc;
  }

  //Cvitation button's
  cvt_light_en = alarmSt&0x100; cvt_alarm_en = alarmSt&0x200; cvt_sound_en = alarmSt&0x400;
  cvt_light_active = alarmSt&0x10000; cvt_alarm_active = alarmSt&0x20000; cvt_sound_active = alarmSt&0x40000;
  toFastCalc = alarmSt&0x10000;

  //Per one second's calls
  if((calcCnt%f_frq) == 0) {
  	//Alarms display
  	actSO = pgCont_pgOpenSrc.parsePath(2).slice(3);
  	soLst = this.nodeList("pg_");
  	for(i = 0; i < soLst.length; i++) {
  		curSO = soLst[i].slice(3);

  		this["wdg_so"+curSO].attrSet("color", ((curSO==actSO)?backColorButtonSel:backColorButton));

  		aSt = this["pg_"+curSO].attr("alarmSt");
  		aLev = aSt&0xFF;
  		if(aLev && aSt&0x100) {
  			if(aLev > 30) wColor = labColorAlarm;
  			else wColor = labColorWarning;
  			curColor = this["wdg_so"+curSO].attr("colorText");
  			this["wdg_so"+curSO].attrSet("colorText",(aSt&0x10000 && curColor==wColor)?"black":wColor);
  		} else this["wdg_so"+curSO].attrSet("colorText", labColorGood);
  	}
  }

  //Events process
  for(off = 0, ev_rez = ""; (sval=event.parse(0,"\n",off)).length; )
  	if(sval == "ws_CombChange:/pgSel" && (tPg=pgSel_value.match("\\((.+)\\)$")).length)
  		toChangeCnt = "/pg_so/" + pgCont_pgOpenSrc.parsePath(2) + "/" + pgCont_pgOpenSrc.parsePath(3) + "/pg_" + tPg[1];
  	else if(sval == "ws_BtPress:/cvt_light")	alarmSt = 0x1000001;
  	else if(sval == "ws_BtPress:/cvt_alarm")	alarmSt = 0x1000002;
  	else if(sval == "ws_BtPress:/cvt_sound")	alarmSt = 0x1000004;
  	else if(sval.parse(0,":") == "ws_BtRelease" && ((tVl=sval.parse(1,":")) == "/prev" || tVl == "/next" || tVl.indexOf("/so") == 0 || tVl.indexOf("/go_view") == 0))
  		toChangeCnt = "1";

  if(toChangeCnt.length) {
  	this.ownerSess().uiCmd("open", "/pg_control/pg_terminator", this.attr("path"));	//!!!! To open the terminator panel before other
  	if(toChangeCnt.length > 1) this.ownerSess().uiCmd("open", toChangeCnt, this.attr("path"));
  	toCalcCycles = 1;
  }

  //Updating cycles processing for big processing periods of that page 
  if(abs(toCalcCycles) > 0.1) {
  	this.attrSet("event", this.attr("event")+"usr_calc\n");	//!!!! Just to calc in the next session cycle for update
  	toCalcCycles = (sign(toCalcCycles) < 0 && pgCont_pgOpenSrc.length) ? 0 : max(0, abs(toCalcCycles)-1)*sign(toCalcCycles);
  }
  if(toFastCalc != toFastCalc_)	{ toFastCalc_ = toFastCalc; this.calcPer(toFastCalc?500:-3); }

  //Demo play process
  if(f_start || !play_value) { stepCur = -1; stepTm = 0; play_img = "start"; }
  if(play_value) {
  	play_img = "stop";
  	if(stepTm > 0) stepTm -= 1/f_frq;
  	else {
  		var args = new Object();
  		args.this = this;
  		args.stepTm = stepTm;
  		args.stepCur = stepCur;
  		SYS.DAQ.funcCall("JavaLikeCalc.JavaScript",args,demoPlayProc);
  		stepTm = args.stepTm;
  		stepCur = args.stepCur;
  	}
  }

  if((tVl=defUser.toInt()) && (tVl2=defUser.parse(1,"-")).length) {
  	if((SYS.time()-this.ownerSess().userActTm()) < tVl*60)	userSetVis = "";
  	else if(this.ownerSess().reqUser() != tVl2.parse(0,":"))	userSetVis = tVl2;
  }


ID: ElViewCadr
PARENT: /wlb_originals/wdg_Box
ATTRS: name;dscr;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CkHOzs7fwOvrhb+aFJiZAAAAABJRU5ErkJggg==

PROC:
  JavaLikeCalc.JavaScript
  if(f_start) {
  	toFastCalc = toFastCalc_ = false;
  	trnd_trcPer = max(1, (this.calcPer()==-2)?10:this.calcPer()/1000);
  }

  toFastCalc = false;

  text_arg0val = name;
  text_arg1val = var;
  trnd_prm0addr = addr;
  if(focus)	bordColor = (bordColor != "silver") ? "silver" : "gray", toFastCalc = true;
  else bordColor = "gray";

  if(toFastCalc != toFastCalc_)	{ toFastCalc_ = toFastCalc; this.calcPer(toFastCalc?500:-3); }


ID: grpCadr
PARENT: /wlb_originals/wdg_Box
ATTRS: name;dscr;geomW;geomH;evProc;backColor;bordWidth;bordColor;
ICO:
  iVBORw0KGgoAAAANSUhEUgAAAEAAAAAqCAIAAACMZMq1AAAACXBIWXMAAAx1AAAMdQEteJR1AAAJ
  50lEQVRYhdWZya4cyXWG/4iMyDmzKmu4M8kWSGijRW/8GN7rSbQTDG/aNuxX8sZuAY1uGw0JQkuC
  piZui2TdoaacY/YieauLVVcgBAFs86zifPFHVA4RJ87JIp999llVlkpr3/etsW3bhmGgtI7CUEpF
  KSGUaqXKqsL/P4vjmK1XqzzPGWNlWXLOuM/TNNVaSymn04nW2hjTWts0zQ99tY8bu18uv3358gf5
  bUopY+zvnIS9fPnyzZs319fXgx+GYd/3u+4D972CDzZ8PB5vNptPP/2U+b6/Wq2cczvRfvvYfa/g
  wwwnhAwNZq1rmmb/Rg9u+sB9r+DDDO+6ru97rTVbLpeEkDAMh+4oivbVB+57BR9seBRFXdcxxqjv
  c845Plpj43HhnDPGDP4QN3fdB+57BR9s+NCw1rLb25u+7621g8I5t2sfu+8VfLDhuwaL4zgMQyHE
  oOCca613Aw7c9wo+2HDOOeecUkqTJPn7T5Mf0NjNzc12u92/0Y8sjIZhFMexlHLo/vjC6Hg8+rjD
  6GKxqKpq9wbw0S0hQkgQBJTSofvjW0JJkiqldoqDuHvgvlfwwYYPx5lzjgZBEEVR3/d93zvnnj9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0Lk2pFG58ZKZctrzuNVG+SZobRN7iXBChnkohMeN1sa3fmOb1EtKZzNrtceI
  b6wy3PqNrVOWRXdqO6GUUvjaSsud39g6Y1nYNJswYpS4QDvhmOMDZ6xiV5c/uvrxcwCMsadPPwFQ
  lttff/m/ltxdPf8H5xzn/pMnzwCs16s/fvPf+Sb/yU+eWWuDILi6egpgtbr/4otfZzP19PSF1jqO
  44uLKwD393e//O2XSCYvJmdaqyRJz88vAdzd3Xz5m6/PeDA9f2aMzrLR6ekZgNvbxbf/9dXTZ8Vs
  duacy/PRfH4K4ObmzZ/+5/NPzq4mkxPAZVk+8MXize9+95/k3//5PxBTAEPVNxqNnHNyI3hU0vDk
  gBO1XNWTyYQC2G63hCDPR8655dLkM+0jfOAkz3PnXKMrE45HxgLYbDae52VZ5pxba1E4R/wIwGaz
  9jw2cP+mbaeccx/Aer3mnKdp6pzj1baPY8YOOaUrJlspawFASwmgFlsATjrOW92+AcCMBIFuWwCe
  k2071loBkJIC6HsBQAgaWiGNAGA8CUJqtQVgYGqrhVYABKeUkk4LDIl0W5uuAcCk8CjVVgDQjpA1
  0xAAeE89RnQrAFBQxMvhAzTnwvM8rSsAhOD/AKsOdIn92aBGAAAAAElFTkSuQmCC

PROC:
  JavaLikeCalc.JavaScript
  curTm = SYS.time();
  if(!trnd1_tSek) trnd1_tSek = curTm;

  //Events process
  for(off = 0, ev_rez = ""; (ev_cur=event.parse(0,"\n",off)).length; ) {
  	//Special.FLibSYS.messPut("Trend",0,"Event: "+ev_cur);
  	if(ev_cur == "key_presSC#3b:/trnd1")			trnd1_tSek -= trnd1_tSize/2;
  	else if(ev_cur == "key_presSC#3c:/trnd1")	trnd1_tSek += trnd1_tSize/2;
  	else ev_rez += (ev_cur+"\n");
  }
  event = ev_rez;

  //Trend time control
  if(trnd1_curSek > trnd1_tSek || trnd1_curSek < (trnd1_tSek-trnd1_tSize)) trnd1_curSek = trnd1_tSek;
  if(trnd1_tSek < curTm)	trnd1_trcPer = 0;
  else trnd1_trcPer = max(1, (this.calcPer()==-2)?10:this.calcPer()/1000), trnd1_tSek = 0;

  //Generic
  name_arg0val = grpName;

  for(i = 0; i < 8; i++) {
  	el = this["el"+(i+1)];
  	if(el.attr("prmAddr").isEVal())	{ el.attrSet("en",false); this.trnd1.attrSet("prm"+i+"addr",""); }
  	else {
    		el.attrSet("en", true);
  		this.trnd1.attrSet("prm"+i+"addr",el.attr("prmAddr"))
  						.attrSet("prm"+i+"bordL",el.attr("min")).attrSet("prm"+i+"bordU",el.attr("max"))
  						.attrSet("prm"+i+"color",el.attr("bordColor"));
  	}
  }


ID: anShow
PARENT: /wlb_originals/wdg_Box
ATTRS: path;perm;name;dscr;active;geomH;tipTool;contextMenu;evProc;backColor;bordWidth;bordColor;
ICO:
  iVBORw0KGgoAAAANSUhEUgAAAEAAAAAZCAIAAAAOir+2AAAAA3NCSVQICAjb4U/gAAAACXBIWXMA
  AA7EAAAOxAGVKw4bAAAF/0lEQVRYhdWW/08bdRjHn8/n7nrXu2tpy1ootmUtDChsK2snk62AsMnG
  5pj1a6LRH4w/+cMS/xT/g4lLNJkxxmjinIvFKduy4QbKgCJQ+pUCLdD1rndt784f6jadQxMDmL1/
  +uTyfu7er+bp83nQ+fPnY7EYPJ1yuVwQCoUYjjNweoyQjmF5Xo+29COa5TiW/osBYR3DEFvX7KhC
  oRAGgL7QS++/M+wwGzp6z7z1xnEjsYUds12nX3vtdBeLHz0zWD3Db4bszFY1Oy4SAAAQY2vuPuhZ
  RACASK7uxEC/jSfXZm9eu/NbsaJhHe/rOdVqKJK1Bshhc+OBvv1ujjMSQkYyOlpddULAW1pSA75m
  jjNSxeg3V26sFyu7A1D9MdXsRqGuLbDXrAMgXZ3drTXSjeuRA729e608AHAWx+HDnvjMXF4GAIRU
  YXF+cUOmmjv3rc0tSVCY+jlSUovR+YVcETf5Ou1G/e6kfwigZRcmflkFb6ubQGStmZXLwmY2W2Z5
  jqEBgKQYvU5eW1vPiwIAYWvyv9DdthmfFzFFI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vHtWTE9desIYpZqPnXwp2LHy648Xw78CprsG3xjsss+Mj9d3B50s
  85h7Y3X20siVI+9+8Fyddufyp9fjks528L23X6SkyNjo1f6h4R25Bx4Tpgyt7R4kb87PRmWtnIxl
  VNLvCZ48i4ybVN3hgFsV0onYfN5Qk9VVxyky2RzOBvPmcjwylyhr8tLUQsDuPXI6RE0uWVsP1XKw
  OBGt7ou7AUCxthdCIWJtemQuKitQTE6O3vL0+ZsO9Q4iTSlJGxNjozPxtLz09YMKoj14xt5gSMyO
  h3+YrABEp8buuE1+d3P/YIumVtZTket3Z8sq7BSAuJm6EQ6X1uOyBgBQkXI3w2EsrorVdlLl8atf
  JOc8Tc46rIipxd+i6Zzyl4tDXY3NXguvZ6OZaoW8mfj20ifRdq/NqC8L2bnZyNrDm/tpX6dJp9N5
  7ty5/zvJf5TT6fwdtJ1wW1UXxCwAAAAASUVORK5CYII=

PROC:
  JavaLikeCalc.JavaScript
  if(f_start)	toFastCalc = toFastCalc_ = false;

  if(!pDscr.isEVal())
  	tipTool = pDscr + ((!pErr.isEVal()&&pErr.toInt())?"\n"+tr("Error")+": "+pErr:"");
  name_text = pName.isEVal() ? tr("No data") : pName;
  val_arg0val = pVal;
  val_font = "Arial 24 1 0 0 0";
  if(!pPrec.isEVal()) val_arg0cfg = ((pPrec>=0)?";f;":";g;")+abs(pPrec);
  if(pVal.isEVal()) {
  	val_color = name_color = "grey";
  	val_font = "Arial 24 0 1 0 1";
  	alarm = "";
  	pErrCode = 0;
  	bordColor = "grey", bordWidth = 1;
  	return;
  }

  //Notification create
  if(!pErr.isEVal() && pErrCode != pErr) {
  	pErrCode = pErr;
  	alTp = (!spName.isEVal() && spName.length) ? 7 : 3;
  	if(pErrCode == 1 || pErrCode == 2)	alarm = (redEVAL == true) ? "100|"+pName+"|"+spName+" - "+tr("reject")+".|7" : "100|"+pName+"||1";
  	else if(pErrCode == 3)	alarm = "50|"+pName+"|"+spName+" "+tr("above alarm border")+".|"+alTp;
  	else if(pErrCode == 4)	alarm = "50|"+pName+"|"+spName+" "+tr("bellow alarm border")+".|"+alTp;
  	else if(pErrCode == 5)	alarm = "10|"+pName+"|"+spName+" "+tr("above warning border")+".|"+alTp;
  	else if(pErrCode == 6)	alarm = "10|"+pName+"|"+spName+" "+tr("bellow warning border")+".|"+alTp;
  	else if(pErrCode == 10) alarm = "10|"+pName+"|"+pErr.parse(1,":")+".|"+alTp;
  	else if(pErrCode == 11) alarm = "50|"+pName+"|"+pErr.parse(1,":")+".|"+alTp;
  	else if(alarmSt&0x100)	alarm = "1|"+pName+"||1";
  }
  if(!pErrCode && alarmSt&0x100 && !(alarmSt&0x10000)) alarm = "";

  toFastCalc = false;

  //Notification color change
  alarmLev = alarmSt&0xFF;
  if(alarmLev && alarmSt&0x100) {
  	blinkPr = true;
  	if(!pErrCode || alarmLev <= 1)	wColor = labColorGood;
  	else if(alarmLev < 30)	wColor = labColorWarning;
  	else if(alarmLev < 75)	wColor = labColorAlarm;
  	else { wColor = "grey"; blinkPr = false; }
  	if(blinkPr) { name_color = val_color = (alarmSt&0x10000 && name_color == wColor) ? "grey" : wColor; if(alarmSt&0x10000) toFastCalc = true; }
  	else { 
  		if(pErrCode == 1 || pErrCode == 2)	{ val_color = wColor; val_font = "Arial 24 0 1 0 1"; name_color = (redEVAL==true) ? labColorAlarm : wColor; }
  		else name_color = val_color = wColor;
  	}
  } else name_color = val_color = labColorGood;

  //Blink focused or linked with ElCadr
  if(this.attr("focus") ||
  	(!pName.isEVal() && pName.length && this.wdgAt("/s/pg_control/pg_ElCadr",true).attr("pgOpen") && this.wdgAt("/s/pg_control/pg_ElCadr",true).attr("prmShifr") == pName))
  {
  	bordColor = (bordColor == "silver") ? "grey" : "silver";
  	bordWidth = 2;
  	toFastCalc = true;
  } else bordColor = "grey", bordWidth = 1;

  //Check the regulator mode
  if(pModeC == true) mode_text = tr("C");
  else mode_text = pModeA.isEVal() ? "" : ((pModeA) ? tr("A") : tr("M"));

  if(toFastCalc != toFastCalc_)	{ toFastCalc_ = toFastCalc; this.calcPer(toFastCalc?500:-3); }


ID: ViewCadr
PARENT: /wlb_originals/wdg_Box
ATTRS: name;dscr;geomW;geomH;backColor;bordWidth;
ICO:
  iVBORw0KGgoAAAANSUhEUgAAAEAAAAAqCAIAAACMZMq1AAAACXBIWXMAAAx1AAAMdQEteJR1AAAE
  CElEQVRYhe2YW2/bRhCFz9kLL5JpuE3ctA996T9t/mpRpC7SWrRFmuLuzPSBshTZsgPUIewAOk9a
  7szHHVLS2R1+/P2jc24cN8OwUdOUkpktF8uu74qiAABgvV7nnPH2tFgswjDckTSzpjkjMKbUNE3f
  9zmnpmlijCmlq6urt1kAgDCmpKoAhs1murTuuunDqm27rgshXF5eHk02s7ZtLy4unqIPw6Cqi8Xi
  qYCJX5bl/+N770OMcfdVObqCuq6Xy+XRWRFp27ZpmqfSVVVVnwl4IV9E3FNz34tOBby2TgW8tkK4
  CCNHOOi1WrJH08G/96MbAchneZy//GE5Lkc42J3prT6Ydc65czcFzMEvyzIUKH32LGmlWTRWpKN2
  21ARqVBRyEitlZEIgMI226XkLldWQWHBrDaWZKANZmIAUkoKLXM5E78oipD7nHNCBwB0pCdJybK7
  QbpJJKchPZ13pqZ5u4I85vFm3D/yytFRVS0bgJyzjppkLr5zLvR9d/BWhsPRMIhIVVXb8Qjc7mdV
  db1eH/jovwfpfd+b2W5935yfcw4hhGecuOu6siyf2guIyPX19TM7hZTSV7cSL+GfnPgN6FTAa+u7
  LyDEd3HkSE/5LDY+dMoYo//ZjxxJ5r+OHMrO3p2l8wQH7VXbY0584cZmLn5VVSGm6MSxoEZFgFs4
  OOxMW0SqTUUjI2MdWZCRJmbDvVOuc7EpQACw2liRkXZnk9GklCRLeVfOxC+KIuQh55xxBwAgnDko
  9kaYc+oSySmAjgw02eYDyCmnLu0eCZVUWt4XoKrJ0kz8yYn7g7eyORxtNiJS1/V2PALr/ewRpxwP
  0vu+V1XnvvilfVN+SunrTlxV1axO/BL+yYnfgE4FvLa++wJC8VORmBAgV7I7yO0UY4y/xmQJRP7z
  iFM2l036McHB1ibXDw+13nv/3qezufhVVYfQBQgYad6wgFs6eOxMW0TiKhJkuHfKkpbN7rZLSbcp
  riIdYbDaXO1QwLovnLiTKHEmflEUQcVMtmdkEGqKDDPb3cCygZgCTI1K6D5ARffpgJpCYGqw+3Sb
  ka+qoW1XB2/l9mDU9/1ms9k75aFUtW1b7/3+0vogYDoTH7TmvynfORfKsny+O71YLJ7pHt/c3Lyw
  O/0S/smJ34BOBby2ArD/z3osu9dTs8+n7wgz8c0sVL9UI0dGyifR4Uj7t/qtEhU6pj8SHqHOP5zr
  BwWha5V/HjplCCF+iHImM/Grqg5cuSCBgR4eC7gzR0dZbUNzzv7K05GOvvQsyYrI2LWXx5vR/+3h
  4OFjFd3SIcI6mzrpKSVZSRjm4hdFDM5RlRCQhGHyuV071ntPkiB0CiAytsH3z3ibCICAAhmwbQDJ
  iTAT3wz/AQrXOAcOBXvwAAAAAElFTkSuQmCC

PROC:
  JavaLikeCalc.JavaScript
  name_arg0val = this.attr("name");

  if(f_start) {
  	el1_1_en = !el1_1_addr.isEVal(); el1_2_en = !el1_2_addr.isEVal(); el1_3_en = !el1_3_addr.isEVal(); 
  	el1_4_en = !el1_4_addr.isEVal(); el1_5_en = !el1_5_addr.isEVal(); el1_6_en = !el1_6_addr.isEVal();
  	el2_1_en = !el2_1_addr.isEVal(); el2_2_en = !el2_2_addr.isEVal(); el2_3_en = !el2_3_addr.isEVal(); 
  	el2_4_en = !el2_4_addr.isEVal(); el2_5_en = !el2_5_addr.isEVal(); el2_6_en = !el2_6_addr.isEVal();
  	el3_1_en = !el3_1_addr.isEVal(); el3_2_en = !el3_2_addr.isEVal(); el3_3_en = !el3_3_addr.isEVal(); 
  	el3_4_en = !el3_4_addr.isEVal(); el3_5_en = !el3_5_addr.isEVal(); el3_6_en = !el3_6_addr.isEVal();
  	el4_1_en = !el4_1_addr.isEVal(); el4_2_en = !el4_2_addr.isEVal(); el4_3_en = !el4_3_addr.isEVal(); 
  	el4_4_en = !el4_4_addr.isEVal(); el4_5_en = !el4_5_addr.isEVal(); el4_6_en = !el4_6_addr.isEVal();

  	rows = new Array(	(el1_1_en||el1_2_en||el1_3_en||el1_4_en||el1_5_en||el1_6_en),
  								(el2_1_en||el2_2_en||el2_3_en||el2_4_en||el2_5_en||el2_6_en),
  								(el3_1_en||el3_2_en||el3_3_en||el3_4_en||el3_5_en||el3_6_en),
  								(el4_1_en||el4_2_en||el4_3_en||el4_4_en||el4_5_en||el4_6_en));
    cols = new Array(	(el1_1_en||el2_1_en||el3_1_en||el4_1_en),
  								(el1_2_en||el2_2_en||el3_2_en||el4_2_en),
  								(el1_3_en||el2_3_en||el3_3_en||el4_3_en),
  								(el1_4_en||el2_4_en||el3_4_en||el4_4_en),
  								(el1_5_en||el2_5_en||el3_5_en||el4_5_en),
  								(el1_6_en||el2_6_en||el3_6_en||el4_6_en));

  	for(xScale = 0, i = 0; i < 6; i++) xScale += cols[i]; if(xScale) xScale = 6/xScale;
  	for(yScale = 0, i = 0; i < 4; i++)	yScale += rows[i]; if(yScale) yScale = 4/yScale;
  	xScale = yScale = min(xScale, yScale);

  	if(xScale > 1)
  		for(i = 1; i <= 4; i++) {
  			for(j = 1; j <= 6; j++) this["wdg_el"+i+"_"+j].attrSet("geomXsc", xScale);
  			this["wdg_el"+i+"_2"].attrSet("geomX", 3+150*xScale*cols[0]);
  			this["wdg_el"+i+"_3"].attrSet("geomX", 3+150*xScale*(cols[0]+cols[1]));
  			this["wdg_el"+i+"_4"].attrSet("geomX", 3+150*xScale*(cols[0]+cols[1]+cols[2]));
  			this["wdg_el"+i+"_5"].attrSet("geomX", 3+150*xScale*(cols[0]+cols[1]+cols[2]+cols[3]));
  			this["wdg_el"+i+"_6"].attrSet("geomX", 3+150*xScale*(cols[0]+cols[1]+cols[2]+cols[3]+cols[4]));
  		}
  	if(yScale > 1)
  		for(j = 1; j <= 6; j++) {
  			for(i = 1; i <= 4; i++) this["wdg_el"+i+"_"+j].attrSet("geomYsc", yScale);
  			this["wdg_el2_"+j].attrSet("geomY", 30+142*yScale*rows[0]);
  			this["wdg_el3_"+j].attrSet("geomY", 30+142*yScale*(rows[0]+rows[1]));
  			this["wdg_el4_"+j].attrSet("geomY", 30+142*yScale*(rows[0]+rows[1]+rows[2]));
  		}
  }


ID: anShow1
PARENT: /wlb_originals/wdg_Box
ATTRS: perm;name;dscr;active;geomH;tipTool;evProc;backColor;bordWidth;bordColor;
ICO:
  iVBORw0KGgoAAAANSUhEUgAAAEAAAAAOCAIAAAAQWY2VAAAAA3NCSVQICAjb4U/gAAAACXBIWXMA
  AA7EAAAOxAGVKw4bAAAEBElEQVRIicWVW0xbdRzHf+ecf6+nLdAeoEAppQXKxdFsDZciSsZlk7GN
  NTM6iYlv+qSJxvjc6JvxwTezmZCYxcy4h7niggZZNU6B4Zgy6dYy6axlXFrKeuXcjw/sgitoTDv9
  vH7/5/f7/v6//+93MI/HA3sTCATS6fTfHPh/sVgsCADGx8eXl5dz5cbGxmAwGA6H889EKMhinZrL
  JpMZ5nENI9QarVopA5HPplJZlt/5nU5fokTiZjTOSQCAyVWkVqPCBC6VSjKc6Ha7EQDEYrFIJJKb
  tby8PH/rAAC4rLn72FCXNXjlS69vfqdBwAhTc2d/T7uJ0gGXvrt04+IXExuMtC2qK5peHDlepU2O
  vv9ROCsoDTX9hw+32owYm7w9953Xdx0A0HaU6qb2dodVBgAivxm5+e30AiMWxrzGYGpxdvV22uU4
  l6vKVPr9rk6KSHhHPyHszx3pdvU9feeCL8hJgNRUT9/BCo3sQamo1TXQWqOZvjCaqjk06DrUEQph
  DwpAHcOvnnn3VDqyLiK5ErIfvn7sg4uBAtgnDEdHXrBq5PxWRiLluTpPJ34YO3cN5zbWE+aKlIBh
  SKkmADgMWRxdTQagBUGNAABwRJpsFSK7EgpFtvgQ01ZtbqhkMMAfxlpd+rqvydrSduT8Aj04cqIE
  FcA/YDKCic1Mjk3OLu5y/wCSyMbX7kaTwlM9Q33P7hNjd36avUlLoKtq6XHWzF/5fi17f2YwRFJa
  XBDpLCtxdJoDUBSVKnB4ZFOpqegdOp4u23fAWhn1huhCPCFjKT4/NcdxoqlKhwOuMxgb7DQvPX6M
  1Ju7uw6UIIlmRZKy2ClZU/vBIm45xshtBAEgN9saSNCTBBBIba5rkAwUAlAVGRGjwDwez9lPP99/
  8q2P33tZ2EzwHB2avfTmG+9Mh9NOpzMajeazhdxut8PhyOsO/olHHVj57dKw4+RizpbLh0AgkEgk
  AMNLTXX1taXx8OLi7+vCjg4gha6+2U5K6Vu/3iL0tc2NptRKiFWVGos1f43E/REMQnljpYpZ/GWO
  1tW32ss3Qj9LZGVBXvqe+P1+v98PQDR3q621+tWQ3+eb5xH10munDLDx2elz92QGZLQ6DEQmvopp
  6wguM3fZe32FlyECAADpT7zyvEXLnD99dimesblkR13VPJNmCSQx8R8nvqntGEAAABI/4z3z9g35
  6q6DVghEUeBYjhe2BwtXkSQJWRyA39qcmvhKcfAZ58CwkFq7Ojl29fYm+7BFBEEzLKtgkvcSW4wQ
  vHZ5qqi/va1XysRmJn0LqxkLAHg8HpvNtmtWp9NpNpufVE2F4P6fmKIomqZz5eLi4mg0+p+7+ncg
  ABgcHNxLLisre9JrJB9MJtOfuAmh/+/YRy0AAAAASUVORK5CYII=

PROC:
  JavaLikeCalc.JavaScript
  if(f_start)	toFastCalc = toFastCalc_ = false;

  var bordWidth_;
  if(bordWidth_.isEVal())	bordWidth_ = bordWidth;
  if(f_stop)	bordWidth = bordWidth_;
  if(!pDscr.isEVal())
  	tipTool = pDscr + ((!pErr.isEVal()&&pErr.toInt())?"\n"+tr("Error")+": "+pErr:"");
  name_en = pName.length;
  name_text = pName;
  name_geomW = pNameSz;
  val_arg0val = pVal;
  val_font = "Arial 20 1 0 0 0";
  if(!prec.isEVal()) val_arg0cfg = ((prec>=0)?";f;":";g;")+abs(prec);
  if(pVal.isEVal()) {
  	val_color = "grey";
  	val_font = "Arial 20 0 1 0 1";
  	alarm = "";
  	pErrCode = 0;
  	bordColor = "gray", bordWidth = bordWidth_;
  	return;
  }

  //Notification create
  if(!pErr.isEVal() && pErrCode != pErr) {
  	pErrCode = pErr;
  	alTp = (!spName.isEVal() && spName.length) ? 7 : 3;
  	if(pErrCode == 1 || pErrCode == 2)	alarm = "100|"+pNAME+"||1";
  	else if(pErrCode == 3)	alarm = "50|"+pNAME+"|"+spName+" "+tr("above alarm border")+".|"+alTp;
  	else if(pErrCode == 4)	alarm = "50|"+pNAME+"|"+spName+" "+tr("bellow alarm border")+".|"+alTp;
  	else if(pErrCode == 5)	alarm = "10|"+pNAME+"|"+spName+" "+tr("above warning border")+".|"+alTp;
  	else if(pErrCode == 6)	alarm = "10|"+pNAME+"|"+spName+" "+tr("bellow warning border")+".|"+alTp;
  	else if(pErrCode == 10) alarm = "10|"+pNAME+"|"+pErr.parse(1,":")+".|"+alTp;
  	else if(pErrCode == 11) alarm = "50|"+pNAME+"|"+pErr.parse(1,":")+".|"+alTp;
  	else if(alarmSt&0x100) alarm = "1|"+pNAME+"||1";
  }
  if(!pErrCode && alarmSt&0x100 && !(alarmSt&0x10000)) alarm = "";

  toFastCalc = false;

  //Notification color change
  alarmLev = alarmSt&0xFF;
  if(alarmLev && alarmSt&0x100) {
  	blinkPr = true;
  	if(!pErrCode || alarmLev <= 1) wColor = labColorGood;
  	else if(alarmLev < 30)	wColor = labColorWarning;
  	else if(alarmLev < 75)	wColor = labColorAlarm;
  	else { wColor = "grey"; blinkPr = false; }
  	if(blinkPr) { val_color = (alarmSt&0x10000 && val_color == wColor) ? "grey" : wColor; if(alarmSt&0x10000) toFastCalc = true; }
  	else { 
  		if(pErrCode == 1 || pErrCode == 2)	{ val_color = wColor; val_font = "Arial 20 0 1 0 1"; }
  		else val_color = wColor;
  	}
  } else val_color = labColorGood;

  //Blink focused or linked with ElCadr
  if(this.attr("focus") ||
  	(!pNAME.isEVal() && pNAME.length && this.wdgAt("/s/pg_control/pg_ElCadr",true).attr("pgOpen") && this.wdgAt("/s/pg_control/pg_ElCadr",true).attr("prmShifr") == pNAME))
  {
  	bordColor = (bordColor == "silver") ? "grey" : "silver";
  	bordWidth = 2;
  	toFastCalc = true;
  } else bordColor = "grey", bordWidth = bordWidth_;

  if(toFastCalc != toFastCalc_)	{ toFastCalc_ = toFastCalc; this.calcPer(toFastCalc?500:-3); }


ID: cntrRegul
PARENT: /wlb_originals/wdg_Box
ATTRS: id;path;name;dscr;active;geomW;geomH;evProc;pgGrp;backColor;bordWidth;
ICO:
  iVBORw0KGgoAAAANSUhEUgAAAEAAAAArCAIAAABHOBkQAAAACXBIWXMAAA06AAANOgEDIh6FAAAE
  DklEQVRoge2ZTU8bRxjHn9mZ2fF4d/2CDREJcUFVLRRLHHyAK+LGAT4INz5Cc04lLqmUxgfU9oCE
  OPEFoK2VVEhcoKQcqFog3lC7NsZv+zrTgwtBKAmDkmhVyb/TzjP7n/3/V8/MWjJ69uy7VqsF0eE6
  PYSJTikA+L5PKfH9kFKiouWck1ardX5eD4NQZ6xfzeVy09PTio/f39//9eULbphY0zDGADA1NZXP
  5xXl5XL55YtydnjEcXq9bi8QvhE3m22HCC81Muq0mqAhzwvjHLc7vmHGpYQvcjmMtasVCACc/PlH
  iGOc6YxqGo0Vs9lCoaDooFar+WEoWhfHJ6ePCo9OT+35+Xl1+cHBQT6fd13PNA2EtFqtlrAM0GjK
  Mjzf96meyWZcx+GxWCothAiCUHie239TAAAgCQDcfzjueZ6u67quA0C9Xj88PFR0cHZ2lrASIMVQ
  JksJnRjPVSoVdXmj0cCEckz6nkZHR5eXl9llL3wYIcTz5yUCAJRSSilCqD/R7XZt21Z00G63+7Ef
  jj3oVy4uLtTlruu+OvhtOJtNZEf+efPaSmUsy+oveCtSSk1DBACqdsXTCJaSM4ooKxaLs7Ozig4Q
  Qr/8/BOhRGcmQSFmfHJyUn0LVavViYlxKTWqaQ/Gcr7v27Ydi8VUtGEYCiEIACTTQ13Xo5TGeQwQ
  chxH/Vzq9Xoj9+6BlIAwYzog1O121eWO48QN62qoadrOzg4hSkeQEAL6m5hxzji/mjg+Pt7c3FR0
  UK1WOY9fr+zt7VUqFUW5bduHv78aHh4BjVAMhLLFxUX1FlpZWSEAUH1TIdzwXD+dNP1QFIvFhYUF
  RQfb29s//vA9AGI8bsRjGqYzMzPqLbS+vm6/PnW8IJm2AteBy8ZQ0QohpJQEAEwz0e51Ol03nTT7
  yaSUig6klMlUuttu0cvXdie5ECI1lPlvwPQwDFdXVzHGCKFbF5FSCiHQkyfftFoX1ycopZlM5n2y
  GzQaDdd1bxQVmxgAfN8/Of6Lc44pp1gSyh4//vrOLXRerzU7TiqZ0AlGmNy1hba2tm4UgyBQlCOE
  KCUIk8sz/M4QAKA6g3ZXhAIIvlXwyRm9P3Z1HQRBqVS69qH9EL7vh6EgAGCYlmG+PcuOjo42NjYU
  H6/+zXofterfLMZA0zGIRCq9tLSkKGw0GqVS6R3N2mw2m83mR9pSp3l+Thlj3GIEpNr5cx3V3fb5
  +PKrtz9dwzBYW1tTFDqOo2mYAMDu7m65XP4s7j41hUJhbm7uamhZCQIAjuPU6/XoXN2BTqdzo6K9
  877/EYMAUTMIEDWDAFEzCBA1gwBRMwgQNYMAUTMIEDWDAFEzCBA1gwBRQwAAY6z4x2DkUEpvVNDT
  p9/2er1I3Hw8lNJ/AdK3tNlT+3/SAAAAAElFTkSuQmCC

PROC:
  JavaLikeCalc.JavaScript
  function setActMess(mess) {
  	if(var_addr.isEVal())	SYS.messNote("OP:"+this.ownerSess().user()+":"+NAME, "'"+NAME+"'."+mess);
  	else SYS.nodeAt(var_addr).nodePrev().messSet("'"+NAME+"'."+mess, 2, "OP", this.ownerSess().user());
  }

  txt_pnlTitle_arg0val = NAME;

  if(f_start) clc = 0;
  clc++;
  if(clc == 3) event += "usr_ElCadr";
  for(off = 0, ev_rez = ""; (ev_wrk=event.parse(0,"\n",off)).length; ) {
  	if(ev_wrk == "ws_LnAccept:/kp") { setActMess("Kp : "+DESCR+" : "+Kp+" : " +kp_value); Kp = kp_value; }
  	else if(ev_wrk == "ws_LnAccept:/ki") { setActMess("Ki : "+DESCR+" : "+Ki+" : " +ki_value); Ki = ki_value; }
  	else if(ev_wrk == "ws_LnAccept:/ti") { setActMess("Ti : "+DESCR+" : "+Ti/1000+" : " +ti_value); Ti = 1000*ti_value; }
  	else if(ev_wrk == "ws_LnAccept:/kd") { setActMess("Kd : "+DESCR+" : "+Kd+" : " +kd_value); Kd = kd_value; }
  	else if(ev_wrk == "ws_LnAccept:/td") { setActMess("Td : "+DESCR+" : "+Td/1000+" : " +td_value); Td = 1000*td_value; }
  	else if(ev_wrk == "ws_LnAccept:/tzd") { setActMess("Tzd : "+DESCR+" : "+Tzd+" : " +tzd_value); Tzd = 1000*tzd_value; }
  	else if(ev_wrk == "ws_LnAccept:/zn") { setActMess("Zn : "+DESCR+" : "+Zi+" : " +zn_value); Zi = zn_value; }
  	else if(ev_wrk == "ws_LnAccept:/h1") { setActMess("H1 : "+DESCR+" : "+Hdwn+" : " +h1_value); Hdwn = h1_value; }
  	else if(ev_wrk == "ws_LnAccept:/h2") { setActMess("H2 : "+DESCR+" : "+Hup+" : " +h2_value); Hup = h2_value; }
  	else if(ev_wrk == "ws_LnAccept:/k1") { setActMess("K1 : "+DESCR+" : "+K1+" : " +k1_value); K1 = k1_value; }
  	else if(ev_wrk == "ws_LnAccept:/k2") { setActMess("K2 : "+DESCR+" : "+K2+" : " +k2_value); K2 = k2_value; }
  	else if(ev_wrk == "ws_LnAccept:/k3") { setActMess("K3 : "+DESCR+" : "+K3+" : " +k3_value); K3 = k3_value; }
  	else if(ev_wrk == "ws_LnAccept:/k4") { setActMess("K4 : "+DESCR+" : "+K4+" : " +k4_value); K4 = k4_value; }
  	else if(ev_wrk == "ws_LnAccept:/tiPer") { setActMess("TImpPer : "+DESCR+" : "+TImpPer/1000+" : " +tiPer_value); TImpPer = 1000*tiPer_value; }
  	else if(ev_wrk == "ws_LnAccept:/tiMin") { setActMess("TImpMin : "+DESCR+" : "+TImpMin/1000+" : " +tiMin_value); TImpMin = 1000*tiMin_value; }    
  	else if(ev_wrk == "ws_LnAccept:/rfct") { setActMess("KImpRfact : "+DESCR+" : "+KImpRfact+" : " +rfct_value); KImpRfact = rfct_value; }
  	else ev_rez += ev_wrk+"\n";
  }
  event = ev_rez;

  kp_value = (kp_active=!Kp.isEVal()) ? Kp : 0;
  ki_value = (ki_active=!Ki.isEVal()) ? Ki : 0;
  ti_value = (ti_active=!Ti.isEVal()) ? Ti/1000 : 0;
  kd_value = (kd_active=!Kd.isEVal()) ? Kd : 0;
  td_value = (td_active=!Td.isEVal()) ? Td/1000 : 0;
  tzd_value = (tzd_active=!Tzd.isEVal()) ? Tzd/1000 : 0;
  zn_value = (zn_active=!Zi.isEVal()) ? Zi : 0;
  h1_value = (h1_active=!Hdwn.isEVal()) ? Hdwn : 0;
  h2_value = (h2_active=!Hup.isEVal()) ? Hup : 0;
  k1_value = (k1_active=!K1.isEVal()) ? K1 : 0;
  k2_value = (k2_active=!K2.isEVal()) ? K2 : 0;
  k3_value = (k3_active=!K3.isEVal()) ? K3 : 0;
  k4_value = (k4_active=!K4.isEVal()) ? K4 : 0;
  tiPer_value = (tiPer_active=!TImpPer.isEVal()) ? TImpPer/1000 :0;
  tiMin_value = (tiMin_active=!TImpMin.isEVal()) ? TImpMin/1000 : 0;
  rfct_value = (rfct_active=!KImpRfact.isEVal()) ? KImpRfact : 0;

  doc_tmpl = "<body bgcolor='"+backColor+"'><table style='color: "+labColor+"' border='1' cellpadding='1' cellspacing='0' width='100%'>\n";
  doc_tmpl += "<tr><td>"+tr("Id")+":</td><td>"+(SHIFR.isEVal()?"":SYS.strEncode(SHIFR,"HTML"))+"</td></tr>\n";
  doc_tmpl += "<tr><td>"+tr("Name")+":</td><td>"+(NAME.isEVal()?"":SYS.strEncode(NAME,"HTML"))+"</td></tr>\n";
  doc_tmpl += "<tr><td>"+tr("Description")+":</td><td>"+(DESCR.isEVal()?"":SYS.strEncode(DESCR,"HTML"))+"</td></tr>\n";
  doc_tmpl += "<tr><td>"+tr("Dimension")+":</td><td>"+(ed.isEVal()?"":SYS.strEncode(ed,"HTML"))+"</td></tr>\n";
  doc_tmpl += "<tr><td>"+tr("Setpoint")+":</td><td>"+(trnd_prm1val.isEVal()?"":(prec.isEVal()?trnd_prm1val:trnd_prm1val.toFixed(prec)));
  doc_tmpl += ((trnd_prm1val.isEVal() || max.isEVal() || min.isEVal() || max == min)?"":("("+(100*(trnd_prm1val-min)/(max-min).toFixed(1))+"%)"))+"</td></tr>\n";
  doc_tmpl += "<tr><td>"+tr("Variable")+":</td><td>"+(trnd_prm2val.isEVal()?"":(prec.isEVal()?trnd_prm2val:trnd_prm2val.toFixed(prec)));
  doc_tmpl += ((trnd_prm2val.isEVal() || max.isEVal() || min.isEVal() || max == min)?"":("("+(100*(trnd_prm2val-min)/(max-min).toFixed(1))+"%)"))+"</td></tr>\n";
  doc_tmpl += "<tr><td>"+tr("Output")+":</td><td>"+(trnd_prm0val.isEVal()?"":trnd_prm0val.toFixed(1)+"%")+"</td></tr>\n";
  doc_tmpl += "<tr><td>"+tr("Scale")+":</td><td>"+(min.isEVal()?"":min)+" ... "+(max.isEVal()?"":max)+"</td></tr>\n";
  doc_tmpl += "<tr><td>"+tr("Mode")+":</td><td>"+(trnd_prm3val.isEVal()?" - ":(trnd_prm3val?tr("Automate"):tr("Manual")))+"</td></tr>\n";
  doc_tmpl += "</table></body>";

  //Diagram
  trnd_prm0addr = out_addr;
  trnd_prm1addr = sp_addr;
  trnd_prm1bordL = min;
  trnd_prm1bordU = max;
  trnd_prm2addr = var_addr;
  trnd_prm2bordL = min;
  trnd_prm2bordU = max;
  trnd_prm3addr = auto_addr;
  trnd_prm4addr = impQup_addr;
  trnd_prm5addr = impQdwn_addr;


ID: ResultGraph
PARENT: /wlb_originals/wdg_Box
ATTRS: name;dscr;geomW;geomH;backColor;bordWidth;
ICO:
  iVBORw0KGgoAAAANSUhEUgAAAEAAAAAqCAIAAACMZMq1AAAACXB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FwFpkjIfx8YD/evHlTCKGUGo/HWmtvKdvttlJqWsrpHre8
  lO12O6ifji4dPSglwOOfHz969KiMJrp45uJBKQHWVtfKea31lXNXgvpJZtJ0DQM75bY2t9bX10sm
  JEly+ZvLZtcwMivefrvt5a+euhrUT1LvYDISwIhSa/9bgnQX64UAdkhG+98Sof2UqaqiiAEROCuc
  96lPqZJRhQERIC3Yy4f2026vuT/+hFL29hay/EMpG/49bmA/1Vrv6uaglEj+8lWbO83qwXCWUob2
  0ygeZfMZAEgrIfF/LU6iyXZre/ZShvaT4CPRJJ6Wz2b+UgIfiidzDlE4Z7MnXj60n1x3NytqwjkH
  UFHq8OHDJROUUtzrZkIIZx1ARcpyXmsd2o+3b9+engZ/2LOWlC/Lsk6n86GU0z2rlLLkHq9fvw7q
  x7vf342rMTAAwv2f7q//VhYOrfW1K9ca840p/3Dl4ZPnT0p4Y8yN724E9RMDy1QyMhP3B/03b96U
  TEiSBBA+8IP9gZcP7Scjd5QZAgCjNMp/cqbFrtYTQLQoI/KfnIX200jNoU4AEZgnVnif+rFq7JvG
  lB876eVD+6nXmx+/L6W1Ve+K9/bm8velLIqav6yB/RQf2qybESMDAOg974rjpbfz1WLKo+n5+cB+
  ctINaoNp+aSW3hU7ccBTQcIIPx/YT5k+EmHVSWR0qfWXMtOHlWgCAoBNnf/0OLSflsYjA4zMjPjF
  kWVz4kTJBCJaSieVQX/Kf760JEt5pVRo/988T/gZm+2WXgAAAABJRU5ErkJggg==

PROC:
  JavaLikeCalc.JavaScript
  name_arg0val = grpName.isEVal() ? "" : grpName;

  if(f_start) {
  	rows = new Array();
  	cols = new Array();
  	for(i = 0; i < 4; i++) {
  		rows[i] = this["wdg_e"+(1+i)].attr("en") || this["wdg_e"+(5+i)].attr("en") || this["wdg_e"+(9+i)].attr("en") || this["wdg_e"+(13+i)].attr("en");
  		cols[i] = this["wdg_e"+(1+i*4)].attr("en") || this["wdg_e"+(2+i*4)].attr("en") || this["wdg_e"+(3+i*4)].attr("en") || this["wdg_e"+(4+i*4)].attr("en");
  	}

  	for(xScale = 0, i = 0; i < 4; i++) xScale += cols[i]; if(xScale) xScale = 4/xScale;
  	for(yScale = 0, i = 0; i < 4; i++) yScale += rows[i]; if(yScale) yScale = 4/yScale;
  	xScale = yScale = min(xScale, yScale);

  	if(xScale > 1)
  		for(i = 1; i <= 4; i++) {
  			for(j = 1; j <= 4; j++) this["wdg_e"+((i-1)*4+j)].attrSet("geomXsc", xScale);
  			this["wdg_e"+(4+i)].attrSet("geomX", 1+224*xScale*cols[0]);
  			this["wdg_e"+(8+i)].attrSet("geomX", 1+224*xScale*(cols[0]+cols[1]));
  			this["wdg_e"+(12+i)].attrSet("geomX", 1+224*xScale*(cols[0]+cols[1]+cols[2]));
  		}
  	if(yScale > 1)
  		for(j = 1; j <= 4; j++) {
  			for(i = 1; i <= 4; i++) this["wdg_e"+((i-1)*4+j)].attrSet("geomYsc", yScale);
  			this["wdg_e"+(2+4*(j-1))].attrSet("geomY", 30+142*yScale*rows[0]);
  			this["wdg_e"+(3+4*(j-1))].attrSet("geomY", 30+142*yScale*(rows[0]+rows[1]));
  			this["wdg_e"+(4+4*(j-1))].attrSet("geomY", 30+142*yScale*(rows[0]+rows[1]+rows[2]));
  		}
  }


ID: ResultGraphEl
PARENT: /wlb_originals/wdg_Box
ATTRS: name;dscr;en;geomW;geomH;backColor;bordWidth;bordColor;bordStyle;
ICO:
  iVBORw0KGgoAAAANSUhEUgAAAEAAAAAoCAIAAADBrGu+AAAACXBIWXMAAAx1AAAMdQEteJR1AAAE
  xUlEQVRYhdWYWW/bRhRG7ywkJZGUqFCKLC+J5TiIlwe3qQ3kB/RfB30uCkRNFQc2EnlRIsXWZpkU
  KZEccmb64CB2arSNVae0D/jCuRzgfOTgDjGo0Wjs7e0hhAzDgPvG3NwcPTw8fPnypeM4T548GQ6H
  xWLRcRzDMIQQmqZ1u93Hjx+fnp5WKpV2u23bNqU0CAJd14UQqqpmMpkUA+zs7FBN02zbDoLA9/3B
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k90farr
  U/1R+xFTmBp/Pipc/LQIAPOn8wCgMe3Fby8uSpV+ZUAGd2gfuHr/xf46V0uc39V94D5y7wPQiW7s
  r23YZ0PLdTDnACARwkJwQrAQAmMAkAgDSJWxk4XFmFJoNNLWvoRGmlbpd3sP5+o/7Sy3jjkhWAoJ
  0KqtLHQ6naWlH17/7lrWsFTe2HsbK0qo3bGzUcP3dN+v8pNsME0orfTOEqqojNlnZ7np1D4bVnrd
  B6OzSNWKo5HCmMCknbb0VajKmMaYxpjlOl9VXACAvDcGACVJnr+uA4DlugBwtwLMMAchZFnWravM
  AMYYvXr1qtvt3mhau92Ooug7Od2IWq32J7gBUGA1eYbJAAAAAElFTkSuQmCC

PROC:
  JavaLikeCalc.JavaScript
  if(f_start) trnd_trcPer = max(5, (this.calcPer()==-2)?60:this.calcPer()/1000);

  en = !p1_addr.isEVal() || !p2_addr.isEVal() || !p3_addr.isEVal() || !p4_addr.isEVal() || !p5_addr.isEVal();
  title_text = title.isEVal() ? "" : title;

  p1_text = p1_name.isEVal() ? "" : p1_name; p1_color = p1_clr;
  p2_text = p2_name.isEVal() ? "" : p2_name; p2_color = p2_clr;
  p3_text = p3_name.isEVal() ? "" : p3_name; p3_color = p3_clr;
  p4_text = p4_name.isEVal() ? "" : p4_name; p4_color = p4_clr;
  p5_text = p5_name.isEVal() ? "" : p5_name; p5_color = p5_clr;

  trnd_prm0addr = p1_addr; trnd_prm0bordL = p1_min; trnd_prm0bordU = p1_max; trnd_prm0color = p1_clr;
  trnd_prm1addr = p2_addr; trnd_prm1bordL = p2_min; trnd_prm1bordU = p2_max; trnd_prm1color = p2_clr;
  trnd_prm2addr = p3_addr; trnd_prm2bordL = p3_min; trnd_prm2bordU = p3_max; trnd_prm2color = p3_clr;
  trnd_prm3addr = p4_addr; trnd_prm3bordL = p4_min; trnd_prm3bordU = p4_max; trnd_prm3color = p4_clr;
  trnd_prm4addr = p5_addr; trnd_prm4bordL = p5_min; trnd_prm4bordU = p5_max; trnd_prm4color = p5_clr;


ID: doc_panel
PARENT: /wlb_originals/wdg_Box
ATTRS: name;dscr;geomW;geomH;pgGrp;backColor;bordWidth;bordColor;
ICO:
  iVBORw0KGgoAAAANSUhEUgAAABcAAABACAIAAAB+w3u4AAAACXBIWXMAAA7EAAAOxAGVKw4bAAAG
  QElEQVRYhe1WTW/TSheeicdxbMeJHROTJi0hfJQWpapE1RWgLgBVSEBZseEHsOcnsGfJT2CBVNRN
  2JQVGzZQiCpRBGqSpk1Jm9R2Yjt2PLHHdzGv8vZy+3Lfe+/mLnoW1szxOY/nfD0euLKyks1mwe8F
  Y2zbNkKI5/l4PA5+Kd1uF2maVigUfnrh+/7Gxsb09LSu60EQxONxSZJM01RVVVGUn4whhLET4TmO
  kySJEGIYBsdxCKGPHz+ORiPLsk60PxkliiJFUQghhUIhkUgIglAulyGEmqadaI/u3LlTKpV+FfeJ
  bgixLEvX29vbzPPnzx3H4Xl+fn6+2+3G4/GZmRlCiOM4qqrKskwIgRCeO3cOY4wxLpfL3W5X07Sp
  qalUKqWqajKZRL1e7/DwUBCEmZkZ27aPjo7y+TytEc3cYDBwXdcwjOFwGIbh1tZWo9EIgkCSpLW1
  teXl5TAMYavV8n2fan3fj8VihBBZlhFCrutyHOe6ru/7kiR5njcajVRV1XVdkqRxRIeHh2htbe3i
  xYt/NS+0AnRRq9XQ5uamrus/fvzo9/vZbBZC6Pv+aDSSJEkQBNu2McbxeNxxnDNnzhwcHIiiSLe+
  72uapijK/v4+oniWZbmu22w2IYSxWIw+h8PhwcEBz/M0om63a1mWZVk8z/f7/Xw+7zgObUJE87y4
  uEhPyDCM53k8z0MIoyianp5mGIYQQp8AAEIIxpieaPwxuLOzMzk5+TeSMs5Lq9VCnue9evVKEISV
  lZVKpeI4zt27d3d3d6vVaqlU4jiu1+vpul4sFjudjud58/PzHz58uHLlytWrV9fX12/cuAEAYJ4+
  feq6Ls/zHMcNBgNBEGhrTk1NMQwjiiLGOJlMKooCIWQYJp/PDwaDbDYry7KmaZ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ZrneUtLS7du3QIARFGE
  CCGU0O/fv//+/fulpaV2u53P5wEA4+MMBgPf969fvx6GIcuyLMtijHO5HHUkhCDTNHd3d2mE5XIZ
  AFAsFul2/PdLJpNHR0d0SqiIouj7PnU0TRPV6/XXr1+DfyD7+/v/TsY8RTlFOUU5Rfk3oiB6Bfsn
  EN1u9zcd131HdACyZgAAAABJRU5ErkJggg==

PROC:
  JavaLikeCalc.JavaScript
  curTm = SYS.time();
  if(n == 0 && !time) { time = curTm; bTime = time - 30; }
  size_en = tmTp_en = Text1_en = Text2_en = prev1_en = next1_en = date_en = dateBeg_en = !n;
  szVal = time - bTime;

  //Archive size
  if(n) {
  	if(vCur >= 0)	cPos = aCur - vCur;
  	if(cPos < 0)		cPos += aSize;
  	Text3_text = Text3_text.parse(0,"\n") + "\n" + (cPos+1) + "(" + aSize + ")";
  }
  else Text3_text = Text3_text.parse(0,"\n");

  //Events process
  prevTime = time;
  for(off = 0, ev_rez = ""; (ev_cur=event.parse(0,"\n",off)).length; ) {
  	//SYS.messInfo("Trend control","Event: "+ev_cur);
  	if(ev_cur == "ws_LnAccept:/size" || ev_cur == "ws_CombChange:/tmTp") {
  		szVal = size_value;
  		if(tmTp_value == tr("m"))			szVal = szVal*60;
  		else if(tmTp_value == tr("h"))	szVal = szVal*60*60;
  		else if(tmTp_value == tr("d"))	szVal = szVal*24*60*60;
  		else if(tmTp_value.search("\\d+"+tr("s")) >= 0)	szVal = tmTp_value.toInt();
  		else if(tmTp_value.search("\\d+"+tr("m")) >= 0)	szVal = tmTp_value.toInt()*60;
  		else if(tmTp_value.search("\\d+"+tr("h")) >= 0)	szVal = tmTp_value.toInt()*60*60;
  		else if(tmTp_value.search("\\d+"+tr("d")) >= 0)	szVal = tmTp_value.toInt()*24*60*60;
  		time += 1;
  	}
  	else if(ev_cur == "ws_LnAccept:/dateBeg") { szVal = max(1, date_value-dateBeg_value); time += 1; }
  	else if(ev_cur == "ws_LnAccept:/date") time = min(curTm, max(szVal,date_value));
  	else if(ev_cur == "ws_BtPress:/curtime") {	
  		if(n == 0) time = curTm;
  		else vCur = aCur;
  	}
  	else if(ev_cur == "ws_BtPress:/prev") {
  		if(n == 0) time = min(curTm, max(szVal,time-szVal));
  		else vCur = -2;
  	}
  	else if(ev_cur == "ws_BtPress:/next") {
  		if(n == 0) time = min(curTm, max(szVal,time+szVal)); 
  		else vCur = -1;
  	}
  	else if(ev_cur == "ws_BtPress:/prev1") time = min(curTm, max(5*szVal,time-5*szVal));
  	else if(ev_cur == "ws_BtPress:/next1") time = min(curTm, max(5*szVal,time+5*szVal));
  	else ev_rez += (ev_cur+"\n");
  }
  event = ev_rez;

  //Time control
  date_value = time;
  if(n == 0 && prevTime != time) { bTime = time - szVal; doc=""; }
  if(szVal < 60)						{ tmTp_value = tr("s"); size_value = szVal; }
  else if(szVal < 60*60)			{ tmTp_value = tr("m"); size_value = szVal/60; }
  else if(szVal < 24*60*60)	{ tmTp_value = tr("h"); size_value = szVal/(60*60); }
  else									{ tmTp_value = tr("d"); size_value = szVal/(24*60*60); }
  dateBeg_value = date_value - szVal;


ID: terminator
PARENT: /wlb_originals/wdg_Box
ATTRS: name;dscr;geomW;geomH;pgGrp;backColor;bordWidth;
ICO:
  iVBORw0KGgoAAAANSUhEUgAAABcAAABACAIAAAB+w3u4AAAACXBIWXMAAAx1AAAMdQEteJR1AAAA
  2UlEQVRYhe3QsWrFMAwFUDlVsGWDDa/ZAvn5138K+QEPITVkiSEJ8hvcoUPpUG9Fd5NAh4vU8/mR
  UoKGOOcwpZTSZ4sCAF3jvSiiiCLKb0rOOcbIzH9WEAC2bTPGzPPMzESUc3bOXdfVdd00TcuyWGvv
  +9Zan+cJAIhIROu6aq2ttY/HOwJACAERvfdKKe/9cRwAQET7vjPzMAylFCLq+56ZY4whhFLKOI6l
  FGPMVxfvPQBYa2u9Ola9ct/L1+UPf2mPKKKIIooooogiiiii/GcFnXNKtRXp3l7PPUhJwkNfYgAA
  AABJRU5ErkJggg==


ID: grph_panel
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ORqNcs6LxSKMBnCYHDp06OTJk50+rK2t7dixAyHUptJ0Ot1GC8ijR48EWZYlSSqXy1evXoU+Rwjx
  PG9tbe3s2bP5fB5agyRJT58+tSwLer4sywKQkCiKqqp6nget3vd9SumZM2cajYbv+9A8i8WiZVnl
  cvl7SR87diwWi3meNzExQSltNpuFQkHTNE3T+vr6gHKh9BhjmqYB5W5sbJBIJLJtqqGUappWqVSA
  10OhkG3bjuOYI2bAD4TMEJFJo9EQGGOUUtu279+/TykFazHG1Wr10qVL+XweIaRpWiAQ0GU9GAwa
  XYZMZEmSCGMMGvPRo0fhAfhydHT05s2bnZWFESTwBxJevXoFkzEoQFOCnocxppTCWH/w4MF0KR1q
  hlzsdqvdnHPCGGs0GgghzvnCwsLk5GSxWKxUKqqqKooCSFhcXLx7966qqrFYDDD000zNGItGozD6
  7Ny5EyFUq9VUVUUIjY2N2bbdnh/AQLJ3795Dhw51xvbLly+7du2CZ+hIHz58SCaTwWCwkwTJwMDA
  +Ph4pyZjDHYWFxf379+PENrc3Ewmk22sf9eE2Lqu++zZsxMnToDDrutWKpUbN25cvHhxdHR0cHDw
  woULnWqPHz8Wjx8/HolEWq1WLBazbdu27W/fvnV1dXmeNzs7q2kajIGDg4PNZtMwDPhdXV39lzXB
  dUEQqtVqPB7nnGOMoVagEd26devkyZMPHz48f/6853mC7/uc87dv316/ft2yLFCAMejatWsLCwuc
  c0C8LMv1ej0YDH4vIKiV4eHhT58+QeEDHh3H0TQtHo9TShljnPN//vkHMgQG4vPnz09OTnZ6v7m5
  GQ6HO3d+/bOWTCb/BxJ38yV7WtdWAAAAAElFTkSuQmCC

PROC:
  JavaLikeCalc.JavaScript
  curTm = SYS.time();
  tSek = tSek ? tSek : curTm;

  //Archivators real list forming
  if(f_start) {
  	arch_items = tr("All");
  	mods = SYS.Archive.nodeList("mod_");
  	for(i_m = 0; i_m < mods.length; i_m++) {
  		vas = SYS.Archive[mods[i_m]].nodeList("val_");
  		for(i_va = 0; i_va < vas.length; i_va++)
  			arch_items += "\n"+mods[i_m].slice(4)+"."+vas[i_va].slice(4);
  	}

  	trcPer_ = max(1, trcPer);
  }

  //Events process
  for(/*ev_rez = "", */off = 0; (ev_cur=event.parse(0,"\n",off)).length; ) {
  	//SYS.messInfo("Trend control", "Event: "+ev_cur);
  	if(ev_cur == "ws_LnAccept:/size" || ev_cur == "ws_CombChange:/tmTp") {
  		tSzPrev = tSize;
  		tSize = size_value;
  		if(tmTp_value == tr("m"))			tSize = tSize*60;
  		else if(tmTp_value == tr("h"))	tSize = tSize*60*60;
  		else if(tmTp_value == tr("d"))	tSize = tSize*24*60*60;
  		else if(tmTp_value.search("\\d+"+tr("s")) >= 0)	tSize = tmTp_value.toInt();
  		else if(tmTp_value.search("\\d+"+tr("m")) >= 0)	tSize = tmTp_value.toInt()*60;
  		else if(tmTp_value.search("\\d+"+tr("h")) >= 0)	tSize = tmTp_value.toInt()*60*60;
  		else if(tmTp_value.search("\\d+"+tr("d")) >= 0)	tSize = tmTp_value.toInt()*24*60*60;
  		//if(tSize < tSzPrev && curSek < tSek && curSek > (tSek-tSzPrev)) tSek = curSek;
  	}
  	else if(ev_cur == "ws_LnAccept:/dateBeg")	{
  		tSzPrev = tSize; tSize = max(1, date_value-dateBeg_value);
  		//if(tSize < tSzPrev && curSek < tSek && curSek > (tSek-tSzPrev)) tSek = curSek;
  	}
  	else if(ev_cur == "ws_BtPress:/curstimeBeg")	{ tSize = max(1, tSek-curSek); }
  	else if(ev_cur == "ws_LnAccept:/date")		{ tSek = date_value; if(sclWin == true) sclWin = false; }
  	else if(ev_cur == "ws_BtPress:/curtime")	{ tSek = curSek = curTm; if(sclWin == true) sclWin = false; }
  	else if(ev_cur == "ws_BtPress:/curstime")	{ tSek = curSek; if(sclWin == true) sclWin = false; }
  	else if(ev_cur == "ws_BtPress:/prev")		{ tSek -= tSize/2; if(sclWin == true) sclWin = false; }
  	else if(ev_cur == "ws_BtPress:/prev1")		{ tSek -= 5*tSize; if(sclWin == true) sclWin = false; }
  	else if(ev_cur == "ws_BtPress:/next")		{ tSek += tSize/2; if(sclWin == true) sclWin = false; }
  	else if(ev_cur == "ws_BtPress:/next1")		{ tSek += 5*tSize; if(sclWin == true) sclWin = false; }
  	else if(ev_cur == "ws_CombChange:/arch")	valArch=(arch_value==tr("All")) ? "" : arch_value;
  	else if(ev_cur == "ws_CombChange:/type")	{ type = (type_value==tr("Spectrum"))?1:((type_value==tr("XY"))?2:0); if(sclWin == true) sclWin = false; }
  	else if(ev_cur == "ws_BtPress:/zoomIn")		{ sclVer *= 0.9; if(sclWin == true) sclWin = false; }
  	else if(ev_cur == "ws_BtPress:/zoomOut")	{ sclVer *= 1.1; if(sclWin == true) sclWin = false; }
  	else if(ev_cur == "ws_BtPress:/zoomOffUp")	{ sclVerOff += sclVer/10; if(sclWin == true) sclWin = false; }
  	else if(ev_cur == "ws_BtPress:/zoomOffDown")	{ sclVerOff -= sclVer/10; if(sclWin == true) sclWin = false; }
  	else if(ev_cur == "ws_BtPress:/zoomDef")	{ sclVer = 100, sclVerOff = 0; if(sclWin == true) sclWin = false; }
  	else if(ev_cur == "ws_BtPress:/xZoomIn")	sclHor *= 0.9;
  	else if(ev_cur == "ws_BtPress:/xZoomOut")	sclHor *= 1.1;
  	else if(ev_cur == "ws_BtPress:/xZoomOffRight")sclHorOff += sclHor/10;
  	else if(ev_cur == "ws_BtPress:/xZoomOffLeft") sclHorOff -= sclHor/10;
  	else if(ev_cur == "ws_BtPress:/xZoomDef")	sclHor = 100, sclHorOff = 0;
  	else if(ev_cur == "ws_BtToggleChange:/selWin") {
  		if(selWin_value && !sclWinCtx.isEVal()) {
  			sclWinCtx.tSek = tSek; sclWinCtx.tSize = tSize; sclWinCtx.sclVer = sclVer; sclWinCtx.sclVerOff = sclVerOff; }
  		else if(!selWin_value && !sclWinCtx.isEVal() && !sclWinCtx.tSek.isEVal()) {
  			tSek = sclWinCtx.tSek; tSize = sclWinCtx.tSize; sclVer = sclWinCtx.sclVer; sclVerOff = sclWinCtx.sclVerOff; }
  		sclWin = selWin_value;
  	}
  	//else ev_rez += (ev_cur+"\n");
  }
  event = "";//ev_rez;

  //scaleInfo
  scaleInfo_arg0val = 1e4/sclVer; scaleInfo_arg1val = sclVerOff;
  xScaleInfo_arg0val = 1e4/sclHor; xScaleInfo_arg1val = sclHorOff;

  //Trend time control
  date_value = tSek;
  if(tSek < curTm) trcPer = 0; else trcPer = trcPer_, tSek = 0;
  if(tSize < 60)					tmTp_value = tr("s"), size_value = tSize;
  else if(tSize < 60*60)			tmTp_value = tr("m"), size_value = tSize/60;
  else if(tSize < 24*60*60)	tmTp_value = tr("h"), size_value = tSize/(60*60);
  else									tmTp_value = tr("d"), size_value = tSize/(24*60*60);
  dateBeg_value = date_value - tSize;

  arch_value = valArch.length ? valArch : tr("All");
  cursor_en = !curSek.isEVal() && type != 2;
  if(cursor_en && type == 0) cursor_arg0val = SYS.strftime(curSek,"%d.%m.%Y %H:%M:%S") + ((curUSek && (tSize/1000) < 1)?"."+curUSek:"");
  if(cursor_en && type == 1) cursor_arg0val = tr("Frequency")+":\n"+(1e6/(1e6*curSek+curUSek)).toFixed(2)+" "+tr("Hz");
  type_value = (type==1)?tr("Spectrum"):((type==2)?tr("XY"):tr("Graph"));
  xScaleInfo_en = xZoomIn_en = xZoomOut_en = xZoomOffRight_en = xZoomOffLeft_en = xZoomDef_en = (type==2);
  selWin_en = (type == 0 && !sclWin.isEVal());
  if(selWin_en)	selWin_value = sclWin;


ID: cntrPasp
PARENT: /wlb_originals/wdg_Box
ATTRS: name;dscr;geomW;geomH;pgGrp;backColor;bordWidth;bordColor;bordStyle;
ICO:
  iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAIAAAAlC+aJAAAAA3NCSVQICAjb4U/gAAAACXBIWXMA
  AA7EAAAOxAGVKw4bAAAAYElEQVRoge3PQQ0AIBDAMMC/50MEj4ZkVbDtmVk/OzrgVQNaA1oDWgNa
  A1oDWgNaA1oDWgNaA1oDWgNaA1oDWgNaA1oDWgNaA1oDWgNaA1oDWgNaA1oDWgNaA1oDWgPaBXKq
  A32hLxFWAAAAAElFTkSuQmCC

PROC:
  JavaLikeCalc.JavaScript
  //if(f_start) focus = true;
  //if(focus) SYS.messInfo("TEST","TEST 00");

  wLst = aLst = EVAL_REAL;
  pwName = pName;
  pwName = pwName.slice(0,pwName.lastIndexOf("/"));
  req = SYS.XMLNode("info").setAttr("path", pwName+"/%2fval");
  doc_tmpl = "<body><table border='1' cellpadding='2' cellspacing='0' width='100%'>";
  if(SYS.cntrReq(req) == 0 && req.childSize()) {
  	chldRoot = req.childGet(0);
  	for(i = 0; i < chldRoot.childSize(); i++) {
  		aID = chldRoot.childGet(i).attr("id");
  		aDscr = chldRoot.childGet(i).attr("dscr");
  		reqVl = SYS.XMLNode("get").setAttr("path", pwName+"/%2fval%2f"+aID);
  		SYS.cntrReq(reqVl);
  		aVl = reqVl.text();

  		//Filter
  		if(aID == "com" || aID == "close" || aID == "stop" || aVl.isEVal()) continue;
  		if(aID == "aMax" || aID == "aMin") {
  			if(aLst.isEVal()) { aLst = aVl; continue; }
  			aDscr = tr("Alarm border");
  			if(aID == "aMax" && aLst < aVl)			aVl = "" + aLst + " ... " + aVl;
  			else if(aID == "aMin" && aLst > aVl)	aVl = "" + aVl + " ... " + aLst;
  			else aVl = tr("not set");
  		}
  		else if(aID == "wMax" || aID == "wMin") {
  			if(wLst.isEVal()) { wLst = aVl; continue; }
  			aDscr = tr("Warning border");
  			if(aID == "wMax" && wLst < aVl)			aVl = "" + wLst + " ... " + aVl;
  			else if(aID == "wMin" && wLst > aVl)	aVl = ""+aVl+" ... "+wLst;
  			else aVl = tr("not set");
  		}
  		//Put record
  		doc_tmpl += "<tr><td>"+SYS.strEncode(aDscr,"HTML")+"</td><td>"+SYS.strEncode(aVl,"HTML")+"</td></tr>\n";
  	}
  }
  doc_tmpl += "</table></body>";


ID: ElViewGraph
PARENT: /wlb_originals/wdg_Box
ICO:
  iVBORw0KGgoAAAANSUhEUgA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1GyVO83OL1qsxAAAAAElFTkSuQmCC

PROC:
  JavaLikeCalc.JavaScript
  var user_;
  if(f_start)	{
  	colorDef_ = color_ = "";
  	allowSel = this.ownerWdg(true).attr("allowSelLst").length;
  	perUserSel = this.ownerWdg(true).attr("perUserSel");

  	toCalcCycles = -max(1, 10000/this.ownerSess().period());
  	toFastCalc = toFastCalc_ = false;
  }

  toFastCalc = false;

  if(colorDef_ != colorDef || !color.length)	color = colorDef_ = colorDef;
  user = (perUserSel == true) ? this.ownerSess().user() : "";
  if(f_start || user != user_) { loadFromSess = false; user_ = user; }
  en = enForce || !name.isEVal();
  if(allowSel && ((en && name.isEVal()) || !loadFromSess)) {
  	//Load stored session's assignments
  	loadOK = false;
  	if(!loadFromSess) {
  		for(off = 0; (lnA="addr;name;dscr;min;max;ed;log;prec;aMax;aMin;wMax;wMin;pModeA;pModeC;color".parse(0,";",off)).length; )
  			if(lnA == "color") {
  				if((tVl=this.attr(user+lnA,true)).length)	color = tVl;
  			}
  			else {
  				if(!f_start) this.linkSet(lnA, "");
  				if((wA=this.attr(user+lnA,true)).length) { this.linkSet(lnA, wA); loadOK = true; }
  			}
  		//if((cVal=this.attr("color",true)).length) this.color = cVal;
  		loadFromSess = true;
  	}
  	if(!loadOK)	name = tr("<No selected>");
  }
  lb_sfr_text = name;
  if(varEl.isEVal()) lb_val_arg0val = "-";
  else if(!digStts.isEVal() && digStts.length) lb_val_arg0val = (varEl^digRevers) ? digStts.parse(0,";").parse(0,"-") : digStts.parse(1,";").parse(0,"-");
  else lb_val_arg0val = prec.isEVal() ? varEl.toPrecision(6) : ((prec < 0) ? varEl.toPrecision(abs(prec)) : ((log==true)?varEl.toExponential(prec):varEl.toFixed(prec)));
  lb_val_color = lb_sfr_color = lb_ed_color = labColorGood;
  if(varEl.isEVal() || (!min.isEVal() && max > min && varEl < min) || (!max.isEVal() && max > min && varEl > max)) lb_val_color = lb_sfr_color = lb_ed_color = "grey";
  else if(!aMax.isEVal() && !aMin.isEVal() && aMax > aMin && (varEl >= aMax || varEl <= aMin)) lb_val_color = lb_sfr_color = lb_ed_color = labColorAlarm;
  else if(!wMax.isEVal() && !wMin.isEVal() && wMax > wMin && (varEl >= wMax || varEl <= wMin)) lb_val_color = lb_sfr_color = lb_ed_color = labColorWarning;

  lb_ed_text = ed.isEVal() ? "" : ed;

  //Blink focused or linked with ElCadr
  if(this.attr("focus") ||
  		(!name.isEVal() && name.length && this.wdgAt("/s/pg_control/pg_ElCadr",true).attr("pgOpen") && this.wdgAt("/s/pg_control/pg_ElCadr",true).attr("prmShifr") == name))
  {
  	bordColor = (bordColor == "silver") ? "gray" : "silver";
  	bordWidth =  2;
  	toFastCalc = true;
  } else bordWidth =  1, bordColor = "black";

  //Check the regulator mode
  if(!enMode.isEVal() && enMode) { 
  	mode_en = true; 
  	if(!pModeC.isEVal() && pModeC) mode_text = tr("C");
  	else mode_text = pModeA.isEVal() ? "" : ((pModeA) ? tr("A") : tr("M")); 
  }
  else mode_en = false;

  //Events process
  toSave = false;
  for(evRez = "", off = 0; (evCur=event.parse(0,"\n",off)).length; ) {
  	//this.messInfo("Event: "+evCur);
  	if(evCur == "key_mouseDblClick" || evCur == "usr_hideshow") bordStyle = (bordStyle==1) ? 3 : 1;
  	//Store session's assignments
  	else if(evCur == "usr_set")	toSave = true;
  	else evRez += evCur+"\n";
  }
  event = evRez;

  if(toSave || (f_start && allowSel && !loadOK)) {
  	for(off = 0; (lnA="addr;name;dscr;min;max;log;ed;prec;aMax;aMin;wMax;wMin;pModeA;pModeC;color".parse(0,";",off)).length; )
  		if(lnA == "color")	this.attrSet(user+lnA, ((color==colorDef)?"":color), true);
  		else this.attrSet(user+lnA, this.link(lnA), true);
  }

  if(!color_.length)	color_ = color;
  if(bordStyle == 1 && color != "-")			color_ = color, color = "-";
  else if(bordStyle != 1 && color == "-")	color = color_;
  trClr_lineClr = (color.length && color != "-") ? color : "gray";

  tipTool = "";
  if(!name.isEVal())	tipTool += tr("Name")+": "+name+"\n";
  if(!min.isEVal() && !max.isEVal() && max > min) tipTool += tr("Scale")+": "+min+" ... "+max+"\n";
  if(!aMin.isEVal() && !aMax.isEVal() && aMax > aMin) tipTool += tr("Alarm border")+": "+aMin+" ... "+aMax+"\n";
  if(!wMin.isEVal() && !wMax.isEVal() && wMax > wMin) tipTool += tr("Warning border")+": "+wMin+" ... "+wMax+"\n";
  if(!dscr.isEVal()) {
  	tipTool += tr("Description")+": "+tr(dscr)+"\n";
  	tipStatus = dscr;
  }

  //Updating cycles processing for big processing periods of that page 
  if(abs(toCalcCycles) > 0.1) {
  	this.attrSet("event", this.attr("event")+"usr_calcIn\n");	//!!!! Just to calc in the next session cycle for update
  	toCalcCycles = (sign(toCalcCycles) < 0 && lb_sfr_color != "grey") ? 0 : max(0, abs(toCalcCycles)-1)*sign(toCalcCycles);
  }
  if(toFastCalc != toFastCalc_)	{ toFastCalc_ = toFastCalc; this.calcPer(toFastCalc?500:-3); }

ATTRS:
  path;perm;name;dscr;en;active;geomW;geomH;tipTool;tipStatus;contextMenu;evProc;backColor;bordWidth;bordColor;bordStyle;


ID: prescrEdit
PARENT: /wlb_originals/wdg_Box
ATTRS: name;dscr;geomW;geomH;evProc;pgGrp;backColor;bordWidth;bordColor;bordStyle;
ICO:
  iVBORw0KGgoAAAANSUhEUgAAAEAAAAAqCAIAAACMZMq1AAAACXBIWXMAAAx1AAAMdQEteJR1AAAF
  gUlEQVRYhe1ZTW8TRxh+52N37fVXDLGd1FEUEomQEqGmUpB66YkjvfYf9HfAkUt/Ab+BUwuX0N4L
  QUV1cdzg2ASEnQTbWcf27uzXTA/TLmaduhslrlUpz2G1fuaZ1/PMzM6+M4vu378Pn6Ldbuu6rmka
  QkgyQohhAUJICDF8DchAIG9s29Y0LZDJGwkpDupyzjHGoYChaKeCjlIY42q1Sim1bZtSKoRwHIdz
  nk6nDcPIZDLyPzzPs217aWmp1WoNBoNYLOY4DiHEcRxKqaqqjDFFUQCAMabrumVZs7OzvV4vmUzO
  zc01m81OpwM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SwuLiKEnj9/
  vru7OxrIdRxFVYeZU/fgF2/A9/1avSZ/GIYhuBBCEEoAoN1u7eyUAeDo6CiTybx5sw8An6/dyOfz
  pVJJ7tN1Xc9kMoVC4fDwcGFhQQhRKpVu3boFAO/evrUsa+IGFEVZu/FxmyeE2N3dlac3hBC5wQsE
  O5VKo9m0LAtjnEgkEokEADDG9vf3+/1BJpNhjDmuaxgGIcTn/qRbDwDUdd0ffnz8T8XlnU+ODFzX
  zedyuVyuVqshhBqNxszMTCqVyufz9Xp9r1YDAErpm/19AGAs6onVeUAxxqur15nFBPz1BYdgIoQA
  BJRQx7EBECCghKia1mq1Dg4OLcZ83zcMI5lMOa7LbPvtu3eu563fvGnb9uMnT765e1dRlGq1es4N
  ZDQDCGWz2YHSNwxDVVXTsnJzs/LrHUKo3bYFCO75udlZVdMQQslkIp1O9xFqtVoAEIvFCMaJZNKx
  7YODAwC4vbkpT8wd55STwAsHunfv3qkHRqcidLp/geLoEEIEXymFEH8CerzvyaSOoEAAAAAASUVO
  RK5CYII=

PROC:
  JavaLikeCalc.JavaScript
  if(f_start) save_active = false;
  progLbUpdt = progSelPrg = progSelCom = progSelTp = false;
  var comOp = "";

  //Events for commands process
  for(ev_rez = "", off = 0; (ev_cur=event.parse(0,"\n",off)).length; ) {
  	//SYS.messInfo(this.nodePath(),"Event: "+ev_cur);
  	if(ev_cur == "ws_BtPress:/progAdd") {
  		if(!progNm_value.length) progNm_value = tr("New program");
  		SYS.BD.nodeAt(dbDB,".").SQLReq("INSERT INTO "+dbProgs+" (name) VALUES ('"+progNm_value+"');");
  		lib_value = progNm_value;
  		progLbUpdt = progSelPrg = progSelCom = true; prog_value = "";
  	}
  	else if(ev_cur == "ws_BtPress:/progCopy") {
  		if(!progNm_value.length) progNm_value = tr("New program");
  		rez = SYS.BD.nodeAt(dbDB,".").SQLReq("SELECT prgTxt FROM "+dbProgs+" WHERE name='"+lib_value+"';");
  		if(rez.length > 1) {
  			SYS.BD.nodeAt(dbDB,".").SQLReq("INSERT INTO "+dbProgs+" (name, prgTxt) VALUES ('"+progNm_value+"', '"+rez[1][0].replace("'","''")+"');");
  			lib_value = progNm_value;
  			progLbUpdt = progSelPrg = progSelCom = true; prog_value = "";
  		}
  	}
  	else if(ev_cur == "ws_BtPress:/progRename") {
  		SYS.BD.nodeAt(dbDB,".").SQLReq("UPDATE "+dbProgs+" SET name='"+progNm_value+"' WHERE name='"+lib_value+"';");
  		lib_value = progNm_value;
  		progLbUpdt = progSelPrg = progSelCom = true; prog_value = "";
  	}
  	else if(ev_cur == "dlg_Apply:/progDel" && lib_value.length) {
  	//else if(ev_cur == "ws_BtPress:/progDel" && lib_value.length) {
  		SYS.BD.nodeAt(dbDB,".").SQLReq("DELETE FROM "+dbProgs+" WHERE name='"+lib_value+"';");
  		lib_value = "";
  		progLbUpdt = progSelPrg = true;
  	}
  	else if(ev_cur == "ws_TreeChange:/lib")	{ progSelPrg = progSelCom = true; prog_value = ""; }
  	else if(ev_cur == "ws_BtPress:/comAdd")	comOp = "add";
  	else if(ev_cur == "ws_BtPress:/comIns")	comOp = "ins";
  	else if(ev_cur == "ws_BtPress:/comInAdd")	comOp = "inAdd";
  	else if(ev_cur == "ws_BtPress:/comDel") comOp = "del";
  	else if(ev_cur == "ws_BtPress:/comUp")	comOp = "up";
  	else if(ev_cur == "ws_BtPress:/comDwn") comOp = "dwn";
  	else if(ev_cur == "ws_TreeChange:/prog"){ progSelCom = true; save_active = false; }
  	else if(ev_cur == "ws_CombChange:/type"){ progSelTp = true; save_active = true; }
  	else if(ev_cur == "ws_BtPress:/save" && prog_value.length) {
  		rez = SYS.BD.nodeAt(dbDB,".").SQLReq("SELECT prgTxt FROM "+dbProgs+" WHERE name='"+lib_value+"';");
  		if(rez.length > 1) {
  			comTree = selNd = SYS.XMLNode("prg"); comTree.load(rez[1][0]);
  			parentPath = "";
  			for(offPV = 0; (vIt=prog_value.parsePath(0,offPV)).length; ) {
  				if(offPV < prog_value.length) parentPath += "/"+vIt;
  				selNd = selNd.childGet((i_c=vIt.toInt()));
  			}
  			if(selNd) {
  				selNd.setAttr("id", type_value);
  				selNd.setAttr("name", name_value);
  				selNd.setAttr("descr", descr_value);
  				selNd.setAttr("backgrnd", backgrnd_value);
  				for(i_a = 1; i_a <= 5; i_a++) {
  					argObj = this["arg"+i_a];
  					argVal = argObj.attr("value");
  					if(!argObj.attr("min").isEVal()) argVal = max(argVal,argObj.attr("min"));
  					if(!argObj.attr("max").isEVal()) argVal = min(argVal,argObj.attr("max"));
  					selNd.setAttr("arg"+i_a, argVal);
  				}
  				SYS.BD.nodeAt(dbDB,".").SQLReq("UPDATE "+dbProgs+" SET prgTxt='"+comTree.save().replace("'","''")+"' WHERE name='"+lib_value+"';");
  				prog_value = parentPath+"/"+i_c+":"+(name_value.length?name_value:type_value);
  				//SYS.messInfo(this.nodePath(),"prog_value: "+prog_value);
  				progSelPrg = true;
  			}
  		}
  		save_active = false;
  	}
  	else if(ev_cur == "ws_BtPress:/progExport" && lib_value.length) {
  		rez = SYS.BD.nodeAt(dbDB,".").SQLReq("SELECT prgTxt FROM "+dbProgs+" WHERE name='"+lib_value+"';");
  		if(rez.length > 1) {
  			expTree = SYS.XMLNode("OpenSCADA_Prescr");
  			expTree.childAdd("prg").load(rez[1][0]);
  			expTree.childGet(0).setAttr("id",lib_value);
  			progExport_value = tr("Prescription-Program")+" (*.prscr)|"+tr("Prescription file")+"|"+lib_value.replace("/","_")+".prscr\n"+expTree.save(0x05);
  		}
  	} 
  	//else if(ev_cur == "ws_BtPress:/progImport")
  	else if(ev_cur == "ws_BtLoad:/progImport" && progImport_value.length && (pCtx=progImport_value.indexOf("\n")) > 0)
  	{
  		expTree = SYS.XMLNode("OpenSCADA_Prescr");
  		expTree.load(progImport_value.slice(pCtx+1));
  		progImport_value = progImport_value.slice(0,pCtx);
  		// Save all recors to DB
  		for(i_p = 0; i_p < expTree.childSize(); i_p++) {
  			treeNd = expTree.childGet(i_p);
  			if(treeNd.name() != "prg") continue;
  			if(lib_items.search(treeNd.attr("id")+"(\n|\\z)") < 0)
  				SYS.BD.nodeAt(dbDB,".").SQLReq("INSERT INTO "+dbProgs+" (name,prgTxt) VALUES ('"+treeNd.attr("id")+"','"+treeNd.save().replace("'","''")+"');");
  			else
  				SYS.BD.nodeAt(dbDB,".").SQLReq("UPDATE "+dbProgs+" SET prgTxt='"+treeNd.save().replace("'","''")+"' WHERE name='"+treeNd.attr("id")+"';");	
  		}
  		progLbUpdt = progSelPrg = progSelCom = true;
  	}
  	else if(ev_cur == "ws_LnAccept:/name" || ev_cur == "ws_TxtAccept:/descr" || ev_cur == "ws_ChkChange:/backgrnd" || (rez=ev_cur.match("ws_LnAccept:\\/arg(\\d)")).length)	save_active = true;
  	else if((rez=ev_cur.match("ws_FocusOut:\\/arg(\\d)")).length) {
  		argObj = this["arg"+rez[1]];
  		argVal = argObj.attr("value");
  		if(!argObj.attr("min").isEVal()) argVal = max(argVal,argObj.attr("min"));
  		if(!argObj.attr("max").isEVal()) argVal = min(argVal,argObj.attr("max"));
  		argObj.attrSet("value",argVal);
  	}
  	else ev_rez += (ev_cur+"\n");
  }
  event = ev_rez;

  //Get programms into library list
  if(f_start || progLbUpdt) {
  	rez = SYS.BD.nodeAt(dbDB,".").SQLReq("SELECT name FROM "+dbProgs+";");
  	lib_items = "";
  	for(i_p = 1; i_p < rez.length; i_p++)
  		lib_items += ((i_p==1)?"":"\n")+rez[i_p][0];
  	lib_items = lib_items.split("\n").sort().join("\n");
  	progNm_cfg = lib_items;
  }
  progCopy_active = progRename_active = progDel_active = progExport_active = comAdd_active = lib_value.length;

  //Command operations process
  if(comOp.length && lib_value.length) {
  	rez = SYS.BD.nodeAt(dbDB,".").SQLReq("SELECT prgTxt FROM "+dbProgs+" WHERE name='"+lib_value+"';");
  	if(rez.length > 1) {
  		comTree = selNd = SYS.XMLNode("prg");
  		comTree.load(rez[1][0]);
  		parentPath = "";
  		if(prog_value.length) {
  			for(offPV = 0; (vIt=prog_value.parsePath(0,offPV)).length; ) {
  				if(offPV < prog_value.length) parentPath += "/"+vIt;
  				selNd = selNd.childGet((i_c=vIt.toInt()));
  			}
  			selNd = selNd.parent();
  		}
  		if(comOp == "add") {
  			selNd.childAdd("com").setAttr("id",tr("New command"));
  			prog_value = parentPath+"/"+(selNd.childSize()-1)+":"+tr("New command");
  		}
  		else {
  			// Get selected command node and position
  			if(i_c < selNd.childSize()) {
  				if(comOp == "inAdd") {
  					selNd.childGet(i_c).childAdd("com").setAttr("id",tr("New command"));
  					prog_value = parentPath+"/"+i_c+":"+selNd.childGet(i_c).attr("id")+"/"+(selNd.childGet(i_c).childSize()-1)+":"+tr("New command");
  				}
  				else if(comOp == "ins") {
  					selNd.childIns(i_c,"com").setAttr("id",tr("New command"));
  					prog_value = parentPath+"/"+i_c+":"+tr("New command");
  				}
  				else if(comOp == "del") {
  					selNd.childDel(i_c);
  					if(!selNd.childSize())	prog_value = parentPath;
  					else {
  						if(i_c >= selNd.childSize()) i_c = selNd.childSize()-1;
  						prog_value = parentPath+"/"+i_c+":"+selNd.childGet(i_c).attr("id");
  					}
  				}
  				else if((comOp == "up" && i_c) || (comOp == "dwn" && i_c < (selNd.childSize()-1))) {
  					storeNd = selNd.childGet(i_c);
  					selNd.childDel(i_c);
  					if(comOp == "up") i_c--; else i_c++;
  					selNd.childIns(i_c,storeNd);
  					prog_value = parentPath+"/"+i_c+":"+storeNd.attr("id");
  				}
  			}
  		}

  		//Save changes
  		SYS.BD.nodeAt(dbDB,".").SQLReq("UPDATE "+dbProgs+" SET prgTxt='"+comTree.save().replace("'","''")+"' WHERE name='"+lib_value+"';");
  		progSelPrg = progSelCom = true;
  	}
  }

  //Get commands of selected program into commands list
  if(f_start || progSelPrg) {
  	prog_items = "";
  	if(lib_value.length) {
  		rez = SYS.BD.nodeAt(dbDB,".").SQLReq("SELECT prgTxt FROM "+dbProgs+" WHERE name='"+lib_value+"';");
  		if(rez.length > 1) {
  			comTree = SYS.XMLNode("prg");
  			comTree.load(rez[1][0]);
  			curNd = comTree; curPos = 0; curPath = ""; comLevs = new Array();
  			for( ; true; curPos++) {
  				if(curPos >= curNd.childSize()) {
  					if(!comLevs.length) break;
  					stObj = comLevs.pop();
  					curNd = curNd.parent();
  					curPos = stObj.curPos; curPath = stObj.curPath;
  					continue;
  				}
  				prog_items += (prog_items.length?"\n":"")+(wPath=curPath+"/"+curPos+":"+curNd.childGet(curPos).attr(curNd.childGet(curPos).attr("name").length?"name":"id"));
  				if(curNd.childGet(curPos).childSize()) {
  					curNd = curNd.childGet(curPos);
  					comLevs.push((stObj=new Object()));
  					stObj.curPos = curPos; stObj.curPath = curPath;
  					curPos = -1; curPath = wPath;
  					continue;
  				}
  			}
  		}
  	}
  	labProg_arg0val = progNm_value = lib_value;
  }
  comIns_active = comInAdd_active = comDel_active = comUp_active = comDwn_active = prog_value.length;

  //Get command properties
  if(f_start || progSelCom || progSelTp) {
  	if(!progSelTp) name_value = type_value = descr_value = "", backgrnd_value = false;
  	for(i_a = 1; i_a <= 5; i_a++) {
  		this["labArg"+i_a].attrSet("en",false).attrSet("text","");
  		this["arg"+i_a].attrSet("en",false).attrSet("value","");
  	}

  	// Types/commands list load
  	if(f_start && !prExtComLs.isEVal()) {
  		type_items = descr_value = ""; backgrnd_value = false;
  		for(var c_nm in prExtComLs)
  			if(c_nm != "Error" && c_nm != "Stop")
  				type_items += (type_items.length?"\n":"")+c_nm;
  	}

  	if(prog_value.length) {
  		selNd = false;
  		rez = SYS.BD.nodeAt(dbDB,".").SQLReq("SELECT prgTxt FROM "+dbProgs+" WHERE name='"+lib_value+"';");
  		if(rez.length > 1) {
  			selNd = SYS.XMLNode("prg"); selNd.load(rez[1][0]);
  			for(off = 0; (vIt=prog_value.parsePath(0,off)).length; ) selNd = selNd.childGet(vIt.toInt());
  		}
  		if(!progSelTp && selNd) {
  			name_value = selNd.attr("name");
  			type_value = selNd.attr("id");
  			descr_value = selNd.attr("descr");
  			backgrnd_value = selNd.attr("backgrnd");
  		}
  		// Load command argument's names
  		if(!prExtComLs.isEVal() && !prExtComLs[type_value].isEVal()) {
  			if((progSelTp || !descr_value.length) && (descr_value=prExtComLs[type_value]["descr"]).isEVal()) descr_value = "";
  			for(i_a = 1; i_a <= 5; i_a++) {
  				argLab = prExtComLs[type_value]["arg"+i_a];
  				if(argLab.isEVal() || !argLab.length)	continue;
  				off = 0;
  				this["labArg"+i_a].attrSet("en",true).attrSet("text",argLab.parse(0,"|",off));
  				argBord = argLab.parse(0,"|",off);
  				this["arg"+i_a].attrSet("min",argBord.length?argBord.toReal():EVAL_REAL);
  				argBord = argLab.parse(0,"|",off);
  				this["arg"+i_a].attrSet("max",argBord.length?argBord.toReal():EVAL_REAL);
  				this["arg"+i_a].attrSet("en",true);
  			}
  		}

  		// Load arguments' values
  		if(!progSelTp && selNd)
  			for(i_a = 1; selNd && i_a <= 5; i_a++) this["arg"+i_a].attrSet("value",selNd.attr("arg"+i_a));
  	}
  }
  type_active = prog_value.length;


ID: prescrRun
PARENT: /wlb_originals/wdg_Box
ATTRS: name;dscr;geomW;geomH;evProc;pgGrp;backColor;bordWidth;bordColor;
ICO:
  iVBORw0KGgoAAAANSUhEUgAAAEAAAAAqCAIAAACMZMq1AAAAA3NCSVQICAjb4U/gAAAACXBIWXMA
  AA0SAAANOgHo3ZneAAAC60lEQVRYhe2ZTU8TQRyH//Oy2+22Ai0hGiqRSvTiAb0YI1y5eODolYQP
  0LvfhJPh6BW+gIkxUeNZ8QU1bYFYCsW+zs67h01ILRSLWueyz2Ezmfll5vdcZg+DSqVSOp2GIRzW
  apO5vEcJQiiesdb2BxBC1gJCYK1FCMXf0xRCCOJlAM55KpU6DcfJGGvjfP8OvxwxrB5jjAZBcIFA
  GKSq5TJCYCzCBButpBBK62wY9iKRCQNMCFgrlWI9dnOhWK/VuywKAl8bAKOk0gTjdBj8aLQmchNK
  CKUtJaANygS+wSQdpK9endmvlJnQFGMDWknj+ZRz7nu+lNKAWVy8R/D5DtZaGoZhEATDBObmi3Pz
  xWGrZykUCsYAIVgpRSntXzqdObs0NXV39CP64ZxTa+1cYXZgx2arpbXO56b6J62FnY+fut3uycmJ
  53lSSq2U53lBmKEYtTudlO9rrVgkCCG+7+Xz077vDTgMDP6STqdDAeDWQpFSWt47yOXynXZzrjBb
  3T+QUhbnb1Sqe7npmeOj+vXZa5SQdzs7KysrhBCMsTEGY3x202Hz/xyl1Pb2NgUAIeW3cuX+g4eb
  m5vLy8ssipRSWusoijJXJjc2NtbX13e/fL1ZnLcWlpaWMpnMf+j3WxhjW1tbGACklOl0sPv58+rq
  ar1+qGK0VkpVK5W1tbVms5nNZoUQrjufAwaAiPMwDI+PDt++eT2RDSPOhZSMsVa7nZua+PjhPY+6
  GKNWu+267TlQhNCLl68opdZajPHB9xoAxNdzubIXh44bP+LBBVeyKygAtFstpZW1gBEihERCBik/
  n8+77jYSVCm98PjJKFEjeeP503EXuiwUIXh0Z2aUqODRs+fj7nNpKADcnvZHiTKmx1zmT/gff5yx
  kgi4JhFwTSLgmkTANYmAaxIB1yQCrkkEXJMIuCYRcE0i4JpEwDWJgGsoADQajVGinEcIQAgx8CLo
  Cs45AKBSqTTwdn0xxpixVbo0vV7vJ+y1bVFUL+7MAAAAAElFTkSuQmCC

PROC:
  JavaLikeCalc.JavaScript
  //Get programms into library list
  if(f_start) {
  	prEndRun = true;
  	lib_value = "";
  	btStop_active = false;
  	prCnt = 0;
  }
  if(prExtMode.isEVal() || prExtProg.isEVal() || prExtStartTm.isEVal() || prExtCurCom.isEVal() || prExtWork.isEVal())
  	return;

  //Check for program list update
  if(f_start || (prCnt%max(1,f_frq)) == 0) {
  	rez = SYS.BD.nodeAt(dbDB,".").SQLReq("SELECT name FROM "+dbProgs+";");
  	curPrLst = "";
  	for(i_p = 1; i_p < rez.length; i_p++)
  		curPrLst += (curPrLst.length?"\n":"")+rez[i_p][0];
  	curPrLst = curPrLst.split("\n").sort().join("\n");
  	if(curPrLst != lib_items) lib_items = curPrLst;
  }

  //Check for ready
  btStart_active = prExtProg.length;

  if(prExtMode <= 0)		{ btStart_img = "start"; btStart_value = false; btStop_active = btPass_active = false; }
  else if(prExtMode == 1){ btStart_img = "pause"; btStart_value = false; btStop_active = btPass_active = true; prEndRun = false; }
  else if(prExtMode == 2){ btStart_img = "start"; btStart_value = true; btStop_active = true; btPass_active = true; }

  //Prepare call status document
  pTxt = "";
  if((prExtMode == 1 || prExtMode == 2 || prExtMode == 3 || ((prCnt%max(1,f_frq)) == 0 && prExtMode <= 0))) {
  	pTxt = "<body>";
  	off = 0;
  	labProg_arg0val = prExtWork.attr("name");

  	if(prExtMode < 0 && !prEndRun) {
  		prEndRun = true;
  		prog_aCur = -1;	//Archiving
  	}

  	//Build result table
  	pTxt += "<i>"+tr("Program:")+" </i>"+Special.FLibSYS.strEnc2HTML(labProg_arg0val)+"<br/>\n";
  	if(prExtMode > 0 || (prExtMode < 0 && prog_aCur < 0)) {
  		pTxt += "<i>"+tr("Started:")+" </i>"+SYS.strftime(prExtStartTm)+"<br/>\n";
  		if(prog_aCur < 0) {
  			if(prExtMode == -1) pTxt += "<i>"+tr("Status:")+" </i>"+tr("Error")+"<br/>\n";
  			else if(prExtMode == -2) pTxt += "<i>"+tr("Status:")+" </i>"+tr("Successful finish")+"<br/>\n";
  			else if(prExtMode == -3) pTxt += "<i>"+tr("Status:")+" </i>"+tr("Terminated")+"<br/>\n";
  			else pTxt += "<i>"+tr("Status:")+" </i>"+tr("Unknown")+"<br/>\n";
  		}
  	}
  	if(prExtMode == 1) {
  		wtm = max(0,prExtWork.attr("wtm").toInt()-(SYS.time()-prExtStartTm));
  		pTxt += "<i>"+tr("Remain:")+" </i>"+(wtm/3600).toString(10)+":"+((wtm/60)%60).toString(10,2)+":"+(wtm%60).toString(10,2)+"<br/>";
  	}
  	pTxt += "<table border='1' cellpadding='2' cellspacing='0' width='100%'>\n"
  					"<tr><th>"+tr("#")+"</th><th>"+tr("Command")+"</th><th>"+tr("Comments")+"</th><th>"+tr("Time")+"</th>";
  	pTxt += "</tr>\n";

  	for(comElN = prExtWork, comPos = 0, comLev = 0, comCur = true, comAftCur = false, comN = "", comPath = ""; true; comPos++) {
  		if(comPos >= comElN.childSize()) {
  			if((comElN=comElN.parent())) {
  				comLev--;
  				comPos = comElN.attr("seekPos").toInt();
  				comCur = comElN.attr("comCur").toInt();
  				comN = comElN.attr("comN");
  				comPath = comElN.attr("comPath");
  				continue;
  			}
  			break;
  		}
  		comEl = comElN.childGet(comPos);
  		comN_ = (comN.length?comN+":":"") + comPos;
  		comPath_ = (comPath.length?comPath+": ":"") + (comEl.attr("name").length?comEl.attr("name"):comEl.attr("id"));
  		isCurCmd = comCur && (tmpComLv=prExtCurCom.parse(comLev,":")).length && tmpComLv.toInt() == comPos && !prExtCurCom.parse(comLev+1,":").length;
  		if(isCurCmd) comAftCur = true;
  		rezVl = comEl.attr("rez");
  		toMark = true;
  		if((isCurCmd || (rezVl.length && rezVl.toInt() == 0)) && (prExtMode > 0 || (prExtMode < 0 && prog_aCur < 0)))				pTxt += "<tr class='"+(prEndRun?"err":"run")+"'>";
  		else if(!comAftCur && (prExtMode > 0 || (prExtMode < 0 && prog_aCur < 0)))	pTxt += "<tr class='"+((rezVl.toInt()==-10)?"skip":((rezVl.toInt()<0)?"err":"pass"))+"'>";
  		else { pTxt += "<tr>"; toMark = false; }
  		pTxt += "<td>"+comN_+"</td>";
  		pTxt += "<td>"+Special.FLibSYS.strEnc2HTML(comPath_)+(comEl.attr("backgrnd")?" "+tr("(background)"):"")+"</td><td>";
  		if(toMark && rezVl.parse(1,":").length) pTxt += Special.FLibSYS.strEnc2HTML(rezVl.parse(1,":"));
  		else {
  			//Arguments values
  			for(i_a = 1; i_a <= 5; i_a++)
  				if(comEl.attr("labArg"+i_a).length)
  					pTxt += Special.FLibSYS.strEnc2HTML(comEl.attr("labArg"+i_a).parse(0,"|")+" = "+comEl.attr("arg"+i_a)+"; ");
  		}
  		pTxt += "</td>";
  		comTm = comEl.attr("tm").toInt();
  		if(toMark && comTm) {
  			comTm -= prExtStartTm;
  			pTxt += "<td>"+(comTm/3600).toString(10)+":"+
  									((comTm/60)%60).toString(10,2)+":"+
  									(comTm%60).toString(10,2)+"</td>";
  		}
  		else pTxt += "<td>---</td>";
  		pTxt += "</tr>\n";

  		if(comEl.childSize()) {
  			comElN.setAttr("seekPos",comPos).setAttr("comCur",comCur).setAttr("comN",comN).setAttr("comPath",comPath);
  			comElN = comEl;
  			comCur = comCur && (tmpComLv=prExtCurCom.parse(comLev,":")).length && tmpComLv.toInt() == comPos;
  			comPos = -1; comLev++; comN = comN_; comPath = comPath_;
  		}
  	}
  	pTxt += "</table></body>";
  }

  if(!prExtProg.length && f_start) pTxt = "<body><H1>"+tr("Select a program please")+"</H1></body>";

  if(pTxt.length) {
  	this.prog.attrSet("aDoc",pTxt);
  	if(this.prog.attr("aCur") == this.prog.attr("vCur")) prog_doc = pTxt;
  }

  prCnt++;

  //Events for commands process
  for(ev_rez = "", off = 0; (ev_cur=event.parse(0,"\n",off)).length; ) {
  	//SYS.messDebug("Prescription edit control","Event: "+ev_cur);
  	if(ev_cur == "ws_TreeChange:/lib") {
  		prog_vCur = prog_aCur;
  		prExtProg = lib_value;
  	}
  	else if(ev_cur == "ws_BtPress:/btStart") {
  		if(prExtMode <= 0)	prExtMode = 1;
  		else if(prExtMode == 1)	prExtMode = 2;
  		prog_vCur = prog_aCur;
  	}
  	else if(ev_cur == "ws_BtRelease:/btStart")	prExtMode = 1;
  	else if(ev_cur == "ws_BtPress:/btStop" && prExtMode >= 0) {
  		prExtMode = prExtCurCom = 0;
  		prog_vCur = prog_aCur;
  	}
  	else if(ev_cur == "ws_BtPress:/btPass" && (prExtMode == 1 || prExtMode == 2))	prExtMode = 3;
  	else ev_rez += (ev_cur+"\n");
  }
  event = ev_rez;

  //Programm select process
  if(!prExtProg.length || lib_items.search("^"+prExtProg.replace(new RegExp("(\\[|\\]|\\(|\\)|\\.|\\+|\\*|\\?|\\^|\\$|\\<|\\>|\\{|\\}|\\\\)","g"),"\\$1")+"$","m") < 0)
  	prExtProg = lib_value;
  else lib_value = prExtProg;


ID: prescrRunSimple
PARENT: /wlb_originals/wdg_Box
ATTRS: name;dscr;geomW;geomH;evProc;backColor;bordWidth;bordColor;bordStyle;
ICO:
  iVBORw0KGgoAAAANSUhEUgAAAEAAAAArCAIAAABHOBkQAAAAA3NCSVQICAjb4U/gAAAACXBIWXMA
  AA7EAAAOxAGVKw4bAAAE0ElEQVRoge2Vy28TVxSHz525nvG8HNtjO2+TEBJqAoEoJBREqSLooqrK
  gj1do6Z/BH9EkYBVoMuyYAeqIkpbYlKkQNqkOAlJbEwcO37FnhnP2PPsghRBFsVQpCmSv9Xo3qtz
  ft89Mxp0+/btSqUCHyeJRAJXKpVUKuV2kvckl8vhZs49mb2fq5nIqLV1HBja10ExLMd4CoVyOCxm
  t7IeiiJJ0ssKNGkXSjtBMShJNYGl6oalNwy/j1XqJk06St2MhPwzP82Mjh2nGZZnqEKhFIqIsqRi
  5NAcVymV/KJYym8blk1RlK7rvM/v9/H/nq0pAdtGJ06fIZXc/OL6vdSGB5N97XxVt5KZQGY9fXAg
  spaVSIDB3sDjP/7q7BtcW0mNDnftqLD6dP3MZ8PpbZNH1ZVk9suvvnAI4t79WcpD7u8U1jOFrv4h
  uSgHaANz3tVkJtTZK+e2/ALFRqIby4nJc+femo1oRuANY4omCTAti2UZQzf9wXB7KOihvASC7ex2
  uD1i6rrI40ylTgJ0BZlnWZki7GJZCQrsxtpG3/5+7KFIhHTdAJKiMKEqUlVWajUVEEF7MCv4u9sj
  Yrg9GAiGRf/b8zQTeuDQMEtjRIYG+7XVVPHo6EiAp9Kb2e7eruqOAlpR4LiRI8exreXLksDzjm07
  iCAQwOFDFiACkbbRrzZshvFytJPmuGNjRwM8HXi+2RPt5TBZKWVJX+94dzTU2a3KCkdjoFnu2JFm
  sqHp6enmP2JT16SaEQz4Xl9sqLJmkX6Bba5CvaroYvDNCpqiGcjv45qM8YpkMokBwLZthvHu2Ws0
  GggQRVOvL9I0hUhtz0maFeimW2LKKwb39qIZnmaaLrGnIAD0RXvGRo89XV6VZAUA2nx87JOD6xtJ
  nuN8PmHp6bJlO+DY0d6e3p7ue/d/oSkae5p69z44uq5T1O6dbmVzuwIIEbNzjw4fGfn8wAGWZRcW
  Fh7+/igSCjX0xuzDxNfnz0ciEVVVZ2ZmdF33YHzy0wlwHFcEJEn2+YSXz4/mH6+trWMAkBUFY8/4
  +Pj169ej0ejZs2cTiYSsKMVSeez4eD6fv3r1KsdxU1NTN2/c4DnGNE3Htl0RME1DURRJknied2wH
  Xk6gXq+LIk8QRDwev3v3biwWY1lWq8myLAmCsLS0dOfOnVgsxjCMaZq245im6bg0AcO0TEubvvnD
  Nxcv2o69K+AThOfpdKVSuXDhwuTkJEmSqVRyf/++DtQxPz8/MTFx+fLltra2ZDJJEMhxHNM0bbcm
  YJkCz3839S0A2C/+ESBJYnCg79q1a6dOnVpcXHwYjw/070OI6GiPrKw8i8fjIyMj+Xz+1q0fT588
  sfJsTdd1260JGIZuGLsyprUrUFPVrq5Omvb+ufAEEAwNDXAsu7mZsSxrePhQsVSMP/iN47nxsVHL
  tlVV+/nXBwR651/4B8F27FetTcvcFSgWy7SXBQCG4wGgVK6WylWCwFpdf5HJAoDQ5geArVwBAEKh
  MCLcSb8HRVGSG0kMAEFRvHTpktt53pnV1ZW5ubn/xV3+F1oCbtMScJuWgNu0BNymJeA2LQG3aQm4
  TUvAbVoCbtMScJuWgNt89AIYAHZ2yleufO92kndGUzWMMV5eXs5ms+n0C7fzvA+yLP8NrZUdC69n
  Pt0AAAAASUVORK5CYII=

PROC:
  JavaLikeCalc.JavaScript
  //Get programms into library list
  if(f_start) {
  	prEndRun = true;
  	lib_name = lib_selValue = "";
  	btStop_active = false;
  	prCnt = 0;
  }
  if(prExtMode.isEVal() || prExtProg.isEVal() || prExtStartTm.isEVal() || prExtCurCom.isEVal() || prExtWork.isEVal())
  	return;

  //Check for program list update
  if(f_start || (prCnt%max(1,f_frq)) == 0) {
  	rez = SYS.BD.nodeAt(dbDB,".").SQLReq("SELECT name FROM "+dbProgs+";");
  	curPrLst = "";
  	for(i_p = 1; i_p < rez.length; i_p++)
  		curPrLst += (curPrLst.length?"\n":"")+rez[i_p][0];
  	curPrLst = curPrLst.split("\n").sort().join("\n");
  	if(curPrLst != lib_items) lib_items = curPrLst;
  }

  //Check for ready
  btStart_active = prExtProg.length;

  if(prExtMode <= 0)		{ btStart_img = "start"; btStart_value = false; btStop_active = btPass_active = false; }
  else if(prExtMode == 1){ btStart_img = "pause"; btStart_value = false; btStop_active = btPass_active = true; prEndRun = false; }
  else if(prExtMode == 2){ btStart_img = "start"; btStart_value = true; btStop_active = true; btPass_active = true; }

  //Prepare call status document
  pTxt = "";
  if((prExtMode == 1 || prExtMode == 2 || prExtMode == 3 || ((prCnt%max(1,f_frq)) == 0 && prExtMode <= 0))) {
  	pTxt = "<body>";
  	//off = 0;
  	labProg_arg0val = prExtWork.attr("name");

  	if(prExtMode < 0 && !prEndRun)	prEndRun = true;

  	//Build result
  	pTxt += "<i>"+tr("Program:")+" </i>"+Special.FLibSYS.strEnc2HTML(lib_name);
  	if(prExtMode > 0) pTxt += "\n<br/><i>"+tr("Started:")+" </i>"+SYS.strftime(prExtStartTm);
  	if(prExtMode == 1) {
  		wtm = max(0,prExtWork.attr("wtm").toInt()-(SYS.time()-prExtStartTm));
  		pTxt += "\n<br/><i>"+tr("Remain:")+" </i>"+(wtm/3600).toString(10)+":"+((wtm/60)%60).toString(10,2)+":"+(wtm%60).toString(10,2);
  	}
  	if(prExtMode > 0 && prExtCurCom.parse(0,":").toInt() < prExtWork.childSize()) {
  		pTxt += "<table border='1' cellpadding='2' cellspacing='0' width='100%'>\n"
  					"<tr><th>"+tr("#")+"</th><th>"+tr("Command")+"</th><th>"+tr("Comments")+"</th><th>"+tr("Time")+"</th></tr>\n";
  		for(comElN = prExtWork, comPos = 0, comLev = 0, comN = "", comPath = ""; true; comPos++) {
  			if(comPos >= comElN.childSize()) {
  				if((comElN=comElN.parent())) {
  					comLev--;
  					comPos = comElN.attr("seekPos2").toInt();
  					comN = comElN.attr("comN2");
  					comPath = comElN.attr("comPath2");
  					continue;
  				}
  				break;
  			}
  			comEl = comElN.childGet(comPos);
  			comN_ = (comN.length?comN+":":"") + comPos;
  			comPath_ = (comPath.length?comPath+": ":"") + (comEl.attr("name").length?comEl.attr("name"):comEl.attr("id"));
  			rezVl = comEl.attr("rez");
  			toMark = true;
  			if((rezVl.length && rezVl.toInt() == 0)) {
  				pTxt += "<tr class='" + (prEndRun?"err":"run") + "'>" +
  					"<td>" + comN_ + "</td>"+
  					"<td>" + Special.FLibSYS.strEnc2HTML(comPath_) + "</td><td>";
  				if(toMark && rezVl.parse(1,":").length) pTxt += Special.FLibSYS.strEnc2HTML(rezVl.parse(1,":"));
  				else {
  					//Arguments values
  					for(i_a = 1; i_a <= 5; i_a++)
  						if(comEl.attr("labArg"+i_a).length)
  							pTxt += Special.FLibSYS.strEnc2HTML(comEl.attr("labArg"+i_a).parse(0,"|")+" = "+comEl.attr("arg"+i_a)+"; ");
  				}
  				pTxt += "</td>";
  				comTm = comEl.attr("tm").toInt();
  				if(toMark && comTm) {
  					comTm -= prExtStartTm;
  					pTxt += "<td>"+(comTm/3600).toString(10)+":"+
  										((comTm/60)%60).toString(10,2)+":"+
  										(comTm%60).toString(10,2)+"</td>";
  				}
  				else pTxt += "<td>---</td>";
  				pTxt += "</tr>\n";
  			}

  			if(comEl.childSize()) {
  				comElN.setAttr("seekPos2",comPos).setAttr("comN2",comN).setAttr("comPath2",comPath);
  				comElN = comEl;
  				comPos = -1; comLev++; comN = comN_; comPath = comPath_;
  			}
  		}
  		pTxt += "</table>";

  		/*comN = 0;
  		if(prExtMode == 0)	comEl = prExtWork.childGet(0);
  		else {
  			comEl = prExtWork;
  			for(off = 0; comEl && (tVl=prExtCurCom.parse(0,":",off)).length; )	comEl = comEl.childGet(tVl.toInt());
  			if(!comEl) comEl = prExtWork.childGet(0); else comN = prExtCurCom;
  		}
  		for(comPath = "", comElI = comEl; comElI; comElI = comElI.parent())
  			if(comElI.name() == "com")
  				comPath = comElI.attr(comElI.attr("name").length?"name":"id")+(comPath.length?": ":"")+comPath;
  		rezVl = comEl.attr("rez");
  		if(prExtMode != 0) pTxt += "<tr class='"+((prExtMode==-1)?"err":"run")+"'>";
  		else pTxt += "<tr>";
  		pTxt += "<td>"+comN+"</td>";
  		pTxt += "<td>"+Special.FLibSYS.strEnc2HTML(comPath)+"</td><td>";
  		if(rezVl.parse(1,":").length) pTxt += Special.FLibSYS.strEnc2HTML(rezVl.parse(1,":"));
  		else {
  			//Arguments values
  			for(i_a = 1; i_a <= 5; i_a++)
  				if(comEl.attr("labArg"+i_a).length)
  					pTxt += Special.FLibSYS.strEnc2HTML(comEl.attr("labArg"+i_a).parse(0,"|")+" = "+comEl.attr("arg"+i_a)+"; ");
  		}
  		pTxt += "</td>";
  		comTm = comEl.attr("tm").toInt();
  		if(!comTm) pTxt += "<td>---</td>";
  		else {
  			comTm -= prExtStartTm;
  			pTxt += "<td>"+(comTm/3600).toString(10)+":"+
  									((comTm/60)%60).toString(10,2)+":"+
  									(comTm%60).toString(10,2)+"</td>";
  		}
  		pTxt += "</tr>\n</table>";*/
  	}
  	pTxt += "</body>";
  }

  if(!prExtProg.length && f_start) pTxt = "<body><H1>"+tr("Select a program")+"</H1></body>";

  if(pTxt.length)	prog_doc = pTxt;

  prCnt++;

  //Events for commands process
  for(ev_rez = "", off = 0; (ev_cur=event.parse(0,"\n",off)).length; ) {
  	//SYS.messInfo("Prescription edit control","Event: "+ev_cur);
  	//if(ev_cur == "ws_CombChange:/lib") prExtProg = lib_name;
  	//if(ev_cur.slice(0,11) == "ws_BtMenu=/")	prExtProg = ev_cur.slice(11).parse(0,":");
  	if(ev_cur == "dlg_Apply:/lib")	prExtProg = lib_selValue;
  	else if(ev_cur == "ws_BtPress:/btStart") {
  		if(prExtMode <= 0)			prExtMode = 1;
  		else if(prExtMode == 1)	prExtMode = 2;
  	}
  	else if(ev_cur == "ws_BtRelease:/btStart")	prExtMode = 1;
  	else if(ev_cur == "ws_BtPress:/btStop" && prExtMode >= 0)	prExtMode = prExtCurCom = 0;
  	else if(ev_cur == "ws_BtPress:/btPass" && (prExtMode == 1 || prExtMode == 2))	prExtMode = 3;
  	else ev_rez += (ev_cur+"\n");
  }
  event = ev_rez;

  //Programm select process
  if(!prExtProg.length || lib_items.search("^"+prExtProg.replace(new RegExp("(\\[|\\]|\\(|\\)|\\.|\\+|\\*|\\?|\\^|\\$|\\<|\\>|\\{|\\}|\\\\)","g"),"\\$1")+"$","m") < 0)
  	prExtProg = lib_name;
  else lib_name = lib_selValue = prExtProg;


ID: accept
PARENT: /wlb_originals/wdg_Box
ATTRS: name;dscr;geomW;geomH;pgGrp;backColor;bordWidth;
ICO:
  iVBORw0KGgoAAAANSUhEUgAAAEAAAAAeCAIAAAATj48OAAAAA3NCSVQICAjb4U/gAAAACXBIWXMA
  AA7EAAAOxAGVKw4bAAADx0lEQVRYhe2X3W/bVBjGX9vHTh27+XCSJWlamvSLds0qsY1O2kDbQIML
  LiYViRX1DgkEUoS44KITEn8LAuUGcVcxCQbthgasWwordEALydZpLW3WNHbjJE7OsQ8XiQrctI0L
  sirld2HZR3re93l85HOOmVQq5fV64WiiaRqSZXlyctJpJzZJp9Os0x4OSzuA07QDOE07gNOgVgWV
  ncLMteuU4Sdee1VgDqah9M6tOSqFz5wcbbXdvrQcQOxUBsK+jr6TczOfbdUEXwcriq71RzklGr+3
  kHll4kpfUPjo05kLz5/9evbGC5demrv+xdip07Nf3jx38fy1z9cAAKglcrXVIgl7xIgi389turgS
  x/s3tv4cHBm/dP70/xuAYZqvPTM/bwihiJeJ9o+Wyub40HAxnz8xMrC6+G0glsivZiPd0YXvbsvB
  SHYl19Mbf/wwi6uWSSmHkP4kt1UT9ZC0UCjybpnS+tCwghCvqaVW/bQcAAAGxk6xbs9bqXe3K5bk
  4gAADydcnZ4LL15kAOJjZ1Tz3tPHR1d+Wx5JJn//5ef40PH1B8tKV/yP+z/VTev295k33k7li4ZX
  EkSBL2iaLHfqeiXSFS7rtVbNMNPT01NTUzZi2EbXdUmSmQN+P3uSTqftzMAhkWX5P6x25JfRdgCn
  aQdwmiMfACmKsrS05LQNmyiKgmKxWDKZdNqJTSilNjcyvVRiwbLd2KjXff6AVtx2CXxzyMTA8QAA
  BAPi99A2sChlEQ/2zkIAQKnlcvEAsInzmOJuIWZYxleluWfcJ2J8977yWr1OKeUR2wjAUBpb/Ljg
  HWU31/lHy+rU1f0NAFQMbD8AAGBCAECi0pvknXP47B02M829f4yJ3Prmpqqq0Xgfb2K9bnndqFgm
  PEPdbrF/cIhHLACYptm4NooAwFpwPJH5BG8UH1y+SnE9c/cucDxiGSSIpKyqhhn0yZhYsj84mOgB
  AKCUAoDtVYhSignBhLAWF9bDs8aND40P4iiOCYl093hEQatUtXKVAmsSgk0aCAa0wsbjzUJDZVom
  ABDTbDxijF0rPxhPdPprHs0vYNOUJMnjD/gVn1bYqJjQ4XYjgVfVnUql0pQQAkAPNwMYN25eN650
  uaMe5GmMhEKhgKIwHLd73OwFAIDQsdCu6u8ZaBShFFdqyy+/xz6ruX9cxJj09vVDUxXZ7fhUb+Kf
  fTmesx+A5VC1tNP0J8aBQtX491Eek73kLMcwDDEtTJqqtecmAAA8SimeAONAfwWK5AEAlMvlWNaB
  7aywXTxkhaK6k81m/wJAAK2A/KcOawAAAABJRU5ErkJggg==

PROC:
  JavaLikeCalc.JavaScript
  if(f_start) mess_text = elMess;

  //Events for commands process
  for(off = 0, ev_rez = ""; (ev_cur=event.parse(0,"\n",off)).length; ) {
  	//SYS.messDebug("Prescription edit control","Event: "+ev_cur);
  	if(ev_cur == "ws_BtPress:/apply") {
  		elEvent += "dlg_Apply\n";
  		this.attrSet("pgOpen",false);
  	}
  	else if(ev_cur == "ws_BtPress:/cancel")	this.attrSet("pgOpen", false);
  	else ev_rez += (ev_cur+"\n");
  }
  event = ev_rez;


ID: treeSelect
PARENT: /wlb_originals/wdg_Box
ATTRS: name;dscr;geomW;geomH;pgGrp;backColor;bordWidth;
ICO:
  iVBORw0KGgoAAAANSUhEUgAAAEAAAAAeCAIAAAATj48OAAAAA3NCSVQICAjb4U/gAAAACXBIWXMA
  AA7EAAAOxAGVKw4bAAADx0lEQVRYhe2X3W/bVBjGX9vHTh27+XCSJWlamvSLds0qsY1O2kDbQIML
  LiYViRX1DgkEUoS44KITEn8LAuUGcVcxCQbthgasWwordEALydZpLW3WNHbjJE7OsQ8XiQrctI0L
  sirld2HZR3re93l85HOOmVQq5fV64WiiaRqSZXlyctJpJzZJp9Os0x4OSzuA07QDOE07gNOgVgWV
  ncLMteuU4Sdee1VgDqah9M6tOSqFz5wcbbXdvrQcQOxUBsK+jr6TczOfbdUEXwcriq71RzklGr+3
  kHll4kpfUPjo05kLz5/9evbGC5demrv+xdip07Nf3jx38fy1z9cAAKglcrXVIgl7xIgi389turgS
  x/s3tv4cHBm/dP70/xuAYZqvPTM/bwihiJeJ9o+Wyub40HAxnz8xMrC6+G0glsivZiPd0YXvbsvB
  SHYl19Mbf/wwi6uWSSmHkP4kt1UT9ZC0UCjybpnS+tCwghCvqaVW/bQcAAAGxk6xbs9bqXe3K5bk
  4gAADydcnZ4LL15kAOJjZ1Tz3tPHR1d+Wx5JJn//5ef40PH1B8tKV/yP+z/VTev295k33k7li4ZX
  EkSBL2iaLHfqeiXSFS7rtVbNMNPT01NTUzZi2EbXdUmSmQN+P3uSTqftzMAhkWX5P6x25JfRdgCn
  aQdwmiMfACmKsrS05LQNmyiKgmKxWDKZdNqJTSilNjcyvVRiwbLd2KjXff6AVtx2CXxzyMTA8QAA
  BAPi99A2sChlEQ/2zkIAQKnlcvEAsInzmOJuIWZYxleluWfcJ2J8977yWr1OKeUR2wjAUBpb/Ljg
  HWU31/lHy+rU1f0NAFQMbD8AAGBCAECi0pvknXP47B02M829f4yJ3Prmpqqq0Xgfb2K9bnndqFgm
  PEPdbrF/cIhHLACYptm4NooAwFpwPJH5BG8UH1y+SnE9c/cucDxiGSSIpKyqhhn0yZhYsj84mOgB
  AKCUAoDtVYhSignBhLAWF9bDs8aND40P4iiOCYl093hEQatUtXKVAmsSgk0aCAa0wsbjzUJDZVom
  ABDTbDxijF0rPxhPdPprHs0vYNOUJMnjD/gVn1bYqJjQ4XYjgVfVnUql0pQQAkAPNwMYN25eN650
  uaMe5GmMhEKhgKIwHLd73OwFAIDQsdCu6u8ZaBShFFdqyy+/xz6ruX9cxJj09vVDUxXZ7fhUb+Kf
  fTmesx+A5VC1tNP0J8aBQtX491Eek73kLMcwDDEtTJqqtecmAAA8SimeAONAfwWK5AEAlMvlWNaB
  7aywXTxkhaK6k81m/wJAAK2A/KcOawAAAABJRU5ErkJggg==

PROC:
  JavaLikeCalc.JavaScript
  if(f_start) { select_items = elItems; select_value = selValue; }

  //Events for commands process
  for(off = 0, ev_rez = ""; (ev_cur=event.parse(0,"\n",off)).length; ) {
  	//SYS.messInfo("Prescription edit control","Event: "+ev_cur);
  	if(ev_cur == "ws_BtPress:/apply") {
  		if(select_value.length)	{ selValue = select_value; elEvent += "dlg_Apply\n"; }
  		this.attrSet("pgOpen", false);
  	}
  	else if(ev_cur == "ws_BtPress:/cancel")	this.attrSet("pgOpen", false);
  	else ev_rez += ev_cur + "\n";
  }
  event = ev_rez;


ID: TextLab
PARENT: /wlb_originals/wdg_Text
ATTRS: name;dscr;active;geomW;geomH;contextMenu;evProc;backColor;bordWidth;bordColor;font;alignment;text;
ICO:
  iVBORw0KGgoAAAANSUhEUgAAAEAAAAAXCAIAAAA0gN7GAAAAA3NCSVQICAjb4U/gAAAACXBIWXMA
  AA7EAAAOxAGVKw4bAAABHUlEQVRYhWNgGOKAkYGBIScnh5ube6BdQjL4+vXrlClTWBgYGDg4ODg5
  OQfaPSSDv3//MjAwMA20MygFox4YaDDqgYEGox4YaDDkPcBCke6/Hx9cv/fszcdfCCFWHgFhKRmu
  51fufUZRyqukI/ntybO3H778Rgiy8YtIKWkq8DOT7wQKPfDp4dXzZ64/QnIrt4S8ijGH6IUDB56i
  KJVmkTB4ff7snYcvviIEeeU0TUTUKPLACE9CTFziCipabII/EEJs/CISwny8qvr6IihKBcX4hDlV
  1NgExJHSG4ewlDgXZWFImQdYhDXM7TSwySgFqmERlVKiyDpsYMgnoVEPDDQY9cBAAxYGBoYfP36w
  sFBWHA0E+PHjB2FFgx8AAE0jPQCZy9M+AAAAAElFTkSuQmCC

PROC:
  JavaLikeCalc.JavaScript
  function setActMess(mess) {
  	if(err.isEVal())	SYS.messNote("OP:"+this.ownerSess().user()+":"+NAME, "'"+NAME+"'."+mess);
  	else SYS.nodeAt(err).nodePrev().messSet("'"+NAME+"'."+mess, 2, "OP", this.ownerSess().user());
  }

  if(f_start) {
  	isErr = false, alBlnk = false, cnt = 0, fixText = (text != "---");
  	toFastCalc = toFastCalc_ = false;
  }
  if(f_stop && !fixText)	{ text = "---"; return; }

  toFastCalc = false;

  //Prepare/update the context menu
  if(f_start || ((cnt++)%max(1,f_frq*10)) == 0) {
  	contextMenu = "";
  	if(!digComs.isEVal() && digComs.length) {
  		if(!com_text.isEVal())
  			for(off = 0; (comVal=digComs.parse(0,";",off)).length; )
  				contextMenu += comVal.parse(0,"-") + ":" + comVal.parse(0,"-") + "\n";
  		else {
  			if((comVal=digComs.parse(0,";")).length)	contextMenu += comVal.parse(0,"-") + ":open\n";
  			if((comVal=digComs.parse(1,";")).length)	contextMenu += comVal.parse(0,"-") + ":close\n";
  			if((comVal=digComs.parse(2,";")).length)	contextMenu += comVal.parse(0,"-") + ":stop\n";
  		}
  	}
  }

  //Display label from st_text
  stCur = -1;
  if(!st_text.isEVal() && st_text.length) {
  	if(!fixText)	text = transTr ? tr(st_text.parse(0,":")) : st_text.parse(0,":");
  	blink = st_text.parse(2,":").toInt();
  	backClr = st_text.parse(1,":").parse(0,"-");
  	if(blink) {
  		backClrBl = st_text.parse(1,":").parse(1,"-");
  		if(!backClrBl.length)	backClrBl = "gray";
  		backColor = (backColor!=backClr) ? backClr : backClrBl;
  	}
  	else	backColor = backClr;
  }
  //Display typical for st_open
  else if(st_open == true || st_close == false) {
  	backColor = (stVal=digStts.parse(0,";").parse(1,"-")).length ? stVal : "green";
  	if(!fixText)
  		text = (!digStts.isEVal() && (stVal=digStts.parse(0,";").parse(0,"-")).length) ? stVal : tr("Enable");
  	stCur = 1;
  }
  else if(st_open == false || st_close == true) {
  	backColor = (stVal=digStts.parse(1,";").parse(1,"-")).length ? stVal : "blue";
  	if(!fixText)
  		text = (!digStts.isEVal() && (stVal=digStts.parse(1,";").parse(0,"-")).length) ? stVal : tr("Disable");
  	stCur = 0;
  }
  else {
  	backColor = "grey";
  	if(!fixText) text = "---";
  	return;
  }
  if(!backColor.length)	backColor = "black-1";	//For the activity cursor

  //Blink linked with ElCadr
  if(this.attr("focus") ||
  	(!NAME.isEVal() && this.wdgAt("/s/pg_control/pg_ElCadr",true).attr("pgOpen") && this.wdgAt("/s/pg_control/pg_ElCadr",true).attr("prmShifr") == NAME))
  {
  	bordColor = (bordColor != "white") ? "white" : "black";
  	bordWidth = 2;
  	toFastCalc = true;
  }
  else if(bordWidth) { bordWidth = 1; bordColor = "black"; }

  //Notification create
  if(ntf.length && (ntf.toInt() == stCur) != isErr) {
  	if((isErr=(ntf.toInt()==stCur)))	alarm = "50|"+NAME+"|"+ntf.parse(2,":")+".|"+ntf.parse(1,":");
  	else if(alarmSt&0x100)	alarm = "1|"+NAME+"||1";
  }
  if(!isErr && alarmSt&0x100 && !(alarmSt&0x10000)) alarm = "";
  if(alarmSt&0x100) {
  	if(!(alarmSt&0x10000) || alBlnk)	backColor = isErr ? "red" : backColor;
  	else backColor = (backColor=="gray")?"#383838":"gray", toFastCalc = true;
  	alBlnk = !alBlnk;
  }

  //Events process
  for(ev_rez = "", off = 0; (sval=event.parse(0,"\n",off)).length; ) {
  	//SYS.messInfo("TextLab","Event: "+sval);
  	if(!com_text.isEVal() && sval.indexOf("usr_") == 0) {
  		com_text = comVal = sval.slice(4);
  		setActMess(tr("Command")+" : "+DESCR+" : : "+comVal);
  	}
  	else if(sval == "usr_open") {
  		if(!com.isEVal())	com = true;
  		else close = false;
  		comVal = (comVal=digComs.parse(0,";")).length ? comVal.parse(0,"-") : tr("ENABLE");
  		setActMess(tr("Command")+" : "+DESCR+" : : "+comVal);
  	}
  	else if(sval == "usr_close") {
  		if(!close.isEVal())	close = true;
  		else com = false;
  		comVal = (comVal=digComs.parse(1,";")).length ? comVal.parse(0,"-") : tr("DISABLE");
  		setActMess(tr("Command")+" : "+DESCR+" : : "+comVal);
  	}
  	else if(sval == "usr_stop") {
  		if(!stop.isEVal())	stop = true;
  		comVal = (comVal=digComs.parse(2,";")).length ? comVal.parse(0,"-") : tr("STOP");
  		setActMess(tr("Command")+" : "+DESCR+" : : "+comVal);
  	}
  	else ev_rez += sval+"\n";
  }
  event = ev_rez;

  if(toFastCalc != toFastCalc_)	{ toFastCalc_ = toFastCalc; this.calcPer(toFastCalc?500:-3); }


ID: cntrPaspExt
PARENT: /wlb_originals/wdg_Box
ATTRS: name;dscr;geomW;geomH;pgGrp;backColor;bordWidth;bordColor;bordStyle;
ICO:
  iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAIAAAAlC+aJAAAAA3NCSVQICAjb4U/gAAAACXBIWXMA
  AA7EAAAOxAGVKw4bAAADaUlEQVRoge2aTW8bRRjH/zM7u469u15vHLu1U1cRThB9FQUkyq2ocOon
  QHwALnwCznDiwKkfoRI3LnAAKioqWqlBFEqFTGQRShJHpI7j+CXZ2Ls7D4dNE0tIrVMjppHmd9rZ
  efbZ/293VnsZ9tEnn6bcHMaDiORwzz8xC4BIDodDIUzDMA4KpIw5PxzGcdTd3Ejq989EIYEJIQAi
  gIGN9o/jaKv+wLKsMfMAEFNZ3y2WD8a1+4uMM84NCcPPOTs7QfH0gmOnklnGWG9zwymWAIRB/+bn
  NwqlsudPM8Y3m81SpfJHreZlM5fevpaZMhPjIAiS+oQ7X30R7A0q8/ONei3ll9K289rly6NPqPn7
  /fHTAxDcMIQQB+PiTPbhUiMdtn6trZ4quY9bvfc/vCgEfzLP4igK9wYAwMy5hVeI0G2u7ewOvfzJ
  P+t1w+ArSw8XXr9iIg2AQIf1yfWcgRvry0utzZYd4q9+cOHVS4f5QUdKD4B9/Nl1J18cfQZSEgBJ
  kjEGYHSFkJTd1mPbnxmzO0m529k6Uv1w45FpmmPWh2Eo2mvL9259nWQ9XhDRfLUqer3elfc+yOZy
  xLhlmkQkpWSMc2N/2ZCUjPOn9xrndjKWAAOIj7zSSWiuN+q3vxQA4ij86fubbuHky2cvAHhw99vt
  Vgcik8mYs9Wz5VOz/8X7oeXffmmsrKQ9b9DtnHvras5zJuwYhUMAAkAUhi+dOU/cDIcDxvj8uTd6
  3a4wU4YBw8pEYUh05G/r35w4XbWz02CMCJZpDAeDZ1/zdIEo2he49ub5SqUyecT/mdXV1es/ficA
  eHbad23VeY5M104DmPzrVIwWUI0WUI0WUI0WUI0WUI0WUI0WUI0WUI0WUI0WUI0WUI0WUI0WUI0W
  UI0WUI0WUI0WUI0WUI0WUA13XTedTquO8TzYtu26Ls/n857nqQ7zPPi+XygUjv8SUh1gUrSAarSA
  arSAaoRlWe12e3Tv63FBSmmapnAce3urVShV8n623+85jptM12q1F/YPXV/beNQOAIriWFAcdrr9
  9bW7f3eDQta9+u47nAGA53nlcvlZrdSwvr378ze3SpW5KIwEY3xqKjXtz81EsFisOttYkJTVMxc5
  59sNiFa7c29x8WDu9g93kgMppW2/oFsZm+1Oux+ACHvBP2ylQnHYJpj5AAAAAElFTkSuQmCC

PROC:
  JavaLikeCalc.JavaScript
  using Special.FLibSYS;

  if(f_start) {
  	if(!name_.length)	name_ = this.attr("name");
  	viewSet_geomY_ = viewSet_geomY, viewSet_geomH_ = viewSet_geomH;
  	pAddr = pName.slice(0, pName.lastIndexOf("/"));
  	if(!(pObj=SYS.nodeAt(pAddr)))	return;
  	scLog = (pObj.nodeAt("a_log").get() == true);
  	aLst = pObj.nodeList("a_");
  	this.attrSet("name", name_+": "+SYS.nodeAt(pName).get());

  	selTab = "view";

  	//View mode clean up
  	view_value = ""; view_geomH = geomH-view_geomY-1;

  	//Standard parameters
  	stdPrms = "var;sp;out;auto;aMin;aMax;wMin;wMax;com;close;stop;st_open;st_close;";
  	//pColors = new Array("darkmagenta", "orange", "blue", "lightgreen", "cyan", "tomato", "magenta", "wheat", "lightyellow", "darkcyan");

  	//Trends prepare
  	trN = 0, trNMax = 10, trNClr = 0; trDigN = 0;
  	trendsList_items = "<tbl sel='row' colsWdthFit='1'><h><s width='0px'>"+tr("ID")+"</s><s width='50%'>"+tr("Name")+"</s><s edit='1' width='25%'>"+tr("Minimum")+"</s><s edit='1' width='25%'>"+tr("Maximum")+"</s></h>";
  	trendsList_value = "";
  	trObj = this.wdgAt("trends");
  	trObj.attrSet("sclVer", scLog?6:2);
  	trObj.attrSet("parNum", trNMax);
  	// Clear previous trends
  	for(iTr = 0; iTr < trNMax; iTr++) trObj.attrSet("prm"+iTr+"addr", "");
  	for(off = 0; (sP=stdPrms.parse(0,";",off)).length && trN < trNMax; ) {
  		if(!(aObj=pObj.nodeAt("a_"+sP)) ||
  			(sP == "aMin" && ((tV=aObj.get()) >= pObj.nodeAt("a_aMax").get() || tV <= pObj.nodeAt("a_min").get())) ||
  			(sP == "aMax" && ((tV=aObj.get()) <= pObj.nodeAt("a_aMin").get() || tV >= pObj.nodeAt("a_max").get())) ||
  			(sP == "wMin" && ((tV=aObj.get()) >= pObj.nodeAt("a_wMax").get() || tV <= pObj.nodeAt("a_min").get())) ||
  			(sP == "wMax" && ((tV=aObj.get()) <= pObj.nodeAt("a_wMin").get() || tV >= pObj.nodeAt("a_max").get())))	continue;
  		isBool = (typeof(aObj.get())=="boolean");
  		trObj.attrSet("prm"+trN+"addr", pAddr+"/a_"+sP);
  		trObj.attrSet("prm"+trN+"color", (trClr=this.attr("labColorGrph"+(trNClr+1)))+(isBool?"-127":""));
  		trObj.attrSet("prm"+trN+"width", 2);
  		if((sP == "var" || sP == "sp" || sP == "aMin" || sP == "aMax" || sP == "wMin" || sP == "wMax") && pObj.nodeAt("a_min")) {
  			trObj.attrSet("prm"+trN+"bordL", pObj.nodeAt("a_min").get()).attrSet("prm"+trN+"bordU", pObj.nodeAt("a_max").get()).attrSet("prm"+trN+"scl",0);
  			if(sP == "aMin" || sP == "aMax" || sP == "wMin" || sP == "wMax")
  				trObj.attrSet("prm"+trN+"addr","line:"+aObj.get()).attrSet("prm"+trN+"color",(trClr=(sP[0]=="a")?"red":"yellow"));
  		}
  		else if(sP == "out") trObj.attrSet("prm"+trN+"bordL",0).attrSet("prm"+trN+"bordU",100).attrSet("prm"+trN+"scl",2);
  		else if(isBool) { trObj.attrSet("prm"+trN+"bordL", -trDigN).attrSet("prm"+trN+"bordU", 20-trDigN).attrSet("prm"+trN+"scl",2); trDigN++; }
  		else trObj.attrSet("prm"+trN+"scl",2);
  		trendsList_items += "<r><s>"+trN+"</s>"
  											"<s color='"+trClr.parse(0,"-")+"'>"+strEnc2HTML(aObj.descr())+"</s>"
  											"<r>"+trObj.attr("prm"+trN+"bordL")+"</r>"
  											"<r>"+trObj.attr("prm"+trN+"bordU")+"</r></r>";
  		trN++; trNClr++;
  	}
  	for(iA = 0; iA < aLst.length && trN < trNMax; iA++) {
  		aId = aLst[iA].slice(2);
  		if(stdPrms.indexOf(aId+";") != -1 || !(aObj=pObj.nodeAt(aLst[iA])) || !aObj.arch()) continue;
  		isBool = (typeof(aObj.get())=="boolean");
  		trObj.attrSet("prm"+trN+"addr", pAddr+"/a_"+sP);
  		trObj.attrSet("prm"+trN+"color", this.attr("labColorGrph"+(trNClr+1))+(isBool?"-127":""));
  		trObj.attrSet("prm"+trN+"width", 2);
  		if(isBool) { trObj.attrSet("prm"+trN+"bordL", -trDigN).attrSet("prm"+trN+"bordU", 20-trDigN); trDigN++; }
  		trendsList_items += "<r><s>"+trN+"</s>"
  											"<s color='"+this.attr("labColorGrph"+(trNClr+1))+"'>"+strEnc2HTML(aObj.descr())+"</s>"
  											"<s>"+trObj.attr("prm"+trN+"bordL")+"</s>"
  											"<s>"+trObj.attr("prm"+trN+"bordU")+"</s></r>";
  		trN++; trNClr++;
  	}
  	trendsList_items += "</tbl>";
  	sel_trends_en = trN;

  	//Data table prepare
  	dtALst = new Array();
  	dtPeriod = 1;
  	for(off = 0; (sP=stdPrms.parse(0,";",off)).length; )
  		if((aObj=pObj.nodeAt("a_"+sP)) && aObj.arch()) {
  			dtALst.push(aObj);
  			dtPeriod = max(dtPeriod, ceil(aObj.arch().cfg("BPER")));
  		}
  	for(iA = 0; iA < aLst.length; iA++) {
  		aId = aLst[iA].slice(2);
  		if(stdPrms.indexOf(aId+";") == -1 && (aObj=pObj.nodeAt(aLst[iA])) && aObj.arch()) {
  			dtALst.push(aObj);
  			dtPeriod = max(dtPeriod, ceil(aObj.arch().cfg("BPER")));
  		}
  	}
  	sel_data_en = dtALst.length;
  	if(!sel_trends_en && !sel_data_en)	 { view_geomH += view_geomY-sel_view_geomY; view_geomY = sel_view_geomY; }
  }
  if(f_stop) viewSet_geomY = viewSet_geomY_, viewSet_geomH = viewSet_geomH_;

  //View update
  if(pObj && view_en) {
  	view_items = "<tbl sel='row' colsWdthFit='1'><h><s width='0px'>"+tr("ID")+"</s><s width='60%'>"+tr("Name")+"</s><s width='30%'>"+tr("Value")+"</s></h>";
  	for(iA = 0; iA < aLst.length; iA++) {
  		if(!hideAttrs.isEVal() && hideAttrs.match("(;|^)"+aLst[iA].slice(2)+"(;|$)").length)	continue;
  		aObj = pObj.nodeAt(aLst[iA]);
  		view_items += "<r><s>"+aLst[iA]+"</s>"
  									"<s>"+strEnc2HTML(aObj.descr())+"</s>"
  									"<s>"+strEnc2HTML(aObj.get())+"</s></r>";
  	}
  	view_items += "</tbl>";
  }

  //Data update
  if(pObj && data_en) {
  	data_tmpl = "<body docProcLang='JavaLikeCalc.JavaScript'>\n"
  		"<table class='data' cellpadding='2' cellspacing='0' export='1' valign='middle' width='100%'>\n";
  	// Header
  	data_tmpl += "<tr><th>Date</th>";
  	for(iA = 0; iA < dtALst.length; iA++)
  		data_tmpl += "<th>"+strEnc2HTML(dtALst[iA].descr())+"</th>";
  	data_tmpl += "</tr>\n";

  	// Date
  	curTime = SYS.time();
  	for(i_rec = curTime; i_rec > (curTime-100*dtPeriod); i_rec-=dtPeriod) {
  		data_tmpl += "<tr><td>"+SYS.strftime(i_rec,"%d %m %H:%M:%S")+"</td>";
  		for(iA = 0; iA < dtALst.length; iA++) {
  			i_rec_ = i_rec;
  			data_tmpl += "<td>"+strEnc2HTML(dtALst[iA].get(i_rec_))+"</td>";
  		}
  		data_tmpl += "</tr>\n";
  	}
  	data_tmpl += "</table></body>\n";
  }

  //Events process
  ev_rez = "";
  for(off = 0; true; ) {
  	sval = event.parse(0, "\n", off);
  	if(!sval.length) break;
  	//SYS.messInfo("ObjProps","Event: "+sval);
  	if(sval.slice(0,16) == "ws_BtPress:/sel_") selTab = sval.slice(16);
  	else if(sval == "ws_TableChangeSel:/view" && (aObj=pObj.nodeAt(view_value))) {
  		if(!(aObj.flg()&0x04)) {
  			if(typeof(aObj.get()) == "string" && aObj.flg()&0x08) {
  				this.viewSet.attrSet("elType",1);	//Text editor
  				viewSet_geomY = viewSet_geomY_ - viewSet_geomH_*3;
  				viewSet_geomH = viewSet_geomH_*4;
  				view_geomH = viewSet_geomY - view_geomY - 1;
  			}
  			else {
  				this.viewSet.attrSet("elType",0).attrSet("view",1);	//Combo box
  				this.viewSet.attrSet("cfg", (aObj.flg()&0x01) ? aObj.values().split(";").join("\n") : "");
  				viewSet_geomH = viewSet_geomH_, viewSet_geomY = viewSet_geomY_;
  				view_geomH = viewSet_geomY - view_geomY - 1;
  			}
  			this.viewSet.attrSet("value",aObj.get());
  		}
  		else view_geomH = geomH-view_geomY-1;
  	}
  	else if((sval == "ws_LnAccept:/viewSet" || sval == "ws_TxtAccept:/viewSet") && (aObj=pObj.nodeAt(view_value))) aObj.set(this.viewSet.attr("value"));
  	else if(sval == "ws_TableChangeSel:/trendsList")
  		for(i_tr = 0; i_tr < trN; i_tr++)
  			trObj.attrSet("prm"+i_tr+"width", ((i_tr==trendsList_value)?3:2));
  	else if((reRez=sval.match("ws_TableEdit_(\\d+)_(\\d+)\\:\\/trendsList")).length)
  		trObj.attrSet("prm"+trendsList_value+((reRez[1]==2)?"bordL":"bordU"), trendsList_set);
  	else ev_rez += sval+"\n";
  }
  event = ev_rez;

  //Tab selection process
  if(f_start || selTab != prevTab) {
  	wLs = this.nodeList("wdg_");
  	for(iW = 0; iW < wLs.length; iW++) {
  		wId = wLs[iW].slice(4);
  		wObj = this.wdgAt(wId);
  		if(wId.indexOf("sel_") != -1)	wObj.attrSet("color",(wId.slice(4)==selTab)?backColorButtonSel:backColorButton);
  		else if(wId.indexOf(selTab) != -1) wObj.attrSet("en",true);
  		else if(wId.indexOf(prevTab) != -1) wObj.attrSet("en",false);
  	}
  	prevTab = selTab;
  }


ID: objProps
PARENT: /wlb_originals/wdg_Box
ATTRS: perm;name;dscr;geomW;geomH;pgOpenSrc;pgGrp;backColor;bordWidth;bordColor;
ICO:
  iVBORw0KGgoAAAANSUhEUgAAAEAAAAAxCAIAAADldTjtAAAAA3NCSVQICAjb4U/gAAAACXBIWXMA
  AA7EAAAOxAGVKw4bAAABvUlEQVRoge3av0rDUBTH8V9ubpNqrVrS+BcKWtFFpYidXBycHbvqSwhd
  fAHHvoEv4CIOLnHQRQcFETpYEPG/VVNtaaw1iUNRHDrJ1YNwPtMlwzn3O2S72tLy0tnoGdR6AQ4B
  C5j6/NIEQsBQucTSrVgxJq0+a311XeXgFgfIAAfABFAHjoEFwFa5YfJ5cnFtUagc+SUEAOwBAmgC
  DtAPJH9llTQixuz5rOKpIWACceAEiAMZoAqcA5rKJal6CoAM38OV/RWVg7+LARef5wP144tGUVqW
  lcvl1M/+E4VC4Xf+gT/EAdQ4gBoHUOMAahxAjQOocQA1DqDGAdQ4gBoHUOMAahxAjQOocQA1DqDG
  AdQ4gNq/D5CNRqNUKlFf44c8z5PJ3i7HcVKj43Yi/uZVX17DZKLbdV3TNCORCPUN27i6K5ebeuv8
  VH+Ttad79Aw+u+WdrY1eu0/vtOfnspqmZbPZaDRKe9e2jk6Kt6fXu9ubE9Mzng9hdnTFO6OVSiXZ
  P5xOj5hSqH3RoFyIUOi6PTBsDwz5vq/l8/mxdFroMgh8IUQQBELotVrVMAwpJfVt27gtP1w+Vlvv
  Ydybiw8wdHLT/ZDoJgAAAABJRU5ErkJggg==

PROC:
  JavaLikeCalc.JavaScript
  using Special.FLibSYS;

  if(f_start) {
  	props_value = "";
  	props_geomH = geomH-props_geomY;
  	objErrCode = 0;
  }

  title_text = objName.isEVal() ? tr("Unknown") : objName;
  title_tipTool = objDescr.isEVal() ? "" : objDescr;

  //Setting alarms state
  if(!objErr.isEVal() && objErrCode != objErr.toInt()) {
  	objErrCode = objErr.toInt();
  	if(objErrCode == 2)			alarm = "50|"+objName+"||3";
  	else if(objErrCode == 1)	alarm = "10|"+objName+"||3";
  	else if(alarmSt&0x100)		alarm = "1|"+objName+"||1";
  }
  if(!objErrCode && alarmSt&0x100 && !(alarmSt&0x10000)) alarm = "";

  //Changing notification-title color
  alarmLev = alarmSt&0xFF;
  if(alarmLev && alarmSt&0x100) {
  	blinkPr = true;
  	if(!objErrCode || alarmLev <= 1)	wColor = "lime";
  	else if(alarmLev < 30)	wColor = "yellow";
  	else if(alarmLev < 75)	wColor = "red";
  	else { wColor = "grey"; blinkPr = false; }
  	if(blinkPr) title_backColor = (alarmSt&0x10000 && title_backColor == wColor) ? "grey" : wColor;
  	else title_backColor = wColor;
  }
  else title_backColor = "lime";

  /*if(!objErr.isEVal()) {
  	if(objErr.toInt() == 0)		title_backColor = "lime";
  	else if(objErr.toInt() == 1)	title_backColor = "yellow";
  	else if(objErr.toInt() == 2)	title_backColor = "red";
  	else title_backColor = "gray";
  }
  else title_backColor = "gray";*/

  if(!objItems.isEVal()) {
  	//Load table with variables
  	tbl = "<tbl sel='row' colsWdthFit='1'>\n"
  		"<h><s width='0px'>"+tr("Property")+"</s><s width='55%'>"+tr("Description")+"</s><s width='30%' align='center'>"+tr("Value")+"</s></h>";
  	for(var aIt in objItems) {
  		it = objItems[aIt];
  		if(it.alarm == 1)	tbl += "<r color='yellow'>";
  		else if(it.alarm == 2)	tbl += "<r color='red'>";
  		else tbl += "<r>";
  		if(typeof(tVl=it.val) != "string") tVl = it.val.toString();
  		tbl +=	"<s>"+aIt+"</s><s>"+strEnc2HTML(tr(it.descr.trim()))+"</s>"
  			"<s>"+strEnc2HTML(tr(tVl.trim()))+"</s></r>\n";
  	}
  	tbl += "</tbl>";
  	props_items = tbl;
  }

  for(ev_rez = "", off = 0; (sval=event.parse(0,"\n",off)).length; ) {
  	//SYS.messInfo("ObjProps","Event: "+sval);
  	if(sval == "ws_TableChangeSel:/props" && (it=objItems[props_value])) {
  		if(!it.wr.isEVal() && it.wr != false) {
  			props_geomH = set_geomY-props_geomY-2;
  			set_cfg = it.wr.length ? it.wr.split(";").join("\n") : "";
  			set_value = it.val;
  		}
  		else props_geomH = geomH-props_geomY;
  		//SYS.messInfo("ObjProps","WR: "+it.wr+"; it="+it);
  	}
  	else if(sval == "ws_LnAccept:/set" && (it=objItems[props_value])) it.set = set_value;
  	else ev_rez += sval+"\n";
  }
  event = ev_rez;


ID: grpGraph10
PARENT: /wlb_originals/wdg_Box
ATTRS: name;dscr;geomW;geomH;evProc;backColor;bordWidth;bordColor;
ICO:
  iVBORw0KGgoAAAANSUhEUgAAAEAAAAAqCAIAAACMZMq1AAAACXBIWXMAAAx1AAAMdQEteJR1AAAE
  xklEQVRYhdVYTW/bRhCd2S8uRVESJbOCZCSAgThBTknR3Jrmnj+R/5Kf2EvgwEacOkod24q+SIHk
  krvbA22akW0ILQSknNO+p/cWXM2sZih8//69ylSSJo7jGGPiOG6327ooALHlulEcE0IAQCmVJAn8
  z6LVarFotQp6vXbbm83n0nGEEEGvt16vXSkBEQEKrV3X/fLly3q9/tkPfE+w828XRx8/1qnj42MA
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qdTqcDjQ22WCym02mD
  S0gI4bpug0eJchXHcclqreudbwNuFezWDjfN+F5BuWZxHH///r1qb1rrei/cgFsFu7VTSgHgIcH1
  ATzP830/iqKSFULUh6cNuFWwW3tZQg/ZhRCMMSaEuLq6qosadomXy2XVBKCBl5j4/g9NYCPjG3Cr
  YLf2u9N4XZBlWVEURAgRBEF6E0+fPkXECo7H48FgUEEhhOd5Fcyy7ODgQClVMWEYlv+Al7G3t1ff
  3Pf90WhUQWPM4eFhlmUV8+jRI8dx6rt1u90Kep43Ho/TNGWMPX78uN1uD4dDfPny18+fT6E50W63
  R6MRAPR6vW63y968+ePVq99+9lP9x3Bd9x9FY7XqUFOtUwAAAABJRU5ErkJggg==

PROC:
  JavaLikeCalc.JavaScript
  if(f_start) {
  	//Parameter selection enable
  	if(allowSelLst.length)
  		for(i_el = 0; i_el < 10; i_el++) {
  			cEl = this["el"+(i_el+1)];
  			cEl.attrSet("enForce", 1);
  			if(cEl.attr("contextMenu").search(":select$") < 0)
  				cEl.attrSet("contextMenu",cEl.attr("contextMenu")+tr("Select")+":select\n");
  		}
  	cnt = 0;
  	toCalcCycles = cnt_ = max(3, 2000/this.ownerSess().period());
  }
  cnt++;
  if(cnt == cnt_)	event = "ws_FocusIn:/trnd1";

  curTm = SYS.time();
  if(!trnd1_tSek)	trnd1_tSek = curTm;
  if(trnd1_curSek > (trnd1_tSek+trnd1_tSize/10) || trnd1_curSek < (trnd1_tSek-trnd1_tSize))
  	trnd1_curSek = trnd1_tSek;
  selSingle = 0;
  selAll = false;

  //Events process
  for(evRez = "", off = 0; (ev_cur=event.parse(0,"\n",off)).length; ) {
  	if(ev_cur == "key_presComma:/trnd1")			trnd1_tSek -= trnd1_tSize/2;
  	else if(ev_cur == "key_presPeriod:/trnd1")	trnd1_tSek += trnd1_tSize/2;
  	else if(ev_cur == "ws_SliderChange:/arh")		trnd1_tSek = arh_value*trnd1_tSize;
  	else if(ev_cur.search("usr_single:/el") == 0) selSingle = ev_cur.slice(14).toInt();
  	else if(ev_cur.search("usr_all:/el") == 0)	selAll = true;
  	else evRez += (ev_cur+"\n");
  	//SYS.messDebug("Trend","Event: "+ev_cur);
  }
  event = evRez;

  //Trend time control
  if(trnd1_tSek < curTm) trnd1_trcPer = 0;
  else trnd1_trcPer = max(1, (this.calcPer()==-2)?10:this.calcPer()/1000), trnd1_tSek = 0;

  //Generic
  name_arg0val = this.attr("name");

  //Scale
  typeXY = (trnd1_type==2);
  cntrAct = cntrLog = xCntrAct = xCntrLog = 0;
  for(i_el = 0; i_el < 10; i_el++) {
  	cEl = this["el"+(i_el+1)];
  	if(!cEl.attr("en")) continue;
  	if(!typeXY || !(i_el%2)) {
  		cntrAct++;
  		if(cEl.attr("log") == true)	cntrLog++;
  	}
  	else {
  		xCntrAct++;
  		if(cEl.attr("log") == true)	xCntrLog++;
  	}
  }
  trnd1_sclVer = (cntrLog > cntrAct/2) ? trnd1_sclVer|0x4 : trnd1_sclVer&(~0x4);
  trnd1_sclHor = (xCntrLog > xCntrAct/2) ? trnd1_sclHor|0x4 : trnd1_sclHor&(~0x4);

  //Trends
  arh_beg = 1e30, arh_end = 0;
  for(i_el = 0; i_el < 10; i_el++) {
  	cEl = this["el"+(i_el+1)];
  	if(selAll)	cEl.attrSet("bordStyle",3);
  	if(selSingle) cEl.attrSet("bordStyle",((i_el+1)==selSingle)?3:1);
  	cTr = this["trnd1"];
  	cTrPrm = "prm"+i_el;
  	if(!cEl.attr("en")) cTr.attrSet(cTrPrm+"addr","");
  	else {
  		cTr.attrSet(cTrPrm+"addr",cEl.attr("addr"));
  		cTr.attrSet(cTrPrm+"bordL",cEl.attr("min"));
  		cTr.attrSet(cTrPrm+"bordU",cEl.attr("max"));
  		cTr.attrSet(cTrPrm+"color",cEl.attr("color"));
  		cTr.attrSet(cTrPrm+"width",cEl.attr("bordWidth")*2);
  		cEl.attrSet("varEl",cTr.attr(cTrPrm+"val"));
  		//Enable/disable of the mode's indication in the regulators ???
  		cEl.attrSet("enMode",((curTm-trnd1_curSek) <= 2));
  		//Archive depth calculate
  		if(cEl.attr("bordStyle") == 3) {
  			arh_tmp = cTr.attr(cTrPrm+"prop");
  			if((arh_vl=arh_tmp.parse(0,":").toReal())) arh_beg = min(arh_beg,arh_vl);
  			if((arh_vl=arh_tmp.parse(1,":").toReal())) arh_end = min(curTm,max(arh_end,arh_vl));
  		}
  		if(!typeXY || !(i_el%2)) {
  			if((cEl.attr("log")==true) == (cntrLog > cntrAct/2) && cEl.attr("bordWidth") == 1) cTr.attrSet(cTrPrm+"scl",0);
  			else cTr.attrSet(cTrPrm+"scl",(cEl.attr("log")==true)?6:2);
  		}
  		else {
  			if((cEl.attr("log")==true) == (xCntrLog > xCntrAct/2)) cTr.attrSet(cTrPrm+"scl",0);
  			else cTr.attrSet(cTrPrm+"scl",(cEl.attr("log")==true)?6:2);
  		}
  	}
  }
  //Set archive scroll
  if(arh_end && ((arh_end-arh_beg)/trnd1_tSize > 2)) {
  	arh_cfg = "0:"+floor(arh_beg/trnd1_tSize+1)+":"+floor(arh_end/trnd1_tSize+1)+":1:5";
  	arh_value = (trnd1_tSek?trnd1_tSek:curTm)/trnd1_tSize;
  	arh_tipTool = tr("Archive space")+": ["+SYS.strftime(arh_beg)+" ... "+SYS.strftime(arh_end)+"]";
  	arh_active = true;
  	if(selSingle) trnd1_tSek = arh_end;
  } else arh_active = false, arh_tipTool = "";

  //Updating cycles processing for big processing periods of that page 
  if(toCalcCycles > 0.1) {
  	this.attrSet("event", this.attr("event")+"usr_calc\n");	//!!!! Just to calc in the next session cycle for update
  	toCalcCycles = max(0, toCalcCycles-1);
  }


ID: anShow1s
PARENT: /wlb_Main/wdg_anShow1
ATTRS: name;geomW;
ICO:
  iVBORw0KGgoAAAANSUhEUgAAAEAAAAAWCAIAAAD/3A1jAAAAA3NCSVQICAjb4U/gAAAACXBIWXMA
  AA7EAAAOxAGVKw4bAAAG50lEQVRYhdVXWWwb1xW9bxYOOdzERRTFVbtEWRIlWY5dWbHdqI2auC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UEAuk4fHlrbIVKSiG6XkGXS1LM8fXbW63WO4x4+fGg828+fP28Ozufz
  siwnEomDg4O5uTmzaXt7u1QqpdPparWaTqfNT1Yj59bWls1mgxC+8cYbZr5cLnMcFwgETp16sm1K
  1+s0xznyedvhoTQ3B3pXlCOfJ2UZAKA7nfLrT75pPL0DkUjE7XazLJsa1IdkMplgMDgyMmJtOdPp
  dCQSGRsb8/l8Xq/XbDJyTkxMsCxrvtIGz/P8wcGBWbhgJKK73VospoVC9l7ZBQAomQwMBm2VCm0K
  eVoAz/O5XM7v9xcKhb5xAAAWFhaMgz4xAQDkcjmO4zY3N0ulUt8OrpGz1Wrt7OxETKpi8FNTUxcv
  XjzaRAIAUDzvzuUIXSdlGbFs3x+xCwtGGdgkXK9U6EWjR4VkWUYISZJklRpVVQ3FsD6kEULdblfX
  daPtMZuMnEazZJ5dR7xZmv4celRof3+foqhOp2Oz2Y4Uw8DKygqEUFVVgiDee+89symfzxeLRWP3
  c2ZmJhQKHZk4jjPeJxVFcTqd586dM/Nut3t9ff3jjz/+KwX0qFAoFEokEhRFGZuyZpw+fToQCIii
  aO12JicnY7GYx+MRBEGWZbMpFArRNC1JUjqdNt8BgwcAJJN/7BP1cQXwPH/v3j0AgM1ms75bff/9
  9wRBDA8PW/d/crnc4eEhQsjr9bK90lGr1SRJGhkZyefz5jbJ4L1er9Pp/IsFvFKhF41XBbxovCrg
  ReOlL4BGCJm/E75c4Hn+v2idbISEe7FeAAAAAElFTkSuQmCC

PROC:
  JavaLikeCalc.JavaScript
  if(f_start) {
  	selDay = selMonth = selYear = selWDay = isDst = 0;	//Selected data parts
  	maxDayInMonth = 30;			//Maximum days into selected month
  	selTime = SYS.time();		//Selected time, ordered to days
  	prevTime = 0;					//Previous time for detect time selection change
  	cntr = 0;						//Global counter for update period limit for some parts
  }

  //Years list update
  if(f_start || (cntr%(f_frq*3600*24)) == 0)	{	//By day
  	curYear = 0;
  	SYS.localtime(SYS.time(), 0, 0, 0, 0, 0, curYear);
  	year_items = "";
  	for(i_y = 0; i_y < 10; i_y++)	year_items += (i_y?"\n":"")+(curYear-i_y);
  }

  //Events process
  for(ev_rez = "", off = 0; (ev_cur=event.parse(0,"\n",off)).length; ) {
  	//SYS.messInfo("MnCntr","Event: "+ev_cur);
  	if(ev_cur == "ws_BtPress:/curDay")	selTime = SYS.time();
  	else if(ev_cur == "ws_CombChange:/year")
  		selTime = SYS.mktime(0, 0, 0, selDay, selMonth, year_value, 0, 0, isDst);
  	else if(ev_cur == "ws_CombChange:/month")
  		selTime = SYS.mktime(0, 0, 0, selDay, (month_value.match("\\((\\d+)\\)","")[1].toInt()-1), selYear, 0, 0, isDst);
  	else if(ev_cur.indexOf("key_mousePresLeft:/w") == 0) {
  		weekWdg = this.wdgAt(ev_cur.slice(19));
  		if(weekWdg.attr("text").length)
  			selTime = SYS.mktime(0, 0, 0, weekWdg.attr("text"), selMonth, selYear, 0, 0, isDst);
  	}
  	else ev_rez += (ev_cur+"\n");
  }
  event = ev_rez;

  if(selTime != prevTime) {
  	selTime = min(selTime, SYS.time());
  	SYS.localtime(selTime, 0, 0, 0, selDay, selMonth, selYear, 0, 0, isDst);
  	selTime = SYS.mktime(0, 0, 0, selDay, selMonth, selYear, 0, 0, isDst);
  	selWDay = 0;
  	selTimeMonth = SYS.mktime(0, 0, 0, 1, selMonth, selYear, selWDay, 0, isDst);
  	title_arg0val = SYS.strftime(selTime, "%d.%m.%Y");

  	year_value = selYear;
  	month_value = month_items.match("([^\n]*\\("+(selMonth+1)+"\\))","m")[0];

  	//Days number into selected month
  	tMonth = selMonth, tYear = selYear, tisDst = isDst;
  	for(maxDayInMonth = 29; true; maxDayInMonth++) {
  		tDayInMonth = maxDayInMonth;
  		SYS.mktime(0, 0, 0, tDayInMonth, tMonth, tYear, 0, 0, tisDst);
  		if(tDayInMonth != maxDayInMonth)	{ maxDayInMonth--; break; }
  		if(maxDayInMonth >= 31)	break;
  	}

  	//Week box update
  	for(i_w = 0, i_d = 1; i_w < 6; i_w++)
  		for(i_wd = 0; i_wd < 7; i_wd++)
  			if((i_w == 0 && i_wd < (((tVl=selWDay-1)<0)?7+tVl:tVl)) || i_d > maxDayInMonth)	//Clear cell
  				this.wdgAt("w"+i_w+"_"+i_wd).attrSet("text","").attrSet("bordWidth","0").attrSet("backColor","");
  			else {
  				this.wdgAt("w"+i_w+"_"+i_wd).attrSet("text",i_d).attrSet("bordWidth","0").attrSet("backColor","lightgray-1");
  				if(i_d == selDay)						//Selected day
  					this.wdgAt("w"+i_w+"_"+i_wd).attrSet("text",i_d).attrSet("bordWidth","1").attrSet("backColor","lightgreen");
  				i_d++;
  			}
  	prevTime = selTime;
  }

  cntr++;


ID: alarmsAct
PARENT: /wlb_originals/wdg_FormEl
ATTRS: owner;name;dscr;active;geomY;geomW;geomH;contextMenu;evProc;elType;value;items;set;
ICO:
  iVBORw0KGgoAAAANSUhEUgAAAEAAAAALCAYAAADP9otxAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz
  AAAOxAAADsQBlSsOGwAABRlJREFUSImVlstyHLcVhj+ggb5Pz4UcUTETzciWHcelhV3lcrkqT5EX
  yMtkn1W8yz7JC6TyGrZTklKKbYU3iaJIzq2ne7rRQBbTHHI4cqpyNl0H58eP/xwcAC3+8Oe//SPr
  9sbS8wAHQF3VeJ6H9CTWWnAgPcldc84hhKAxDdY2OOfwg2ATr02NVnoL76zb8DSmxlM++WJGknY2
  OGstUsoNfz6fk3TWcdtYAIQQCCm2dNSmRgqJ53lba67KkjCKtrRLHLFWSNy/VZJ2HoVR/GvpeeDW
  BXh99Jyrt+ek3S5a+5TFEts0PP3y61tyQADXlxecnx5z8fqUNOuSZl2k9CiWOUIIPhg9pr83xAEX
  r0+5fvcWU1X8YvSYwbDHD8++B2CZLwjDCGNqRh9/Sn//AQI4Pz3h9dErnLV4WlMul0gpGD35lP7+
  cKNjcnrE27MTpPTo7w05HH+IA6ZXl5y9+glw1HWF1j6/Gj9GExJoVYk//vXvz4Iw/M2bF98Cjqq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AP4Gn7ynCBWwKAHAFfNsW
  LQBGdwoA8F2radLqSYGzO+t77ZyzlksDC2AJJK3++7pvzNeKKI5QVV396Gttz7s9roAZkLdEQZtQ
  CczvJ5OkGCGoWn/Vir3xX97Dz5OUjhCb8UYplNZ8pm//Meo78+ZJyi/bc37XnvwM7/0b5yb28j0c
  izglSmLy6fSn/wJZ90oLtw/oIAAAAABJRU5ErkJggg==

PROC:
  JavaLikeCalc.JavaScript
  function testLev( v1, v2 )
  {
  	isSub = abs(v1) > 7 && abs(v2) > 7;
  	v1_ = abs((!isSub && abs(v1) > 7) ? v1/10 : v1);
  	v2_ = abs((!isSub && abs(v2) > 7) ? v2/10 : v2);
  	return (v1_ >= v2_);
  }

  if(f_start) {
  	cnt = 0;
  	toUpdate = false;
  	messItSep = ": ";
  	alUnSel = 0;
  	geomH_ = geomH;
  	highLght_ = new Array();
  	for(off = 0; (iH=highLght.parse(0,"\n",off)).length || off < highLght.length; ) {
  		if(!iH.length || iH[0] == "#")	continue;
  		iHo = new Object();
  		if(iH.parse(0,":").length > 2)
  			iHo.lev = iH.slice(0,2).toInt(), iHo.quiet = iH.slice(2,3).toInt()?1:0;
  		else iHo.lev = iH.slice(0,1).toInt(), iHo.quiet = iH.slice(1,2).toInt()?1:0;
  		iHo.color = iH.parse(1,":"); iHo.font = iH.parse(2,":"); iHo.fontColor = iH.parse(3,":");
  		highLght_.push(iHo);
  	}
  	sourceCache = new Object();
  }

  if(focus)	alUnSel = 10;	//Wait for 10 seconds
  else if(alUnSel > 0 && (alUnSel=max(0,alUnSel-1/f_frq)) <= 0)	{
  	value = "";
  	if(this.wdgAt("/s/pg_control/pg_ElCadr",true).attr("prmShifr") == NAME)
  		this.wdgAt("/s/pg_control/pg_terminator",true).attrSet("pgOpen", true);
  }
  if(com) { event += "usr_qtc\n"; st_open = true; }

  //Call per 1 seconds, start or force update
  if(((cnt++)%(f_frq*1) == 0 || f_start || toUpdate) && !f_stop) {
  	curAlMess = SYS.Archive.messGet(0, SYS.time(), messCat, -1);

  	//Sort the messages
  	sortAr = new Array();
  	for(iM = 0; iM < curAlMess.length; iM++)
  		//!!!! Define here self sort criteries
  		sortAr.push(">"+(curAlMess[iM].mess.parse(3,messItSep).length?"0":"1")+(((tVl=abs(curAlMess[iM].level))>9)?tVl:tVl+"-")+">"+iM.toString(10,6)+"\n"+iM);
  	sortAr = sortAr.sort().reverse();

  	//The table content update
  	items = "<tbl sel='row' colsWdthFit='1' hHdrVis='"+(hHdrVis?1:0)+"' vHdrVis='"+(vHdrVis?1:0)+"'>\n";
  	items += "<h><s width='0px'>ID</s>";
  	for(vC = "", off = 0; (vC=colms.parse(0,",",off)).length; )
  		if(vC == "atm")			items += "<s>"+tr("Alarm time")+"</s>";
  		else if(vC == "qttm")	items += "<s>"+tr("Quietance time")+"</s>";
  		else if(vC == "lev")	items += "<s>"+tr("Lev.")+"</s>";
  		else if(vC == "type")	items += "<s align='center'>"+tr("Type")+"</s>";
  		else if(vC == "cat")	items += "<s>"+tr("Category")+"</s>";
  		else if(vC == "mess")	items += "<s>"+tr("Message")+"</s>";
  		else if(vC == "prm")	items += "<s>"+tr("Source")+"</s>";
  		else if(vC == "dscr")	items += "<s>"+tr("Description")+"</s>";
  		else if(vC == "alrm")	items += "<s>"+tr("Alarm")+"</s>";
  		else if(vC == "cmnt")	items += "<s edit='1'>"+tr("Comment")+"</s>";
  		//else if(vC == "src")	items += "<s>"+tr("Source")+"</s>";
  		else if(vC.slice(0,8) == "dscrCust")
  			items += "<s>"+((tVl=colDscrCustNames.parse(vC.slice(8).toInt(),";")).length?tVl:tr("Custom")+" "+vC.slice(8))+"</s>";
  	items += "</h>\n";
  	for(iSM = 0; iSM < sortAr.length; iSM++) {
  		iM = curAlMess[iMid=sortAr[iSM].parse(1,"\n").toInt()];
  		//Check for higlight properties match
  		for(iHgl = false, iH = 0; iH < highLght_.length && !iHgl; iH++) {
  			iHo = highLght_[iH];
  			//this.messInfo("TEST 00: lev: "+iM.level+":"+iHo.lev);
  			if(testLev(iM.level,iHo.lev) && (iM.mess.parse(3,messItSep).length?1:0) == iHo.quiet)
  				iHgl = iHo;
  		}
  		items += "<r"+(iHgl?" color='"+iHgl.color+"' font='"+iHgl.font+"' colorText='"+iHgl.fontColor+"'":"")+"><i>"+iMid+"</i>";
  		for(vC = "", off = 0; (vC=colms.parse(0,",",off)).length; )
  			if(vC == "atm")	items += "<s>"+SYS.strftime(iM.tm,formDtTm.replace("%MS",(iM.utm/1000).toString(10,3)).replace("%US",iM.utm.toString(10,6)))+"</s>";
  			else if(vC == "qttm")	items += ((tVl=iM.mess.parse(3,messItSep)).length ? "<s>"+tVl+"</s>" : "<b edit='1'>0</b>");
  			else if(vC == "lev")	items += "<i>"+abs(iM.level)+"</i>";
  			else if(vC == "type")	items += "<s>"+types.parse(abs(iM.level),";")+"</s>";
  			else if(vC == "cat")	items += "<s>"+SYS.strEncode(iM.categ,"HTML")+"</s>";
  			else if(vC == "mess")	items += "<s>"+SYS.strEncode(iM.mess,"HTML")+"</s>";
  			else if(vC == "prm") {
  				srcO = iM.categ.match("^al(.+):([^\\.]+)|^(.*):al");
  				tVl = "";
  				//From remote station
  				if(srcO.length == 4)
  					for(off2 = 0, isFirst = true; (tVl2=srcO[3].parse(0,":",off2)).length; tVl += (tVl.length?".":"")+tVl2, isFirst = false) {
  						if(!isFirst)	continue;
  						if(!sourceCache[tVl2].isEVal())	tVl2 = sourceCache[tVl2];
  						else {
  							req = SYS.XMLNode("get").setAttr("path","/Transport/%2fsub%2fehost").setAttr("upRiseSYS",1);
  							SYS.cntrReq(req);
  							for(iTr = 0; req.childSize() && iTr < req.childGet(0).childSize(); iTr++)
  								if(req.childGet(0).childGet(iTr).text() == tVl2) {
  									tVl2 = sourceCache[tVl2] = req.childGet(1).childGet(iTr).text();
  									break;
  								}
  						}
  					}

  				items += "<s>"+SYS.strEncode((tVl.length?tVl+" > ":"")+iM.mess.parse(0,messItSep),"HTML")+"</s>";
  			}
  			else if(vC == "dscr")	items += "<s>"+SYS.strEncode(iM.mess.parse(1,messItSep).replace(new RegExp("\\[\\[.+\\]\\]"),""),"HTML")+"</s>";
  			else if(vC == "alrm")	items += "<s>"+SYS.strEncode(iM.mess.parse(2,messItSep),"HTML")+"</s>";
  			else if(vC == "cmnt")	items += "<s>"+SYS.strEncode(iM.mess.parse(5,messItSep),"HTML")+"</s>";
  			else if(vC.slice(0,8) == "dscrCust") {
  			    sVl = (sVl=iM.mess.parse(1,messItSep).match("\\[\\[(.+)\\]\\]")).length ? sVl[1].parse(vC.slice(8).toInt(),"=>") : "";
  			    items += "<s>"+SYS.strEncode(sVl,"HTML")+"</s>";
  			}
  		items += "</r>\n";
  	}
  	items += "</tbl>";
  	toUpdate = false;
  }

  //Events process
  for(off = 0; (sval=event.parse(0,"\n",off)).length; ) {
  	//this.messInfo("TEST 01: Event="+sval);
  	if(abs(expOnFocus) && sval == "ws_FocusIn" && expOnItems >= 0 && sortAr.length > expOnItems && geomH == geomH_) {
  		if(expOnFocus < 0) geomY += expOnFocus;
  		geomH += abs(expOnFocus);
  		if(value.length) event += "usr_goquiet\n";
  	}
  	else if(abs(expOnFocus) && sval == "ws_FocusOut" && expOnItems >= 0 && sortAr.length > expOnItems && geomH != geomH_) {
  		if(expOnFocus < 0) geomY -= expOnFocus;
  		geomH -= abs(expOnFocus);
  	}
  	else if(sval == "ws_TableChangeSel") {
  		iM = curAlMess[value];
  		NAME = iM.mess.parse(0, messItSep);
  		DESCR = iM.mess.parse(1, messItSep) + " -> " + iM.mess.parse(2, messItSep);
  		st_open = iM.mess.parse(3, messItSep).length;
  		if(value.length) event += "usr_goquiet\n";
  	}
  	else if(( (sval == "usr_qtc" && (iM=curAlMess[value])) ||
  					(sval.slice(0,12) == "ws_TableEdit" && colms.parse(sval.parse(2,"_").toInt()-1,",") == "qttm" && (iM=curAlMess[sortAr[sval.parse(3,"_").toInt()].parse(1,"\n").toInt()])) )
  			&& !iM.mess.parse(3,messItSep).length)
  	{
  		//this.messInfo("TEST 02: value="+value+"; set="+set);
  		if(!com) SYS.messNote("OP:"+this.ownerSess().user()+":"+NAME, "'"+NAME+"'. "+tr("Command")+" : "+DESCR+" : : "+digComs.parse(0,";").parse(0,"-"));
  		var tmU;
  		tMess = iM.mess.parse(0,messItSep)+messItSep+iM.mess.parse(1,messItSep)+messItSep+iM.mess.parse(2,messItSep)+messItSep+
  					SYS.strftime(SYS.time(tmU),formDtTm.replace("%MS",(tmU/1000).toString(10,3)).replace("%US",tmU.toString(10,6)));
  		if((tVl1=iM.mess.parse(4,messItSep)).length || (tVl2=iM.mess.parse(5,messItSep)).length) {
  			tMess += messItSep+tVl1;
  			if((tVl2=iM.mess.parse(5,messItSep)).length) tMess += messItSep+tVl2;
  		}
  		iM.mess = tMess;
  		SYS.Archive.messPut(iM.tm, iM.utm, iM.categ, iM.level, iM.mess);
  		toUpdate = true;
  		com = false;
  	}
  	else if(sval == "usr_qtcMass")
  		for(i = 0; i < curAlMess.length; i++) {
  			iM = curAlMess[i];
  			if(!iM.mess.parse(3,messItSep).length) {
  				SYS.messNote("OP:"+this.ownerSess().user()+":"+iM.mess.parse(0,messItSep),
  						"'"+iM.mess.parse(0,messItSep)+"'. "+tr("Command")+" : "+iM.mess.parse(1, messItSep) + " -> " + iM.mess.parse(2, messItSep)+" : : "+digComs.parse(0,";").parse(0,"-"));
  				tMess = iM.mess.parse(0,messItSep)+messItSep+iM.mess.parse(1,messItSep)+messItSep+iM.mess.parse(2,messItSep)+messItSep+
  						SYS.strftime(SYS.time(tmU),formDtTm.replace("%MS",(tmU/1000).toString(10,3)).replace("%US",tmU.toString(10,6)));
  				if((tVl1=iM.mess.parse(4,messItSep)).length || (tVl2=iM.mess.parse(5,messItSep)).length) {
  					tMess += messItSep+tVl1;
  					if((tVl2=iM.mess.parse(5,messItSep)).length) tMess += messItSep+tVl2;
  				}
  				iM.mess = tMess;
  				SYS.Archive.messPut(iM.tm, iM.utm, iM.categ, iM.level, iM.mess);
  			}
  		}
  	else if(sval.slice(0,12) == "ws_TableEdit" && colms.parse(sval.parse(2,"_").toInt()-1,",") == "cmnt") {
  		iM = curAlMess[sortAr[sval.parse(3,"_").toInt()].parse(1,"\n").toInt()];
  		//this.messInfo("TEST 02: value="+value+"; set="+set);
  		SYS.Archive.messPut(iM.tm, iM.utm, iM.categ, iM.level, iM.mess.parse(0,messItSep)+messItSep+iM.mess.parse(1,messItSep)+messItSep+iM.mess.parse(2,messItSep)+messItSep+
  										iM.mess.parse(3,messItSep)+messItSep+iM.mess.parse(4,messItSep)+messItSep+set);
  	}
  }


ID: alarmsSt
PARENT: /wlb_originals/wdg_Box
ATTRS: owner;name;dscr;geomX;geomY;geomW;geomH;geomZ;evProc;pgOpenSrc;pgGrp;backColor;bordWidth;bordColor;
ICO:
  iVBORw0KGgoAAAANSUhEUgAAAEAAAAAnCAIAAAAw+tlrAAAAA3NCSVQICAjb4U/gAAAACXBIWXMA
  AA7EAAAOxAGVKw4bAAAE60lEQVRYhe2YTW8kRwGGn/qumpn2jJ1db+z1JpsEwgJCCkJw4PeQPwEX
  Llw5w50rd05RDhyQkDgmkdkQstpo7bXX3vXMdFd31wcHx4CEcjASGSLNc6y3q/p9qrtVUov33/9Z
  08ylFHfv7j9dDX3sS63W+f2DQ76CVxcv8sUzb/VXXfA/5bs//umPvvP2crnc29v7/R8+0MGHpplZ
  a4VAwc7OTq1FCDl2a6CWKoRQqdXqX3UXVsg7e0Z/3QIDaozdfPe1g4ODw8NDKWWz2NXT6TRMp3u7
  e0qpK90tX76SWitldvcPgJxSu14+mE6apvma6/4nn55cViFPnj75dGaHYdBGX5w+0/bo3bvf/p4Q
  ArDD8W5ohFRhMt279zpQa72O1vD5449daF6/f3S93HX08vz07PTUeW996FbLO4cPmqYZ+/ji/KzW
  Ol8sXjw/TSnVWu8//JYx8vO/Hhsf+vVqOt+9d3hfSHny5G+xHw8fvGmsvb7Xv3N+8kW7XiOEVPro
  0XvXgx9dAZaInb8mfv7r38xn0/XlmRQy5aykRFByEVKUXKzzKQ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FNsxXYNFuBTbMV2DRbgU2zFdg0W4FNsxXY
  NN94Af3qxfNnX+gr9Y38sXV+fv4PnB1oGOFeta8AAAAASUVORK5CYII=

PROC:
  JavaLikeCalc.JavaScript
  function testLev( v1, v2 ) {
  	isSub = abs(v1) > 7 && abs(v2) > 7;
  	v1_ = abs((!isSub && abs(v1) > 7) ? v1/10 : v1);
  	v2_ = abs((!isSub && abs(v2) > 7) ? v2/10 : v2);
  	return (v1_ >= v2_);
  }

  function getSrc( categ, sourceCache ) {
  	srcO = categ.match("^al(.+):([^\\.]+)|^(.*):al");
  	tVl = "";

  	//From remote station
  	if(srcO.length == 4)
  		for(off2 = 0, isFirst = true; (tVl2=srcO[3].parse(0,":",off2)).length; tVl += (tVl.length?".":"")+tVl2, isFirst = false) {
  			if(!isFirst)	continue;
  			if(!sourceCache[tVl2].isEVal())	tVl2 = sourceCache[tVl2];
  			else {
  				req = SYS.XMLNode("get").setAttr("path","/Transport/%2fsub%2fehost").setAttr("upRiseSYS",1);
  				SYS.cntrReq(req);
  				for(iTr = 0; req.childSize() && iTr < req.childGet(0).childSize(); iTr++)
  					if(req.childGet(0).childGet(iTr).text() == tVl2) {
  						tVl2 = sourceCache[tVl2] = req.childGet(1).childGet(iTr).text();
  						break;
  					}
  			}
  		}

  	return tVl;
  }

  if(f_start) {
  	cnt = 0;
  	toUpdate = makeReport = toMassQuitt = false;
  	wTm = 0;							//From current time
  	realPrTm = prTm = SYS.time() - 86400*size_value, prTmU = 0;		//From default set depth
  	messItSep = ": ";
  	als = new Array();			//Hierarchical alarms with the statuses
  	cAls = new Object();		//Last alarms by the criteria
  	alUnSel = 0;
  	highLght_ = new Array();
  	for(off = 0; (iH=highLght.parse(0,"\n",off)).length || off < highLght.length; ) {
  		if(!iH.length || iH[0] == "#")	continue;
  		iHo = new Object();
  		if(iH.parse(0,":").length > 3)
  			iHo.lev = iH.slice(0,2).toInt(), iHo.quiet = iH.slice(2,3).toInt()?1:0, iHo.act = iH.slice(3,4).toInt()?1:0;
  		else iHo.lev = iH.slice(0,1).toInt(), iHo.quiet = iH.slice(1,2).toInt()?1:0, iHo.act = iH.slice(2,3).toInt()?1:0;
  		iHo.color = iH.parse(1,":"); iHo.font = iH.parse(2,":"); iHo.fontColor = iH.parse(3,":");
  		highLght_.push(iHo);
  	}
  	colVars = new Array();
  	//Filters curent state proceed
  	fMax = 5;
  	fTopOrig = fTop = this["fltr0"].attr("geomY") + this["fltr0"].attr("geomH");
  	for(iF = fMax-1; iF > 0 && !this["fltr"+iF].attr("en"); iF--) ;
  	fTop = this["fltr"+iF].attr("geomY") + this["fltr"+iF].attr("geomH");

  	sourceCache = new Object();

  	user = user_ = "";
  }

  //Permitions load
  user = this.ownerSess().user();
  if(f_start || user != user_) {
  	user_ = user;
  	permLoc = EVAL, permLev = 0;
  	if(user != "root") {
  		permLoc = new Array();
  		permLev = 10;
  		gList = SYS.Security["usr_"+user].groups();
  		for(iG = 0; iG < gList.length; iG++) {
  			if(gList[iG] == "root") { permLoc = EVAL; break; }
  			gDescr = SYS.Security["grp_"+gList[iG]].cfg("LONGDESCR");
  			for(iLc = 0; iLc < 10; iLc++) {
  				if(permLoc[iLc].isEVal())	permLoc[iLc] = new Object();
  				if((itLc=gDescr.match("^loc"+iLc+"=(.+?)$","m")).length)
  					for(off = 0; (tVl=itLc[1].parse(0,";",off)).length; )
  						permLoc[iLc][tVl] = true;
  			}
  			if((itLev=gDescr.match("^lev=(.+?)$","m")).length)	permLev = min(permLev, itLev[1].toInt());
  		}
  		if(permLev == 10)	permLev = 0;
  	}

  	//To reload
  	realPrTm = prTm = (wTm?wTm:SYS.time()) - 86400*size_value, prTmU = 0;
  	als = new Array(); cAls = new Object();
  	toUpdate = true;
  }

  if(this.alarms.attr("focus"))	alUnSel = 10;	//Wait for 10 seconds
  else if(alUnSel > 0 && (alUnSel=max(0,alUnSel-1/f_frq)) <= 0) {
  	alarms_value = "";
  	if(this.wdgAt("/s/pg_control/pg_ElCadr",true).attr("prmShifr") == alarms_NAME)
  		this.wdgAt("/s/pg_control/pg_terminator",true).attrSet("pgOpen", true);
  }
  if(alarms_com) { event += "usr_qtc:/alarms\n"; alarms_st_open = true; }

  //Call per 1 seconds, start or force update
  if((((cnt++)%(f_frq*1) == 0 && !wTm) || f_start || toUpdate) && !f_stop) {
  	alMess = SYS.Archive.messGet(realPrTm, (wTm?wTm:SYS.time()), messCat, 1, alArch);

  	for(iM = 0, iRecv = 0, iAppend = 0; iM < alMess.length && iAppend < messLim; iM++) {
  		iMo = alMess[iM];
  		if(iMo.tm < prTm || (iMo.tm == prTm && iMo.utm <= prTmU) || abs(iMo.level) < permLev) continue;
  		// Check for permited location
  		if(!permLoc.isEVal() && (sVl=iMo.mess.parse(1,messItSep).match("\\[\\[(.+)\\]\\]")).length) {
  			for(off = 0, iLc = 0; (sVl2=sVl[1].parse(0,"=>",off)).length; iLc++)
  				if(!(permLoc[iLc]["*"] == true || permLoc[iLc][sVl2] == true))	break;
  			if(sVl2.length)	continue;
  		}

  		if(iMo.level < 0) {	//Alarm message
  			iMoA = cAls[iMo.categ];
  			// !!!! To prevent the duplicate entries for new alarms in that category.
  			if(!iMoA.isEVal() && iMoA.categ == iMo.categ && iMoA.tm == iMo.tm && iMoA.utm == iMo.utm) continue;
  			if(!iMoA.isEVal() && !iMoA.mess.parse(4,messItSep).length) {	//Renewal state set for not marked as NORMAL
  				iMoA.mess = iMoA.mess.parse(0,messItSep)+messItSep+iMoA.mess.parse(1,messItSep)+messItSep+iMoA.mess.parse(2,messItSep)+messItSep+iMoA.mess.parse(3,messItSep)+messItSep+
  						tr("Renewal")+messItSep+iMoA.mess.parse(5,messItSep);
  				/*if(iMoA.mess.parse(3,messItSep).length && !iMo.mess.parse(3,messItSep).length)	//Inherit the quietance fact from the previous
  					iMo.mess = iMo.mess.parse(0,messItSep)+messItSep+iMo.mess.parse(1,messItSep)+messItSep+iMo.mess.parse(2,messItSep)+messItSep+iMoA.mess.parse(3,messItSep)+messItSep+
  						iMo.mess.parse(4,messItSep)+messItSep+iMo.mess.parse(5,messItSep);
  				if(iMoA.mess.parse(5,messItSep).length && !iMo.mess.parse(5,messItSep).length)	//Inherit the comment from the previous
  					iMo.mess = iMo.mess.parse(0,messItSep)+messItSep+iMo.mess.parse(1,messItSep)+messItSep+iMo.mess.parse(2,messItSep)+messItSep+iMo.mess.parse(3,messItSep)+messItSep+
  						iMo.mess.parse(4,messItSep)+messItSep+iMoA.mess.parse(5,messItSep);*/
  			}
  			cAls[iMo.categ] = iMo;
  			iMo.lsPos = als.length;
  			als.push(iMo);
  			iAppend++;
  		}
  		else if(!(iMoA=cAls[iMo.categ]).isEVal()) {	//Norma or quietance
  			/*if(iMo.mess.parse(2,messItSep).match("\\s*(.+?)\\s*$")[1] == tr("QUITANCE")) {
  				if(!iMoA.mess.parse(3,messItSep).length)	//Fill for missed
  					iMoA.mess = iMoA.mess.parse(0,messItSep)+messItSep+iMoA.mess.parse(1,messItSep)+messItSep+iMoA.mess.parse(2,messItSep)+messItSep+
  						SYS.strftime(iMo.tm,formDtTm.replace("%MS",(iMo.utm/1000).toString(10,3)).replace("%US",iMo.utm.toString(10,6)))+messItSep+
  						iMoA.mess.parse(4,messItSep)+messItSep+iMoA.mess.parse(5,messItSep);
  			}
  			else*/
  			if(!(tVl=iMoA.mess.parse(4,messItSep)).length || tVl == tr("Norm on down"))	//Fill for missed
  				iMoA.mess = iMoA.mess.parse(0,messItSep)+messItSep+iMoA.mess.parse(1,messItSep)+messItSep+iMoA.mess.parse(2,messItSep)+messItSep+iMoA.mess.parse(3,messItSep)+messItSep+
  						SYS.strftime(iMo.tm,formDtTm.replace("%MS",(iMo.utm/1000).toString(10,3)).replace("%US",iMo.utm.toString(10,6)))+messItSep+
  						iMoA.mess.parse(5,messItSep);
  		}
  		iRecv++;
  		prTm = iMo.tm; prTmU = iMo.utm;
  	}
  	if(iM < alMess.length && iAppend >= messLim)	{ sizeLim_text = ((alMess.tm-alMess[iM-1].tm)/86400).toFixed(3); go_prev_sizeLim_en = true; }
  	else if(wTm || (SYS.time()-realPrTm) > 3600) { sizeLim_text = ""; go_prev_sizeLim_en = false; }
  	realPrTm = alMess.tm;
  	//Active alarms get for the gone on down ones detect
  	if(!wTm) {
  		actAlMess = SYS.Archive.messGet(0, SYS.time(), messCat, -1);
  		actAls = new Object();
  		for(iM = 0; iM < actAlMess.length; iM++) {
  			iMo = actAlMess[iM];
  			if(abs(iMo.level) < permLev) continue;
  			// Check for permited location
  			if(!permLoc.isEVal() && (sVl=iMo.mess.parse(1,messItSep).match("\\[\\[(.+)\\]\\]")).length) {
  				for(off = 0, iLc = 0; (sVl2=sVl[1].parse(0,"=>",off)).length; iLc++)
  					if(!(permLoc[iLc]["*"] == true || permLoc[iLc][sVl2] == true))	break;
  				if(sVl2.length)	continue;
  			}

  			actAls[iMo.categ] = iMo;
  		}
  		//Detect and mark "Norm on down"
  		for(var iA in cAls)
  			if(!(iMo=cAls[iA]).mess.parse(4,messItSep).length && !actAls[iMo.categ])
  				iMo.mess = iMo.mess.parse(0,messItSep)+messItSep+iMo.mess.parse(1,messItSep)+messItSep+iMo.mess.parse(2,messItSep)+messItSep+iMo.mess.parse(3,messItSep)+messItSep+
  						tr("Norm on down")+messItSep+iMo.mess.parse(5,messItSep);
  		//Force placing the active alarms to the list
  		for(var iA in actAls) {
  			iMo = cAls[iA]; iMo1 = actAls[iA];
  			if(iMo.isEVal() /*|| iMo1.tm > iMo.tm || (iMo1.tm == iMo.tm && iMo1.utm > iMo.utm)*/)
  			{ als.push(iMo1); cAls[iA] = iMo1; iRecv = true; }
  		}
  	}

  	if(iRecv || toUpdate) {
  		//Sort the messages
  		sortAr = new Array();
  		sR = sort_value.match("\\((.+)\\)")[1];
  		//this.messInfo("TEST 00: sR="+sR);		
  		for(iM = 0; iM < als.length; iM++) {
  			iMo = als[iM];
  			tvl = iM.toString(10,6);
  			if((sR_=sR.parse(0,":")) == "atm")	tvl = SYS.strftime(iMo.tm,formDtTm.replace("%MS",(iMo.utm/1000).toString(10,3)).replace("%US",iMo.utm.toString(10,6)));
  			else if(sR_ == "qttm")	tvl = iMo.mess.parse(3, messItSep);
  			else if(sR_ == "nrmtm")tvl = iMo.mess.parse(4, messItSep);
  			else if(sR_ == "lev")	tvl = iMo.level;
  			else if(sR_ == "type")	tvl = types.parse(abs(iMo.level), ";");
  			else if(sR_ == "cat")	tvl = iMo.categ;
  			else if(sR_ == "mess")	tvl = iMo.mess;
  			else if(sR_ == "prm")	{
  				tvl = iMo.mess.parse(0, messItSep);
  				if((tvl2=getSrc(iMo.categ,sourceCache)).length)	tvl = tvl2 + " > " + tvl;
  			}
  			else if(sR_ == "dscr")	tvl = iMo.mess.parse(1, messItSep).replace(new RegExp("\\[\\[.+\\]\\]"),"");
  			else if(sR_ == "alrm")	tvl = iMo.mess.parse(2, messItSep);
  			else if(sR_ == "cmnt")	tvl = iMo.mess.parse(5, messItSep);
  			//else if(sR_ == "src")	tvl = getSrc(iMo.categ, sourceCache);
  			else if(sR_.slice(0,8) == "dscrCust")
  				tvl = (tvl=iMo.mess.parse(1,messItSep).match("\\[\\[(.+)\\]\\]")).length ? tvl[1].parse(sR_.slice(8).toInt(),"=>") : "";
  			sortAr.push(">"+tvl+"\n"+iM);
  		}
  		sortAr = sortAr.sort();
  		if(sR.isEVal() || sR.parse(1,":") == "!")	sortAr = sortAr.reverse();
  		sort_items = tr("Disable");

  		for(iF = 0; iF < fMax; iF++) this["fltrCol"+iF].attrSet("items", tr("Disable"));

  		//The table content update
  		alarms_items = "<tbl sel='row' sortEn='1' colsWdthFit='1' hHdrVis='"+(hHdrVis?1:0)+"' vHdrVis='"+(vHdrVis?1:0)+"'>\n";
  		alarms_items += "<h><s width='0px'>ID</s>";
  		if(makeReport) rep = "<body>\n"
  			"<h1>"+tr("Alarms report for")+" "+SYS.strftime(wTm?wTm:SYS.time())+"</h1>\n"
  			"<table class='data' width='100%' export='1'><tr>\n";
  		for(vC = "", off = 0; (vC=colms.parse(0,",",off)).length; ) {
  			tvl = ""; toEdit = false;
  			if(vC == "atm")			tvl = tr("Alarm time");
  			else if(vC == "qttm")	tvl = tr("Quietance time");
  			else if(vC == "nrmtm")	{ tvl = tr("Norm"); colVars[vC] = new Object(); }
  			else if(vC == "lev")	tvl = tr("Lev.");
  			else if(vC == "type")	tvl = tr("Type");
  			else if(vC == "cat")	tvl = tr("Category");
  			else if(vC == "mess")	tvl = tr("Message");
  			else if(vC == "prm")	tvl = tr("Source");
  			else if(vC == "dscr")	tvl = tr("Description");
  			else if(vC == "alrm")	tvl = tr("Alarm");
  			else if(vC == "cmnt")	tvl = tr("Comment"), toEdit = true;
  			//else if(vC == "src")	tvl = tr("Source");
  			else if(vC.slice(0,8) == "dscrCust") {
  				nCust = vC.slice(8).toInt();
  				tvl = (tVl=colDscrCustNames.parse(nCust,";")).length ? tVl : tr("Custom")+" "+nCust;
  				colVars[vC] = new Object();
  			}
  			if(tvl.length) {
  				alarms_items += "<s"+(toEdit?" edit='1'":"")+((vC=="atm")?" sort='1'":"")+">"+tvl+"</s>";
  				if(makeReport) rep += "<th>"+tvl+"</th>";
  				sort_items += "\n"+tvl+" ("+vC+")\n"+tvl+", "+tr("reversed")+" ("+vC+":!)";
  				for(iF = 0; iF < fMax; iF++)
  					this["fltrCol"+iF].attrSet("items", this["fltrCol"+iF].attr("items")+"\n"+tvl+" ("+vC+")");
  			}
  		}
  		alarms_items += "</h>\n";
  		if(makeReport) rep += "</tr>\n";
  		for(iSM = 0; iSM < sortAr.length; iSM++) {
  			iM = als[iMid=sortAr[iSM].parse(1,"\n").toInt()];
  			//Check for higlight properties match
  			for(iHgl = false, iH = 0; iH < highLght_.length && !iHgl; iH++) {
  				iHo = highLght_[iH];
  				if(testLev(iM.level,iHo.lev) && (iM.mess.parse(3,messItSep).length?1:0) == iHo.quiet &&
  																 ((wTm||iM.mess.parse(4,messItSep).length)?0:1) == iHo.act)
  					iHgl = iHo;
  			}
  			aRow = "<r"+(iHgl?" color='"+iHgl.color+"' font='"+iHgl.font+"' colorText='"+iHgl.fontColor+"'":"")+"><i>"+iMid+"</i>";
  			if(makeReport) repRow = "<tr>\n";
  			for(vC = "", off = 0, isMatch = true; isMatch && (vC=colms.parse(0,",",off)).length; ) {
  				if(vC == "atm")			{ sVl = SYS.strftime(iM.tm,formDtTm.replace("%MS",(iM.utm/1000).toString(10,3)).replace("%US",iM.utm.toString(10,6))); aRow += "<s>"+sVl+"</s>"; }
  				else if(vC == "qttm")	{ sVl = iM.mess.parse(3, messItSep); aRow += (sVl.length ? "<s>"+sVl+"</s>" : "<b edit='1'>0</b>"); }
  				else if(vC == "nrmtm")	{
  					if(!(sVl=iM.mess.parse(4,messItSep)).length && !wTm) sVl = tr("Active");
  					aRow += "<s align='center'>"+sVl+"</s>";
  					if(!sVl.toInt()) colVars[vC][sVl] = true;
  				}
  				else if(vC == "lev")	{ sVl = abs(iM.level).toString(); aRow += "<s align='center'>"+sVl+"</s>"; }
  				else if(vC == "type")	{ sVl = types.parse(abs(iM.level), ";"); aRow += "<s align='center'>"+sVl+"</s>"; }
  				else if(vC == "cat")	{ sVl = iM.categ; aRow += "<s>"+SYS.strEncode(sVl,"HTML")+"</s>"; }
  				else if(vC == "mess")	{ sVl = iM.mess; aRow += "<s>"+SYS.strEncode(sVl,"HTML")+"</s>"; }
  				else if(vC == "prm")	{
  					sVl = iM.mess.parse(0, messItSep);
  					if((tvl2=getSrc(iM.categ, sourceCache)).length)	sVl = tvl2 + " > " + sVl;
  					aRow += "<s>"+SYS.strEncode(sVl,"HTML")+"</s>";
  				}
  				else if(vC == "dscr")	{ sVl = iM.mess.parse(1, messItSep).replace(new RegExp("\\[\\[.+\\]\\]"),""); aRow += "<s>"+SYS.strEncode(sVl,"HTML")+"</s>"; }
  				else if(vC == "alrm")	{ sVl = iM.mess.parse(2, messItSep); aRow += "<s>"+SYS.strEncode(sVl,"HTML")+"</s>"; }
  				else if(vC == "cmnt")	{ sVl = iM.mess.parse(5, messItSep); aRow += "<s>"+SYS.strEncode(sVl,"HTML")+"</s>"; }
  				//else if(vC == "src")	{ sVl = getSrc(iM.categ, sourceCache); aRow += "<s>"+SYS.strEncode(sVl,"HTML")+"</s>"; }
  				else if(vC.slice(0,8) == "dscrCust") {
  					nCust = vC.slice(8).toInt();
  					sVl = (sVl=iM.mess.parse(1,messItSep).match("\\[\\[(.+)\\]\\]")).length ? sVl[1].parse(nCust,"=>") : "";
  					aRow += "<s>"+SYS.strEncode(sVl,"HTML")+"</s>";
  					colVars[vC][sVl] = true;
  				}
  				for(iF = 0; iF < fMax; iF++)
  					if(vC == this["fltrCol"+iF].attr("value").match("\\((.+)\\)")[1] && (tVl=this["fltr"+iF].attr("value")).length) {
  							if(vC == "lev")	isMatch = (sVl.toInt() >= tVl.toInt());
  							else if(vC == "nrmtm" || vC.slice(0,8) == "dscrCust")	isMatch = (sVl.match(tVl).length > 0);
  							else isMatch = (sVl.indexOf(tVl) >= 0);
  					}
  				if(makeReport) repRow += "<td>"+SYS.strEncode(sVl,"HTML")+"</td>";
  			}
  			if(isMatch) {
  				alarms_items += aRow + "</r>\n";
  				if(makeReport) rep += repRow + "</tr>\n";
  				if(toMassQuitt && !iM.mess.parse(3,messItSep).length) {
  					SYS.messNote("OP:"+this.ownerSess().user()+":"+iM.mess.parse(0,messItSep),
  						"'"+iM.mess.parse(0,messItSep)+"'. "+tr("Command")+" : "+iM.mess.parse(1, messItSep) + " -> " + iM.mess.parse(2, messItSep)+" : : "+alarms_digComs.parse(0,";").parse(0,"-"));
  					tmU = 0;
  					tMess = iM.mess.parse(0,messItSep)+messItSep+iM.mess.parse(1,messItSep)+messItSep+iM.mess.parse(2,messItSep)+messItSep+
  						SYS.strftime(SYS.time(tmU),formDtTm.replace("%MS",(tmU/1000).toString(10,3)).replace("%US",tmU.toString(10,6)));
  					if((tVl1=iM.mess.parse(4,messItSep)).length || (tVl2=iM.mess.parse(5,messItSep)).length) {
  						tMess += messItSep+tVl1;
  						if((tVl2=iM.mess.parse(5,messItSep)).length) tMess += messItSep+tVl2;
  					}
  					iM.mess = tMess;
  					isCurAct = ((iAo=actAls[iM.categ]) && iAo.tm == iM.tm && iAo.utm == iM.utm);
  					SYS.Archive.messPut(iM.tm, iM.utm, iM.categ, iM.level, iM.mess, isCurAct?"":alArch);
  				}
  			}
  		}
  		alarms_items += "</tbl>";
  		if(makeReport) { rep += "</table>\n</body>\n"; go_report_report = rep; }

  		//Filter's selection list update
  		for(iF = 0; iF < fMax; iF++) {
  			iFCo = this["fltrCol"+iF]; iFo = this["fltr"+iF];
  			fCol = iFCo.attr("value").match("\\((.+)\\)")[1];
  			fCfg = "";
  			if(colVars[fCol]) {
  				fCfgPref = iFo.attr("value");
  				for(sumVl = "", tVl1 = "", off = 0; (tVl=fCfgPref.parse(0,"|",off)).length; tVl1 = tVl)
  					if(tVl1.length) { sumVl += (sumVl.length?"|":"")+tVl1; fCfg += sumVl + "\n"; }
  				custColO = colVars[fCol];
  				for(var iFv in custColO)
  					if(iFv.length && fCfgPref.indexOf(iFv) < 0) fCfg += (fCfgPref.length?fCfgPref+"|":"") + iFv + "\n";
  			}
  			iFo.attrSet("cfg", fCfg);
  		}
  	}
  	toUpdate = makeReport = false;
  }

  if(toMassQuitt) { toMassQuitt = false; toUpdate = true; }

  //Events process
  for(off = 0; (sval=event.parse(0,"\n",off)).length; ) {
  	//this.messInfo("TEST 01: Event="+sval+" : "+alarms_value);
  	isFirst = isSec = false;
  	if(sval == "ws_FocusIn:/alarms") {
  		alarms_geomY = fTopOrig; alarms_geomH += fTop-fTopOrig;
  		if(alarms_value.length) event += "usr_goquiet:/alarms\n";
  	}
  	else if(sval == "ws_FocusOut:/alarms")	{ alarms_geomY = fTop; alarms_geomH -= fTop-fTopOrig; }
  	else if(( (sval == "usr_qtc:/alarms" && (iM=als[alarms_value])) ||
  					(sval.slice(0,12) == "ws_TableEdit" && colms.parse(sval.parse(2,"_").toInt()-1,",") == "qttm" && (iM=als[sortAr[sval.parse(3,"_").toInt()].parse(1,"\n").toInt()])) )
  			&& !iM.mess.parse(3,messItSep).length)
  	{
  		//this.messInfo("TEST 02: value="+alarms_value+"; set="+alarms_set);
  		if(!alarms_com) SYS.messNote("OP:"+this.ownerSess().user()+":"+alarms_NAME, "'"+alarms_NAME+"'. "+tr("Command")+" : "+alarms_DESCR+" : : "+alarms_digComs.parse(0,";").parse(0,"-"));
  		tmU = 0;
  		tMess = iM.mess.parse(0,messItSep)+messItSep+iM.mess.parse(1,messItSep)+messItSep+iM.mess.parse(2,messItSep)+messItSep+
  					SYS.strftime(SYS.time(tmU),formDtTm.replace("%MS",(tmU/1000).toString(10,3)).replace("%US",tmU.toString(10,6)));
  		if((tVl1=iM.mess.parse(4,messItSep)).length || (tVl2=iM.mess.parse(5,messItSep)).length) {
  			tMess += messItSep+tVl1;
  			if((tVl2=iM.mess.parse(5,messItSep)).length) tMess += messItSep+tVl2;
  		}
  		iM.mess = tMess;
  		isCurAct = ((iAo=actAls[iM.categ]) && iAo.tm == iM.tm && iAo.utm == iM.utm);
  		SYS.Archive.messPut(iM.tm, iM.utm, iM.categ, iM.level, iM.mess, isCurAct?"":alArch);
  		toUpdate = true;
  		alarms_com = false;
  	}
  	else if(sval == "ws_BtPress:/quietMass")	toMassQuitt = toUpdate = true;
  	else if(sval == "ws_TableChangeSel:/alarms") {
  		iM = als[alarms_value];
  		alarms_NAME = iM.mess.parse(0, messItSep);
  		alarms_DESCR = iM.mess.parse(1, messItSep) + " -> " + iM.mess.parse(2, messItSep);
  		alarms_st_open = iM.mess.parse(3, messItSep).length;
  		if(alarms_value.length) event += "usr_goquiet:/alarms\n";
  	}
  	else if(sval.slice(0,12) == "ws_TableEdit" && colms.parse(sval.parse(2,"_").toInt()-1,",") == "cmnt") {
  		iM = als[sortAr[sval.parse(3,"_").toInt()].parse(1,"\n").toInt()];
  		//this.messInfo("TEST 03: value="+alarms_value+"; set="+alarms_set);
  		iM.mess = iM.mess.parse(0,messItSep)+messItSep+iM.mess.parse(1,messItSep)+messItSep+iM.mess.parse(2,messItSep)+messItSep+
  						iM.mess.parse(3,messItSep)+messItSep+iM.mess.parse(4,messItSep)+messItSep+alarms_set;
  		isCurAct = ((iAo=actAls[iM.categ]) && iAo.tm == iM.tm && iAo.utm == iM.utm);
  		SYS.Archive.messPut(iM.tm, iM.utm, iM.categ, iM.level, iM.mess, isCurAct?"":alArch);
  	}
  	else if(sval == "ws_CombChange:/sort")	toUpdate = true;
  	else if(sval.slice(0,22) == "ws_CombChange:/fltrCol") {
  		fN = sval.slice(22).toInt();
  		fAct = !this["fltrCol"+fN].attr("value").match("\\((.+)\\)")[1].isEVal();
  		this["fltr"+fN].attrSet("active", fAct).attrSet("value", "");
  		if(fAct && (fN+1) < fMax && !this["fltrCol"+(fN+1)].attr("en")) {
  			this["fltrCol"+(fN+1)].attrSet("en", true);
  			this["fltr"+(fN+1)].attrSet("en", true).attrSet("active", false).attrSet("value", "");
  		}
  		else for(iF = fMax-1; !fAct && iF >= fN; iF--)
  			if(iF < (fMax-1)) {
  				this["fltrCol"+(iF+1)].attrSet("en", false).attrSet("value", tr("Disable"));
  				this["fltr"+(iF+1)].attrSet("en", false).attrSet("active", false).attrSet("value", "");
  			}
  		//Apply filter vertical offset and size
  		for(iF = fMax-1; iF > 0 && !this["fltr"+iF].attr("en"); iF--) ;
  		fTop_ = this["fltr"+iF].attr("geomY") + this["fltr"+iF].attr("geomH");
  		alarms_geomH += fTop-fTop_; fTop = fTop_; alarms_geomY = fTop;

  		toUpdate = true;
  	}
  	else if(sval.slice(0,17) == "ws_LnAccept:/fltr")	toUpdate = true;
  	else if((isFirst=(sval=="ws_LnAccept:/size")) || (isSec=(sval=="ws_LnAccept:/time")) || sval == "ws_BtPress:/go_cur") {
  		if(!isFirst)	{
  			wTm = isSec ? time_value : 0;
  			if(wTm >= SYS.time()) wTm = 0;
  		}
  		realPrTm = prTm = (wTm?wTm:SYS.time()) - 86400*size_value, prTmU = 0;
  		als = new Array(); cAls = new Object();
  		toUpdate = true;
  	}
  	else if((isFirst=(sval=="ws_BtPress:/go_prev")) || (isSec=(sval=="ws_BtPress:/go_prev_sizeLim")) || sval == "ws_BtPress:/go_prev1") {
  		wTm = max(0, (wTm?wTm:SYS.time())-86400*(isSec?sizeLim_text.toReal():size_value)*((isFirst||isSec)?1:5));
  		realPrTm = prTm = wTm - 86400*size_value, prTmU = 0;
  		als = new Array(); cAls = new Object();
  		toUpdate = true;
  	}
  	else if((isFirst=(sval=="ws_BtPress:/go_next")) || sval == "ws_BtPress:/go_next1") {
  		if((wTm=(wTm?wTm:SYS.time()) + 86400*size_value*(isFirst?1:5)) >= SYS.time()) wTm = 0;
  		realPrTm = prTm = (wTm?wTm:SYS.time()) - 86400*size_value, prTmU = 0;
  		als = new Array(); cAls = new Object();
  		toUpdate = true;
  	}
  	else if(sval == "ws_BtPress:/go_report")				toUpdate = makeReport = true;
  }

  time_value = wTm ? wTm : SYS.time();
  //go_cur_active = wTm;


ID: ImgLab
PARENT: /wlb_originals/wdg_Media
ATTRS: owner;name;dscr;active;geomW;geomH;contextMenu;evProc;backColor;bordWidth;bordColor;src;fit;
ICO:
  [encoded data, 4568 characters]

PROC:
  JavaLikeCalc.JavaScript
  function setActMess(mess) {
  	if(err.isEVal())	SYS.messNote("OP:"+this.ownerSess().user()+":"+NAME, "'"+NAME+"'."+mess);
  	else SYS.nodeAt(err).nodePrev().messSet("'"+NAME+"'."+mess, 2, "OP", this.ownerSess().user());
  }

  if(f_start) {
  	isErr = false, alBlnk = false, cnt = 0;
  	toFastCalc = toFastCalc_ = false;
  }

  toFastCalc = false;

  //Prepare/update the context menu
  if(f_start || ((cnt++)%max(1,f_frq*10)) == 0) {
  	EVALclr = imgs.parse(2,":").parse(1,"-");
  	contextMenu = "";
  	if(!digComs.isEVal() && digComs.length) {
  		if(!com_text.isEVal())
  			for(off = 0; (comVal=digComs.parse(0,";",off)).length; )
  				contextMenu += comVal.parse(0,"-") + ":" + comVal.parse(0,"-") + "\n";
  		else {
  			if((comVal=digComs.parse(0,";")).length)	contextMenu += comVal.parse(0,"-") + ":open\n";
  			if((comVal=digComs.parse(1,";")).length)	contextMenu += comVal.parse(0,"-") + ":close\n";
  			if((comVal=digComs.parse(2,";")).length)	contextMenu += comVal.parse(0,"-") + ":stop\n";
  		}
  	}
  }

  //Display label from st_img
  stCur = -1;
  if(!st_img.isEVal() && st_img.length) {
  	src = st_img.parse(0,":");
  	blink = st_img.parse(2,":").toInt();
  	backClr = st_img.parse(1,":").parse(0,"-");
  	if(blink) {
  		backClrBl = st_img.parse(1,":").parse(1,"-");
  		if(!backClrBl.length)	backClrBl = EVALclr;
  		backColor = (backColor!=backClr) ? backClr : backClrBl;
  	}
  	else	backColor = backClr;
  }
  //Display typical for st_open
  else if(st_open == true || st_close == false) {
  	backColor = (stVal=imgs.parse(0,":").parse(1,"-")) ? "*" : digStts.parse(0,";").parse(1,"-");
  	src = imgs.parse(0, ":");
  	stCur = 1;
  }
  else if(st_open == false || st_close == true) {
  	backColor = (stVal=imgs.parse(1,":").parse(1,"-")) ? "*" : digStts.parse(1,";").parse(1,"-");
  	src = imgs.parse(1, ":");
  	stCur = 0;
  }
  else {
  	src = imgs.parse(2,":").parse(0,"-");
  	backColor = EVALclr;
  	return;
  }
  if(!backColor.length)	backColor = "black-1";	//For the activity cursor

  //Blink linked with ElCadr
  if(this.attr("focus") ||
  	(!NAME.isEVal() && this.wdgAt("/s/pg_control/pg_ElCadr",true).attr("pgOpen") && this.wdgAt("/s/pg_control/pg_ElCadr",true).attr("prmShifr") == NAME))
  {
  	bordColor = (bordColor != "white") ? "white" : "black";
  	if(bordWidth) bordWidth = 2;
  	toFastCalc = true;
  }
  else { if(bordWidth) bordWidth = 1; bordColor = "black"; }

  //Notification create
  if(ntf.length && (ntf.toInt() == stCur) != isErr) {
  	if((isErr=(ntf.toInt()==stCur)))	alarm = "50|"+NAME+"|"+ntf.parse(2,":")+".|"+ntf.parse(1,":");
  	else if(alarmSt&0x100)	alarm = "1|"+NAME+"||1";
  }
  if(!isErr && alarmSt&0x100 && !(alarmSt&0x10000)) alarm = "";
  if(alarmSt&0x100) {
  	if(!(alarmSt&0x10000) || alBlnk)	backColor = isErr ? "red" : backColor;
  	else backColor = (backColor==EVALclr) ? "#383838" : EVALclr, toFastCalc = true;
  	alBlnk = !alBlnk;
  }

  //Events process
  for(ev_rez = "", off = 0; (sval=event.parse(0,"\n",off)).length; ) {
  	//SYS.messInfo("TextLab","Event: "+sval);
  	if(!com_text.isEVal() && sval.indexOf("usr_") == 0) {
  		com_text = comVal = sval.slice(4);
  		setActMess(tr("Command")+" : "+DESCR+" : : "+comVal);
  	}
  	else if(sval == "usr_open") {
  		if(!com.isEVal())	com = true;
  		else close = false;
  		comVal = (comVal=digComs.parse(0,";")).length ? comVal.parse(0,"-") : tr("ENABLE");
  		setActMess(tr("Command")+" : "+DESCR+" : : "+comVal);
  	}
  	else if(sval == "usr_close") {
  		if(!close.isEVal())	close = true;
  		else com = false;
  		comVal = (comVal=digComs.parse(1,";")).length ? comVal.parse(0,"-") : tr("DISABLE");
  		setActMess(tr("Command")+" : "+DESCR+" : : "+comVal);
  	}
  	else if(sval == "usr_stop") {
  		if(!stop.isEVal())	stop = true;
  		comVal = (comVal=digComs.parse(2,";")).length ? comVal.parse(0,"-") : tr("STOP");
  		setActMess(tr("Command")+" : "+DESCR+" : : "+comVal);
  	}
  	else ev_rez += sval+"\n";
  }
  event = ev_rez;

  if(toFastCalc != toFastCalc_)	{ toFastCalc_ = toFastCalc; this.calcPer(toFastCalc?500:-3); }


ID: userManager
PARENT: /wlb_Main/wdg_RootPgSo/wdg_pgCont
ATTRS: id;owner;perm;name;dscr;geomH;evProc;backColor;
ICO:
  iVBORw0KGgoAAAANSUhEUgAAAEAAAAAnCAIAAAAw+tlrAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAC
  /klEQVRYhe2Zy07bQBiFx+OxnYydC04h0K5ggRJub8ArAEuegrdgy2OwZcGGHS/AgghEKhEJobYh
  JUIE4kkm8Xj+LqwiBC5N0z9EkfhWo7kczxlf5tg2dnZ2UqkUQaLb7abTaSy1vyKlZKlUinOOpXh9
  fd3v95VSruu6rttut03TfHh4yGazQRBQSgkha2trjDGsIzLOOdaaAUC5XP5Tq1IKACzLchwndvL/
  SCkZ53xxcXFoCQCoVCoAYBjG2z2fVr3X6w19uBcIIdjU1NTm5ubQEkqpSqVyf3/f6XRyuVwmk8Ga
  3IDgXIu+7/u+/7zGsizP81DEEwGAVqtFsAzc3t6GYUgImZmZsSyLELKwsLC9vY0inohSand3l2AZ
  mJ6efnEb1Ov1g4MDFPFEtNZxAcdAq9WKoshxHCklAPi+Pzc3t7GxgSKeSBRF5+fnBMtALpfr9Xq2
  bdu2TQihlDabzePjYxTxRKIoigs4BtrtNqVUa621BoAwDIvFYrFYRBFPJL7lCJYB0zTDMLRtGwAo
  pYZhZDKZ1dVVFPFEpJSHh4cEy8BIn5hvg7Olj5EPA+Nm4g2g5fIXBEEQbzQjAvkxGoZhHIFiAEBK
  WavVUMQTQY4SQojHx8c48TPGOOelUmlrawtFPBGl1NnZGcEykM/n8/n885parba3t4cinggAxAW0
  MBcvP6U0nU4bhlEoFNbX14dTu7i4qFarA3bGMcAYo5RKKR3HiWs8z1tZWRlOrdlsvreBOEogft0Y
  nInfBz4MjJuJNzCqKNFoNPb394cbe3d3N3jnURnodDqXl5cjEn/OxF9CHwbGzcQbYEKIk5OTocc/
  5fJxwTzPXS6XEtu6slutfjUpZZa1vLSU2EdrfXR09BRu3x/W7/e/ff9hmlRr/frHyezsbFyo39wQ
  QgzD0FqLIOCca9CGQcc49RjGudsOAkqpbdta6/n5+Te+UvVk92ejYWaztm1fXV0VPhW+fP78ntN9
  DTs9Pf2nl1cAUGFIzd/nCkggxEimNgBCiF83DDWOMRA+MgAAAABJRU5ErkJggg==

PROC:
  JavaLikeCalc.JavaScript
  if(f_start) {
  	grpLs = new Array(); userSelVl = lib_value_ = sesUer = "";
  	userLbUpdt = userSel = 0;
  }

  if(sesUer != this.ownerSess().reqUser()) {
  	userSel = userLbUpdt = SYS.mtime();
  	userSelVl = sesUer = this.ownerSess().reqUser();
  	if(denyUsers.indexOf(userSelVl) >= 0)	userSelVl = "";
  }

  //Events for commands process
  for(ev_rez = "", offEv = 0; (ev_cur=event.parse(0,"\n",offEv)).length; ) {
  	//this.messInfo("Event: "+ev_cur);
  	if(ev_cur == "ws_ListChange:/lib") {
  		userSel = SYS.mtime();
  		userSelVl = ((userSelVl=lib_value.match("\\((.+)\\)$")).length > 1) ? userSelVl[1] : "";
  	}
  	if(ev_cur == "ws_BtPress:/userAdd") {
  		if(!userNm_value.length) userNm_value = tr("NewUser");
  		req = SYS.XMLNode("add").setAttr("path","/sub_Security/%2fbr%2fusr_").setText(userNm_value);
  		if(!SYS.cntrReq(req).toInt()) {
  			userNm_value = req.text();
  			if(storeDB.length)
  				SYS.cntrReq(SYS.XMLNode("set").setAttr("path","/sub_Security/"+userNm_value+"/%2fprm%2fdb").setText(storeDB));
  			for(off = 0; (iIt=newUseGrps.parse(0,";",off)).length; )
  				if((oIt=SYS.Security.nodeAt("grp_"+iIt)))
  					oIt.cfgSet("USERS", oIt.cfg("USERS")+userNm_value+";");
  			lib_value_ = userNm_value+" ("+userNm_value+")"; userSelVl = userNm_value;
  			userLbUpdt = userSel = SYS.mtime()+500;

  			SYS.messNote("OP:"+this.ownerSess().user()+":{Page}."+this.attr("id"), title_text+" : "+tr("Added user \"%1\"").replace("%1",userNm_value));
  		}

  		SYS.cntrReq(SYS.XMLNode("save").setAttr("path","/sub_Security/%2fobj"));	//To save all users and groups
  	}
  	else if(ev_cur == "dlg_Apply:/userDel" && userSelVl.length) {
  		req = SYS.XMLNode("del").setAttr("path","/sub_Security/%2fbr%2fusr_").setText(userSelVl);
  		rez = SYS.cntrReq(req);
  		SYS.messNote("OP:"+this.ownerSess().user()+":{Page}."+this.attr("id"), title_text+" : "+tr("Deleted user \"%1\"").replace("%1",userNm_value));
  		//this.messInfo("Result: "+rez+": "+req.save());
  		lib_value_ = userSelVl = "";
  		userLbUpdt = userSel = SYS.mtime()+500;

  		SYS.cntrReq(SYS.XMLNode("save").setAttr("path","/sub_Security/%2fobj"));	//To save all groups
  	}
  	else if(ev_cur == "ws_LnAccept:/fullName" && (oIt=SYS.Security.nodeAt("usr_"+userSelVl))) {
  		oIt.cfgSet("DESCR", fullName_value);
  		SYS.cntrReq(SYS.XMLNode("save").setAttr("path","/sub_Security/usr_"+userSelVl+"/%2fobj"));
  		SYS.messNote("OP:"+this.ownerSess().user()+":{Page}."+this.attr("id"), title_text+" : "+tr("Set the user \"%1\" for").replace("%1",userSelVl)+" "+tr("Full name")+" : : "+fullName_value);
  		lib_value_ = fullName_value + " ("+userSelVl+")";
  		userLbUpdt = userSel = SYS.mtime()+500;
  	}
  	else if(ev_cur == "ws_TxtAccept:/descr" && (oIt=SYS.Security.nodeAt("usr_"+userSelVl))) {
  		oIt.cfgSet("LONGDESCR", descr_value);
  		SYS.cntrReq(SYS.XMLNode("save").setAttr("path","/sub_Security/usr_"+userSelVl+"/%2fobj"));
  		SYS.messNote("OP:"+this.ownerSess().user()+":{Page}."+this.attr("id"), title_text+" : "+tr("Set the user \"%1\" for").replace("%1",userSelVl)+" "+tr("Description")+" : : "+descr_value);
  		userSel = SYS.mtime()+500;
  	}
  	else if(ev_cur == "ws_LnAccept:/pass" && (oIt=SYS.Security.nodeAt("usr_"+userSelVl))) {
  		oIt.cfgSet("PASS", pass_value);
  		SYS.cntrReq(SYS.XMLNode("save").setAttr("path","/sub_Security/usr_"+userSelVl+"/%2fobj")); 
  		SYS.messNote("OP:"+this.ownerSess().user()+":{Page}."+this.attr("id"), title_text+" : "+tr("Set the user \"%1\" for").replace("%1",userSelVl)+" "+tr("Password")+" : : "+tr("CHANGED"));
  		userSel = SYS.mtime()+500;
  	}
  	else if(ev_cur == "ws_TableChangeSel:/grp" && (oIt=SYS.Security.nodeAt("usr_"+userSelVl)) &&
  			grp_value.length && (oIt1=SYS.Security.nodeAt(grp_value))) {
  		grp_value = grp_value.slice(4);
  		SYS.messNote("OP:"+this.ownerSess().user()+":{Page}."+this.attr("id"), title_text+" : "+tr("Set the user \"%1\" for").replace("%1",userSelVl)+" "+(oIt1.user(userSelVl)?tr("Group uncheck"):tr("Group check"))+" : : "+grp_value);
  		users = oIt1.cfg("USERS");
  		//this.messInfo("grp_value="+grp_value+"; users="+users);
  		oIt1.cfgSet("USERS", oIt1.user(userSelVl) ? users.replace(userSelVl+";","") : users+userSelVl+";");
  		SYS.cntrReq(SYS.XMLNode("save").setAttr("path","/sub_Security/grp_"+grp_value+"/%2fobj"));
  		//SYS.cntrReq(SYS.XMLNode("save").setAttr("path","/sub_Security/usr_"+userSelVl+"/%2fobj")); 
  		userSel = SYS.mtime()+500;
  	}
  	else ev_rez += (ev_cur+"\n");
  }
  event = ev_rez;

  //Get users and groups list
  if(f_start || (userLbUpdt && SYS.mtime() >= userLbUpdt)) {
  	userLbUpdt = 0;
  	rez = SYS.Security.nodeList("usr_");
  	//rez = SYS.BD.nodeAt(dbDB,".").SQLReq("SELECT name FROM "+dbProgs+";");
  	lib_items = userNm_cfg = "";
  	for(iIt = 0; iIt < rez.length; iIt++) {
  		if(denyUsers.indexOf(rez[iIt].slice(4)) >= 0 || !(oIt=SYS.Security.nodeAt(rez[iIt])))	continue;
  		tVl1 = ((tVl=oIt.cfg("DESCR")).length?tVl:rez[iIt].slice(4)) + " ("+rez[iIt].slice(4)+")";
  		lib_items += (lib_items.length?"\n":"") + tVl1;
  		userNm_cfg += (userNm_cfg.length?"\n":"") + rez[iIt].slice(4);
  		if(!userSelVl.length) userSelVl = rez[iIt].slice(4);
  		if(userSelVl == rez[iIt].slice(4))	lib_value_ = tVl1;
  	}
  	lib_value = lib_value_;

  	grpLs = SYS.Security.nodeList("grp_");
  	for(iL = 0; iL < grpLs.length; iL++)
  		if(denyGroups.indexOf(grpLs[iL].slice(4)) >= 0)
  		{ grpLs.splice(iL, 1); iL--; }
  }
  userDel_active = userSelVl.length;

  if(userSel && SYS.mtime() >= userSel) {
  	userSel = 0;
  	fullName_active = descr_active = pass_active = grp_active = false;
  	name_value = fullName_value = descr_value = pass_value = grp_items = "";

  	if(userSelVl.length && (oIt=SYS.Security.nodeAt(userSelVl))) {
  		//this.messInfo("userSelVl="+userSelVl);
  		fullName_active = descr_active = pass_active = grp_active = true;
  		name_value = oIt.cfg("NAME");
  		fullName_value = oIt.cfg("DESCR");
  		descr_value = oIt.cfg("LONGDESCR");
  		pass_value = oIt.cfg("PASS");
  		//Groups
  		grp_items = "<tbl sel='row' colsWdthFit='1' vHdrVis='0' hHdrVis='0' keyID='0'>\n"
  			"<h><s width='0'>Ідентифікатор</s><s>Група</s></h>\n";
  		for(iIt = 0; iIt < grpLs.length; iIt++) {
  			if(!(oIt=SYS.Security.nodeAt(grpLs[iIt])))	continue;
  			grp_items += "<r"+(oIt.user(userSelVl)?" color='#777799'":"")+">"
  				"<s>"+SYS.strEncode(grpLs[iIt],"HTML")+"</s>"
  				"<s>"+SYS.strEncode(oIt.cfg("DESCR")+" ("+grpLs[iIt].slice(4)+")","HTML")+"</s></r>";
  		}
  		grp_items += "</tbl>";
  		grp_value = "";
  	}
  }


ID: graphCalc
PARENT: /wlb_originals/wdg_Box
ATTRS: owner;name;dscr;geomW;geomH;pgOpenSrc;pgGrp;backColor;bordWidth;
ICO:
  iVBORw0KGgoAAAANSUhEUgAAAEAAAAAgCAIAAAAt/+nTAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAD
  X0lEQVRYhe2YzU7jRgCAZ8YziWPPjBNTwoJQoBKicEBqJLgguPMkPEDeaXvgxEOgPAGI21aiIK2d
  LPHP+Hc8nh6yaqtNWJVSyaXKd7DkGXv8fRrJkg0vLy8ppZ7nIYSUUlmWua4rhKjruigK27aVUhjj
  JEk452VZ5nlu2zZjLE1TpVRVVRjj+TFJEkopIWQ6nW5vb0dRVJal1towDMuyyrLknD8+PnLOhRCM
  sV6v53kexhghJKUEADw8POzv7wdBsLe3N5lMJpPJ2tra8/PzYDCIoghCKKXUWiulbNvu9/tCCEQp
  5Zx3Oh2EUBiGjuPEcUwIieO42+1CCH3f7/V67Xbbtm3HcSzLiqIoz/Msy4IgQAjN7YMggBAmSTIY
  DI6Pjw3DCIKAUuq6brvdTpIky7KyLBFC3W6XUiqEQAghhIqiEELMZrPZbDYcDuM45pwjhNbX1xFC
  GGPGmJQyz/OqqhzHabVanU5HSsk5p5TC0WjEOQcvoLXO87zT6XwzPpdevF5KWde1UqooCoyxaZpK
  KaWU53mMMcuywjDc2tpavAtCqJRqtVoQwm9mi6Jot9tL9aIoWiLxVyCEi/YAgKX2AID7+/soiiil
  aZq2Wq08z+u6Pjk5wRjf3d0xxo6OjhbvIoR8Z82X7L+afD9gKYwx13WXTu3s7CwdPzg4OD8//wfP
  eomnp6eqqsAfAWmaEkIMwwAASCkJIVprhNDihgIADg8Ph8OfPe/z1uZWGEWU0krKqqowwUADDQBj
  NI7jqqoYY7PnWa01Y8w029S2365eFGVd1x8//jKZTv8MKMsyy7LpdOq6bhAEGGOtdb/fp5QuLqFU
  laVJmee/fvoUhMGPu7tFUQiRQAgoY3Ecb3744Pu+lDKmdPrli6614zibm5vEMP6VgKqStdbzUzga
  jU5PTy3L+vtLcM5+WFt7u8pbePjtMYqi8XiMAQBnZ2cbGxvNCr2Wnw4Ofd8fj8eoaZO3sgpomlVA
  06wCmmYV0DSrgKZZBTTNKqBpMADg5ubmVR80/xHSNAXzgNvb29lsVtc1IYQQEoZhv99H6H1szldL
  0zTnv4DCMGxW6LVgAMDFxUW3223a5NUEQXB1dYUBALu7u+/umxgA4Ps++B+8hd59ABZCXF9fm6bZ
  tMmryfNcCPE7hI+m2a6F3MAAAAAASUVORK5CYII=

PROC:
  JavaLikeCalc.JavaScript
  if(f_start) {
  	//Connect to linked widget 
  	if(pgOpenSrc.length) lWdg = this.wdgAt(pgOpenSrc, true);
  	if(lWdg) {
  		attrO = SYS.nodeAt(lWdg.attr("addr"));
  		if(typeof(attrO) == "TCntrNode:TVal")	archO = attrO.arch();
  		else archO = attrO;
  		//this.messInfo("attrO="+typeof(attrO));
  	}

  	funcLs_active = funcCode_active = (lWdg && archO);
  	result_value = "";

  	if(funcCode_active) {
  		dtTm = lWdg.nodePrev().trnd1.attr("tSek");
  		if(dtTm <= 0)	dtTm = SYS.time();
  		dtTmBeg = dtTm - lWdg.nodePrev().trnd1.attr("tSize");
  		valArch = lWdg.nodePrev().trnd1.attr("valArch");

  		//Prepare the execution context
  		inPrcId = this.nodePath("_");
  		inPrcLng = "JavaLikeCalc.JavaScript";
  		inPrcErr = "";
  		inPrcArgs = new Object();
  		inPrcArgs.beg = dtTmBeg*1e6;
  		inPrcArgs.end = dtTm*1e6;
  		inPrcArgs.per = (inPrcArgs.end-inPrcArgs.beg) / 1000;
  		inPrcArgs.data = archO.getVals(inPrcArgs.beg, inPrcArgs.end, inPrcArgs.per, valArch);

  		title_text = tr("Calculation for the parameter \"%1\" archive at the data range [%2...%3] and the archiver \"%4\"")
  			.replace("%1", lWdg.attr("name"))
  			.replace("%2", SYS.strftime(1e-6*inPrcArgs.beg,"%Y-%m-%dT%H:%M:%S"))
  			.replace("%3", SYS.strftime(1e-6*inPrcArgs.end,"%Y-%m-%dT%H:%M:%S"))
  			.replace("%4", valArch.length ? valArch : tr("All"));

  		//Functions library
  		fLib = new Object();
  		fLib[tr("Sum, at hour")] = "vl = 0, prVl = EVAL;\n"
  			"for(i = 0; i < data.length; i++) {\n"
  			"	if((cVl=data[i]).isEVal() && !prVl.isEVal())	cVl = prVl;\n"
  			"	if(cVl.isEVal())	continue;\n"
  			"	vl += cVl;\n"
  			"	prVl = cVl;\n"
  			"}\n"
  			"result = \"Summary=\"+vl.toPrecision(6)+\"; \"\n"
  			"	\"Hours=\"+((end-beg)/3600e6).toPrecision(6)+\"; \"\n"
  			"	\"Value*hours=\"+(vl*per/3600e6).toPrecision(6);";
  		fLib[tr("Average and range")] = "vl = EVAL, cnt = 0, vlMax = -1e300, tmMax = 0, vlMin = 1e300, tmMin = 0;\n"
  			"for(i = 0; i < data.length; i++)\n"
  			"	if((cVl=data[i]).isEVal())	continue;\n"
  			"	else {\n"
  			"		if(vl.isEVal())	vl = cVl;\n"
  			"		else vl += cVl;\n"
  			"		if(cVl > vlMax)	vlMax = cVl, tmMax = i;\n"
  			"		if(cVl < vlMin)	vlMin = cVl, tmMin = i;\n"
  			"		cnt++;\n"
  			"	}\n"
  			"result = \"Average=\"+(vl/cnt).toPrecision(6)+\"; \"\n"
  			"	\"Minimum=\"+vlMin.toPrecision(6)+\"(\"+SYS.strftime(1e-6*(beg+tmMin*per))+\"); \"\n"
  			"	\"Maximum=\"+vlMax.toPrecision(6)+\"(\"+SYS.strftime(1e-6*(beg+tmMax*per))+\")\";";

  		funcLs_items = "";
  		for(var iL in fLib)	funcLs_items += (funcLs_items.length?"\n":"") + iL;			
  	}
  	else title_text = tr("Error connecting to the widget '%1'!").replace("%1", pgOpenSrc);

  	toCalc = funcCode_value.length;
  }

  //Events for commands process
  for(evRez = "", off = 0; (evCur=event.parse(0,"\n",off)).length; ) {
  	//this.messInfo("Event: "+evCur);
  	if(evCur == "ws_CombChange:/funcLs" && !fLib[funcLs_value].isEVal())
  		funcCode_value = fLib[funcLs_value], toCalc = true;
  	else if(evCur == "ws_TxtAccept:/funcCode")	toCalc = true;
  }

  //Calculation
  if(toCalc)	{
  	inPrcArgs.result = "";
  	rez = SYS.DAQ.funcCall(inPrcLng, inPrcArgs, funcCode_value, inPrcId, inPrcErr);
  	result_value = rez ? inPrcArgs.result : inPrcErr;
  	toCalc = false;
  }


ID: alarmsStReport
PARENT: /wlb_originals/wdg_Box
ATTRS: owner;name;dscr;geomW;geomH;pgGrp;backColor;bordWidth;
ICO:
  iVBORw0KGgoAAAANSUhEUgAAAEAAAAAwCAIAAAAuKetIAAAAA3NCSVQICAjb4U/gAAAACXBIWXMA
  AA7EAAAOxAGVKw4bAAAAqUlEQVRoge3PQQqDMBRF0ZjvtDj4ZP/LysBJnRSh+WBaG+sgpEsQ7OAh
  vLOCe7sYo6q6azKzXlVDCOiS8zw64F8cQOMAGgfQOIDGATQOoHEAjQNoHEDjABoH0DiAxgE0DqBx
  AI0DaBxA4wAaB9A4gMYBtMsP9OM4ppTQGQfinFsnS3sW9x6K7mUbNIiXdUm9mdVa0YUHpulRnZ/b
  3XeSy/bdyu31EZF9zT9OVjILd/qtqAAAAABJRU5ErkJggg==

PROC:
  JavaLikeCalc.JavaScript
  //Events for commands process
  for(off = 0, ev_rez = ""; (ev_cur=event.parse(0,"\n",off)).length; ) {
  	if(ev_cur == "ws_BtPress:/apply")	this.attrSet("pgOpen",false);
  	else ev_rez += ev_cur + "\n";
  }
  event = ev_rez;


ID: storeHouse
PARENT: /wlb_originals/wdg_Box
ATTRS: owner;name;dscr;geomX;geomY;geomW;geomH;geomZ;evProc;pgOpenSrc;pgGrp;backColor;bordWidth;bordColor;
ICO:
  iVBORw0KGgoAAAANSUhEUgAAAEAAAAApCAIAAAAK8LgbAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAB
  UklEQVRYhe3PQU/CMBjG8ba022C02yDEuSiYSNSIn40vxnfw7t2LmuhhV2S6dRusY3hB402Chjcm
  7+/UQ9s8fzqdTh3HITuYTG6KsrAty/P8oBfs8mQPpaUqY+bzRfx43+m4/tkVS0xSa10k0guUHzzf
  3Z4Pw+jo2PL6aZZxzrlSSghBCCHC5rZDNoRS2uKcUvr965pbQhjKWLksm/l6900bQujPt7YqktR1
  XZWrnuy4UjmcqEFjko3XHy116na7o8trZtNaBUy0y3XGpZTGGCllFEXGchdvabVaUUaH44tWi3/9
  2zRNVeY+M9vUQzj5PLTH0ntf1q+JtpvVIDp9eXogLPMCofOCzmazMAwPtemPxXHMoDf8FgZAwwBo
  GAANA6BhADQMgIYB0DAAGgZAwwBoGAANA6BhADQMgIYB0DAAGgZA+/cBXGudpin0jD3lef4BCBlp
  6Y0NgVMAAAAASUVORK5CYII=

PROC:
  JavaLikeCalc.JavaScript
  function messByLang(iMess) {
  	if((tVl=iMess.match("^"+(this.ownerSess().reqLang().length?this.ownerSess().reqLang():SYS.lang())+":(.+)$","m")).length)
  		return tVl[1];
  	return iMess.parseLine(0);
  }

  function labSize( ltext, charW ) {
  	if(charW == null)	charW = 11;
  	for(labSz = 0, off = 0; off < ltext.length; labSz++)
  		ltext.charAt(off, "UTF-8");

  	return ceil(ceil(labSz*charW*0.6)/10)*10;
  }

  function itHighl( celO, itVl ) {
  	if(celO == null)	return "";
  	tLs = new Array();
  	if(celO.fltr.indexOf("index") == 0 && itVl.length) { celO.ls[tVl=itVl.trim()] = true; tLs.push(tVl); }
  	else if(celO.fltr.indexOf("list") == 0)
  		for(tLs = itVl.split(celO.fltr[4]), iLs = 0; iLs < tLs.length; iLs++)
  			celO.ls[tLs[iLs]=tLs[iLs].trim()] = true;

  	for(iLn = 0, off = 0; tLs.length && (tVl=celO.fltr.parseLine(0,off)).length; iLn++)
  		if(iLn && tLs.indexOf(tVl.parse(0,":")) >= 0) return tVl;

  	return "";
  }

  function updProc(iR, dataTbl, clsLsO ) {
  	procLng = "JavaLikeCalc.JavaScript";
  	procArgs = new Object();

  	updReq = "";
  	for(iC = 0; iC < dataTbl[iR].length; iC++)
  		if((itID=dataTbl[0][iC]).indexOf("SP_") == 0)
  			procArgs[itID.slice(3)] = ((itVl=dataTbl[iR][iC]) != "<NULL>") ? itVl : "";
  	for(iC = 0; iC < dataTbl[iR].length; iC++) {
  		if((itID=dataTbl[0][iC]).indexOf("SP_") != 0 || (tClO=clsLsO[(itID=itID.slice(3))]).isEVal() || !tClO.prc.length || dataTbl[iR][iC] != "<NULL>") continue;
  		if(tClO.prcId == null) tClO.prcId = this.nodePath("_")+"_"+itID;
  			SYS.DAQ.funcCall(procLng, procArgs, tClO.prc, tClO.prcId);
  			dataTbl[iR][iC] = procArgs[itID];
  			updReq += (updReq.length?", ":"") + "`SP_"+itID+"`='"+SYS.strEncode(procArgs[itID],"SQL")+"'";
  		}
  	if(updReq.length)
  		SYS.BD.nodeAt(db,".").SQLReq("UPDATE `sh_"+class+"` SET "+updReq+" WHERE `"+dataTbl[0][0]+"`='"+dataTbl[iR][0]+"';", true);
  }

  var wUser;

  if(f_start || wUser != this.ownerSess().reqUser()) {
  	wUser = this.ownerSess().reqUser(), f_start = true;

  	geomHOrig = 580;
  	toUpdate = toReport = false;
  	fMax = 5; fClrTo = -1;
  	itEdFormMarg = 20;
  	itEdFormX = itEdFormMarg;
  	itEdFormY = this.lab_fltr.attr("geomY");
  	itEdFormW = geomW - 2*itEdFormMarg;
  	itEdFormLineHigh = 20;
  	itEdFormOff = null;	//Height offset of the last item of the configuration form
  	btClassEdit_en = dataEditable && classEditable;
  	if(classFix.length)	classNm_text = class = classFix;
  	else classSel_en = true;
  	colVars = new Object(), colLists = new Object();
  	btClassEdit_value = btEdit_en = btEdit_value = btItEdit_value = false;
  	geomH = geomHOrig;
  	dataTbl_geomH = itDel_geomY - dataTbl_geomY + itDel_geomH;
  }

  //Common events process
  for(off = 0; (sval=event.parse(0,"\n",off)).length; )
  	if(sval == "ws_BtToggleChange:/btClassEdit")	toUpdate = true, itDel_active = itCopy_active = false, dataTbl_value = "";
  	else if(sval == "ws_BtToggleChange:/btEdit")	toUpdate = true;
  	else if(sval == "ws_CombChange:/classSel") {
  		class = ((tVl=classSel_value.match("\\((.+)\\)$")).length) ? tVl[1] : classSel_value;
  		toUpdate = true; colVars = new Object(), colLists = new Object(); fClrTo = 0; dataTbl_value = "";
  		if(itEdFormOff != null)	itEdFormOff = -1;
  	}
  	else if(sval == "ws_LnAccept:/classEd") {
  		class = ((tVl=classEd_value.match("\\((.+)\\)$")).length) ? tVl[1] : classEd_value;
  		toUpdate = true; colVars = new Object(), colLists = new Object();
  	}

  if((f_start || toUpdate) /*&& !classFix.length*/) {
  	clsLs = SYS.BD.nodeAt(db,".").SQLReq("SELECT DISTINCT CLASS FROM `classes`;");
  	classSel_items = "";
  	for(iR = 1; iR < clsLs.length; iR++) {
  		clsNm = SYS.BD.nodeAt(db,".").SQLReq("SELECT `NAME` FROM `classes` WHERE `CLASS`='"+clsLs[iR][0]+"' AND `ID`='*TITLE';");
  		classSel_items += (classSel_items.length?"\n":"") + ((clsNm.length==2)?messByLang(clsNm[1][0]) + " ("+clsLs[iR][0]+")":clsLs[iR][0]);
  	}
  	classEd_cfg = classSel_items;

  	clsNm = SYS.BD.nodeAt(db,".").SQLReq("SELECT `NAME` FROM `classes` WHERE `CLASS`='"+class+"' AND `ID`='*TITLE';");
  	classNm_text = classSel_value = classEd_value = class;
  	if(clsNm.length == 2)	classNm_text = classSel_value = messByLang(clsNm[1][0]) + " ("+class+")";

  	dataTbl_geomY = btClassEdit_value ? lab_fltr_geomY : fltrCol0_geomY + fltrCol0_geomH;
  	dataTbl_geomH = itDel_geomY - dataTbl_geomY + ((btClassEdit_value||btEdit_value)?0:itDel_geomH);

  	//Apply filter vertical offset and size
  	if(!btClassEdit_value) {
  		for(iF = fMax-1; iF > 0 && !this["fltr"+iF].attr("en"); iF--) ;
  		dataTbl_geomY = this["fltr"+iF].attr("geomY") + this["fltr"+iF].attr("geomH");
  		dataTbl_geomH = itDel_geomY + (btEdit_value?0:itDel_geomH) - dataTbl_geomY;
  	}

  	btClassEdit_en = !(btItEdit_en && btItEdit_value);
  	btClassEdit_active = class.length;
  	classEd_en = btClassEdit_en && !classFix.length && btClassEdit_value;
  	classSel_en = btClassEdit_en && !classFix.length && !btClassEdit_value;

  	go_report_en = go_reportIt_en = !btClassEdit_value;
  }

  //Removing old edition fields of the item configuration form
  if(f_start || (btClassEdit_value && itEdFormOff != null) || itEdFormOff == -1) {
  	itEdFormOff = null;
  	geomH = geomHOrig;

  	wLs = this.nodeList("wdg_");
  	for(iW = 0; iW < wLs.length; iW++)
  		if(wLs[iW].indexOf("wdg_fItLab") == 0 || wLs[iW].indexOf("wdg_fItVal") == 0)
  			this.wdgDel(wLs[iW].slice(4));
  }

  //The class edition mode
  if(btClassEdit_value) {
  	dataTbl_en = itDel_en = itAdd_en = true;
  	btEdit_en = btItEdit_en = btItEdit_value = itCopy_en = false;

  	SYS.BD.nodeAt(db,".").SQLReq("CREATE TABLE IF NOT EXISTS `classes` (`CLASS` varchar(20) DEFAULT '', `ID` varchar(20) DEFAULT '', `NAME` text, `TP` varchar(100) DEFAULT '', `TBL` varchar(100) DEFAULT '', `FILTER` text, `PROC` text, PRIMARY KEY (`CLASS`,`ID`));", true);

  	//Updation the main table
  	if(f_start || toUpdate) {
  		// Requesting the table structure
  		dataTbl = SYS.BD.nodeAt(db,".").SQLReq("SELECT `ID`,`NAME`,`TP`,`TBL`,`FILTER`,`PROC` FROM `classes` WHERE `CLASS`='"+class+"';", false);
  		dataTbl_items = "<tbl sel='row' colsWdthFit='0' hHdrVis='1' vHdrVis='1'>\n";
  		for(iR = 0; iR < dataTbl.length; iR++) {
  			dataTbl_items += iR ? "<r>" : "<h>";
  			for(iC = 0; iC < dataTbl[iR].length; iC++) {
  				itVl = dataTbl[iR][iC];
  				tNm = "s", opt = "";
  				if(iR == 0)	 {
  					opt += " edit='1'";
  					if(itVl == "ID")				itVl = tr("Identifier");
  					else if(itVl == "NAME")	itVl = tr("Name");
  					else if(itVl == "TP")		itVl = tr("Type");
  					else if(itVl == "TBL")		itVl = tr("Table properties");
  					else if(itVl == "FILTER") itVl = tr("Filter");
  					else if(itVl == "PROC")	{ itVl = tr("Procedure"); opt += " width='400px'"; }
  				}
  				else {
  				    if(iC == 1 || iC == 4 || iC == 5)	tNm = "t";
  				    if(itVl == "<NULL>")	itVl = "";
  				}
  				dataTbl_items += "<"+tNm+opt+">"+SYS.strEncode(itVl,"HTML")+"</"+tNm+">";
  			}
  			dataTbl_items += iR ? "</r>\n" : "</h>\n";
  		}
  		dataTbl_items += "</tbl>";

  		toUpdate = false;
  	}

  	//Class edition events process
  	for(off = 0; (sval=event.parse(0,"\n",off)).length; ) {
  		itDel_active = itCopy_active = dataTbl_value.length;
  		if(sval == "ws_BtRelease:/itAdd") {
  			// Creation the empty data table with the default structure
  			if(dataTbl.length == 1) {
  				SYS.BD.nodeAt(db,".").SQLReq("CREATE TABLE IF NOT EXISTS `sh_"+class+"` (`ID` INT AUTO_INCREMENT, `NAME` varchar(200) DEFAULT '', `DSCR` text, PRIMARY KEY (`ID`));", true);
  				SYS.BD.nodeAt(db,".").SQLReq("INSERT INTO `classes` (`CLASS`,`ID`,`NAME`) VALUES ('"+class+"','*TITLE','');", true);
  				SYS.BD.nodeAt(db,".").SQLReq("INSERT INTO `classes` (`CLASS`,`ID`,`NAME`) VALUES ('"+class+"','*ID','');", true);
  				SYS.BD.nodeAt(db,".").SQLReq("INSERT INTO `classes` (`CLASS`,`ID`,`NAME`) VALUES ('"+class+"','*NAME','');", true);
  				SYS.BD.nodeAt(db,".").SQLReq("INSERT INTO `classes` (`CLASS`,`ID`,`NAME`) VALUES ('"+class+"','*DSCR','');", true);
  			}
  			SYS.BD.nodeAt(db,".").SQLReq("INSERT INTO `classes` (`CLASS`,`ID`,`NAME`,`TP`) VALUES ('"+class+"','NewItem','"+tr("New item")+"','varchar(100)');", true);
  			SYS.BD.nodeAt(db,".").SQLReq("ALTER TABLE `sh_"+class+"` ADD `SP_NewItem` varchar(100) DEFAULT '';", true);
  			toUpdate = true; toCalcCycles = 1;
  		}
  		else if(sval == "dlg_Apply:/itDel" && dataTbl_value[0] != "*") {
  		//else if(sval == "ws_BtRelease:/itDel") {
  			SYS.BD.nodeAt(db,".").SQLReq("DELETE FROM `classes` WHERE `ID`='"+dataTbl_value+"' AND `CLASS`='"+class+"';", true);
  			if(dataTbl.length > 2)	SYS.BD.nodeAt(db,".").SQLReq("ALTER TABLE `sh_"+class+"` DROP `SP_"+dataTbl_value+"`;", true);
  			else SYS.BD.nodeAt(db,".").SQLReq("DROP TABLE `sh_"+class+"`;", true);
  			toUpdate = true; toCalcCycles = 1;
  		}
  		else if(sval.indexOf("ws_TableEdit") == 0) {
  			col = sval.parse(0,"_",13).toInt(); row = sval.parse(1,"_",13).toInt();
  			colID = dataTbl[0][col];
  			fldID = dataTbl[row+1][0];
  			if(!SYS.BD.nodeAt(db,".").SQLReq("UPDATE `classes` SET `"+colID+"`='"+SYS.strEncode(dataTbl_set,"SQL")+"' WHERE `CLASS`='"+class+"' AND `ID`='"+fldID+"';",true).err.length) {
  				if(colID == "ID"  && fldID[0] != "*") {
  					SYS.BD.nodeAt(db,".").SQLReq("ALTER TABLE `sh_"+class+"` CHANGE `SP_"+fldID+"` `SP_"+dataTbl_set+"` "+dataTbl[row+1][2].parse(0,":")+";", true);
  					toCalcCycles = 1; //2000/this.ownerSess().period();
  				}
  				else if(colID == "TP" && (fldID[0] != "*" || fldID == "*NAME"))
  					SYS.BD.nodeAt(db,".").SQLReq("ALTER TABLE `sh_"+class+"` MODIFY `"+(fldID[0]=="*"?fldID.slice(1):"SP_"+fldID)+"` "+dataTbl_set.parse(0,":")+";", true);
  				else if(colID == "PROC" && dataTbl_set.length)
  					SYS.BD.nodeAt(db,".").SQLReq("UPDATE `sh_"+class+"` SET `SP_"+fldID+"`=NULL;", true);
  			}
  			toUpdate = true;
  		}
  	}

  	if(toCalcCycles > 0.1) {
  		this.attrSet("event", this.attr("event")+"usr_calc\n");	//!!!! Just to calc in the next session cycle for update
  		toCalcCycles = max(0, toCalcCycles-1);
  	}

  	return;
  }

  //The data representing mode
  if(f_start || toUpdate) {
  	go_report_active = dataTbl_en = lab_fltr_en = btEdit_en = itDel_en = itAdd_en = itCopy_en = fltr0_en = fltrCol0_en = !btItEdit_value;

  	//Generic table
  	//------------------
  	if(dataTbl_en) {
  		geomH = geomHOrig;

  		// Initiate the filter
  		for(iF = 0; iF < fMax; iF++)
  			this["fltrCol"+iF].attrSet("items", tr("Disabled")+"\n"+tr("Name")+" (NAME)\n"+tr("Description")+" (DSCR)");

  		// Requesting the table structure
  		clsLs = SYS.BD.nodeAt(db,".").SQLReq("SELECT `ID`,`NAME`,`TP`,`TBL`,`FILTER`,`PROC` FROM `classes` WHERE `CLASS`='"+class+"';");
  		clsLsO = new Object();	 clsLsSort = new Array();
  		hasProc = false;		//The scheme has procedures of the logical columns
  		for(iR = 1; iR < clsLs.length; iR++) {
  			clsLsO[clsLs[iR][0]] = tO = new Object();
  			tO.name = ((tO.name=clsLs[iR][1]) == "<NULL>" || !tO.name.length) ? clsLs[iR][0] : messByLang(tO.name);
  			tO.tp = clsLs[iR][2];
  			tO.tbl = clsLs[iR][3];
  			if((tO.fltr=clsLs[iR][4]) == "<NULL>")	tO.fltr = "";
  			if((tO.prc=clsLs[iR][5]) == "<NULL>")	tO.prc = "";
  			if(tO.prc.length) hasProc = true;
  			if(clsLs[iR][0] == "*ID") {
  				tO.name = (tO.name==clsLs[iR][0]) ? tr("Identifier") : tO.name;
  				tO.tp = "int";
  				tO.tbl = tO.tbl.length ? tO.tbl : "center:0px";
  			}
  			else if(clsLs[iR][0] == "*NAME") {
  				tO.name = (tO.name==clsLs[iR][0]) ? tr("Name") : tO.name;
  				tO.tp = tO.tp.length ? tO.tp : "varchar(200)";
  				tO.tbl = tO.tbl.length ? tO.tbl : "center:170px";
  			}
  			else if(clsLs[iR][0] == "*DSCR") {
  				tO.name = (tO.name==clsLs[iR][0]) ? tr("Description") : tO.name;
  				tO.tp = tO.tp.length ? tO.tp : "text";
  				tO.tbl = tO.tbl.length ? tO.tbl : ":350px";
  			}

  			if(clsLs[iR][0][0] != "*")
  				for(iF = 0; iF < fMax; iF++)
  					this["fltrCol"+iF].attrSet("items", this["fltrCol"+iF].attr("items")+"\n"+tO.name+" (SP_"+clsLs[iR][0]+")");

  			if(clsLs[iR][0] != "*TITLE") clsLsSort.push(tO.tbl.parse(2,":")+":"+iR.toString(10,3));
  		}
  		clsLsSort.sort();
  		clsLsReq = "";
  		for(iL = 0; iL < clsLsSort.length; iL++)
  			if((tVl=clsLs[clsLsSort[iL].parse(1,":").toInt()][0]) != "*ID")
  				clsLsReq += (clsLsReq.length?",":"") + "`"+((tVl[0]=="*")?tVl.slice(1):"SP_"+tVl)+"`";

  		//Updation the main table
  		// Where prepairing for the filter
  		noFilter = true;
  		for(wherePart = "", iF = 0; iF < fMax; iF++) {
  			if(!(tVl=this["fltr"+iF].attr("value")).length)	continue;
  			itVl = this["fltrCol"+iF].attr("value").match("\\((.+)\\)")[1];
  			wherePart += (wherePart.length?"AND":"") + " `"+itVl+"` REGEXP '"+tVl+"' ";
  			if(!colVars[itVl].isEVal())	colVars[itVl]["<lock>"] = true;
  			noFilter = false;
  		}
  		for(var iC in colVars)
  			if(colVars[iC]["<lock>"] == true)	delete colVars[iC]["<lock>"];
  			else delete colVars[iC];
  		// Same requesting
  		dataTbl = SYS.BD.nodeAt(db,".").SQLReq("SELECT `ID`,"+clsLsReq+" FROM `sh_"+class+"` "+(wherePart.length?"WHERE"+wherePart:"")+"ORDER BY 'ID';");
  		dataTbl_items = "<tbl sel='row' sortEn='"+(btEdit_value?0:1)+"' colsWdthFit='0' hHdrVis='1' vHdrVis='1'>\n";
  		colTps = new Object();
  		if(toReport)	tRep = "<body>\n"
  								"<h1>"+classNm_text+"</h1>\n"
  								"<table class='data' width='100%' export='1'>\n";
  		noDataTbl_value = true;
  		for(iR = 0; iR < dataTbl.length; iR++) {
  			cntR = optR = "";
  			if(toReport) tRep += "<tr>";
  			//   ... the header
  			if(iR == 0)
  				for(iC = 0; iC < dataTbl[iR].length; iC++) {
  					itVl = dataTbl[iR][iC];
  					opt = "";
  					if(itVl == "ID" && clsLsO["*"+itVl] == null)	opt += " width='0px'";
  					else if((itVl.indexOf("SP_") == 0 && !(tVl=clsLsO[itVl.slice(3)]).isEVal()) || ((itVl == "ID" || itVl == "NAME" || itVl == "DSCR") && !(tVl=clsLsO["*"+itVl]).isEVal()))
  					{
  						if((tVl.fltr == "index" || tVl.fltr.indexOf("list") == 0) && colVars[itVl] == null) {
  							colVars[itVl] = new Object();
  							colVars[itVl].ls = new Object();
  							colVars[itVl].fltr = tVl.fltr;
  						}
  						opt += (btEdit_value && !tVl.prc.length && itVl != "ID") ? " edit='1'" : "";
  						itVl = tVl.name;
  						if(tVl.tp.search("bool","i") >= 0)		colTps[iC] = "b";
  						else if(tVl.tp.search("int","i") >= 0)	colTps[iC] = "i";
  						else if(tVl.tp.search("(float|double)","i") >= 0) colTps[iC] = "r";
  						else if(tVl.tp.search("text","i") >= 0)	colTps[iC] = "t";
  						if((tVl2=tVl.tbl.parse(0,":")).length)	opt += " align='"+tVl2+"'";
  						if((tVl2=tVl.tbl.parse(1,":")).length)	opt += " width='"+tVl2+"'";
  						//this.messInfo("iC="+iC+"; tp="+tVl.tp+" = "+colTps[iC]+"; tVl.fltr="+tVl.fltr);
  					}
  					cntR += "<s"+opt+">"+SYS.strEncode(itVl,"HTML")+"</s>";
  					if(toReport) tRep += "<th>"+SYS.strEncode(itVl,"HTML")+"</th>";
  				}
  			//  ... the data
  			else {
  				//  ... prepairing the logical cells
  				if(hasProc) updProc(iR, dataTbl, clsLsO);

  				//  ... representing
  				for(iC = 0; iC < dataTbl[iR].length; iC++) {
  					itVlCol = dataTbl[0][iC];
  					itVl = dataTbl[iR][iC];
  					opt = "";
  					if(itVl == "<NULL>")	itVl = "";
  					if((tVl1=itHighl(colVars[itVlCol],itVl)).length) {
  						tVl = ((tVl=tVl1.parse(2,":")).length?" color='"+tVl+"'":"") + ((tVl=tVl1.parse(3,":")).length?" font='"+tVl+"'":"");
  						if(tVl1.parse(1,":")[0] == "1") optR += tVl; else opt += tVl;
  					}
  					if(noFilter)	colLists[itVlCol] = colVars[itVlCol].ls;
  					if(dataTbl_value.length && itVlCol == "ID" && itVl == dataTbl_value)	noDataTbl_value = false;
  				
  					if(!colTps[iC].isEVal())	cntR += "<"+colTps[iC]+opt+">"+SYS.strEncode(itVl,"HTML")+"</"+colTps[iC]+">";
  					else cntR += "<s"+opt+">"+SYS.strEncode(itVl,"HTML")+"</s>";
  					if(toReport)
  						tRep += "<td style='white-space: pre-wrap;"+((colTps[iC]=="t")?"text-align: left;":"")+"'>"+
  							SYS.strEncode(itVl,"HTML").replace(new RegExp("(http|https|ftp)://(\\S+)","g"),"<a target='_blank' href='$1://$2'>$2</a>")+
  							"</td>";
  				}
  			}
  			dataTbl_items += (iR?"<r":"<h")+optR+">" + cntR + (iR?"</r>\n":"</h>\n");
  			if(toReport) tRep += "</tr>\n";
  		}
  		dataTbl_items += "</tbl>\n";
  		if(toReport) { tRep += "</table>\n</body>\n"; go_report_report = tRep; tRep = ""; }

  		if(noDataTbl_value)	dataTbl_value = "";

  		//Filter's selection list update
  		for(iF = 0; iF < fMax; iF++) {
  			iFCo = this["fltrCol"+iF]; iFo = this["fltr"+iF];
  			fCol = iFCo.attr("value").match("\\((.+)\\)")[1];
  			//this.messInfo("iF="+iF+"; fCol="+fCol+"; colVars[fCol]="+colVars[fCol]);
  			if((tO=colVars[fCol]).isEVal())	continue;
  			tO = tO.ls;
  			fCfg = "";
  			fCfgPref = iFo.attr("value");
  			for(sumVl = "", tVl1 = "", off = 0; (tVl=fCfgPref.parse(0,"|",off)).length; tVl1 = tVl)
  				if(tVl1.length) { sumVl += (sumVl.length?"|":"")+tVl1; fCfg += sumVl + "\n"; }
  			for(var iFv in tO)
  				if(iFv.length && fCfgPref.indexOf(iFv) < 0)
  					fCfg += (fCfgPref.length?fCfgPref+"|":"") + iFv + "\n";
  				//fCfg += iFv+"\n";
  			iFo.attrSet("cfg", fCfg);
  		}
  	}
  	//Item edition form
  	//------------------
  	else if(btItEdit_value) {
  		toCreatFormIt = (itEdFormOff == null);	//Creating the form items

  		dataTblOneReq = SYS.BD.nodeAt(db,".").SQLReq("SELECT `ID`,"+clsLsReq+" FROM `sh_"+class+"` WHERE `ID`='"+dataTbl_value+"';");
  		for(iR = 1; iR < dataTblOneReq.length; iR++) {
  			if(dataTblOneReq[iR][0] != dataTbl_value) continue;

  			if(hasProc) updProc(iR, dataTblOneReq, clsLsO);

  			for(iC = 0; iC < dataTblOneReq[iR].length; iC++) {
  				itVlNm = itVlId = dataTblOneReq[0][iC];
  				if((itVlId.indexOf("SP_") == 0 && !(celO=clsLsO[itVlId.slice(3)]).isEVal()) || ((itVlId == "NAME" || itVlId == "DSCR") && !(celO=clsLsO["*"+itVlId]).isEVal()))
  					itVlNm = celO.name;
  				if((itVl=dataTblOneReq[iR][iC]) == "<NULL>") itVl = "";
  				if(toCreatFormIt) {
  					if(itEdFormOff == null)	itEdFormOff = itEdFormY, geomZoff = 100;
  					// Label
  					nwlO = this.wdgAdd("fItLab"+itVlId, "", "/wlb_originals/wdg_Text");
  					nwlO.attrSet("geomX", itEdFormX).attrSet("geomW", tVl2=labSize(itVlNm+":"))
  						.attrSet("geomY", itEdFormOff).attrSet("geomH", itEdFormLineHigh)
  						.attrSet("text", itVlNm+":").attrSet("alignment", 8);
  					// Value
  					if(celO.prc.length || itVlId == "ID") {	//RO items
  						nwO = this.wdgAdd("fItVal"+itVlId, "", "/wlb_originals/wdg_Text");
  						nwO.attrSet("geomX", itEdFormX+tVl2).attrSet("geomW", itEdFormW - tVl2)
  							.attrSet("geomY", itEdFormOff).attrSet("geomH", itEdFormLineHigh).attrSet("geomZ", geomZoff++)
  							.attrSet("alignment", 8);
  						itEdFormOff += itEdFormLineHigh;
  					}
  					else {
  						nwO = this.wdgAdd("fItVal"+itVlId, "", "/wlb_originals/wdg_FormEl");
  						nwO.attrSet("geomX", itEdFormX+tVl2).attrSet("geomW", itEdFormW - tVl2)
  							.attrSet("geomY", itEdFormOff).attrSet("geomH", itEdFormLineHigh).attrSet("geomZ", geomZoff++)
  							.attrSet("active", 1).attrSet("confirm", 0);
  						itEdFormOff += itEdFormLineHigh;
  						//this.messInfo("TEST 00: "+itVlId+" > "+celO.tp);
  						if(celO.tp.search("bool","i") >= 0)
  							nwO.attrSet("elType", 2);
  						else if(celO.tp.search("int","i") >= 0)
  							nwO.attrSet("geomW", 100).attrSet("elType", 0).attrSet("view", 0);
  						else if(celO.tp.search("(float|double)","i") >= 0)
  							nwO.attrSet("geomW", 100).attrSet("elType", 0).attrSet("view", 0);
  						else if(celO.tp.search("text","i") >= 0) {
  							txtH = 10*itEdFormLineHigh;
  							if((tVl3=celO.tbl.parse(1,":")).length) {
  								if(tVl3.indexOf("px") > 0)	txtH = (tVl3.toInt()/geomW)*geomHOrig;
  								else if(tVl3.indexOf("%") > 0)	txtH = (tVl3.toInt()/100)*geomHOrig;
  								else txtH = 3*itEdFormLineHigh;
  							}
  							nwO.attrSet("geomX", itEdFormX).attrSet("geomW", itEdFormW)
  								.attrSet("geomY", itEdFormOff).attrSet("geomH", txtH).attrSet("elType", 1);
  							itEdFormOff += txtH;
  						}
  					}
  				} else nwlO = this.wdgAt("fItLab"+itVlId), nwO = this.wdgAt("fItVal"+itVlId);
  				//Dynamic
  				// Selection for indexes
  				if((celO.fltr == "index" || celO.fltr.indexOf("list") == 0) && nwO.attr("elType") == 0) {
  					nwO.attrSet("view", 1);
  					fCfg = "", fCfgPref = (celO.fltr == "index" || !itVl.length) ? "" :
  														itVl+((celO.fltr[4]==" ")?"":celO.fltr[4]+" ");
  					if(celO.fltr.indexOf("list") == 0)
  						for(fCfgAdd = "", off = 0; (iFv=itVl.parse(0,celO.fltr[4],off)).length; )
  							fCfgAdd += (fCfgAdd.length?celO.fltr[4]:"") + iFv, fCfg += fCfgAdd + "\n";
  					for(var iFv in colLists[itVlId])
  						if(fCfg.indexOf(iFv) < 0)
  							fCfg += fCfgPref + iFv + "\n";
  					nwO.attrSet("cfg", fCfg);
  				}
  				// Highlighting
  				nwlO.attrSet("backColor","").attrSet("font","Arial 11");
  				if((tVl1=itHighl(celO,itVl)).length) {
  					if((tVl=tVl1.parse(2,":")).length)	nwlO.attrSet("backColor", tVl);
  					if((tVl=tVl1.parse(3,":")).length)	nwlO.attrSet("font", tVl);
  				}
  				// Value
  				nwO.attrSet((celO.prc.length||itVlId == "ID")?"text":"value", itVl);
  				delete nwlO; delete nwO;

  				if(itEdFormOff && (itEdFormOff+itEdFormMarg) > geomH)	geomH = itEdFormOff + itEdFormMarg;
  			}
  			break;
  		}
  		delete dataTblOneReq;
  	}

  	toUpdate = toReport = false;
  }

  if(event.length) {
  	itDel_active = itCopy_active = go_reportIt_active = dataTbl_value.length;
  	btItEdit_en = ((btEdit_en || btItEdit_value) && dataTbl_value.length);
  	if(btItEdit_en)	btItEdit_tipTool = btItEdit_value ? tr("Go to the Table") : tr("Go to the Item");
  }

  //Representing events process
  for(off = 0; (sval=event.parse(0,"\n",off)).length; ) {
  	if(sval == "ws_BtToggleChange:/btItEdit")	{
  		toUpdate = true, toCalcCycles = 1;
  		// Dynamic filter fields hide/show
  		var fClrToEd;
  		for(iF = 1; iF < fMax; iF++) {
  			tVal = (fClrToEd && iF <= fClrToEd);
  			if(this["fltr"+iF].attr("en"))	fClrToEd = iF;
  			this["fltrCol"+iF].attrSet("en", tVal); this["fltr"+iF].attrSet("en", tVal);
  		}
  		if(!btItEdit_en)	fClrToEd = null;
  		// Item edition fields show/hide
  		wLs = this.nodeList("wdg_");
  		for(iW = 0; iW < wLs.length; iW++)
  			if(wLs[iW].indexOf("wdg_fItLab") == 0 || wLs[iW].indexOf("wdg_fItVal") == 0)
  				this[wLs[iW]].attrSet("en", btItEdit_value);
  	}
  	else if(sval == "ws_BtRelease:/itAdd") {
  		nmLs = vlLs = "";
  		//Prepairing the filter values
  		for(iF = 0; iF < fMax; iF++) {
  			if(!(tVl=this["fltr"+iF].attr("value")).length)	continue;
  			nmLs += (nmLs.length?",":"") + "`"+this["fltrCol"+iF].attr("value").match("\\((.+)\\)")[1]+"`";
  			vlLs += (vlLs.length?",":"") + "'"+tVl+"'";
  		}
  		if(nmLs.indexOf("`NAME`") < 0)	{ nmLs += (nmLs.length?",":"") + "`NAME`"; vlLs += (vlLs.length?",":"") + "'"+tr("New item")+"'"; }
  		SYS.BD.nodeAt(db,".").SQLReq("INSERT INTO `sh_"+class+"` ("+nmLs+") VALUES ("+vlLs+");");
  		toUpdate = true; toCalcCycles = 1;
  	}
  	else if(sval == "dlg_Apply:/itDel") {
  	//else if(sval == "ws_BtRelease:/itDel") {
  		SYS.BD.nodeAt(db,".").SQLReq("DELETE FROM `sh_"+class+"` WHERE `ID`='"+dataTbl_value+"';");
  		toUpdate = true; toCalcCycles = 1;
  	}
  	else if(sval == "ws_BtRelease:/itCopy") {
  		for(colLs = "", iC = 1; iC < dataTbl[0].length; iC++)
  			colLs += (colLs.length?", ":"") + "`"+dataTbl[0][iC]+"`";
  		SYS.BD.nodeAt(db,".").SQLReq("INSERT INTO `sh_"+class+"` ("+colLs+") (SELECT "+colLs+" FROM `sh_"+class+"` WHERE `ID` = "+dataTbl_value+");");
  		toUpdate = true; toCalcCycles = 1;
  	}
  	else if((isTbl=(sval.slice(0,12)=="ws_TableEdit")) || (tVl=sval.match("^ws_(LnAccept|TxtAccept|ChkChange):/fItVal(.+)$")).length) {
  		if(isTbl) col = dataTbl[0][sval.parse(0,"_",13).toInt()], row = dataTbl[sval.parse(1,"_",13).toInt()+1][0], toVal = dataTbl_set;
  		else col = tVl[2], row = this.fItValID.attr("text"), toVal = this["fItVal"+col].attr("value");
  		//this.messInfo("TEST 00: col="+col+", row="+row+", toVal="+toVal);
  		//SYS.BD.nodeAt(db,".").SQLReq("UPDATE `sh_"+class+"` SET `"+dataTbl[0][col]+"`='"+SYS.strEncode(dataTbl_set,"SQL")+"' WHERE `"+dataTbl[0][0]+"`='"+dataTbl[row+1][0]+"';");
  		updReq = "`"+col+"`='"+SYS.strEncode(toVal,"SQL")+"'";
  		for(var itID in clsLsO)
  			if(itID[0] != "*" && clsLsO[itID].prc.length)
  				updReq += ", `SP_"+itID+"`=NULL";
  		SYS.BD.nodeAt(db,".").SQLReq("UPDATE `sh_"+class+"` SET "+updReq+" WHERE `"+dataTbl[0][0]+"`='"+row+"';");
  		if(colVars[col].fltr.parseLine(1).length || hasProc)	toUpdate = true, toCalcCycles = 1;
  	}
  	else if(sval.slice(0,22) == "ws_CombChange:/fltrCol") {
  		fN = sval.slice(22).toInt();
  		fAct = !this["fltrCol"+fN].attr("value").match("\\((.+)\\)")[1].isEVal();
  		this["fltr"+fN].attrSet("active", fAct).attrSet("value", "").attrSet("cfg", "");
  		if(fAct && (fN+1) < fMax && !this["fltrCol"+(fN+1)].attr("en")) {
  			this["fltrCol"+(fN+1)].attrSet("en", true);
  			this["fltr"+(fN+1)].attrSet("en", true).attrSet("active", false).attrSet("value", "");
  		}
  		else if(!fAct) fClrTo = fN+1;

  		toUpdate = true; toCalcCycles = 1;
  	}
  	else if(sval.slice(0,17) == "ws_LnAccept:/fltr")	toUpdate = true, toCalcCycles = 1;
  	else if(sval == "ws_BtRelease:/go_reportIt") {
  		go_reportIt_report = "<body>\n"
  			"<h1>"+tr("%1 item:").replace("%1",classNm_text)+"</h1>\n";
  		dataTblOneReq = SYS.BD.nodeAt(db,".").SQLReq("SELECT `ID`,"+clsLsReq+" FROM `sh_"+class+"` WHERE `ID`='"+dataTbl_value+"';");
  		for(iR = 1; iR < dataTblOneReq.length; iR++) {
  			if(dataTblOneReq[iR][0] != dataTbl_value) continue;
  			for(iC = 0; iC < dataTblOneReq[iR].length; iC++) {
  				itVl = dataTblOneReq[0][iC];
  				if((itVl.indexOf("SP_") == 0 && !(tVl=clsLsO[itVl.slice(3)]).isEVal()) || ((itVl == "NAME" || itVl == "DSCR") && !(tVl=clsLsO["*"+itVl]).isEVal()))
  					itVl = tVl.name;
  				go_reportIt_report += "<span style='font: bold 15px/25px Arial, sans-serif'>"+SYS.strEncode(itVl,"HTML")+":</span>";
  				if(colTps[iC] == "t")	go_reportIt_report += "<br/>";
  				if((itVl=dataTblOneReq[iR][iC]) == "<NULL>") itVl = "";
  				go_reportIt_report += "<span style='white-space: pre-wrap;"+((colTps[iC] == "t")?"":" margin-left: 3pt;")+"'>"+
  						SYS.strEncode(itVl,"HTML").replace(new RegExp("(http|https|ftp)://(\\S+)","g"),"<a target='_blank' href='$1://$2'>$2</a>")+
  						"</span><br/>";
  			}
  			break;
  		}
  		delete dataTblOneReq;
  		go_reportIt_report += "</body>";

  		this.attrSet("event", this.attr("event")+"usr_report:/go_reportIt\n");
  	}
  	else if(sval == "ws_BtRelease:/go_report") {
  		toUpdate = toReport = true, toCalcCycles = 1;

  		this.attrSet("event", this.attr("event")+"usr_report:/go_report\n");
  	}
  }

  //Clearing the filter up to fClrTo
  if(fClrTo >= 0) {
  	for(iF = fMax-1; iF >= fClrTo; iF--) {
  		if(iF) { this["fltrCol"+iF].attrSet("en", false); this["fltr"+iF].attrSet("en", false); }
  		this["fltrCol"+iF].attrSet("value", tr("Disabled")); this["fltr"+iF].attrSet("active", false).attrSet("value", "");
  	}
  	fClrTo = -1; toUpdate = true; toCalcCycles = 1;
  }

  if(toCalcCycles > 0.1) {
  	this.attrSet("event", this.attr("event")+"usr_calc\n");	//!!!! Just to calc in the next session cycle for update
  	toCalcCycles = max(0, toCalcCycles-1);
  }


