Package io.openems.common.types
Class EdgeConfig.Component
- java.lang.Object
-
- io.openems.common.types.EdgeConfig.Component
-
- Enclosing class:
- EdgeConfig
public static class EdgeConfig.Component extends java.lang.Object
Represents an instance of an OpenEMS Component.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
EdgeConfig.Component.Channel
Represents a Channel of an OpenEMS Component.static class
EdgeConfig.Component.JsonFormat
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
NO_SERVICE_PID
-
Constructor Summary
Constructors Constructor Description Component(java.lang.String id, java.lang.String alias, java.lang.String factoryId, com.google.gson.JsonObject properties)
Constructor with NO_SERVICE_PID, properties as JsonObject and no channels.Component(java.lang.String servicePid, java.lang.String id, java.lang.String alias, java.lang.String factoryId, java.util.SortedMap<java.lang.String,com.google.gson.JsonElement> properties, java.util.SortedMap<java.lang.String,EdgeConfig.Component.Channel> channels)
Component(java.lang.String id, java.lang.String alias, java.lang.String factoryId, java.util.SortedMap<java.lang.String,com.google.gson.JsonElement> properties, java.util.SortedMap<java.lang.String,EdgeConfig.Component.Channel> channels)
Constructor with NO_SERVICE_PID.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static EdgeConfig.Component
fromJson(java.lang.String componentId, com.google.gson.JsonElement json)
Creates a Component from JSON.java.lang.String
getAlias()
Gets the Alias of theEdgeConfig.Component
.java.util.Map<java.lang.String,EdgeConfig.Component.Channel>
getChannels()
Gets a map ofEdgeConfig.Component.Channel
s of theEdgeConfig.Component
.java.util.Map<java.lang.String,EdgeConfig.Component.Channel>
getChannelsOfCategory(ChannelCategory channelCategory)
Gets the Channels of the givenChannelCategory
.java.lang.String
getFactoryId()
Gets the Factory-ID of theEdgeConfig.Component
, e.g.java.lang.String
getId()
Gets the ID of theEdgeConfig.Component
, e.g.java.lang.String
getPid()
Gets the PID of theEdgeConfig.Component
.java.util.Map<java.lang.String,com.google.gson.JsonElement>
getProperties()
Gets the Properties of theEdgeConfig.Component
.java.util.Optional<com.google.gson.JsonElement>
getProperty(java.lang.String propertyId)
Gets the Property with the given ID.com.google.gson.JsonElement
getPropertyOrError(java.lang.String propertyId)
Gets the Property with the given ID or throws an Exception if it does not exist.java.util.Optional<EdgeConfig.Component.Channel>
getStateChannel(java.lang.String channelId)
Get the StateChannel with the given Channel-ID.java.util.Map<java.lang.String,EdgeConfig.Component.Channel>
getStateChannels()
Gets the StateChannels.boolean
isStateChannel(java.lang.String channelId)
Is the given Channel-ID a StateChannel?.void
setChannels(java.util.Map<java.lang.String,EdgeConfig.Component.Channel> channels)
com.google.gson.JsonObject
toJson(EdgeConfig.Component.JsonFormat jsonFormat)
Returns the Component configuration as a JSON Object.
-
-
-
Field Detail
-
NO_SERVICE_PID
public static final java.lang.String NO_SERVICE_PID
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Component
public Component(java.lang.String servicePid, java.lang.String id, java.lang.String alias, java.lang.String factoryId, java.util.SortedMap<java.lang.String,com.google.gson.JsonElement> properties, java.util.SortedMap<java.lang.String,EdgeConfig.Component.Channel> channels)
-
Component
public Component(java.lang.String id, java.lang.String alias, java.lang.String factoryId, java.util.SortedMap<java.lang.String,com.google.gson.JsonElement> properties, java.util.SortedMap<java.lang.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
public Component(java.lang.String id, java.lang.String alias, java.lang.String factoryId, com.google.gson.JsonObject properties)
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 Detail
-
getPid
public java.lang.String getPid()
Gets the PID of theEdgeConfig.Component
.- Returns:
- the PID
-
getId
public java.lang.String getId()
Gets the ID of theEdgeConfig.Component
, e.g. 'ctrlDebugLog0'.- Returns:
- the Component-ID
-
getAlias
public java.lang.String getAlias()
Gets the Alias of theEdgeConfig.Component
.- Returns:
- the Alias
-
getFactoryId
public java.lang.String getFactoryId()
Gets the Factory-ID of theEdgeConfig.Component
, e.g. 'Controller.Debug.Log'.- Returns:
- the Factory-ID
-
getProperties
public java.util.Map<java.lang.String,com.google.gson.JsonElement> getProperties()
Gets the Properties of theEdgeConfig.Component
.- Returns:
- the Properties
-
getProperty
public java.util.Optional<com.google.gson.JsonElement> getProperty(java.lang.String propertyId)
Gets the Property with the given ID.- Parameters:
propertyId
- the Property-ID- Returns:
- the Property as
Optional
-
getPropertyOrError
public com.google.gson.JsonElement getPropertyOrError(java.lang.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
public java.util.Map<java.lang.String,EdgeConfig.Component.Channel> getChannels()
Gets a map ofEdgeConfig.Component.Channel
s of theEdgeConfig.Component
.- Returns:
- the map of
EdgeConfig.Component.Channel
s by their Channel-IDs.
-
setChannels
public void setChannels(java.util.Map<java.lang.String,EdgeConfig.Component.Channel> channels)
-
getChannelsOfCategory
public java.util.Map<java.lang.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
public java.util.Map<java.lang.String,EdgeConfig.Component.Channel> getStateChannels()
Gets the StateChannels.- Returns:
- the StateChannels
-
isStateChannel
public boolean isStateChannel(java.lang.String channelId)
Is the given Channel-ID a StateChannel?.- Parameters:
channelId
- the Channel-ID- Returns:
- true if it is a StateChannel
-
getStateChannel
public java.util.Optional<EdgeConfig.Component.Channel> getStateChannel(java.lang.String channelId)
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
public com.google.gson.JsonObject toJson(EdgeConfig.Component.JsonFormat jsonFormat)
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(java.lang.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
-
-