Package io.openems.edge.core.appmanager
Interface ComponentUtil
- All Known Implementing Classes:
ComponentUtilImpl
public interface ComponentUtil
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final record
static final record
static final record
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionboolean
anyComponentUses
(String value, List<String> ignoreIds) Checks if any component has the given String in its configuration.default List<ComponentUtil.RelayInfo>
Gets allRelayInfos
of allDigitalOutputs
.default List<ComponentUtil.RelayInfo>
getAllRelayInfos
(Predicate<DigitalOutput> componentFilter, BiPredicate<DigitalOutput, BooleanWriteChannel> channelFilter, BiFunction<DigitalOutput, BooleanWriteChannel, List<String>> disabledReasons) Gets allRelayInfos
of allDigitalOutputs
.default List<ComponentUtil.RelayInfo>
getAllRelayInfos
(List<String> ignoreIds) Gets allRelayInfos
of allDigitalOutputs
.getAllRelayInfos
(List<String> ignoreIds, Predicate<DigitalOutput> componentFilter, Function<DigitalOutput, String> componentAliasMapper, BiPredicate<DigitalOutput, BooleanWriteChannel> channelFilter, BiFunction<DigitalOutput, BooleanWriteChannel, String> channelAliasMapper, BiFunction<DigitalOutput, BooleanWriteChannel, List<String>> disabledReasons) Gets allRelayInfos
of allDigitalOutputs
.getComponent
(String id, String factoryId) Gets anOptional
of anEdgeConfig.Component
.getComponentByConfig
(EdgeConfig.Component component) Searches a component with the given component configuration.<T extends OpenemsComponent>
List<T>Gets the enabled Components with the starting id.<T extends OpenemsComponent>
List<T>getEnabledComponentsOfType
(Class<T> clazz) Gets the enabled Components of a Type.List<NetworkInterface<?>>
Gets the interfaces of the currently active network settings.getNextAvailableId
(String baseName, int startingNumber, List<String> componentIds) Gets the next available id with the baseName starting with the given startingNumber.default String
getNextAvailableId
(String baseName, List<String> componentIds) Gets the next available id with the baseName.String[]
getPreferredRelays
(List<ComponentUtil.RelayInfo> relayInfos, int numberOfRelays, List<ComponentUtil.PreferredRelay> preferredRelays) Gets the preferred relays.Gets the scheduler Component.Gets the current id's in the scheduler.int[]
getUsedModbusUnitIds
(String modbusComponent) Gets an array of modbus unit ids which are already used by other components.insertSchedulerOrder
(List<String> actualOrder, List<String> insertOrder) Inserts the insertOrder into the actual Order.void
removeIdsInSchedulerIfExisting
(User user, List<String> removedIds) removes the given id s from the scheduler if they exist in the scheduler.removeIdsWhichNotExist
(List<String> ids, List<EdgeConfig.Component> components) Creates a new List with only components which exist in the current configuration or in the passed components list.void
updateHosts
(User user, List<InterfaceConfiguration> ips, List<InterfaceConfiguration> oldIps) updates the host configuration deletes ip s that are inoldIps
but not inips
and adds ip s that are inips
but not inoldIps
.void
updateInterfaces
(User user, List<NetworkInterface<?>> interfaces) updates the interfaces in the Host configuration.void
updateScheduler
(User user, List<String> schedulerExecutionOrder, List<EdgeConfig.Component> components) updates the execution order of the scheduler only adds or changes order of the given id s.
-
Field Details
-
CORE_COMPONENT_IDS
-
-
Method Details
-
getInterfaces
Gets the interfaces of the currently active network settings.- Returns:
- all interfaces in the host configuration
- Throws:
OpenemsError.OpenemsNamedException
- on error
-
anyComponentUses
Checks if any component has the given String in its configuration.- Parameters:
value
- that no component should haveignoreIds
- the id s of components which configuration should be ignored- Returns:
- true if a component has the given String in its configuration
-
getAllRelayInfos
Gets allRelayInfos
of allDigitalOutputs
.- Parameters:
ignoreIds
- the Component-IDs that should be ignored to check if they use any relay- Returns:
- a list of
RelayInfos
-
getAllRelayInfos
List<ComponentUtil.RelayInfo> getAllRelayInfos(List<String> ignoreIds, Predicate<DigitalOutput> componentFilter, Function<DigitalOutput, String> componentAliasMapper, BiPredicate<DigitalOutput, BooleanWriteChannel> channelFilter, BiFunction<DigitalOutput, BooleanWriteChannel, String> channelAliasMapper, BiFunction<DigitalOutput, BooleanWriteChannel, List<String>> disabledReasons) Gets allRelayInfos
of allDigitalOutputs
.- Parameters:
ignoreIds
- the Component-IDs that should be ignored to check if they use any relaycomponentFilter
- aDigitalOutput
component filtercomponentAliasMapper
- aDigitalOutput
component alias mapperchannelFilter
- aDigitalOutput
channel filterchannelAliasMapper
- aDigitalOutput
channel alias mapperdisabledReasons
- aDigitalOutput
channel disabled function- Returns:
- a list of
RelayInfos
-
getAllRelayInfos
Gets allRelayInfos
of allDigitalOutputs
.- Returns:
- a list of
RelayInfos
-
getAllRelayInfos
default List<ComponentUtil.RelayInfo> getAllRelayInfos(Predicate<DigitalOutput> componentFilter, BiPredicate<DigitalOutput, BooleanWriteChannel> channelFilter, BiFunction<DigitalOutput, BooleanWriteChannel, List<String>> disabledReasons) Gets allRelayInfos
of allDigitalOutputs
.- Parameters:
componentFilter
- aDigitalOutput
component filterchannelFilter
- aDigitalOutput
channel filterdisabledReasons
- additional reasons why a channel is disabled- Returns:
- a list of
RelayInfos
-
getComponentByConfig
Searches a component with the given component configuration.- Parameters:
component
- with the configuration to be searched for- Returns:
- the found component or null if not found
-
getEnabledComponentsOfStartingId
Gets the enabled Components with the starting id.- Type Parameters:
T
- the type to which the components should be assignable to- Parameters:
id
- the starting id of the components- Returns:
- a list of found components
-
getEnabledComponentsOfType
Gets the enabled Components of a Type.the method 'this.componentManager.getEnabledComponentsOfType(clazz)' does not return the component if the given class is an interface and the component has the interface implemented
- Type Parameters:
T
- the type to which the components should be assignable to- Parameters:
clazz
- to which the component should be assignable to- Returns:
- a list of found components
-
getNextAvailableId
Gets the next available id with the baseName.- Parameters:
baseName
- like ess, meter without a numbercomponentIds
- the used componentIds from the other apps, because if the user updates multiple instances very quickly and components of the same type are created they are not instantly added to the componentManager- Returns:
- the id
-
getNextAvailableId
Gets the next available id with the baseName starting with the given startingNumber.- Parameters:
baseName
- like ess, meter without a numberstartingNumber
- the number at the end of the id to start fromcomponentIds
- the used componentIds from the other apps, because if the user updates multiple instances very quickly and components of the same type are created they are not instantly added to the componentManager- Returns:
- the id
-
getPreferredRelays
String[] getPreferredRelays(List<ComponentUtil.RelayInfo> relayInfos, int numberOfRelays, List<ComponentUtil.PreferredRelay> preferredRelays) Gets the preferred relays. If the default ports are already taken the next available in a row are taken. If not enough in a row are available the first available relays of any relay are returned.- Parameters:
relayInfos
- theRelayInfos
to search in for the preferred relaysnumberOfRelays
- the number of the result number of relayspreferredRelays
- theComponentUtil.PreferredRelay
options- Returns:
- the first found preferred relays
-
updateInterfaces
void updateInterfaces(User user, List<NetworkInterface<?>> interfaces) throws OpenemsError.OpenemsNamedException updates the interfaces in the Host configuration.- Parameters:
user
- the executing userinterfaces
- the new interfaces- Throws:
OpenemsError.OpenemsNamedException
- on error
-
updateScheduler
void updateScheduler(User user, List<String> schedulerExecutionOrder, List<EdgeConfig.Component> components) throws OpenemsError.OpenemsNamedException updates the execution order of the scheduler only adds or changes order of the given id s.- Parameters:
user
- the executing userschedulerExecutionOrder
- the execution ordercomponents
- the components which are currently created- Throws:
OpenemsError.OpenemsNamedException
- when the scheduler can not be updated
-
removeIdsInSchedulerIfExisting
void removeIdsInSchedulerIfExisting(User user, List<String> removedIds) throws OpenemsError.OpenemsNamedException removes the given id s from the scheduler if they exist in the scheduler.- Parameters:
user
- the executing userremovedIds
- the ip s that should be removed- Throws:
OpenemsError.OpenemsNamedException
- on error
-
getSchedulerIds
Gets the current id's in the scheduler.- Returns:
- the id's
- Throws:
OpenemsError.OpenemsNamedException
- on error
-
getScheduler
Gets the scheduler Component.- Returns:
- the scheduler component
- Throws:
OpenemsError.OpenemsNamedException
- if more or no scheduler is available
-
removeIdsWhichNotExist
Creates a new List with only components which exist in the current configuration or in the passed components list.- Parameters:
ids
- the initial listcomponents
- the current creating components- Returns:
- a new list only with id's of components that exist
-
insertSchedulerOrder
Inserts the insertOrder into the actual Order.- Parameters:
actualOrder
- the current scheduler orderinsertOrder
- the order which should be inserted- Returns:
- the complete order
-
updateHosts
void updateHosts(User user, List<InterfaceConfiguration> ips, List<InterfaceConfiguration> oldIps) throws OpenemsError.OpenemsNamedException updates the host configuration deletes ip s that are inoldIps
but not inips
and adds ip s that are inips
but not inoldIps
.- Parameters:
user
- the executing userips
- the ip s that should be in the configurationoldIps
- the old ip s that were in the old configuration- Throws:
OpenemsError.OpenemsNamedException
- on error
-
getComponent
Gets anOptional
of anEdgeConfig.Component
.- Parameters:
id
- the id of the componentfactoryId
- the factoryId of the component- Returns:
- the optional component
-
getUsedModbusUnitIds
Gets an array of modbus unit ids which are already used by other components. The result of this method may not contain all modbus unit ids.- Parameters:
modbusComponent
- the id of the modbus component- Returns:
- an array of used modbus unit ids
-