diff --git a/io.openems.edge.controller.pvinverter.reversepowerrelay/.classpath b/io.openems.edge.controller.pvinverter.reversepowerrelay/.classpath new file mode 100644 index 00000000000..bbfbdbe40e7 --- /dev/null +++ b/io.openems.edge.controller.pvinverter.reversepowerrelay/.classpath @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/io.openems.edge.controller.pvinverter.reversepowerrelay/.settings/org.eclipse.core.resources.prefs b/io.openems.edge.controller.pvinverter.reversepowerrelay/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 00000000000..99f26c0203a --- /dev/null +++ b/io.openems.edge.controller.pvinverter.reversepowerrelay/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/io.openems.edge.controller.pvinverter.reversepowerrelay/bnd.bnd b/io.openems.edge.controller.pvinverter.reversepowerrelay/bnd.bnd index 0b4a6932320..b1bb9ef00e3 100644 --- a/io.openems.edge.controller.pvinverter.reversepowerrelay/bnd.bnd +++ b/io.openems.edge.controller.pvinverter.reversepowerrelay/bnd.bnd @@ -9,7 +9,8 @@ Bundle-Version: 1.0.0.${tstamp} io.openems.edge.common,\ io.openems.edge.controller.api,\ io.openems.edge.meter.api,\ - io.openems.edge.pvinverter.api + io.openems.edge.pvinverter.api,\ + osgi.cmpn -testpath: \ ${testpath},\ diff --git a/io.openems.edge.controller.pvinverter.reversepowerrelay/src/io/openems/edge/controller/pvinverter/reversepowerrelay/ReversePowerRelayImpl.java b/io.openems.edge.controller.pvinverter.reversepowerrelay/src/io/openems/edge/controller/pvinverter/reversepowerrelay/ReversePowerRelayImpl.java index 4058eb8df12..5c1796b9903 100644 --- a/io.openems.edge.controller.pvinverter.reversepowerrelay/src/io/openems/edge/controller/pvinverter/reversepowerrelay/ReversePowerRelayImpl.java +++ b/io.openems.edge.controller.pvinverter.reversepowerrelay/src/io/openems/edge/controller/pvinverter/reversepowerrelay/ReversePowerRelayImpl.java @@ -2,13 +2,6 @@ import java.util.Optional; -import org.osgi.service.component.ComponentContext; -import org.osgi.service.component.annotations.Activate; -import org.osgi.service.component.annotations.Component; -import org.osgi.service.component.annotations.ConfigurationPolicy; -import org.osgi.service.component.annotations.Deactivate; -import org.osgi.service.component.annotations.Reference; -import org.osgi.service.metatype.annotations.Designate; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -21,6 +14,15 @@ import io.openems.edge.pvinverter.api.ManagedSymmetricPvInverter; import io.openems.edge.common.channel.BooleanReadChannel; +import org.osgi.service.component.ComponentContext; +import org.osgi.service.component.annotations.Activate; +import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.annotations.ConfigurationPolicy; +import org.osgi.service.component.annotations.Deactivate; +import org.osgi.service.component.annotations.Reference; + +import org.osgi.service.metatype.annotations.Designate; + @Designate(ocd = Config.class, factory = true) @Component(// name = "Controller.PvInverter.ReversePowerRelay", // @@ -129,7 +131,7 @@ private Optional getChannelValue(ChannelAddress address) { BooleanReadChannel channel = this.componentManager.getChannel(address); return channel.value().asOptional(); } catch (OpenemsNamedException e) { - this.log.error("Error reading channel value", e); + this.log.error("Error reading channel value for address: " + address, e); return Optional.empty(); } } @@ -172,6 +174,7 @@ public void run() throws OpenemsNamedException { } catch (Exception e) { this.log.error("No values from modbus channels yet", e); + this.setPvLimit(0); return; } diff --git a/io.openems.edge.controller.pvinverter.reversepowerrelay/test/io/openems/edge/controller/pvinverter/reversepowerrelay/ReversePowerRelayImplTest.java b/io.openems.edge.controller.pvinverter.reversepowerrelay/test/io/openems/edge/controller/pvinverter/reversepowerrelay/ReversePowerRelayImplTest.java index 98563095235..0ead7749d34 100644 --- a/io.openems.edge.controller.pvinverter.reversepowerrelay/test/io/openems/edge/controller/pvinverter/reversepowerrelay/ReversePowerRelayImplTest.java +++ b/io.openems.edge.controller.pvinverter.reversepowerrelay/test/io/openems/edge/controller/pvinverter/reversepowerrelay/ReversePowerRelayImplTest.java @@ -13,6 +13,7 @@ import io.openems.edge.io.test.DummyInputOutput; + public class ReversePowerRelayImplTest { private static final String CTRL_ID = "ctrl0"; @@ -30,6 +31,8 @@ public class ReversePowerRelayImplTest { private static final ChannelAddress IO_INPUT_OUTPUT1 = new ChannelAddress(IO_ID, "InputOutput1"); private static final ChannelAddress IO_INPUT_OUTPUT2 = new ChannelAddress(IO_ID, "InputOutput2"); private static final ChannelAddress IO_INPUT_OUTPUT3 = new ChannelAddress(IO_ID, "InputOutput3"); + + private static final int powerLimit100 = 1500; @Test public void testReversePowerRelay() throws Exception { @@ -48,6 +51,7 @@ public void testReversePowerRelay() throws Exception { .setInputChannelAddress30Percent(IO_INPUT_OUTPUT1.toString()) // .setInputChannelAddress60Percent(IO_INPUT_OUTPUT2.toString()) // .setInputChannelAddress100Percent(IO_INPUT_OUTPUT3.toString()) // + .setPowerLimit100(powerLimit100) .build()) .next(new TestCase() // .input(GRID_ACTIVE_POWER, -15000) // @@ -61,7 +65,7 @@ public void testReversePowerRelay() throws Exception { .input(IO_INPUT_OUTPUT1, true) // .input(IO_INPUT_OUTPUT2, false) // .input(IO_INPUT_OUTPUT3, false) // - .output(PV_INVERTER_SET_ACTIVE_POWER_EQUALS, 30)) // + .output(PV_INVERTER_SET_ACTIVE_POWER_EQUALS, 450)) // .next(new TestCase() // .input(GRID_ACTIVE_POWER, -15000) // .input(PV_INVERTER_ACTIVE_POWER, 8000) // @@ -69,7 +73,7 @@ public void testReversePowerRelay() throws Exception { .input(IO_INPUT_OUTPUT1, false) // .input(IO_INPUT_OUTPUT2, true) // .input(IO_INPUT_OUTPUT3, false) // - .output(PV_INVERTER_SET_ACTIVE_POWER_EQUALS, 60)) // + .output(PV_INVERTER_SET_ACTIVE_POWER_EQUALS, 900)) // .next(new TestCase() // .input(GRID_ACTIVE_POWER, -13000) // .input(PV_INVERTER_ACTIVE_POWER, 7000) //