JavaLikeCalc.JavaScript
//Same request to the device
function req(data, pref, respPref) {
	if(data == EVAL)	data = "";

	for(SUM = 0, iCh = 0; iCh < data.length; iCh++)
		SUM += data.charCodeAt(iCh);

	req = pref + data + SYS.strFromCharCode(SUM&0xFF, 0x16);

	SYS.messDebug("/FF/"+this.cfg("SHIFR"), tr("Request")+": "+SYS.strDecode(req,"Bin"," "));

	resp = tr.messIO(req);
	//Waiting the acceptance
	while(resp.length && (tresp=tr.messIO("")).length) resp += tresp;
	if(resp.length < 21 || resp.indexOf(respPref) != 0 || resp.charCodeAt(resp.length-1) != 0x16)
		return tr("3:No response or the response is inconsistent. ");

	data = resp.slice(respPref.length, -2);

	SYS.messDebug("/FF/"+this.cfg("SHIFR"), tr("Response")+": "+SYS.strDecode(data,"Bin"," "));

	for(SUM = 0, iCh = 0; iCh < data.length; iCh++)
		SUM += data.charCodeAt(iCh);
	if(resp.charCodeAt(resp.length-2) != (SUM&0xFF))
		return tr("3:Control sum error "+(SUM&0xFF)+" != "+resp.charCodeAt(resp.length-2));

	return "0";
}

if(f_start || f_stop) {
	EnActFull = EnActImp = EnActExp = EnActFullDrop = EnActImpDrop = EnActExpDrop = EVAL;
	EnReactFull = EnReactImp = EnReactExp = EnReactFullDrop = EnReactImpDrop = EnReactExpDrop = EVAL;
	V_L1 = V_L2 = V_L3 = V_L12 = V_L23 = V_L31 = EVAL;
	I_1 = I_2 = I_3 = I_N = EVAL;
	P = P_1 = P_2 = P_3 = EVAL;
	Pr = Pr_1 = Pr_2 = Pr_3 = EVAL;
	CoefP = CoefP_1 = CoefP_2 = CoefP_3 = EVAL;
	return;
}

tErr = "";

if(!(tr=SYS.Transport.outAt(transport)) || !tr.start(true))
	tErr = "1:"+tr("Output transport '%1' error.").replace("%1",transport);
else if(addr < 0 || addr > 255)
	tErr = "2:"+tr("Address '%1' out of range [0...255].").replace("%1",addr.toString());
