Package io.openems.common.types
Class EdgeConfig.Component
java.lang.Object
io.openems.common.types.EdgeConfig.Component
- Enclosing class:
- EdgeConfig
Represents an instance of an OpenEMS Component.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Represents a Channel of an OpenEMS Component.static enum
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionConstructor with NO_SERVICE_PID, properties as JsonObject and no channels.Component
(String servicePid, String id, String alias, String factoryId, SortedMap<String, com.google.gson.JsonElement> properties, SortedMap<String, EdgeConfig.Component.Channel> channels) Component
(String id, String alias, String factoryId, SortedMap<String, com.google.gson.JsonElement> properties, SortedMap<String, EdgeConfig.Component.Channel> channels) Constructor with NO_SERVICE_PID. -
Method Summary
Modifier and TypeMethodDescriptionstatic EdgeConfig.Component
Creates a Component from JSON.getAlias()
Gets the Alias of theEdgeConfig.Component
.Gets a map ofEdgeConfig.Component.Channel
s of theEdgeConfig.Component
.getChannelsOfCategory
(ChannelCategory channelCategory) Gets the Channels of the givenChannelCategory
.Gets the Factory-ID of theEdgeConfig.Component
, e.g.getId()
Gets the ID of theEdgeConfig.Component
, e.g.getPid()
Gets the PID of theEdgeConfig.Component
.Gets the Properties of theEdgeConfig.Component
.Optional<com.google.gson.JsonElement>
getProperty
(String propertyId) Gets the Property with the given ID.com.google.gson.JsonElement
getPropertyOrError
(String propertyId) Gets the Property with the given ID or throws an Exception if it does not exist.getStateChannel
(String channelId) Get the StateChannel with the given Channel-ID.Gets the StateChannels.boolean
isStateChannel
(String channelId) Is the given Channel-ID a StateChannel?.void
setChannels
(Map<String, EdgeConfig.Component.Channel> channels) com.google.gson.JsonObject
toJson
(EdgeConfig.Component.JsonFormat jsonFormat) Returns the Component configuration as a JSON Object.
-
Field Details
-
NO_SERVICE_PID
- See Also:
-
-
Constructor Details
-
Component
-
Component
public Component(String id, String alias, String factoryId, SortedMap<String, com.google.gson.JsonElement> properties, SortedMap<String, EdgeConfig.Component.Channel> channels) Constructor with NO_SERVICE_PID.- Parameters:
id
- the Component-IDalias
- the AliasfactoryId
- the Factory-IDproperties
- the configuration propertieschannels
- the channels
-
Component
Constructor with NO_SERVICE_PID, properties as JsonObject and no channels.- Parameters:
id
- the Component-IDalias
- the AliasfactoryId
- the Factory-IDproperties
- the configuration properties
-
-
Method Details
-
getPid
Gets the PID of theEdgeConfig.Component
.- Returns:
- the PID
-
getId
Gets the ID of theEdgeConfig.Component
, e.g. 'ctrlDebugLog0'.- Returns:
- the Component-ID
-
getAlias
Gets the Alias of theEdgeConfig.Component
.- Returns:
- the Alias
-
getFactoryId
Gets the Factory-ID of theEdgeConfig.Component
, e.g. 'Controller.Debug.Log'.- Returns:
- the Factory-ID
-
getProperties
Gets the Properties of theEdgeConfig.Component
.- Returns:
- the Properties
-
getProperty
Gets the Property with the given ID.- Parameters:
propertyId
- the Property-ID- Returns:
- the Property as
Optional
-
getPropertyOrError
public com.google.gson.JsonElement getPropertyOrError(String propertyId) throws InvalidValueException Gets the Property with the given ID or throws an Exception if it does not exist.- Parameters:
propertyId
- the Property-ID- Returns:
- the Property
- Throws:
InvalidValueException
-
getChannels
Gets a map ofEdgeConfig.Component.Channel
s of theEdgeConfig.Component
.- Returns:
- the map of
EdgeConfig.Component.Channel
s by their Channel-IDs.
-
setChannels
-
getChannelsOfCategory
public Map<String,EdgeConfig.Component.Channel> getChannelsOfCategory(ChannelCategory channelCategory) Gets the Channels of the givenChannelCategory
.- Parameters:
channelCategory
- theChannelCategory
- Returns:
- a map of
EdgeConfig.Component.Channel
s
-
getStateChannels
Gets the StateChannels.- Returns:
- the StateChannels
-
isStateChannel
Is the given Channel-ID a StateChannel?.- Parameters:
channelId
- the Channel-ID- Returns:
- true if it is a StateChannel
-
getStateChannel
Get the StateChannel with the given Channel-ID.- Parameters:
channelId
- the Channel-ID- Returns:
- the Channel; or empty if the Channel does not exist or is not a StateChannel.
-
toJson
Returns the Component configuration as a JSON Object.{ alias: string, factoryId: string, properties: { [key: string]: value }, channels: { [channelId: string]: {} } }
- Parameters:
jsonFormat
- theEdgeConfig.Component.JsonFormat
- Returns:
- configuration as a JSON Object
-
fromJson
public static EdgeConfig.Component fromJson(String componentId, com.google.gson.JsonElement json) throws OpenemsError.OpenemsNamedException Creates a Component from JSON.- Parameters:
componentId
- the Component-IDjson
- the JSON- Returns:
- the Component
- Throws:
OpenemsError.OpenemsNamedException
- on error
-