Skip to content

Commit

Permalink
FEMS Backports 2024-10 (2) (#2846)
Browse files Browse the repository at this point in the history
- EVCS HardyBarth: communicate via HTTP-Bridge
  - Implemented BridgeHttp in Impl of HardyBarthEvcs
  - All Api Calls now flow through that Bridge
  - Api Calls (esp. setHeartBeat that previously was synchronous) are now asynchronous
  - Add JUnit tests

- EVCS: implement ElectricityMeter
  - Migrate all EVCS to ElectricityMeter Nature
  - Add `DeprecatedEvcs` Nature to mark EVCS that have to be migrated and still support old Channels ChargePower and ActiveConsumptionEnergy
  - Implement generic `evaluatePhaseCount()` method
  - UI:  Mix Evcs & ElectricityMeter (live != history)
    - Live: use ElectricityMeter if its already available (e.g. for power of individual phases)
    - History: use Evcs to ensure availability of historic data
  - Implement configurable PhaseRotation in configuration and Apps (copied and adjusted from #2047)
  - Fix AbstractManagedEvcs deactivate()

- UI: Performance improvements
  - Navigation for users with at most Role `OWNER` with one fems assigned, get directly routed to `device/edgeId/live`
  - Navigation for users with at least Role  `INSTALLER` -> `/overview`
  - Removed flickering of headerComponent. Issue results from creating header component for each view

- Sum: do not ignore ExtremeEverValues in EdgeConfig

- Update gradle to 8.10.2
  - https://github.com/gradle/gradle/releases/tag/v8.10.2

- UI: Refactor heating element history
  - Refactoring HeatingElement and using the new ```Cumulated[Level 1 -3]ActiveTime```

- UI: Adjust Chart-axis generation
  - Multiple yAxis: Increase chart canvas by putting y axis labels into ticks, the most upper tick gets replaced by axis title

- Extend export to Excel file
  - Added detailed data for the excel export of historic data

- UI: fix header in history charts and add enable rescaling in history charts
  - Rescaling of charts was not possible due to not ignoring hidden values
  - Header was shown in the chart views
  - Introduce `<app-header>` and keep `<header>` as single navigation point header

- Java JUnit tests: improve framework + cleanup
  - Improve OpenEMS JUnit test framework
  - Apply best practices to JUnit tests

---------

Co-authored-by: Lukas Rieger <[email protected]>
Co-authored-by: Sebastian Asen <[email protected]>
Co-authored-by: Stefan Feilmeier <[email protected]>
Co-authored-by: Johann Kaufmann <[email protected]>
  • Loading branch information
5 people authored Oct 18, 2024
1 parent 1b18fa0 commit 0b2071c
Show file tree
Hide file tree
Showing 399 changed files with 8,998 additions and 9,086 deletions.
2 changes: 1 addition & 1 deletion .gradle-wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@
import static io.openems.common.utils.JsonUtils.getAsString;
import static java.util.Collections.emptyMap;

import java.io.IOException;
import java.time.temporal.ChronoUnit;
import java.util.Collections;
import java.util.Map;
import java.util.Optional;
import java.util.TreeSet;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;

Expand All @@ -15,6 +19,7 @@
import io.openems.backend.common.metadata.User;
import io.openems.common.exceptions.OpenemsError;
import io.openems.common.exceptions.OpenemsError.OpenemsNamedException;
import io.openems.common.exceptions.OpenemsException;
import io.openems.common.jsonrpc.base.JsonrpcResponseSuccess;
import io.openems.common.jsonrpc.request.AppCenterRequest;
import io.openems.common.jsonrpc.request.ComponentJsonApiRequest;
Expand All @@ -29,7 +34,13 @@
import io.openems.common.jsonrpc.response.QueryHistoricTimeseriesDataResponse;
import io.openems.common.jsonrpc.response.QueryHistoricTimeseriesEnergyPerPeriodResponse;
import io.openems.common.jsonrpc.response.QueryHistoricTimeseriesEnergyResponse;
import io.openems.common.jsonrpc.response.QueryHistoricTimeseriesExportXlsxResponse;
import io.openems.common.session.Language;
import io.openems.common.session.Role;
import io.openems.common.timedata.Resolution;
import io.openems.common.timedata.XlsxExportDetailData.XlsxExportDataEntry.HistoricTimedataSaveType;
import io.openems.common.timedata.XlsxExportUtil;
import io.openems.common.types.ChannelAddress;

public class EdgeRpcRequestHandler {

Expand Down Expand Up @@ -265,8 +276,38 @@ private CompletableFuture<JsonrpcResponseSuccess> handleQueryHistoricEnergyPerPe
*/
private CompletableFuture<JsonrpcResponseSuccess> handleQueryHistoricTimeseriesExportXlxsRequest(String edgeId,
User user, QueryHistoricTimeseriesExportXlxsRequest request) throws OpenemsNamedException {
return CompletableFuture.completedFuture(this.parent.timedataManager
.handleQueryHistoricTimeseriesExportXlxsRequest(edgeId, request, user.getLanguage()));
return CompletableFuture.completedFuture(
this.handleQueryHistoricTimeseriesExportXlxsRequest(edgeId, request, user.getLanguage()));
}

private QueryHistoricTimeseriesExportXlsxResponse handleQueryHistoricTimeseriesExportXlxsRequest(String edgeId,
QueryHistoricTimeseriesExportXlxsRequest request, Language language) throws OpenemsNamedException {
final var powerChannels = new TreeSet<ChannelAddress>(QueryHistoricTimeseriesExportXlsxResponse.POWER_CHANNELS);
final var energyChannels = new TreeSet<ChannelAddress>(
QueryHistoricTimeseriesExportXlsxResponse.ENERGY_CHANNELS);

final var edge = this.parent.metadata.edge().getEdgeConfig(edgeId);

final var detailData = XlsxExportUtil.getDetailData(edge);
final var channelsByType = detailData.getChannelsBySaveType();
powerChannels.addAll(channelsByType.getOrDefault(HistoricTimedataSaveType.POWER, Collections.emptyList()));
energyChannels.addAll(channelsByType.getOrDefault(HistoricTimedataSaveType.ENERGY, Collections.emptyList()));

var powerData = this.parent.timedataManager.queryHistoricData(edgeId, request.getFromDate(),
request.getToDate(), powerChannels, new Resolution(15, ChronoUnit.MINUTES));

var energyData = this.parent.timedataManager.queryHistoricEnergy(edgeId, request.getFromDate(),
request.getToDate(), energyChannels);
if (powerData == null || energyData == null) {
return null;
}
try {
return new QueryHistoricTimeseriesExportXlsxResponse(request.getId(), edgeId, request.getFromDate(),
request.getToDate(), powerData, energyData, language, detailData);

} catch (IOException e) {
throw new OpenemsException("QueryHistoricTimeseriesExportXlxsRequest failed: " + e.getMessage());
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,14 @@

public class MyControllerTest {

private static final String CTRL_ID = "ctrl0";

@Test
public void test() throws Exception {
new ControllerTest(new MyControllerImpl()) //
.activate(MyConfig.create() //
.setId(CTRL_ID) //
.build())
.next(new TestCase());
.setId("ctrl0") //
.build()) //
.next(new TestCase()) //
.deactivate();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,17 @@

public class MyModbusDeviceTest {

private static final String COMPONENT_ID = "component0";
private static final String MODBUS_ID = "modbus0";

@Test
public void test() throws Exception {
new ComponentTest(new MyModbusDeviceImpl()) //
.addReference("cm", new DummyConfigurationAdmin()) //
.addReference("setModbus", new DummyModbusBridge(MODBUS_ID)) //
.addReference("setModbus", new DummyModbusBridge("modbus0")) //
.activate(MyConfig.create() //
.setId(COMPONENT_ID) //
.setModbusId(MODBUS_ID) //
.build())
.next(new TestCase());
.setId("component0") //
.setModbusId("modbus0") //
.build()) //
.next(new TestCase()) //
.deactivate();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,14 @@

public class MyDeviceTest {

private static final String COMPONENT_ID = "component0";

@Test
public void test() throws Exception {
new ComponentTest(new MyDeviceImpl()) //
.activate(MyConfig.create() //
.setId(COMPONENT_ID) //
.build())
.next(new TestCase());
.setId("component0") //
.build()) //
.next(new TestCase()) //
.deactivate();
}

}
Loading

0 comments on commit 0b2071c

Please sign in to comment.