Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implementation of grid CO2 traffic light component #2793

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions io.openems.edge.greenconsumptionadvisor.api/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="aQute.bnd.classpath.container"/>
<classpathentry kind="src" output="bin" path="src"/>
<classpathentry kind="src" output="bin_test" path="test">
<attributes>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="bin"/>
</classpath>
1 change: 1 addition & 0 deletions io.openems.edge.greenconsumptionadvisor.api/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/bin_test/
29 changes: 29 additions & 0 deletions io.openems.edge.greenconsumptionadvisor.api/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>io.openems.edge.greenconsumptionadvisor.api</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>bndtools.core.bndbuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>net.sf.eclipsecs.core.CheckstyleBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>bndtools.core.bndnature</nature>
<nature>net.sf.eclipsecs.core.CheckstyleNature</nature>
</natures>
</projectDescription>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
eclipse.preferences.version=1
encoding//src/io/openems/edge/greenconsumptionadvisor/api/GreenConsumptionAdvisor.java=UTF-8
encoding//src/io/openems/edge/greenconsumptionadvisor/api/package-info.java=UTF-8
encoding/bnd.bnd=UTF-8
encoding/readme.adoc=UTF-8
13 changes: 13 additions & 0 deletions io.openems.edge.greenconsumptionadvisor.api/bnd.bnd
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Bundle-Name: OpenEMS Edge io.openems.edge.greenconsumptionadvisor.api Api
Bundle-Vendor: OpenEMS Association e.V.
Bundle-License: https://opensource.org/licenses/EPL-2.0
Bundle-Version: 1.0.0.${tstamp}

-buildpath: \
${buildpath},\
io.openems.common,\
io.openems.edge.common,\
io.openems.edge.controller.api

-testpath: \
${testpath}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
C:/Users/xs9796/Documents/_public_openems/openems/io.openems.edge.greenconsumptionadvisor.api/generated/io.openems.edge.greenconsumptionadvisor.api.jar
3 changes: 3 additions & 0 deletions io.openems.edge.greenconsumptionadvisor.api/readme.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
= io.openems.edge.greenconsumptionadvisor.api

https://github.com/OpenEMS/openems/tree/develop/io.openems.edge.greenconsumptionadvisor.api[Source Code icon:github[]]
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package io.openems.edge.greenconsumptionadvisor.api;

import org.osgi.service.metatype.annotations.AttributeDefinition;
import org.osgi.service.metatype.annotations.ObjectClassDefinition;

@ObjectClassDefinition(//
name = "Green Consumption Advice API", //
description = "Provides a recomendation whether to use power from the grid or not based on current associated CO2 emissions per kWh.")
@interface Config {

@AttributeDefinition(name = "Component-ID", description = "Unique ID of this Component")
String id() default "greenConsumptionAdvisor0";

@AttributeDefinition(name = "Alias", description = "Human-readable name of this Component; defaults to Component-ID")
String alias() default "";

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

@AttributeDefinition(name = "Zip-Code", description = "Zip-Code of the system location (Only works for Germany).")
String zip_code();

String webconsole_configurationFactory_nameHint() default "Green Consumption Advice API [{id}]";

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package io.openems.edge.greenconsumptionadvisor.api;

import io.openems.common.types.OptionsEnum;

public enum ConsumptionAdvice implements OptionsEnum {
UNDEFINED(-1, "Undefined"), //
GREEN(0, "Grid consumption recommended"), //
YELLOW(1, "Reduce grid consumption"), //
RED(2, "Avoid grid consumption");

private final int value;
private final String name;

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

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

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

@Override
public OptionsEnum getUndefined() {
return UNDEFINED;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
package io.openems.edge.greenconsumptionadvisor.api;

import org.osgi.annotation.versioning.ProviderType;

import io.openems.common.channel.AccessMode;
import io.openems.common.channel.PersistencePriority;
import io.openems.common.types.OpenemsType;
import io.openems.edge.common.channel.Channel;
import io.openems.edge.common.channel.Doc;
import io.openems.edge.common.channel.value.Value;
import io.openems.edge.common.component.OpenemsComponent;

@ProviderType
public interface GreenConsumptionAdvisor extends OpenemsComponent {

public enum ChannelId implements io.openems.edge.common.channel.ChannelId {

/**
* Consumption Advice.
*
* <p>
* Consumption Advice based on the associated CO2 emissions per kWh taken from the grid.
*/
CONSUMPTION_ADVICE(Doc.of(ConsumptionAdvice.values()) //
.accessMode(AccessMode.READ_ONLY) //
.persistencePriority(PersistencePriority.HIGH)),

/**
* CO2-Emissions per kWh taken from the grid.
*
* <p>
* Associated CO2 emissions per kWh taken from the grid.
*/
CO2_EMISSIONS_GRAM_PER_KILOWATTHOUR(Doc.of(OpenemsType.INTEGER) //
.accessMode(AccessMode.READ_ONLY) //
.persistencePriority(PersistencePriority.HIGH));

private final Doc doc;

private ChannelId(Doc doc) {
this.doc = doc;
}

@Override
public Doc doc() {
return this.doc;
}
}

/**
* Gets the Channel for {@link ChannelId#CONSUMPTION_ADVICE}.
*
* @return the Channel
*/
public default Channel<ConsumptionAdvice> getConsumptionAdviceChannel() {
return this.channel(ChannelId.CONSUMPTION_ADVICE);
}

/**
* Gets the current consumption advice. See {@link ChannelId#CONSUMPTION_ADVICE}.
*
* @return the Channel {@link Value}
*/
public default ConsumptionAdvice getConsumptionAdvice() {
return this.getConsumptionAdviceChannel().value().asEnum();
}

/**
* Internal method to set the 'nextValue' on {@link ChannelId#CONSUMPTION_ADVICE} Channel.
*
* @param value the next value
*/
public default void _setConsumptionAdvice(ConsumptionAdvice value) {
this.getConsumptionAdviceChannel().setNextValue(value);
}

/**
* Gets the Channel for {@link ChannelId#CO2_EMISSIONS_GRAM_PER_KILOWATTHOUR}.
*
* @return the Channel
*/
public default Channel<Integer> getCo2EmissionsPerKilowatthourChannel() {
return this.channel(ChannelId.CO2_EMISSIONS_GRAM_PER_KILOWATTHOUR);
}

/**
* Gets the current conumption advice. See {@link ChannelId#CO2_EMISSIONS_GRAM_PER_KILOWATTHOUR}.
*
* @return the Channel {@link Value}
*/
public default Value<Integer> getCo2EmissionsPerKilowatthour() {
return this.getCo2EmissionsPerKilowatthourChannel().value();
}

/**
* Internal method to set the 'nextValue' on {@link ChannelId#CO2_EMISSIONS_GRAM_PER_KILOWATTHOUR} Channel.
*
* @param value the next value
*/
public default void _setCo2EmissionsPerKilowatthour(int value) {
this.getCo2EmissionsPerKilowatthourChannel().setNextValue(value);
}
}
Loading