Skip to content

Commit

Permalink
Merge branch 'release/2019.12.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
sfeilmeier committed Sep 26, 2019
2 parents f320676 + 5d2346c commit c259000
Show file tree
Hide file tree
Showing 107 changed files with 4,429 additions and 1,957 deletions.
2 changes: 1 addition & 1 deletion doc/modules/ROOT/pages/single_document.adoc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
= OpenEMS - Open Energy Management System
ifndef::toc[]
(c) 2019 OpenEMS Association e.V.
Version 2019.11.0
Version 2019.12.0
:sectnums:
:sectnumlevels: 4
:toc:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class OpenemsConstants {
*
* This is usually the number of the sprint within the year
*/
public final static short VERSION_MINOR = 11;
public final static short VERSION_MINOR = 12;

/**
* The patch version of OpenEMS.
Expand Down
9 changes: 6 additions & 3 deletions io.openems.edge.application/EdgeApp.bndrun
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@
bnd.identity;id='io.openems.edge.controller.chp.soc',\
bnd.identity;id='io.openems.edge.controller.debug.detailedlog',\
bnd.identity;id='io.openems.edge.controller.debug.log',\
bnd.identity;id='io.openems.edge.controller.dischargelimitconsideringcellvoltage',\
bnd.identity;id='io.openems.edge.controller.ess.acisland',\
bnd.identity;id='io.openems.edge.controller.ess.delaycharge',\
bnd.identity;id='io.openems.edge.controller.ess.limitdischargecellvoltage',\
bnd.identity;id='io.openems.edge.controller.ess.limittotaldischarge',\
bnd.identity;id='io.openems.edge.controller.ess.onefullcycle',\
bnd.identity;id='io.openems.edge.controller.evcs',\
Expand Down Expand Up @@ -92,6 +92,7 @@
bnd.identity;id='io.openems.edge.scheduler.allalphabetically',\
bnd.identity;id='io.openems.edge.scheduler.fixedorder',\
bnd.identity;id='io.openems.edge.simulator',\
bnd.identity;id='io.openems.edge.solaredge',\
bnd.identity;id='io.openems.edge.timedata.influxdb',\
bnd.identity;id='io.openems.edge.tesla.powerwall2'

Expand All @@ -116,9 +117,9 @@
io.openems.edge.controller.chp.soc;version=snapshot,\
io.openems.edge.controller.debug.detailedlog;version=snapshot,\
io.openems.edge.controller.debug.log;version=snapshot,\
io.openems.edge.controller.dischargelimitconsideringcellvoltage;version=snapshot,\
io.openems.edge.controller.ess.acisland;version=snapshot,\
io.openems.edge.controller.ess.limittotaldischarge;version=snapshot,\
io.openems.edge.controller.ess.limitdischargecellvoltage;version=snapshot,\
io.openems.edge.controller.ess.onefullcycle;version=snapshot,\
io.openems.edge.controller.evcs;version=snapshot,\
io.openems.edge.controller.highloadtimeslot;version=snapshot,\
Expand Down Expand Up @@ -206,4 +207,6 @@
com.google.guava;version='[28.1.0,28.1.1)',\
org.ops4j.pax.logging.pax-logging-api;version='[1.11.2,1.11.3)',\
org.ops4j.pax.logging.pax-logging-service;version='[1.11.2,1.11.3)',\
com.fazecast.jSerialComm;version='[2.5.2,2.5.3)'
com.fazecast.jSerialComm;version='[2.5.2,2.5.3)',\
io.openems.edge.meter.sunspec;version=snapshot,\
io.openems.edge.solaredge;version=snapshot
4 changes: 3 additions & 1 deletion io.openems.edge.controller.chp.soc/bnd.bnd
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ Private-Package: \
io.openems.edge.controller.api;version=latest,\
io.openems.edge.common;version=latest,\
io.openems.edge.ess.api;version=latest,\
io.openems.edge.io.api;version=latest
io.openems.edge.io.api;version=latest,\
com.google.guava,\
com.google.gson

-testpath: \
osgi.enroute.junit.wrapper;version=4.12, \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import org.osgi.service.metatype.annotations.AttributeDefinition;
import org.osgi.service.metatype.annotations.ObjectClassDefinition;

@ObjectClassDefinition( //
@ObjectClassDefinition(//
name = "Controller CHP SOC", //
description = "This is a Controller for CHP (Combined Heat and Power Unit, German: BHKW - Blockheizkraftwerk). The Controller is used to signal CHP turn ON or turn OFF when the battery is empty or battery is full respectively, based on the SoC percentage")
@interface Config {
Expand All @@ -16,6 +16,9 @@

@AttributeDefinition(name = "Is enabled?", description = "Is this Component enabled?")
boolean enabled() default true;

@AttributeDefinition(name = "Mode", description = "Set the type of mode.")
Mode mode() default Mode.AUTOMATIC;

@AttributeDefinition(name = "Input Channel", description = "Address of the input channel")
String inputChannelAddress();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ public class ControllerChpSoc extends AbstractOpenemsComponent implements Contro
protected ComponentManager componentManager;

public enum ChannelId implements io.openems.edge.common.channel.ChannelId {
MODE(Doc.of(Mode.values()) //
.initialValue(Mode.AUTOMATIC) //
.text("Configured Mode")), //
STATE_MACHINE(Doc.of(State.values()) //
.text("Current State of State-Machine"));

Expand Down Expand Up @@ -66,11 +69,17 @@ public ControllerChpSoc() {

@Activate
void activate(ComponentContext context, Config config) throws OpenemsNamedException {

this.lowThreshold = config.lowThreshold();
this.highThreshold = config.highThreshold();
if (this.lowThreshold > this.highThreshold) {
throw new OpenemsException("Low threshold Soc " + this.lowThreshold
+ " should be less than the high threshold Soc " + this.highThreshold);
}
this.inputChannelAddress = ChannelAddress.fromString(config.inputChannelAddress());
this.outputChannelAddress = ChannelAddress.fromString(config.outputChannelAddress());

this.mode = config.mode();
this.channel(ChannelId.MODE).setNextValue(mode);
super.activate(context, config.id(), config.alias(), config.enabled());
}

Expand All @@ -79,14 +88,41 @@ protected void deactivate() {
super.deactivate();
}

private Mode mode;
/**
* The current state in the State Machine
* The current state in the State Machine.
*/
private State state = State.UNDEFINED;

@Override
public void run() throws OpenemsNamedException {

boolean modeChanged;

do {
modeChanged = false;
switch (this.mode) {
case MANUAL_ON:
setOutput(true);
modeChanged = this.changeMode(Mode.MANUAL_ON);
break;
case MANUAL_OFF:
setOutput(false);
modeChanged = this.changeMode(Mode.MANUAL_OFF);
break;
case AUTOMATIC:
this.automaticMode();
modeChanged = this.changeMode(Mode.AUTOMATIC);
break;
}
} while (modeChanged);

this.channel(ChannelId.MODE).setNextValue(this.mode);

}

private void automaticMode() throws IllegalArgumentException, OpenemsNamedException {

Channel<?> inputChannel = this.componentManager.getChannel(this.inputChannelAddress);
int value = TypeUtils.getAsType(OpenemsType.INTEGER, inputChannel.value().getOrError());

Expand Down Expand Up @@ -146,7 +182,7 @@ public void run() throws OpenemsNamedException {
}

/**
* A flag to maintain change in the state
* A flag to maintain change in the state.
*
* @param nextState the target state
* @return Flag that the state is changed or not
Expand All @@ -155,15 +191,16 @@ private boolean changeState(State nextState) {
if (this.state != nextState) {
this.state = nextState;
return true;
} else
} else {
return false;
}
}

/**
* Switch the output ON.
*
* @throws OpenemsNamedException
* @throws IllegalArgumentException
* @throws OpenemsNamedException on error
* @throws IllegalArgumentException on error
*/
private void on() throws IllegalArgumentException, OpenemsNamedException {
this.setOutput(true);
Expand All @@ -172,8 +209,8 @@ private void on() throws IllegalArgumentException, OpenemsNamedException {
/**
* Switch the output OFF.
*
* @throws OpenemsNamedException
* @throws IllegalArgumentException
* @throws OpenemsNamedException on error
* @throws IllegalArgumentException on error
*/
private void off() throws IllegalArgumentException, OpenemsNamedException {
this.setOutput(false);
Expand All @@ -198,4 +235,19 @@ private void setOutput(Boolean value) throws IllegalArgumentException, OpenemsNa
this.logError(this.log, "Unable to set output: [" + this.outputChannelAddress + "] " + e.getMessage());
}
}

/**
* A flag to maintain change in the mode.
*
* @param nextMode the target mode
* @return Flag that the mode is changed or not
*/
private boolean changeMode(Mode nextMode) {
if (this.mode != nextMode) {
this.mode = nextMode;
return true;
} else {
return false;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package io.openems.edge.controller.chp.soc;

import io.openems.common.types.OptionsEnum;

public enum Mode implements OptionsEnum {
MANUAL_ON(0, "Manual control for the ON signal"), //
MANUAL_OFF(1, "Manual control for the OFF signal"), //
AUTOMATIC(2, "Automatic control"); //

private final int value;
private final String name;

private Mode(int value, String name) {
this.value = value;
this.name = name;
}

@Override
public int getValue() {
return value;
}

@Override
public String getName() {
return name;
}

@Override
public OptionsEnum getUndefined() {
return AUTOMATIC;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@ private static class MyConfig extends AbstractComponentConfig implements Config
private final String outputChannelAddress;
private final int lowThreshold;
private final int highThreshold;
private final Mode mode;

public MyConfig(String id, String inputChannelAddress, String outputChannelAddress, int lowThreshold,
public MyConfig(String id, Mode mode, String inputChannelAddress, String outputChannelAddress, int lowThreshold,
int highThreshold) {
super(Config.class, id);
this.mode = mode;
this.inputChannelAddress = inputChannelAddress;
this.outputChannelAddress = outputChannelAddress;
this.lowThreshold = lowThreshold;
Expand All @@ -49,6 +51,11 @@ public int lowThreshold() {
public int highThreshold() {
return this.highThreshold;
}

@Override
public Mode mode() {
return this.mode;
}
}

@Test
Expand All @@ -62,12 +69,13 @@ public void test() throws Exception {
ChannelAddress ess0 = new ChannelAddress("ess0", "Soc");
ChannelAddress output0 = new ChannelAddress("io0", "InputOutput0");

MyConfig myconfig = new MyConfig("ctrl1", ess0.toString(), output0.toString(), 15, 85);
MyConfig myconfig = new MyConfig("ctrl1", Mode.AUTOMATIC, ess0.toString(), output0.toString(), 15, 85);
controller.activate(null, myconfig);
controller.activate(null, myconfig);

ManagedSymmetricEss ess = new DummyManagedSymmetricEss("ess0");
DummyInputOutput io = new DummyInputOutput("io0");

// Build and run test
new ControllerTest(controller, componentManager, ess, io).next(new TestCase() //
.input(ess0, 14) //
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit c259000

Please sign in to comment.