1
0

pretty bad regulation, but won't collapse

This commit is contained in:
Rémi Heredero 2023-06-13 06:32:08 +02:00
parent c97d428935
commit 4d428fe301

View File

@ -19,7 +19,7 @@ public class SmartControl {
private static final float PV_PANEL_NOMINAL = 1000f; private static final float PV_PANEL_NOMINAL = 1000f;
private static final float PV_PANEL_NOMINAL_RAINING = 500f; private static final float PV_PANEL_NOMINAL_RAINING = 500f;
public static final long TIME_BETWEEN_UPDATES = 20; public static final long TIME_BETWEEN_UPDATES = 100;
@ -40,12 +40,12 @@ public class SmartControl {
private float igpCoalAmount = 0f; private float igpCoalAmount = 0f;
// Time variables // Time variables
private int day = 2; // TODO : Change to 1 private int day = 1;
private boolean dayChanged = false; private boolean dayChanged = false;
private float previousCoalAmount = 0f; private float previousCoalAmount = 0f;
private float initialTime; private float initialTime;
final float kpiFactory = 0.5f; final float kpiFactory = 0.1f;
final float kpiCoal = 0.5f; final float kpiCoal = 0.1f;
final float kpiCoalBatt = 0.8f; final float kpiCoalBatt = 0.8f;
private void defineDataPoints(){ private void defineDataPoints(){
@ -62,8 +62,8 @@ public class SmartControl {
remoteFactorySp = (FloatDataPoint) DataPoint.getDataPointOnListFromLabel("REMOTE_FACTORY_SP"); remoteFactorySp = (FloatDataPoint) DataPoint.getDataPointOnListFromLabel("REMOTE_FACTORY_SP");
coalAmount = (FloatDataPoint) DataPoint.getDataPointOnListFromLabel("COAL_AMOUNT"); coalAmount = (FloatDataPoint) DataPoint.getDataPointOnListFromLabel("COAL_AMOUNT");
gridVoltage = (FloatDataPoint) DataPoint.getDataPointOnListFromLabel("GRID_U_FLOAT"); gridVoltage = (FloatDataPoint) DataPoint.getDataPointOnListFromLabel("GRID_U_FLOAT");
System.out.println("Test if data points are defined");
} while (!testIfDataPointsAreDefined()); } while (!testIfDataPointsAreDefined());
System.out.println("Data points defined");
} }
private boolean testIfDataPointsAreDefined(){ private boolean testIfDataPointsAreDefined(){
@ -218,16 +218,18 @@ public class SmartControl {
float spCoal = remoteCoalSp.getValue(); float spCoal = remoteCoalSp.getValue();
float spFactory = remoteFactorySp.getValue(); float spFactory = remoteFactorySp.getValue();
if (getTimeOfTheDay() < 1f && !dayChanged) { if ((getTimeOfTheDay() < 0.5f) && !dayChanged) {
dayChanged = true; dayChanged = true;
day++; day++;
} }
if (getPeriodOfDay() > 23f) { if (getTimeOfTheDay() > 23f) {
dayChanged = false; dayChanged = false;
} }
if(coalAmount.getValue() > previousCoalAmount) { if(coalAmount.getValue() > previousCoalAmount) {
previousCoalAmount = coalAmount.getValue();
day = 1; day = 1;
} }
defineIGPbatteryLevel(); defineIGPbatteryLevel();
defineIGPcoalAmount(day); defineIGPcoalAmount(day);
@ -260,26 +262,34 @@ public class SmartControl {
new FloatDataPoint("COAL_DIFF", true).setValue(coalDiff); new FloatDataPoint("COAL_DIFF", true).setValue(coalDiff);
//debug += "Coal diff.: " + coalDiff + " - "; //debug += "Coal diff.: " + coalDiff + " - ";
if(balance < 0){ // Produce more energy or consume less if(balance < 0){ // Produce more energy or consume less
if(coalDiff > 0){ // Produce more energy if(coalDiff > 0){ // Produce more energy
spCoal += kpiCoal * (balance / COAL_POWER_MAX); spCoal += kpiCoal * (balance / COAL_POWER_MAX);
spFactory -= kpiFactory * (balance / FACTORY_POWER_MAX);
debug += "Produce more energy"; debug += "Produce more energy";
} else { // Consume less energy } else { // Consume less energy
spFactory -= kpiFactory * (balance / FACTORY_POWER_MAX); spFactory -= kpiFactory * (balance / FACTORY_POWER_MAX);
spCoal += kpiCoal * (balance / COAL_POWER_MAX);
debug += "Consume less energy"; debug += "Consume less energy";
} }
} else { // Produce less energy or consume more } else { // Produce less energy or consume more
if(coalDiff > 0){ // Produce less energy if(coalDiff < 0){ // Produce less energy
spCoal -= kpiCoal * (balance / COAL_POWER_MAX); spCoal -= kpiCoal * (balance / COAL_POWER_MAX);
spFactory += kpiFactory * (balance / FACTORY_POWER_MAX);
debug += "Produce less energy"; debug += "Produce less energy";
} else { // Consume more energy } else { // Consume more energy
spFactory += kpiFactory * (balance / FACTORY_POWER_MAX); spFactory += kpiFactory * (balance / FACTORY_POWER_MAX);
spCoal -= kpiCoal * (balance / COAL_POWER_MAX);
debug += "Consume more energy"; debug += "Consume more energy";
} }
} }
FloatDataPoint solar = (FloatDataPoint) DataPoint.getDataPointOnListFromLabel("SOLAR_P_FLOAT");
float foo = (1000f- solar.getValue()) / 1000f;
if(spCoal > foo) spCoal = foo;
@ -288,8 +298,8 @@ public class SmartControl {
if (spCoal > 1f) spCoal = 1f; if (spCoal > 1f) spCoal = 1f;
if (spCoal < 0f) spCoal = 0f; if (spCoal < 0f) spCoal = 0f;
remoteFactorySp.setValue(spFactory); new FloatDataPoint("REMOTE_FACTORY_SP", true).setValue(spFactory);
remoteCoalSp.setValue(spCoal); new FloatDataPoint("REMOTE_COAL_SP", true).setValue(spCoal);
System.out.println(debug); System.out.println(debug);