pretty bad regulation, but won't collapse
This commit is contained in:
		| @@ -19,7 +19,7 @@ public class SmartControl { | ||||
|     private static final float PV_PANEL_NOMINAL = 1000f; | ||||
|     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; | ||||
|  | ||||
|     // Time variables | ||||
|     private int day = 2; // TODO : Change to 1 | ||||
|     private int day = 1; | ||||
|     private boolean dayChanged = false; | ||||
|     private float previousCoalAmount = 0f; | ||||
|     private float initialTime; | ||||
|     final float kpiFactory = 0.5f; | ||||
|     final float kpiCoal = 0.5f; | ||||
|     final float kpiFactory = 0.1f; | ||||
|     final float kpiCoal = 0.1f; | ||||
|     final float kpiCoalBatt = 0.8f; | ||||
|  | ||||
|     private void defineDataPoints(){ | ||||
| @@ -62,8 +62,8 @@ public class SmartControl { | ||||
|             remoteFactorySp = (FloatDataPoint) DataPoint.getDataPointOnListFromLabel("REMOTE_FACTORY_SP"); | ||||
|             coalAmount = (FloatDataPoint) DataPoint.getDataPointOnListFromLabel("COAL_AMOUNT"); | ||||
|             gridVoltage = (FloatDataPoint) DataPoint.getDataPointOnListFromLabel("GRID_U_FLOAT"); | ||||
|             System.out.println("Test if data points are defined"); | ||||
|         } while (!testIfDataPointsAreDefined()); | ||||
|         System.out.println("Data points defined"); | ||||
|     } | ||||
|  | ||||
|     private boolean testIfDataPointsAreDefined(){ | ||||
| @@ -218,16 +218,18 @@ public class SmartControl { | ||||
|         float spCoal = remoteCoalSp.getValue(); | ||||
|         float spFactory = remoteFactorySp.getValue(); | ||||
|  | ||||
|         if (getTimeOfTheDay() < 1f && !dayChanged) { | ||||
|         if ((getTimeOfTheDay() < 0.5f) && !dayChanged) { | ||||
|             dayChanged = true; | ||||
|             day++; | ||||
|         } | ||||
|         if (getPeriodOfDay() > 23f) { | ||||
|         if (getTimeOfTheDay() > 23f) { | ||||
|             dayChanged = false; | ||||
|         } | ||||
|         if(coalAmount.getValue() > previousCoalAmount) { | ||||
|             previousCoalAmount = coalAmount.getValue(); | ||||
|             day = 1; | ||||
|         } | ||||
|  | ||||
|         defineIGPbatteryLevel(); | ||||
|         defineIGPcoalAmount(day); | ||||
|  | ||||
| @@ -260,26 +262,34 @@ public class SmartControl { | ||||
|         new FloatDataPoint("COAL_DIFF", true).setValue(coalDiff); | ||||
|         //debug += "Coal diff.: " + coalDiff + " - "; | ||||
|  | ||||
|  | ||||
|         if(balance < 0){ // Produce more energy or consume less | ||||
|             if(coalDiff > 0){ // Produce more energy | ||||
|                 spCoal += kpiCoal * (balance / COAL_POWER_MAX); | ||||
|                 spFactory -= kpiFactory * (balance / FACTORY_POWER_MAX); | ||||
|                 debug += "Produce more energy"; | ||||
|             } else { // Consume less energy | ||||
|                 spFactory -= kpiFactory * (balance / FACTORY_POWER_MAX); | ||||
|                 spCoal += kpiCoal * (balance / COAL_POWER_MAX); | ||||
|                 debug += "Consume less energy"; | ||||
|             } | ||||
|         } 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); | ||||
|                 spFactory += kpiFactory * (balance / FACTORY_POWER_MAX); | ||||
|                 debug += "Produce less energy"; | ||||
|             } else { // Consume more energy | ||||
|                 spFactory += kpiFactory * (balance / FACTORY_POWER_MAX); | ||||
|                 spCoal -= kpiCoal * (balance / COAL_POWER_MAX); | ||||
|                 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 < 0f) spCoal = 0f; | ||||
|  | ||||
|         remoteFactorySp.setValue(spFactory); | ||||
|         remoteCoalSp.setValue(spCoal); | ||||
|         new FloatDataPoint("REMOTE_FACTORY_SP", true).setValue(spFactory); | ||||
|         new FloatDataPoint("REMOTE_COAL_SP", true).setValue(spCoal); | ||||
|  | ||||
|         System.out.println(debug); | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user