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

feature/rev-pi-bsp #2203

Open
wants to merge 1 commit 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
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
/bin/
/bin_test/
/generated/
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>io.openems.edge.io.revpi</name>
<name>io.openems.edge.io.revpi.bsp</name>
<comment></comment>
<projects>
</projects>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Bundle-Name: OpenEMS Edge RevolutionPi Data IO module
Bundle-Name: RevolutionPi board support package
Bundle-Vendor: opernikus GmbH
Bundle-License: https://opensource.org/licenses/EPL-2.0
Bundle-Version: 1.0.0.${tstamp}
Expand All @@ -16,3 +16,4 @@ Bundle-Version: 1.0.0.${tstamp}

-testpath: \
${testpath}

40 changes: 40 additions & 0 deletions io.openems.edge.io.revpi.bsp/readme.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
= RevolutionPi Board Support Package

This bundle provides board support package for Kunbus RevolutionPI Connect Plus and Connect S.
It also provides support to the digital IO enhancement boards.


== Compatibility

** Kunbus Connect Plus, access to
*** hardware watchdog
*** Leds A1, A2, A3
*** integrated relais (Default Channel: `bsp0/OnBoardRelais`)
** Kunbus Connect S, access to
*** hardware watchdog
*** Leds A1, A2, A3
*** integrated relais (Default Channel: `bsp0/OnBoardRelais`)
** Kunbus Enhancement Board
*** Digital Input/Output, access to
**** 14 Digital Inputs (Default Channels: `io0/In1 - io0/In14`)
**** 14 Digital Outputs (Default Channels: `io0/Out1 - io0/Out14`)
*** Digital Input, access to
**** 16 Digital Inputs




== Additional application notes
=== Configuration
Kunbus has an internal configuration website, where one can map an 'alias name' to each pin of multiple enhancement boards.
You need to provide this 'alias name' in OpenEMS to get access to the hardware pin.

=== Dependencies
* The RevolutionPi Digital IO OpenEms Bundle depends on the library project `librevpi-dio-java`. A binary version of this library is already included in this OpenEMS Bundle. See https://github.com/clehne/librevpi-dio-java for more information.
* External library was compiled with Java 17 (probably not backwards compatible)

== Code Quality
Production State: *pilot projects*

Development State:
-
Original file line number Diff line number Diff line change
@@ -0,0 +1,199 @@
package io.openems.edge.io.revpi.bsp.core;

import java.time.Duration;
import java.time.Instant;
import java.util.Optional;

import io.openems.common.channel.AccessMode;
import io.openems.common.channel.PersistencePriority;
import io.openems.common.channel.Unit;
import io.openems.common.types.OpenemsType;
import io.openems.edge.common.channel.BooleanDoc;
import io.openems.edge.common.channel.BooleanReadChannel;
import io.openems.edge.common.channel.BooleanWriteChannel;
import io.openems.edge.common.channel.Doc;
import io.openems.edge.common.channel.EnumReadChannel;
import io.openems.edge.common.channel.value.Value;
import io.openems.edge.common.component.OpenemsComponent;
import io.openems.edge.io.api.DigitalInput;
import io.openems.edge.io.api.DigitalOutput;

