flow: - Update STCAL
var Deviceid = flow.get('Deviceid');
msg.topic = "Select *from stcalA where deviceID = '"+ Deviceid +"'";
return msg;
flow : - stcalA json
var obj = msg.payload;
var json = JSON.parse(obj);
var Deviceid = flow.get('Deviceid');
var SHTActual = flow.get('SHTActual')||0;
var STActual = flow.get('STActual')||0;
var resetcounter = flow.get('resetcounter');
var amenddata = flow.get('amenddata');
var Indata = flow.get('Indata'); //![stcal|637x500]
if(json[0].OutputPin === 'RST MASTER'){
resetcounter = 1;
amenddata = 0;
SHTActual = 0;
STActual = 0;
Indata.ATCounter = 0;
Indata.STCounter = 0;
json[0].OutputPin = Indata.PinStatus;
flow.set('Indata.ATCounter',Indata.ATCounter);
flow.set('Indata.STCounter',Indata.STCounter);
}
else if(json[0].OutputPin === 'AMEND'){
resetcounter = 0;
if(amenddata === 1){
amenddata = 0;
json[0].OutputPin = Indata.PinStatus;
}
else {amenddata = 1;}
SHTActual = json[0].shiftActual;
STActual = json[0].stActual;
Indata.ATCounter = json[0].SHTActual;
Indata.STCounter = json[0].STActual;
json[0].OutputPin = Indata.PinStatus;
flow.set('Indata.ATCounter',Indata.ATCounter);
flow.set('Indata.STCounter',Indata.STCounter);
}
else{
resetcounter = 0;
amenddata = 0;
var status = flow.get('Indata.ATCounter')
if (!status){
SHTActual = json[0].shiftActual;
STActual = json[0].stActual;
}
else{
SHTActual = flow.get('Indata.ATCounter');
STActual = flow.get('Indata.STCounter');
}
if(Indata.PinStatus){
json[0].OutputPin = Indata.PinStatus;
}
else{json[0].OutputPin = 'Not_Assigned';}
}
flow.set('resetcounter',resetcounter);
flow.set('amenddata',amenddata);
flow.set('SHTActual',SHTActual);
flow.set('STActual',STActual);
var stcal = {
"line_name" : json[0].lineName,
"line_No" : json[0].line,
"currpct" : json[0].curPercentage,
"SHTPLAN" : json[0].shiftPlan,
"PinStatus" : json[0].OutputPin, //from php input
"STActual" : json[0].stActual, //STActual
"SHTActual" : json[0].shiftActual, //Shift Actual
"remark" : json[0].remarks
}
flow.set('stcal',stcal);
return msg;*******************************************************************************************************
Note: In fact all the tab's are enable while testing in progress.