Package io.openems.edge.common.channel
Class ChannelUtils
java.lang.Object
io.openems.edge.common.channel.ChannelUtils
-
Method Summary
Modifier and TypeMethodDescriptiongetValues
(OpenemsComponent component, Class<T> clazz) static <T extends Record>
TgetValuesOrError
(OpenemsComponent component, Class<T> clazz) static void
setWriteValueIfNotRead
(BooleanWriteChannel channel, Boolean value) Set write value of aBooleanWriteChannel
if the read value is not equal.static void
setWriteValueIfNotRead
(EnumWriteChannel channel, OptionsEnum value) Set write value of aEnumWriteChannel
if the read value is not equal.static void
setWriteValueIfNotRead
(IntegerWriteChannel channel, Integer value) Set write value of aIntegerWriteChannel
if the read value is not equal.
-
Method Details
-
getValuesOrError
public static <T extends Record> T getValuesOrError(OpenemsComponent component, Class<T> clazz) throws OpenemsException - Type Parameters:
T
- the type of theRecord
. The names of the Members of the Record must match the Channel-Ids of the Component- Parameters:
component
- theOpenemsComponent
clazz
- the Class of theRecord
- Returns:
- an object of type T
- Throws:
OpenemsException
- if at least one Value is not available
-
getValues
- Type Parameters:
T
- the type of theRecord
. The names of the Members of the Record must match the Channel-Ids of the Component- Parameters:
component
- theOpenemsComponent
clazz
- the Class of theRecord
- Returns:
- an Optional object of type T
-
setWriteValueIfNotRead
public static void setWriteValueIfNotRead(EnumWriteChannel channel, OptionsEnum value) throws OpenemsError.OpenemsNamedException Set write value of aEnumWriteChannel
if the read value is not equal.Use this method if you do not want to write a Channel on every cycle, but only if the Write-Values differs from the current Read-Value.
- Parameters:
channel
- theEnumWriteChannel
value
- value to be set- Throws:
OpenemsError.OpenemsNamedException
- on error
-
setWriteValueIfNotRead
public static void setWriteValueIfNotRead(IntegerWriteChannel channel, Integer value) throws OpenemsError.OpenemsNamedException Set write value of aIntegerWriteChannel
if the read value is not equal.Use this method if you do not want to write a Channel on every cycle, but only if the Write-Values differs from the current Read-Value.
- Parameters:
channel
- theIntegerWriteChannel
value
- value to be set- Throws:
OpenemsError.OpenemsNamedException
- on error
-
setWriteValueIfNotRead
public static void setWriteValueIfNotRead(BooleanWriteChannel channel, Boolean value) throws OpenemsError.OpenemsNamedException Set write value of aBooleanWriteChannel
if the read value is not equal.Use this method if you do not want to write a Channel on every cycle, but only if the Write-Values differs from the current Read-Value.
- Parameters:
channel
- theBooleanWriteChannel
value
- value to be set- Throws:
OpenemsError.OpenemsNamedException
- on error
-