public interface BoardSupportPackage extends DigitalOutput, DigitalInput, OpenemsComponent {
public enum ChannelId implements io.openems.edge.common.channel.ChannelId {

/**
* Time openems is running in min.
*/
UPTIME(Doc.of(OpenemsType.INTEGER) //
.unit(Unit.MINUTE) //
.persistencePriority(PersistencePriority.HIGH) //

),
/**
* Hardware dependent status LED of the edge, used for showing the general
* OpenEMS state.
*
* @note hardware may not have such an LED. Channel is ignored in that case.
*/
STATUS_LED_EDGE(Doc.of(LedState.values()) //
.persistencePriority(PersistencePriority.MEDIUM) //
),

/**
* Hardware dependent status LED, used for showing the OpenEMS backend
* connection state.
*
* @note hardware may not have such an LED. Channel is ignored in that case.
*/
STATUS_LED_BACKEND(Doc.of(LedState.values()) //
.persistencePriority(PersistencePriority.MEDIUM) //
), //
/**
* hardware dependent status LED (reserve).
*
* @note hardware may not have such an LED. Channel is ignored in that case.
*/
STATUS_LED3(Doc.of(LedState.values()) //

), //
/**
* Digital Output or Relais output 1.
*
* <ul>
* <li>Type: Boolean
* <li>Range: On/Off
* </ul>
*/
DIGITAL_OUT1(new BooleanDoc() //
.unit(Unit.ON_OFF) //
.accessMode(AccessMode.READ_WRITE) //
.persistencePriority(PersistencePriority.MEDIUM) //
), //
/**
* Digital Output or Relais output 1.
*
* <ul>
* <li>Type: Boolean
* <li>Range: On/Off
* </ul>
*/
DIGITAL_IN1(new BooleanDoc() //
.unit(Unit.ON_OFF) //
.persistencePriority(PersistencePriority.MEDIUM) //
), //
/**
* Digital Output or Relais output 1.
*
* <ul>
* <li>Type: Boolean
* <li>Range: On/Off
* </ul>
*/
DIGITAL_IN2(new BooleanDoc() //
.unit(Unit.ON_OFF) //
.persistencePriority(PersistencePriority.MEDIUM) //
), //
/**
* Digital Output or Relais output 1.
*
* <ul>
* <li>Type: Boolean
* <li>Range: On/Off
* </ul>
*/
DIGITAL_IN3(new BooleanDoc() //
.unit(Unit.ON_OFF) //
.persistencePriority(PersistencePriority.MEDIUM) //
), //
/**
* Digital Output or Relais output 1.
*
* <ul>
* <li>Type: Boolean
* <li>Range: On/Off
* </ul>
*/
DIGITAL_IN4(new BooleanDoc() //
.unit(Unit.ON_OFF) //
.persistencePriority(PersistencePriority.MEDIUM) //
), //

;

private final Doc doc;

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

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

/**
* Increments Uptime.
*
* @param systemStartTime an instant holding the time OpenEMS was started.
*/
public default void updateUptime(Instant systemStartTime) {
var uptime = (int) Duration.between(systemStartTime, Instant.now()).toMinutes();
this.channel(ChannelId.UPTIME).setNextValue(uptime);
}

public default EnumReadChannel getStatusLedEdgeChannel() {
return this.<EnumReadChannel>channel(ChannelId.STATUS_LED_EDGE);
}

public default Value<LedState> getStatusLedEdgeValue() {
return this.getStatusLedEdgeChannel().value().asEnum();
}

public default void setStatusLedEdgeValue(LedState value) {
this.getStatusLedEdgeChannel().setNextValue(value);
}

public default EnumReadChannel getStatusLedBackendChannel() {
return this.<EnumReadChannel>channel(ChannelId.STATUS_LED_BACKEND);
}

public default Value<LedState> getStatusLedBackendValue() {
return this.getStatusLedBackendChannel().value().asEnum();
}

public default void setStatusLedBackendValue(LedState value) {
this.getStatusLedBackendChannel().setNextValue(value);
}

public default BooleanWriteChannel getDigitalOut1WriteChannel() {
return this.<BooleanWriteChannel>channel(ChannelId.DIGITAL_OUT1);
}

public default Optional<Boolean> getDigitalOut1WriteValue() {
return this.getDigitalOut1WriteChannel().value().asOptional();
}

public default Optional<Boolean> getDigitalOut1WriteValueAndReset() {
return this.getDigitalOut1WriteChannel().getNextWriteValueAndReset();
}

public default void setDigitalOut1Value(Boolean value) {
this.<BooleanWriteChannel>channel(ChannelId.DIGITAL_OUT1).setNextValue(value);
}

public default BooleanReadChannel getDigitalIn1Channel() {
return this.<BooleanReadChannel>channel(ChannelId.DIGITAL_IN1);
}

public default BooleanReadChannel getDigitalIn2Channel() {
return this.<BooleanReadChannel>channel(ChannelId.DIGITAL_IN2);
}

public default BooleanReadChannel getDigitalIn3Channel() {
return this.<BooleanReadChannel>channel(ChannelId.DIGITAL_IN3);
}

public default BooleanReadChannel getDigitalIn4Channel() {
return this.<BooleanReadChannel>channel(ChannelId.DIGITAL_IN4);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package io.openems.edge.io.revpi.bsp.core;

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

@ObjectClassDefinition(//
name = "IO RevolutionPi BSP Core", //
description = "Implements the Kunbus RevPi on board LEDs and the Relais")
@interface Config {

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

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

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

@AttributeDefinition(name = "Backend Component-ID", description = "Component-ID of the backend to surveillance and use for LED color")
String backendComponentId() default "ctrlBackend0";

String webconsole_configurationFactory_nameHint() default "IO RevolutionPi BSP Core[{id}]";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package io.openems.edge.io.revpi.bsp.core;

import java.io.IOException;
import io.openems.edge.common.channel.Doc;
import io.openems.edge.common.component.OpenemsComponent;

public interface Core extends OpenemsComponent {

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

private final Doc doc;

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

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

}

/**
* Toggles the Hardware watchdog.
* @throws IOException on any error
*/
public void toggleWatchdog() throws IOException;
}
Loading