else {
	//Reading the electricity information
	if(!tErr.toInt()) {
		data = SYS.strFromCharCode(0x7B, addr);
		if((tErr=req(data,SYS.strFromCharCode(0x10),SYS.strFromCharCode(0x68,0x5D,0x5D,0x68))).toInt()) ;
		else if(data.charCodeAt(1) != addr)	tErr = tr("4:Error the address response");
		else {
			EnActFull = SYS.strDecode(SYS.strEncode(data.slice(17+6*0,17+6*0+4),"Reverse"),"Bin").toInt() / 100;
			EnActImp = SYS.strDecode(SYS.strEncode(data.slice(17+6*1,17+6*1+4),"Reverse"),"Bin").toInt() / 100;
			EnActExp = SYS.strDecode(SYS.strEncode(data.slice(17+6*2,17+6*2+4),"Reverse"),"Bin").toInt() / 100;
			EnActFullDrop = SYS.strDecode(SYS.strEncode(data.slice(17+6*3,17+6*3+4),"Reverse"),"Bin").toInt() / 100;
			EnActImpDrop = SYS.strDecode(SYS.strEncode(data.slice(17+6*4,17+6*4+4),"Reverse"),"Bin").toInt() / 100;
			EnActExpDrop = SYS.strDecode(SYS.strEncode(data.slice(17+6*5,17+6*5+4),"Reverse"),"Bin").toInt() / 100;

			EnReactFull = (tVl=SYS.strDecode(SYS.strEncode(data.slice(54+7*0,54+7*0+4),"Reverse"),"Bin")).toInt() / 100;
			EnReactImp = (tVl=SYS.strDecode(SYS.strEncode(data.slice(54+7*1,54+7*1+4),"Reverse"),"Bin")).toInt() / 100;
			EnReactExp = (tVl=SYS.strDecode(SYS.strEncode(data.slice(54+7*2,54+7*2+4),"Reverse"),"Bin")).toInt() / 100;
			EnReactFullDrop = (tVl=SYS.strDecode(SYS.strEncode(data.slice(54+7*3,54+7*3+4),"Reverse"),"Bin")).toInt() / 100;
			EnReactImpDrop = (tVl=SYS.strDecode(SYS.strEncode(data.slice(54+7*4,54+7*4+4),"Reverse"),"Bin")).toInt() / 100;
			EnReactExpDrop = (tVl=SYS.strDecode(SYS.strEncode(data.slice(54+7*5,54+7*5+4),"Reverse"),"Bin")).toInt() / 100;
		}
	}

	//Reading the Instanceous
	if(!tErr.toInt()) {
		data = SYS.strFromCharCode(0x53, addr, 0xB1);
		if((tErr=req(data,SYS.strFromCharCode(0x68,0x03,0x03,0x68),SYS.strFromCharCode(0x68,0x90,0x90,0x68))).toInt()) ;
		else if(data.charCodeAt(1) != addr)	tErr = tr("4:Error the address response");
		else {
			V_L1 = SYS.strDecode(SYS.strEncode(data.slice(18+6*0,18+6*0+3),"Reverse"),"Bin").toInt() / 100;
			V_L2 = SYS.strDecode(SYS.strEncode(data.slice(18+6*1,18+6*1+3),"Reverse"),"Bin").toInt() / 100;
			V_L3 = SYS.strDecode(SYS.strEncode(data.slice(18+6*2,18+6*2+3),"Reverse"),"Bin").toInt() / 100;
			V_L12 = SYS.strDecode(SYS.strEncode(data.slice(18+6*3,18+6*3+3),"Reverse"),"Bin").toInt() / 100;
			V_L23 = SYS.strDecode(SYS.strEncode(data.slice(18+6*4,18+6*4+3),"Reverse"),"Bin").toInt() / 100;
			V_L31 = SYS.strDecode(SYS.strEncode(data.slice(18+6*5,18+6*5+3),"Reverse"),"Bin").toInt() / 100;
			I_1 = SYS.strDecode(SYS.strEncode(data.slice(18+6*6,18+6*6+3),"Reverse"),"Bin").toInt() / 1000;
			I_2 = SYS.strDecode(SYS.strEncode(data.slice(18+6*7,18+6*7+3),"Reverse"),"Bin").toInt() / 1000;
			I_3 = SYS.strDecode(SYS.strEncode(data.slice(18+6*8,18+6*8+3),"Reverse"),"Bin").toInt() / 1000;
			I_N = SYS.strDecode(SYS.strEncode(data.slice(18+6*9,18+6*9+3),"Reverse"),"Bin").toInt() / 1000;

			P = SYS.strDecode(SYS.strEncode(data.slice(77+5*0,77+5*0+3),"Reverse"),"Bin").toInt() / 100;
			P_1 = SYS.strDecode(SYS.strEncode(data.slice(77+5*1,77+5*1+3),"Reverse"),"Bin").toInt() / 1000;
			P_2 = SYS.strDecode(SYS.strEncode(data.slice(77+5*2,77+5*2+3),"Reverse"),"Bin").toInt() / 1000;
			P_3 = SYS.strDecode(SYS.strEncode(data.slice(77+5*3,77+5*3+3),"Reverse"),"Bin").toInt() / 1000;

			Pr = SYS.strDecode(SYS.strEncode(data.slice(98+6*0,98+6*0+3),"Reverse"),"Bin").toInt() / 1000;
			Pr_1 = SYS.strDecode(SYS.strEncode(data.slice(98+6*1,98+6*1+3),"Reverse"),"Bin").toInt() / 10000;
			Pr_2 = SYS.strDecode(SYS.strEncode(data.slice(98+6*2,98+6*2+3),"Reverse"),"Bin").toInt() / 10000;
			Pr_3 = SYS.strDecode(SYS.strEncode(data.slice(98+6*3,98+6*3+3),"Reverse"),"Bin").toInt() / 10000;

			CoefP = SYS.strDecode(SYS.strEncode(data.slice(122+5*0,122+5*0+2),"Reverse"),"Bin").toInt() / 1000;
			CoefP_1 = SYS.strDecode(SYS.strEncode(data.slice(122+5*1,122+5*1+2),"Reverse"),"Bin").toInt() / 1000;
			CoefP_2 = SYS.strDecode(SYS.strEncode(data.slice(122+5*2,122+5*2+2),"Reverse"),"Bin").toInt() / 1000;
			CoefP_3 = SYS.strDecode(SYS.strEncode(data.slice(122+5*3,122+5*3+2),"Reverse"),"Bin").toInt() / 1000;
		}
	}
}

//Error set
if(!tErr.length)	tErr = "0";
if(tErr.toInt()) {
	if(!tr.isEVal() && tr.start()) tr.start(false);
	if(f_err != tErr) {
		SYS.messDebug("/FF/"+this.cfg("SHIFR"), tr("Error")+": "+tErr);

		EnActFull = EnActImp = EnActExp = EnActFullDrop = EnActImpDrop = EnActExpDrop = EVAL;
		EnReactFull = EnReactImp = EnReactExp = EnReactFullDrop = EnReactImpDrop = EnReactExpDrop = EVAL;
		V_L1 = V_L2 = V_L3 = V_L12 = V_L23 = V_L31 = EVAL;
		I_1 = I_2 = I_3 = I_N = EVAL;
		P = P_1 = P_2 = P_3 = EVAL;
		Pr = Pr_1 = Pr_2 = Pr_3 = EVAL;
		CoefP = CoefP_1 = CoefP_2 = CoefP_3 = EVAL;
	}
}
f_err = tErr;