Align machineGroupControl with current architecture
This commit is contained in:
43
mgc.html
43
mgc.html
@@ -1,15 +1,12 @@
|
||||
<!--
|
||||
brabantse delta kleuren:
|
||||
#eaf4f1
|
||||
#86bbdd
|
||||
#bad33b
|
||||
#0c99d9
|
||||
#a9daee
|
||||
#0f52a5
|
||||
#50a8d9
|
||||
#cade63
|
||||
#4f8582
|
||||
#c4cce0
|
||||
| S88-niveau | Primair (blokkleur) | Tekstkleur |
|
||||
| ---------------------- | ------------------- | ---------- |
|
||||
| **Area** | `#0f52a5` | wit |
|
||||
| **Process Cell** | `#0c99d9` | wit |
|
||||
| **Unit** | `#50a8d9` | zwart |
|
||||
| **Equipment (Module)** | `#86bbdd` | zwart |
|
||||
| **Control Module** | `#a9daee` | zwart |
|
||||
|
||||
-->
|
||||
<script src="/machineGroupControl/menu.js"></script> <!-- Load the menu script for dynamic dropdowns -->
|
||||
<script src="/machineGroupControl/configData.js"></script> <!-- Load the config script for node information -->
|
||||
@@ -17,10 +14,12 @@
|
||||
<script>
|
||||
RED.nodes.registerType('machineGroupControl',{
|
||||
category: "EVOLV",
|
||||
color: "#eaf4f1",
|
||||
color: "#50a8d9",
|
||||
defaults: {
|
||||
// Define default properties
|
||||
name: { value: "" },
|
||||
processOutputFormat: { value: "process" },
|
||||
dbaseOutputFormat: { value: "influxdb" },
|
||||
|
||||
// Logger properties
|
||||
enableLog: { value: false },
|
||||
@@ -39,7 +38,7 @@
|
||||
outputs:3,
|
||||
inputLabels: ["Input"],
|
||||
outputLabels: ["process", "dbase", "parent"],
|
||||
icon: "font-awesome/fa-tachometer",
|
||||
icon: "font-awesome/fa-cogs",
|
||||
|
||||
label: function () {
|
||||
return this.positionIcon + " " + "machineGroup";
|
||||
@@ -77,6 +76,24 @@
|
||||
|
||||
<script type="text/html" data-template-name="machineGroupControl">
|
||||
|
||||
<h3>Output Formats</h3>
|
||||
<div class="form-row">
|
||||
<label for="node-input-processOutputFormat"><i class="fa fa-random"></i> Process Output</label>
|
||||
<select id="node-input-processOutputFormat" style="width:60%;">
|
||||
<option value="process">process</option>
|
||||
<option value="json">json</option>
|
||||
<option value="csv">csv</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<label for="node-input-dbaseOutputFormat"><i class="fa fa-database"></i> Database Output</label>
|
||||
<select id="node-input-dbaseOutputFormat" style="width:60%;">
|
||||
<option value="influxdb">influxdb</option>
|
||||
<option value="json">json</option>
|
||||
<option value="csv">csv</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<!-- Logger fields injected here -->
|
||||
<div id="logger-fields-placeholder"></div>
|
||||
|
||||
|
||||
@@ -38,21 +38,9 @@ class nodeClass {
|
||||
const cfgMgr = new configManager();
|
||||
this.defaultConfig = cfgMgr.getConfig(this.name);
|
||||
|
||||
// Merge UI config over defaults
|
||||
this.config = {
|
||||
general: {
|
||||
name: uiConfig.name,
|
||||
id: node.id, // node.id is for the child registration process
|
||||
unit: uiConfig.unit, // add converter options later to convert to default units (need like a model that defines this which units we are going to use and then conver to those standards)
|
||||
logging: {
|
||||
enabled: uiConfig.enableLog,
|
||||
logLevel: uiConfig.logLevel,
|
||||
},
|
||||
},
|
||||
functionality: {
|
||||
positionVsParent: uiConfig.positionVsParent || "atEquipment", // Default to 'atEquipment' if not set
|
||||
},
|
||||
};
|
||||
// Build config: base sections (no domain-specific config for group controller)
|
||||
this.config = cfgMgr.buildConfig(this.name, uiConfig, node.id);
|
||||
|
||||
// Utility for formatting outputs
|
||||
this._output = new outputUtils();
|
||||
}
|
||||
@@ -80,7 +68,7 @@ class nodeClass {
|
||||
const availableMachines = Object.values(mg.machines || {}).filter((machine) => {
|
||||
// Safety check: ensure machine and machine.state exist
|
||||
if (!machine || !machine.state || typeof machine.state.getCurrentState !== 'function') {
|
||||
console.warn(`Machine missing or invalid:`, machine?.config?.general?.id || 'unknown');
|
||||
mg.logger.warn(`Machine missing or invalid: ${machine?.config?.general?.id || 'unknown'}`);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -198,40 +186,35 @@ class nodeClass {
|
||||
const mg = this.source;
|
||||
const RED = this.RED;
|
||||
switch (msg.topic) {
|
||||
case "registerChild":
|
||||
console.log(`Registering child in mgc: ${msg.payload}`);
|
||||
case "registerChild": {
|
||||
const childId = msg.payload;
|
||||
const childObj = RED.nodes.getNode(childId);
|
||||
|
||||
// Debug: Check what we're getting
|
||||
console.log(`Child object:`, childObj ? 'found' : 'NOT FOUND');
|
||||
console.log(`Child source:`, childObj?.source ? 'exists' : 'MISSING');
|
||||
if (childObj?.source) {
|
||||
console.log(`Child source type:`, childObj.source.constructor.name);
|
||||
console.log(`Child has state:`, !!childObj.source.state);
|
||||
}
|
||||
mg.logger.debug(`Registering child: ${childId}, found: ${!!childObj}, source: ${!!childObj?.source}`);
|
||||
|
||||
mg.childRegistrationUtils.registerChild(
|
||||
childObj.source,
|
||||
msg.positionVsParent
|
||||
);
|
||||
|
||||
// Debug: Check machines after registration
|
||||
console.log(`Total machines after registration:`, Object.keys(mg.machines || {}).length);
|
||||
mg.logger.debug(`Total machines after registration: ${Object.keys(mg.machines || {}).length}`);
|
||||
break;
|
||||
}
|
||||
|
||||
case "setMode":
|
||||
case "setMode": {
|
||||
const mode = msg.payload;
|
||||
mg.setMode(mode);
|
||||
break;
|
||||
}
|
||||
|
||||
case "setScaling":
|
||||
case "setScaling": {
|
||||
const scaling = msg.payload;
|
||||
mg.setScaling(scaling);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case "Qd":
|
||||
case "Qd": {
|
||||
const Qd = parseFloat(msg.payload);
|
||||
const sourceQd = "parent";
|
||||
|
||||
@@ -245,9 +228,10 @@ class nodeClass {
|
||||
msg.payload = "done";
|
||||
send(msg);
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
mg.logger.error(`Demand handling failed: ${e.message}`);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
// Handle unknown topics if needed
|
||||
|
||||
@@ -1,20 +1,6 @@
|
||||
/**
|
||||
* @summary A class to interact and manipulate machines with a non-euclidian curve
|
||||
* @description A class to interact and manipulate machines with a non-euclidian curve
|
||||
* @module machineGroup
|
||||
* @exports machineGroup
|
||||
* @version 0.1.0
|
||||
* @since 0.1.0
|
||||
*
|
||||
* Author:
|
||||
* - Rene De Ren
|
||||
* Email:
|
||||
* - r.de.ren@brabantsedelta.nl
|
||||
*/
|
||||
|
||||
//load local dependencies
|
||||
const EventEmitter = require("events");
|
||||
const {logger,configUtils,configManager, MeasurementContainer, interpolation , childRegistrationUtils} = require('generalFunctions');
|
||||
const {logger,configUtils,configManager, MeasurementContainer, interpolation , childRegistrationUtils, POSITIONS} = require('generalFunctions');
|
||||
|
||||
class MachineGroup {
|
||||
constructor(machineGroupConfig = {}) {
|
||||
@@ -89,7 +75,7 @@ class MachineGroup {
|
||||
Object.values(this.machines).forEach(machine => {
|
||||
const totals = { flow: { min: Infinity, max: 0 }, power: { min: Infinity, max: 0 } };
|
||||
//fetch min flow ever seen over all machines
|
||||
Object.entries(machine.predictFlow.inputCurve).forEach(([pressure, xyCurve], index) => {
|
||||
Object.entries(machine.predictFlow.inputCurve).forEach(([pressure, xyCurve], _index) => {
|
||||
const minFlow = Math.min(...xyCurve.y);
|
||||
const maxFlow = Math.max(...xyCurve.y);
|
||||
|
||||
@@ -154,8 +140,8 @@ class MachineGroup {
|
||||
const maxFlow = machine.predictFlow.currentFxyYMax;
|
||||
const minPower = machine.predictPower.currentFxyYMin;
|
||||
const maxPower = machine.predictPower.currentFxyYMax;
|
||||
const actFlow = machine.measurements.type("flow").variant("predicted").position("downstream").getCurrentValue();
|
||||
const actPower = machine.measurements.type("power").variant("predicted").position("atEquipment").getCurrentValue();
|
||||
const actFlow = machine.measurements.type("flow").variant("predicted").position(POSITIONS.DOWNSTREAM).getCurrentValue();
|
||||
const actPower = machine.measurements.type("power").variant("predicted").position(POSITIONS.AT_EQUIPMENT).getCurrentValue();
|
||||
|
||||
this.logger.debug(`Machine ${machine.config.general.id} - Min Flow: ${minFlow}, Max Flow: ${maxFlow}, Min Power: ${minPower}, Max Power: ${maxPower}, NCog: ${machine.NCog}`);
|
||||
|
||||
@@ -209,11 +195,11 @@ class MachineGroup {
|
||||
const { flow, power } = this.calcDynamicTotals();
|
||||
|
||||
this.logger.debug(`Dynamic Totals after pressure change - Flow: Min ${flow.min}, Max ${flow.max}, Act ${flow.act} | Power: Min ${power.min}, Max ${power.max}, Act ${power.act}`);
|
||||
this.measurements.type("flow").variant("predicted").position("downstream").value(flow.act);
|
||||
this.measurements.type("power").variant("predicted").position("atEquipment").value(power.act);
|
||||
this.measurements.type("flow").variant("predicted").position(POSITIONS.DOWNSTREAM).value(flow.act);
|
||||
this.measurements.type("power").variant("predicted").position(POSITIONS.AT_EQUIPMENT).value(power.act);
|
||||
|
||||
const { maxEfficiency, lowestEfficiency } = this.calcGroupEfficiency(this.machines);
|
||||
const efficiency = this.measurements.type("efficiency").variant("predicted").position("atEquipment").getCurrentValue();
|
||||
const efficiency = this.measurements.type("efficiency").variant("predicted").position(POSITIONS.AT_EQUIPMENT).getCurrentValue();
|
||||
this.calcDistanceBEP(efficiency,maxEfficiency,lowestEfficiency);
|
||||
}
|
||||
|
||||
@@ -249,11 +235,11 @@ class MachineGroup {
|
||||
//add special cases
|
||||
if( state === "operational" && ( mode == "virtualControl" || mode === "fysicalControl") ){
|
||||
let flow = 0;
|
||||
if(machine.measurements.type("flow").variant("measured").position("downstream").getCurrentValue()){
|
||||
flow = machine.measurements.type("flow").variant("measured").position("downstream").getCurrentValue();
|
||||
if(machine.measurements.type("flow").variant("measured").position(POSITIONS.DOWNSTREAM).getCurrentValue()){
|
||||
flow = machine.measurements.type("flow").variant("measured").position(POSITIONS.DOWNSTREAM).getCurrentValue();
|
||||
}
|
||||
else if(machine.measurements.type("flow").variant("predicted").position("downstream").getCurrentValue()){
|
||||
flow = machine.measurements.type("flow").variant("predicted").position("downstream").getCurrentValue();
|
||||
else if(machine.measurements.type("flow").variant("predicted").position(POSITIONS.DOWNSTREAM).getCurrentValue()){
|
||||
flow = machine.measurements.type("flow").variant("predicted").position(POSITIONS.DOWNSTREAM).getCurrentValue();
|
||||
}
|
||||
else{
|
||||
this.logger.error("Dont perform calculation at all seeing that there is a machine working but we dont know the flow its producing");
|
||||
@@ -403,10 +389,10 @@ class MachineGroup {
|
||||
try{
|
||||
//we need to force the pressures of all machines to be equal to the highest pressure measured in the group
|
||||
// this is to ensure a correct evaluation of the flow and power consumption
|
||||
const pressures = Object.entries(this.machines).map(([machineId, machine]) => {
|
||||
const pressures = Object.entries(this.machines).map(([_machineId, machine]) => {
|
||||
return {
|
||||
downstream: machine.measurements.type("pressure").variant("measured").position("downstream").getCurrentValue(),
|
||||
upstream: machine.measurements.type("pressure").variant("measured").position("upstream").getCurrentValue()
|
||||
downstream: machine.measurements.type("pressure").variant("measured").position(POSITIONS.DOWNSTREAM).getCurrentValue(),
|
||||
upstream: machine.measurements.type("pressure").variant("measured").position(POSITIONS.UPSTREAM).getCurrentValue()
|
||||
};
|
||||
});
|
||||
|
||||
@@ -416,12 +402,12 @@ class MachineGroup {
|
||||
this.logger.debug(`Max downstream pressure: ${maxDownstream}, Min upstream pressure: ${minUpstream}`);
|
||||
|
||||
//set the pressures
|
||||
Object.entries(this.machines).forEach(([machineId, machine]) => {
|
||||
Object.entries(this.machines).forEach(([_machineId, machine]) => {
|
||||
if(machine.state.getCurrentState() !== "operational" && machine.state.getCurrentState() !== "accelerating" && machine.state.getCurrentState() !== "decelerating"){
|
||||
|
||||
//Equilize pressures over all machines so we can make a proper calculation
|
||||
machine.measurements.type("pressure").variant("measured").position("downstream").value(maxDownstream);
|
||||
machine.measurements.type("pressure").variant("measured").position("upstream").value(minUpstream);
|
||||
machine.measurements.type("pressure").variant("measured").position(POSITIONS.DOWNSTREAM).value(maxDownstream);
|
||||
machine.measurements.type("pressure").variant("measured").position(POSITIONS.UPSTREAM).value(minUpstream);
|
||||
|
||||
// after updating the measurement directly we need to force the update of the value OLIFANT this is not so clear now in the code
|
||||
// we need to find a better way to do this but for now it works
|
||||
@@ -465,10 +451,10 @@ class MachineGroup {
|
||||
this.logger.debug(`Moving to demand: ${Qd.toFixed(2)} -> Pumps: [${debugInfo}] => Total Power: ${bestResult.bestPower.toFixed(2)}`);
|
||||
|
||||
//store the total delivered power
|
||||
this.measurements.type("power").variant("predicted").position("atEquipment").value(bestResult.bestPower);
|
||||
this.measurements.type("flow").variant("predicted").position("downstream").value(bestResult.bestFlow);
|
||||
this.measurements.type("efficiency").variant("predicted").position("atEquipment").value(bestResult.bestFlow / bestResult.bestPower);
|
||||
this.measurements.type("Ncog").variant("predicted").position("atEquipment").value(bestResult.bestCog);
|
||||
this.measurements.type("power").variant("predicted").position(POSITIONS.AT_EQUIPMENT).value(bestResult.bestPower);
|
||||
this.measurements.type("flow").variant("predicted").position(POSITIONS.DOWNSTREAM).value(bestResult.bestFlow);
|
||||
this.measurements.type("efficiency").variant("predicted").position(POSITIONS.AT_EQUIPMENT).value(bestResult.bestFlow / bestResult.bestPower);
|
||||
this.measurements.type("Ncog").variant("predicted").position(POSITIONS.AT_EQUIPMENT).value(bestResult.bestCog);
|
||||
|
||||
await Promise.all(Object.entries(this.machines).map(async ([machineId, machine]) => {
|
||||
// Find the flow for this machine in the best combination
|
||||
@@ -504,10 +490,10 @@ class MachineGroup {
|
||||
// Equalize pressure across all machines for machines that are not running. This is needed to ensure accurate flow and power predictions.
|
||||
equalizePressure(){
|
||||
// Get current pressures from all machines
|
||||
const pressures = Object.entries(this.machines).map(([machineId, machine]) => {
|
||||
const pressures = Object.entries(this.machines).map(([_machineId, machine]) => {
|
||||
return {
|
||||
downstream: machine.measurements.type("pressure").variant("measured").position("downstream").getCurrentValue(),
|
||||
upstream: machine.measurements.type("pressure").variant("measured").position("upstream").getCurrentValue()
|
||||
downstream: machine.measurements.type("pressure").variant("measured").position(POSITIONS.DOWNSTREAM).getCurrentValue(),
|
||||
upstream: machine.measurements.type("pressure").variant("measured").position(POSITIONS.UPSTREAM).getCurrentValue()
|
||||
};
|
||||
});
|
||||
|
||||
@@ -518,8 +504,8 @@ class MachineGroup {
|
||||
// Set consistent pressures across machines
|
||||
Object.entries(this.machines).forEach(([machineId, machine]) => {
|
||||
if(!this.isMachineActive(machineId)){
|
||||
machine.measurements.type("pressure").variant("measured").position("downstream").value(maxDownstream);
|
||||
machine.measurements.type("pressure").variant("measured").position("upstream").value(minUpstream);
|
||||
machine.measurements.type("pressure").variant("measured").position(POSITIONS.DOWNSTREAM).value(maxDownstream);
|
||||
machine.measurements.type("pressure").variant("measured").position(POSITIONS.UPSTREAM).value(minUpstream);
|
||||
// Update the measured pressure value
|
||||
const pressure = machine.getMeasuredPressure();
|
||||
this.logger.debug(`Setting pressure for machine ${machineId} to ${pressure}`);
|
||||
@@ -563,7 +549,7 @@ class MachineGroup {
|
||||
}
|
||||
|
||||
filterOutUnavailableMachines(list) {
|
||||
const newList = list.filter(({ id, machine }) => {
|
||||
const newList = list.filter(({ machine }) => {
|
||||
const state = machine.state.getCurrentState();
|
||||
const validActionForMode = machine.isValidActionForMode("execSequence", "auto");
|
||||
|
||||
@@ -578,7 +564,7 @@ class MachineGroup {
|
||||
let lowestEfficiency = Infinity;
|
||||
|
||||
// Calculate the average efficiency of all machines -> peak is the average of them all
|
||||
Object.entries(machines).forEach(([machineId, machine]) => {
|
||||
Object.entries(machines).forEach(([_machineId, machine]) => {
|
||||
cumEfficiency += machine.cog;
|
||||
if(machine.cog < lowestEfficiency){
|
||||
lowestEfficiency = machine.cog;
|
||||
@@ -593,7 +579,7 @@ class MachineGroup {
|
||||
}
|
||||
|
||||
//move machines assuming equal control in flow and a priority list
|
||||
async equalFlowControl(Qd, powerCap = Infinity, priorityList = null) {
|
||||
async equalFlowControl(Qd, _powerCap = Infinity, priorityList = null) {
|
||||
try {
|
||||
|
||||
// equalize pressure across all machines
|
||||
@@ -648,7 +634,7 @@ class MachineGroup {
|
||||
break;
|
||||
}
|
||||
|
||||
case (Qd > activeTotals.flow.max):
|
||||
case (Qd > activeTotals.flow.max): {
|
||||
// Case 2: Demand is above the maximum available flow.
|
||||
// Start the non-active machine with the highest priority and distribute Qd over all available machines.
|
||||
let i = 1;
|
||||
@@ -668,9 +654,10 @@ class MachineGroup {
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
default:
|
||||
default: {
|
||||
// Default case: Demand is within the active range.
|
||||
const countActiveMachines = machinesInPriorityOrder.filter(({ id }) => this.isMachineActive(id)).length;
|
||||
|
||||
@@ -685,6 +672,7 @@ class MachineGroup {
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Log information about flow distribution
|
||||
const debugInfo = flowDistribution
|
||||
@@ -695,10 +683,10 @@ class MachineGroup {
|
||||
this.logger.debug(`Priority control for demand: ${totalFlow.toFixed(2)} -> Active pumps: [${debugInfo}] => Total Power: ${totalPower.toFixed(2)}`);
|
||||
|
||||
// Store measurements
|
||||
this.measurements.type("power").variant("predicted").position("atEquipment").value(totalPower);
|
||||
this.measurements.type("flow").variant("predicted").position("downstream").value(totalFlow);
|
||||
this.measurements.type("efficiency").variant("predicted").position("atEquipment").value(totalFlow / totalPower);
|
||||
this.measurements.type("Ncog").variant("predicted").position("atEquipment").value(totalCog);
|
||||
this.measurements.type("power").variant("predicted").position(POSITIONS.AT_EQUIPMENT).value(totalPower);
|
||||
this.measurements.type("flow").variant("predicted").position(POSITIONS.DOWNSTREAM).value(totalFlow);
|
||||
this.measurements.type("efficiency").variant("predicted").position(POSITIONS.AT_EQUIPMENT).value(totalFlow / totalPower);
|
||||
this.measurements.type("Ncog").variant("predicted").position(POSITIONS.AT_EQUIPMENT).value(totalCog);
|
||||
|
||||
this.logger.debug(`Flow distribution: ${JSON.stringify(flowDistribution)}`);
|
||||
// Apply the flow distribution to machines
|
||||
@@ -736,7 +724,7 @@ class MachineGroup {
|
||||
}
|
||||
|
||||
//capp input to 100
|
||||
input > 100 ? input = 100 : input = input;
|
||||
if (input > 100) { input = 100; }
|
||||
|
||||
const numOfMachines = Object.keys(this.machines).length;
|
||||
const procentTotal = numOfMachines * input;
|
||||
@@ -750,7 +738,7 @@ class MachineGroup {
|
||||
if(machinesNeeded > machinesActive){
|
||||
|
||||
//start extra machine and put all active machines at min control
|
||||
machinesInPriorityOrder.forEach(({ id, machine }, index) => {
|
||||
machinesInPriorityOrder.forEach(({ id }, index) => {
|
||||
if(index < machinesNeeded){
|
||||
ctrlDistribution.push({machineId : id, ctrl : 0});
|
||||
}
|
||||
@@ -759,7 +747,7 @@ class MachineGroup {
|
||||
|
||||
if(machinesNeeded < machinesActive){
|
||||
|
||||
machinesInPriorityOrder.forEach(({ id, machine }, index) => {
|
||||
machinesInPriorityOrder.forEach(({ id }, index) => {
|
||||
if(this.isMachineActive(id)){
|
||||
if(index < machinesNeeded){
|
||||
ctrlDistribution.push({machineId : id, ctrl : 100});
|
||||
@@ -776,7 +764,7 @@ class MachineGroup {
|
||||
// distribute input equally among active machines (0 - 100%)
|
||||
const ctrlPerMachine = procentTotal / machinesActive;
|
||||
|
||||
machinesInPriorityOrder.forEach(({ id, machine }) => {
|
||||
machinesInPriorityOrder.forEach(({ id }) => {
|
||||
if (this.isMachineActive(id)) {
|
||||
// ensure ctrl is capped between 0 and 100%
|
||||
const ctrlValue = Math.max(0, Math.min(ctrlPerMachine, 100));
|
||||
@@ -808,10 +796,10 @@ class MachineGroup {
|
||||
const totalFlow = [];
|
||||
|
||||
// fetch and store measurements
|
||||
Object.entries(this.machines).forEach(([machineId, machine]) => {
|
||||
Object.entries(this.machines).forEach(([_machineId, machine]) => {
|
||||
|
||||
const powerValue = machine.measurements.type("power").variant("predicted").position("atEquipment").getCurrentValue();
|
||||
const flowValue = machine.measurements.type("flow").variant("predicted").position("downstream").getCurrentValue();
|
||||
const powerValue = machine.measurements.type("power").variant("predicted").position(POSITIONS.AT_EQUIPMENT).getCurrentValue();
|
||||
const flowValue = machine.measurements.type("flow").variant("predicted").position(POSITIONS.DOWNSTREAM).getCurrentValue();
|
||||
|
||||
if (powerValue !== null) {
|
||||
totalPower.push(powerValue);
|
||||
@@ -821,11 +809,11 @@ class MachineGroup {
|
||||
}
|
||||
});
|
||||
|
||||
this.measurements.type("power").variant("predicted").position("atEquipment").value(totalPower.reduce((a, b) => a + b, 0));
|
||||
this.measurements.type("flow").variant("predicted").position("downstream").value(totalFlow.reduce((a, b) => a + b, 0));
|
||||
this.measurements.type("power").variant("predicted").position(POSITIONS.AT_EQUIPMENT).value(totalPower.reduce((a, b) => a + b, 0));
|
||||
this.measurements.type("flow").variant("predicted").position(POSITIONS.DOWNSTREAM).value(totalFlow.reduce((a, b) => a + b, 0));
|
||||
|
||||
if(totalPower.reduce((a, b) => a + b, 0) > 0){
|
||||
this.measurements.type("efficiency").variant("predicted").position("atEquipment").value(totalFlow.reduce((a, b) => a + b, 0) / totalPower.reduce((a, b) => a + b, 0));
|
||||
this.measurements.type("efficiency").variant("predicted").position(POSITIONS.AT_EQUIPMENT).value(totalFlow.reduce((a, b) => a + b, 0) / totalPower.reduce((a, b) => a + b, 0));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -855,12 +843,12 @@ class MachineGroup {
|
||||
return;
|
||||
}
|
||||
|
||||
if (demandQ < absoluteTotals.flow.min) {
|
||||
this.logger.warn(`Flow demand ${demandQ} is below minimum possible flow ${absoluteTotals.flow.min}. Capping to minimum flow.`);
|
||||
if (demandQ < this.absoluteTotals.flow.min) {
|
||||
this.logger.warn(`Flow demand ${demandQ} is below minimum possible flow ${this.absoluteTotals.flow.min}. Capping to minimum flow.`);
|
||||
demandQout = this.absoluteTotals.flow.min;
|
||||
} else if (demandQout > absoluteTotals.flow.max) {
|
||||
this.logger.warn(`Flow demand ${demandQ} is above maximum possible flow ${absoluteTotals.flow.max}. Capping to maximum flow.`);
|
||||
demandQout = absoluteTotals.flow.max;
|
||||
} else if (demandQout > this.absoluteTotals.flow.max) {
|
||||
this.logger.warn(`Flow demand ${demandQ} is above maximum possible flow ${this.absoluteTotals.flow.max}. Capping to maximum flow.`);
|
||||
demandQout = this.absoluteTotals.flow.max;
|
||||
}else if(demandQout <= 0){
|
||||
this.logger.debug(`Turning machines off`);
|
||||
demandQout = 0;
|
||||
@@ -918,7 +906,7 @@ class MachineGroup {
|
||||
|
||||
//recalc distance from BEP
|
||||
const { maxEfficiency, lowestEfficiency } = this.calcGroupEfficiency(this.machines);
|
||||
const efficiency = this.measurements.type("efficiency").variant("predicted").position("downstream").getCurrentValue();
|
||||
const efficiency = this.measurements.type("efficiency").variant("predicted").position(POSITIONS.DOWNSTREAM).getCurrentValue();
|
||||
this.calcDistanceBEP(efficiency,maxEfficiency,lowestEfficiency);
|
||||
|
||||
}
|
||||
@@ -942,9 +930,9 @@ class MachineGroup {
|
||||
this.measurements.getTypes().forEach(type => {
|
||||
this.measurements.getVariants(type).forEach(variant => {
|
||||
|
||||
const downstreamVal = this.measurements.type(type).variant(variant).position("downstream").getCurrentValue();
|
||||
const atEquipmentVal = this.measurements.type(type).variant(variant).position("atEquipment").getCurrentValue();
|
||||
const upstreamVal = this.measurements.type(type).variant(variant).position("upstream").getCurrentValue();
|
||||
const downstreamVal = this.measurements.type(type).variant(variant).position(POSITIONS.DOWNSTREAM).getCurrentValue();
|
||||
const atEquipmentVal = this.measurements.type(type).variant(variant).position(POSITIONS.AT_EQUIPMENT).getCurrentValue();
|
||||
const upstreamVal = this.measurements.type(type).variant(variant).position(POSITIONS.UPSTREAM).getCurrentValue();
|
||||
|
||||
if (downstreamVal != null) {
|
||||
output[`downstream_${variant}_${type}`] = downstreamVal;
|
||||
@@ -1101,11 +1089,11 @@ async function makeMachines(){
|
||||
for(let i = 1; i <= numofMachines; i++){
|
||||
const machine = new Machine(machineConfigs[i],stateConfigs[i]);
|
||||
//mg.machines[i] = machine;
|
||||
mg.childRegistrationUtils.registerChild(machine, "downstream");
|
||||
mg.childRegistrationUtils.registerChild(machine, POSITIONS.DOWNSTREAM);
|
||||
}
|
||||
|
||||
Object.keys(mg.machines).forEach(machineId => {
|
||||
mg.machines[machineId].childRegistrationUtils.registerChild(pt1, "downstream");
|
||||
mg.machines[machineId].childRegistrationUtils.registerChild(pt1, POSITIONS.DOWNSTREAM);
|
||||
});
|
||||
|
||||
mg.setMode("prioritycontrol");
|
||||
|
||||
Reference in New Issue
Block a user