converted J.tack to mainstream v 0.1
This commit is contained in:
@@ -111,13 +111,15 @@ class nodeClass {
|
||||
|
||||
}
|
||||
|
||||
_updateNodeStatus() {
|
||||
_updateNodeStatus() {
|
||||
const v = this.source;
|
||||
|
||||
try {
|
||||
const mode = v.currentMode; // modus is bijv. auto, manual, etc.
|
||||
const state = v.state.getCurrentState(); //is bijv. operational, idle, off, etc.
|
||||
const flow = Math.round(v.measurements.type("flow").variant("measured").position("downstream").getCurrentValue());
|
||||
// check if measured flow is available otherwise use predicted flow
|
||||
const flow = Math.round(v.measurements.type("flow").variant("predicted").position("downstream").getCurrentValue());
|
||||
|
||||
let deltaP = v.measurements.type("pressure").variant("predicted").position("delta").getCurrentValue();
|
||||
if (deltaP !== null) {
|
||||
deltaP = parseFloat(deltaP.toFixed(0));
|
||||
|
||||
@@ -90,7 +90,7 @@ class Valve {
|
||||
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.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 -------- //
|
||||
@@ -149,37 +149,6 @@ class Valve {
|
||||
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 -------- //
|
||||
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) {
|
||||
this.logger.debug(`---------------------- updating ${subType} ------------------ `);
|
||||
switch (subType) {
|
||||
case "pressure":
|
||||
// Update pressure measurement
|
||||
//this.updatePressure(variant,value,position);
|
||||
this.updatePressure(variant,value,position);
|
||||
break;
|
||||
case "flow":
|
||||
this.updateFlow(variant,value,position);
|
||||
@@ -255,37 +255,51 @@ class Valve {
|
||||
//convert downstreamP to absolute bar
|
||||
downstreamP += 1.01325;
|
||||
|
||||
//calculate deltaP
|
||||
let deltaP = ( q**2 * rho * temp ) / ( 514**2 * kv**2 * downstreamP);
|
||||
|
||||
//convert deltaP to mbar
|
||||
deltaP = deltaP * 1000;
|
||||
if( kv !== 0 && downstreamP != 0 && q != 0) { //check if kv and downstreamP are not zero to avoid division by zero
|
||||
|
||||
//calculate deltaP
|
||||
let deltaP = ( q**2 * rho * temp ) / ( 514**2 * kv**2 * downstreamP);
|
||||
|
||||
//convert deltaP to mbar
|
||||
deltaP = deltaP * 1000;
|
||||
|
||||
// Synchroniseer deltaP met het Valve-object
|
||||
this.deltaPKlep = deltaP
|
||||
// Synchroniseer deltaP met het Valve-object
|
||||
this.deltaPKlep = deltaP
|
||||
|
||||
// Opslaan in measurement container
|
||||
this.measurements.type("pressure").variant("predicted").position("delta").value(deltaP);
|
||||
this.logger.info('DeltaP updated to: ' + deltaP);
|
||||
// Opslaan in measurement container
|
||||
this.measurements.type("pressure").variant("predicted").position("delta").value(deltaP);
|
||||
this.logger.info('DeltaP updated to: ' + deltaP);
|
||||
|
||||
this.emitter.emit('deltaPChange', deltaP); // Emit event to notify valveGroupController of deltaP change
|
||||
this.logger.info('DeltaPChange emitted to valveGroupController');
|
||||
}
|
||||
|
||||
this.emitter.emit('deltaPChange', deltaP); // Emit event to notify valveGroupController of deltaP change
|
||||
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
|
||||
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) {
|
||||
case ("measured"):
|
||||
// put value in measurements
|
||||
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
|
||||
this.updateDeltaPKlep(value,this.kv,downStreamP,this.rho,this.T); //update deltaP based on new flow
|
||||
// put value in measurements container
|
||||
this.measurements.type("flow").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"):
|
||||
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;
|
||||
|
||||
default:
|
||||
@@ -299,7 +313,10 @@ class Valve {
|
||||
|
||||
this.logger.debug('Calculating new deltaP');
|
||||
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 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
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
icon: "font-awesome/fa-tachometer",
|
||||
|
||||
label: function () {
|
||||
return this.positionIcon + " " + this.assetType || "valve";
|
||||
return this.positionIcon + " " + this.category.slice(0, -1) || "Valve";
|
||||
},
|
||||
|
||||
oneditprepare: function() {
|
||||
|
||||
Reference in New Issue
Block a user