JavaLikeCalc.JavaScript
if(f_start)	{ srcPrm = false; items = new Object(); }

alLev = 0;
tErr = "";

//Connect to source
if(typeof(srcPrm) != "TCntrNode:TValue:TParamContr") srcPrm = SYS.DAQ.nodeAt(srcAddr,".");
if(!srcPrm) { tErr = tr("No connection to source object"); alLev = 3; }
else if(srcPrm.err.get() != 0)	 { tErr = tr("Source error")+": "+srcPrm.err.get().parse(1,":"); alLev = 3; }
else {
	//Attributes list get and "items" update
	nLst = srcPrm.nodeList("a_");
	for(i_n = 0; i_n < nLst.length; i_n++) {
		aId = nLst[i_n].slice(2);
		aNd = srcPrm[nLst[i_n]];
		if(items[aId].isEVal()) {
			items[aId] = itW = new Object();
			itW.descr = aNd.descr();
			if((tVl=defs.match("^"+aId+":([^\n]+)","m")).length)
				itW.descr = tVl[1];

			// Writeable check
			//SYS.messInfo("UPS test", aId+": aNd.flg()="+aNd.flg());
			if((itW.wr=!(aNd.flg()&0x04)) && aNd.flg()&0x01) {
				itW.wr = "";
				for(off = 0, pos = 0; (selId=aNd.values().parse(0,";",off)).length; pos++)
					itW.wr += ((selId==(selNm=aNd.selNames().parse(pos,";")))?selId:(selNm+" ("+selId+")"))+";";
			}
			itW.alarm = 0;
		}
		itW = items[aId];
		tvl = aNd.get();
		if(aId == 5) {	//Realocated sectors count
			if(tvl > 100)	{ itW.alarm = 2; tErr += tr("Too many realocated sectors")+"; "; }
			else if(tvl)	{ itW.alarm = 1; tErr += tr("Some reallocated sectors are presented")+"; "; }
			else itW.alarm = 0;
		}
		else if(aId == 190) {	//Airflow temperature
			if(tvl > 255)	tvl = tvl&0xFF;
			if(tvl > 70)		{ itW.alarm = 2; tErr += tr("Hard disk is overheated")+"; "; }
			else if(tvl > 50) { itW.alarm = 1; tErr += tr("Temperature high")+"; "; }
			else itW.alarm = 0;
		}
		else if(aId == 194) {	//Temperature
			if(tvl > 255)	{ tvl = tvl&0xFF; itW.val = tvl; }
			if(tvl > 70)		{ itW.alarm = 2; tErr += tr("Hard disk is overheated")+"; "; }
			else if(tvl > 50) { itW.alarm = 1; tErr += tr("Temperature high")+"; "; }
			else itW.alarm = 0;
		}
		else if(aId == 197) {	//Current pending sectors
			if(tvl > 10) { itW.alarm = 2; tErr += tr("Too many pending sectors")+"; "; }
			else if(tvl) { itW.alarm = 1; tErr += tr("Some pending sectors are presented")+"; "; }
			else itW.alarm = 0;
		}
		itW.val = tvl;
	}

	//Alarms process and mark
	//SYS.messInfo("HDDSMART", "TEST 00");
	/*varS = 5;	//Realocated sectors count
	if(!(tP=srcPrm[varS]).isEVal()) {
		if(tP.get() > 10) { items[varS].alarm = 2; tErr += tr("Too many realocated sectors")+"; "; }
		else if(tP.get()) { items[varS].alarm = 1; tErr += tr("A realocated sectors present")+"; "; }
		else items[varS].alarm = 0;
	}
	varS = 190;	//Airflow temperature
	if(!(tP=srcPrm[varS]).isEVal()) {
		tvl = tP.get();
		if(tvl > 255) { tvl = tvl&0xFF; items[varS].val = tvl; }
		if(tvl > 70) { items[varS].alarm = 2; tErr += tr("Hard disk overheated")+"; "; }
		else if(tvl > 50) { items[varS].alarm = 1; tErr += tr("Temperature high")+"; "; }
		else items[varS].alarm = 0;
	}
	varS = 194;	//Temperature
	if(!(tP=srcPrm[varS]).isEVal()) {
		tvl = tP.get();
		if(tvl > 255) { tvl = tvl&0xFF; items[varS].val = tvl; }
		if(tvl > 70) { items[varS].alarm = 2; tErr += tr("Hard disk overheated")+"; "; }
		else if(tvl > 50) { items[varS].alarm = 1; tErr += tr("Temperature high")+"; "; }
		else items[varS].alarm = 0;
	}
	varS = 197;	//Current pending sectors
	if(!(tP=srcPrm[varS]).isEVal()) {
		if(tP.get() > 10) { items[varS].alarm = 2; tErr += tr("Too many pending sectors")+"; "; }
		else if(tP.get()) { items[varS].alarm = 1; tErr += tr("A pending sectors present")+"; "; }
		else items[varS].alarm = 0;
	}*/

	//Set variables process
	for(var aIt in items) {
		it = items[aIt];
		if(!it.set.isEVal()) {
			aNd = srcPrm["a_"+it.id];
			if(aNd.flg()&0x01 && (selV=it.set.match(".+\\((.+)\\)$")).length) it.set = selV[1];
			aNd.set(it.set);
			it.set = EVAL_REAL;
		}
		alLev = max(alLev, it.alarm);
	}
}

//SYS.messInfo("UPS test", "tErr="+tErr+"; alLev="+alLev);
tErr = tErr.length ? ""+alLev+":"+tErr : "0";

//Alarms forming
if(tErr.toInt() && tErr.toInt() != f_err.toInt())
	this.cntr().alarmSet((NAME.length?NAME:SHIFR)+": "+DESCR+": "+tErr.parse(1,":"), -(2+alLev), SHIFR);
else if(f_err.toInt() && !tErr.toInt())
	this.cntr().alarmSet((NAME.length?NAME:SHIFR)+": "+DESCR+": "+tr("NORMA"), 1, SHIFR);
f_err = tErr;