|
|
|
@@ -90,7 +90,7 @@ class Valve {
|
|
|
|
this.childRegistrationUtils = new childRegistrationUtils(this); // Child registration utility
|
|
|
|
this.childRegistrationUtils = new childRegistrationUtils(this); // Child registration utility
|
|
|
|
this.vCurve = this.curve[1.204]; // specificy the desired density RECALC THIS AUTOMTICALLY BASED ON DENSITY OF AIR LATER OLIFANT!!
|
|
|
|
this.vCurve = this.curve[1.204]; // specificy the desired density RECALC THIS AUTOMTICALLY BASED ON DENSITY OF AIR LATER OLIFANT!!
|
|
|
|
this.predictKv = new predict({curve:this.vCurve}); // load valve size (x : ctrl , y : kv relationship)
|
|
|
|
this.predictKv = new predict({curve:this.vCurve}); // load valve size (x : ctrl , y : kv relationship)
|
|
|
|
console.log(`PredictKv initialized with curve: ${JSON.stringify(this.predictKv)}`);
|
|
|
|
this.logger.debug(`PredictKv initialized with curve: ${JSON.stringify(this.predictKv)}`);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// -------- Config -------- //
|
|
|
|
// -------- Config -------- //
|
|
|
|
@@ -149,37 +149,6 @@ class Valve {
|
|
|
|
this.logger.info(`Mode successfully changed to '${newMode}'.`);
|
|
|
|
this.logger.info(`Mode successfully changed to '${newMode}'.`);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
loadSpecs(){ //static betekend dat die in andere classes kan worden aangeroepen met const specs = Valve.loadSpecs()
|
|
|
|
|
|
|
|
//lateron based on valve caracteristics --> then it searches for right valve
|
|
|
|
|
|
|
|
let specs = {
|
|
|
|
|
|
|
|
supplier : "Binder",
|
|
|
|
|
|
|
|
type : "HDCV",
|
|
|
|
|
|
|
|
units:{
|
|
|
|
|
|
|
|
Nm3: { "temp": 20, "pressure" : 1.01325 , "RH" : 0 }, // according to DIN
|
|
|
|
|
|
|
|
v_curve : { x : "% stroke", y : "Kv value"} ,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
v_curve: {
|
|
|
|
|
|
|
|
125: // valve size
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
x:[0,10,20,30,40,50,60,70,80,90,100], //stroke in %
|
|
|
|
|
|
|
|
y:[0,18,50,95,150,216,337,564,882,1398,1870], //Kv value expressed in m3/h
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
150: // valve size
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
x:[0,10,20,30,40,50,60,70,80,90,100], //stroke in %
|
|
|
|
|
|
|
|
y:[0,25,73,138,217,314,490,818,1281,2029,2715], //oxygen transfer rate expressed in gram o2 / normal m3/h / per m
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
400: // valve size
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
x:[0,10,20,30,40,50,60,70,80,90,100], //stroke in %
|
|
|
|
|
|
|
|
y:[0,155,443,839,1322,1911,2982,4980,7795,12349,16524], //oxygen transfer rate expressed in gram o2 / normal m3/h / per m
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return specs;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// -------- Sequence Handlers -------- //
|
|
|
|
// -------- Sequence Handlers -------- //
|
|
|
|
async executeSequence(sequenceName) {
|
|
|
|
async executeSequence(sequenceName) {
|
|
|
|
|
|
|
|
|
|
|
|
@@ -225,12 +194,43 @@ class Valve {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
updatePressure(variant,value,position) {
|
|
|
|
|
|
|
|
if( value === null || value === undefined) {
|
|
|
|
|
|
|
|
this.logger.warn(`Received null or undefined value for flow update. Variant: ${variant}, Position: ${position}`);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
this.logger.debug(`Updating pressure: variant=${variant}, value=${value}, position=${position}`);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch (variant) {
|
|
|
|
|
|
|
|
case ("measured"):
|
|
|
|
|
|
|
|
// put value in measurements container
|
|
|
|
|
|
|
|
console.log( 'wtf ... ' + value);
|
|
|
|
|
|
|
|
this.measurements.type("pressure").variant("measured").position(position).value(value);
|
|
|
|
|
|
|
|
// get latest downstream pressure measurement
|
|
|
|
|
|
|
|
const measuredDownStreamP = this.measurements.type("pressure").variant("measured").position("downstream").getCurrentValue(); //update downstream pressure measurement
|
|
|
|
|
|
|
|
// update predicted flow measurement
|
|
|
|
|
|
|
|
this.updateDeltaPKlep(value,this.kv,measuredDownStreamP,this.rho,this.T); //update deltaP based on new flow
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case ("predicted"):
|
|
|
|
|
|
|
|
// put value in measurements container
|
|
|
|
|
|
|
|
this.measurements.type("pressure").variant("predicted").position(position).value(value);
|
|
|
|
|
|
|
|
const predictedDownStreamP = this.measurements.type("pressure").variant("measured").position("downstream").getCurrentValue(); //update downstream pressure measurement
|
|
|
|
|
|
|
|
this.updateDeltaPKlep(value,this.kv,predictedDownStreamP,this.rho,this.T); //update deltaP based on new flow
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
this.logger.warn(`Unrecognized variant '${variant}' for flow update.`);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
updateMeasurement(variant, subType, value, position) {
|
|
|
|
updateMeasurement(variant, subType, value, position) {
|
|
|
|
this.logger.debug(`---------------------- updating ${subType} ------------------ `);
|
|
|
|
this.logger.debug(`---------------------- updating ${subType} ------------------ `);
|
|
|
|
switch (subType) {
|
|
|
|
switch (subType) {
|
|
|
|
case "pressure":
|
|
|
|
case "pressure":
|
|
|
|
// Update pressure measurement
|
|
|
|
// Update pressure measurement
|
|
|
|
//this.updatePressure(variant,value,position);
|
|
|
|
this.updatePressure(variant,value,position);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case "flow":
|
|
|
|
case "flow":
|
|
|
|
this.updateFlow(variant,value,position);
|
|
|
|
this.updateFlow(variant,value,position);
|
|
|
|
@@ -255,6 +255,8 @@ class Valve {
|
|
|
|
//convert downstreamP to absolute bar
|
|
|
|
//convert downstreamP to absolute bar
|
|
|
|
downstreamP += 1.01325;
|
|
|
|
downstreamP += 1.01325;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if( kv !== 0 && downstreamP != 0 && q != 0) { //check if kv and downstreamP are not zero to avoid division by zero
|
|
|
|
|
|
|
|
|
|
|
|
//calculate deltaP
|
|
|
|
//calculate deltaP
|
|
|
|
let deltaP = ( q**2 * rho * temp ) / ( 514**2 * kv**2 * downstreamP);
|
|
|
|
let deltaP = ( q**2 * rho * temp ) / ( 514**2 * kv**2 * downstreamP);
|
|
|
|
|
|
|
|
|
|
|
|
@@ -272,20 +274,32 @@ class Valve {
|
|
|
|
this.logger.info('DeltaPChange emitted to valveGroupController');
|
|
|
|
this.logger.info('DeltaPChange emitted to valveGroupController');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Als er een nieuwe flow door de klep komt doordat de machines harder zijn gaan werken, dan update deze functie dit ook in de valve attributes en measurements
|
|
|
|
// Als er een nieuwe flow door de klep komt doordat de machines harder zijn gaan werken, dan update deze functie dit ook in de valve attributes en measurements
|
|
|
|
updateFlow(variant,value,position) {
|
|
|
|
updateFlow(variant,value,position) {
|
|
|
|
|
|
|
|
if( value === null || value === undefined) {
|
|
|
|
|
|
|
|
this.logger.warn(`Received null or undefined value for flow update. Variant: ${variant}, Position: ${position}`);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
this.logger.debug(`Updating flow: variant=${variant}, value=${value}, position=${position}`);
|
|
|
|
|
|
|
|
|
|
|
|
switch (variant) {
|
|
|
|
switch (variant) {
|
|
|
|
case ("measured"):
|
|
|
|
case ("measured"):
|
|
|
|
// put value in measurements
|
|
|
|
// put value in measurements container
|
|
|
|
this.measurements.type("flow").variant("measured").position(position).value(value);
|
|
|
|
this.measurements.type("flow").variant("measured").position(position).value(value);
|
|
|
|
const downStreamP = this.measurements.type("pressure").variant("measured").position("downstream").getCurrentValue(); //update downstream pressure measurement
|
|
|
|
// get latest downstream pressure measurement
|
|
|
|
this.updateDeltaPKlep(value,this.kv,downStreamP,this.rho,this.T); //update deltaP based on new flow
|
|
|
|
const measuredDownStreamP = this.measurements.type("pressure").variant("measured").position("downstream").getCurrentValue(); //update downstream pressure measurement
|
|
|
|
|
|
|
|
// update predicted flow measurement
|
|
|
|
|
|
|
|
this.updateDeltaPKlep(value,this.kv,measuredDownStreamP,this.rho,this.T); //update deltaP based on new flow
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case ("predicted"):
|
|
|
|
case ("predicted"):
|
|
|
|
this.logger.debug('not doing anythin yet');
|
|
|
|
// put value in measurements container
|
|
|
|
|
|
|
|
this.measurements.type("flow").variant("predicted").position(position).value(value);
|
|
|
|
|
|
|
|
const predictedDownStreamP = this.measurements.type("pressure").variant("measured").position("downstream").getCurrentValue(); //update downstream pressure measurement
|
|
|
|
|
|
|
|
this.updateDeltaPKlep(value,this.kv,predictedDownStreamP,this.rho,this.T); //update deltaP based on new flow
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
@@ -299,7 +313,10 @@ class Valve {
|
|
|
|
|
|
|
|
|
|
|
|
this.logger.debug('Calculating new deltaP');
|
|
|
|
this.logger.debug('Calculating new deltaP');
|
|
|
|
const currentPosition = this.state.getCurrentPosition();
|
|
|
|
const currentPosition = this.state.getCurrentPosition();
|
|
|
|
const currentFlow = this.measurements.type("flow").variant("measured").position("downstream").getCurrentValue(); // haal de flow op uit de measurement containe
|
|
|
|
const measuredFlow = this.measurements.type("flow").variant("measured").position("downstream").getCurrentValue(); // haal de flow op uit de measurement containe
|
|
|
|
|
|
|
|
const predictedFlow = this.measurements.type("flow").variant("predicted").position("downstream").getCurrentValue(); // haal de predicted flow op uit de measurement container
|
|
|
|
|
|
|
|
const currentFlow = predictedFlow ;
|
|
|
|
|
|
|
|
|
|
|
|
const downstreamP = this.measurements.type("pressure").variant("measured").position("downstream").getCurrentValue(); // haal de downstream pressure op uit de measurement container
|
|
|
|
const downstreamP = this.measurements.type("pressure").variant("measured").position("downstream").getCurrentValue(); // haal de downstream pressure op uit de measurement container
|
|
|
|
//const valveSize = 125; //NOTE: nu nog hardcoded maar moet een attribute van de valve worden
|
|
|
|
//const valveSize = 125; //NOTE: nu nog hardcoded maar moet een attribute van de valve worden
|
|
|
|
this.predictKv.fDimension = 125; //load valve size by defining fdimension in predict class
|
|
|
|
this.predictKv.fDimension = 125; //load valve size by defining fdimension in predict class
|
|
|
|
|