forked from OpenEMS/openems
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Export Channels to Excel (OpenEMS#1526)
Adds a link in UI Profile to download an Excel file with all Channels and their current value. Also adds information about the 'source' of a Channel, e.g. the modbus register address.
- Loading branch information
1 parent
16bef31
commit d311364
Showing
15 changed files
with
550 additions
and
141 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
io.openems.edge.bridge.modbus/src/io/openems/edge/bridge/modbus/api/ModbusChannelSource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package io.openems.edge.bridge.modbus.api; | ||
|
||
public class ModbusChannelSource { | ||
|
||
/** | ||
* Holds the Start-Address of the Modbus Register. | ||
*/ | ||
private final int address; | ||
|
||
/** | ||
* Holds the index of the bit inside the Register if applicable. | ||
*/ | ||
private final int bit; | ||
|
||
public ModbusChannelSource(int address) { | ||
this.address = address; | ||
this.bit = -1; | ||
} | ||
|
||
public ModbusChannelSource(int address, int bit) { | ||
this.address = address; | ||
this.bit = bit; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
StringBuilder b = new StringBuilder(); | ||
b.append("0x").append(Integer.toHexString(this.address)); | ||
if (this.bit >= 0) { | ||
b.append("|bit").append(String.format("%02d", this.bit)); | ||
} | ||
return b.toString(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
...edge.core/src/io/openems/edge/core/componentmanager/jsonrpc/ChannelExportXlsxRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package io.openems.edge.core.componentmanager.jsonrpc; | ||
|
||
import com.google.gson.JsonObject; | ||
|
||
import io.openems.common.exceptions.OpenemsError.OpenemsNamedException; | ||
import io.openems.common.jsonrpc.base.JsonrpcRequest; | ||
import io.openems.common.utils.JsonUtils; | ||
|
||
/** | ||
* Exports Channels with current value and metadata to an Excel (xlsx) file. | ||
* | ||
* <pre> | ||
* { | ||
* "jsonrpc": "2.0", | ||
* "id": "UUID", | ||
* "method": "channelExportXlsx", | ||
* "params": { | ||
* "componentId": string | ||
* } | ||
* } | ||
* </pre> | ||
*/ | ||
public class ChannelExportXlsxRequest extends JsonrpcRequest { | ||
|
||
public static final String METHOD = "channelExportXlsx"; | ||
|
||
/** | ||
* Create {@link ChannelExportXlsxRequest} from a template | ||
* {@link JsonrpcRequest}. | ||
* | ||
* @param r the template {@link JsonrpcRequest} | ||
* @return the {@link ChannelExportXlsxRequest} | ||
* @throws OpenemsNamedException on parse error | ||
*/ | ||
public static ChannelExportXlsxRequest from(JsonrpcRequest r) throws OpenemsNamedException { | ||
JsonObject p = r.getParams(); | ||
String componentId = JsonUtils.getAsString(p, "componentId"); | ||
return new ChannelExportXlsxRequest(r, componentId); | ||
} | ||
|
||
private final String componentId; | ||
|
||
public ChannelExportXlsxRequest(String componentId) { | ||
super(METHOD); | ||
this.componentId = componentId; | ||
} | ||
|
||
private ChannelExportXlsxRequest(JsonrpcRequest request, String componentId) { | ||
super(request, METHOD); | ||
this.componentId = componentId; | ||
} | ||
|
||
@Override | ||
public JsonObject getParams() { | ||
return JsonUtils.buildJsonObject() // | ||
.addProperty("componentId", this.componentId) // | ||
.build(); | ||
} | ||
|
||
/** | ||
* Gets the Component-ID. | ||
* | ||
* @return Component-ID | ||
*/ | ||
public String getComponentId() { | ||
return this.componentId; | ||
} | ||
|
||
} |
Oops, something went wrong.