JavaLikeCalc.JavaScript
//using Special.FLibSYS;
ev_wrk = ev_rez = "";
if(f_start) cntr = prevCntr = holdCntr = 0;
cntr++;

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--; 
	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--; 
		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--;
		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;
				SYS.messNote("OP:"+this.ownerSess().user()+":"+prmShifr,"'"+prmShifr+"'. "+tr("Mode")+" : "+(prmDescr.isEVal()?"":prmDescr)+" : "+prevMode+" : "+tr("Manual"));
			}
			else if(ev_wrk == "ws_BtPress:/modAuto" && (!prmAuto || prmCasc)) {  
				prmAuto = true; if(prmCasc==true) prmCasc = false;
				SYS.messNote("OP:"+this.ownerSess().user()+":"+prmShifr,"'"+prmShifr+"'. "+tr("Mode")+" : "+(prmDescr.isEVal()?"":prmDescr)+" : "+prevMode+" : "+tr("Automate"));
			}
			else if(ev_wrk == "ws_BtPress:/modCasc" && !prmCasc) {  
		prmAuto = prmCasc = true;
		SYS.messNote("OP:"+this.ownerSess().user()+":"+prmShifr,"'"+prmShifr+"'. "+tr("Mode")+" : "+(prmDescr.isEVal()?"":prmDescr)+" : "+prevMode+" : "+tr("Cascade"));
			}
			else if(ev_wrk == "key_mousePresLeft:/info_sp") {
				SYS.messNote("OP:"+this.ownerSess().user()+":"+prmShifr,"'"+prmShifr+"'. "+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") {
				SYS.messNote("OP:"+this.ownerSess().user()+":"+prmShifr,"'"+prmShifr+"'. "+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;
			}
			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;
		}
   	else if(appToVl && !prmAuto) {
			if(prmAnalog==false) {
				prmManIn = 50+2.5*appToVl;
				if(appToVl == -1)			SYS.messNote("OP:"+this.ownerSess().user()+":"+prmShifr,"'"+prmShifr+"'."+tr("Output")+": "+(prmDescr.isEVal()?"":prmDescr)+" :: "+tr("Close")+" ( < )");
				else if(appToVl == 1)	SYS.messNote("OP:"+this.ownerSess().user()+":"+prmShifr,"'"+prmShifr+"'."+tr("Output")+": "+(prmDescr.isEVal()?"":prmDescr)+" :: "+tr("Open")+" ( > )");
				else if(appToVl == -10)	SYS.messNote("OP:"+this.ownerSess().user()+":"+prmShifr,"'"+prmShifr+"'."+tr("Output")+": "+(prmDescr.isEVal()?"":prmDescr)+" :: "+tr("Close")+" ( << )");
				else if(appToVl == 10)	SYS.messNote("OP:"+this.ownerSess().user()+":"+prmShifr,"'"+prmShifr+"'."+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;
			}
		}

		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") {
				SYS.messNote("OP:"+this.ownerSess().user()+":"+prmShifr,"'"+prmShifr+"'. "+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;
		}
	}
}
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;
			SYS.messNote("OP:"+this.ownerSess().user()+":"+prmShifr,"'"+prmShifr+"'. "+tr("Command")+" : "+(prmDescr.isEVal()?"":prmDescr)+" : : "+com_open_name);
		}
		else if(ev_wrk == "ws_BtPress:/com_close") {
			if(!prmClose.isEVal()) prmClose = true; prmCom = false;
			SYS.messNote("OP:"+this.ownerSess().user()+":"+prmShifr,"'"+prmShifr+"'. "+tr("Command")+" : "+(prmDescr.isEVal()?"":prmDescr)+" : : "+com_close_name);
		}
		else if(ev_wrk == "ws_BtPress:/com_stop") {
			prmStop = true;
			SYS.messNote("OP:"+this.ownerSess().user()+":"+prmShifr,"'"+prmShifr+"'. "+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;
			SYS.messNote("OP:"+this.ownerSess().user()+":"+prmShifr,"'"+prmShifr+"'. "+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;
	}
}