Package io.openems.edge.core.appmanager
Interface ComponentUtil
-
- All Known Implementing Classes:
ComponentUtilImpl
public interface ComponentUtil
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description boolean
anyComponentUses(java.lang.String value, java.util.List<java.lang.String> ignoreIds)
Checks if any component has the given String in its configuration.java.util.List<ComponentUtilImpl.Relay>
getAllRelays()
Gets a list of current Relays.java.util.List<ComponentUtilImpl.Relay>
getAvailableRelays()
Gets a list of currently available Relays of IOs which are not used by any component.java.util.List<java.lang.String>
getAvailableRelays(java.lang.String ioId)
Gets a list of currently available Relays of given IO which are not used by any component.java.util.List<java.lang.String>
getAvailableRelays(java.lang.String ioId, java.util.List<java.lang.String> ignoreIds)
Gets a list of currently available Relays of given IO which are not used by any component.java.util.List<ComponentUtilImpl.Relay>
getAvailableRelays(java.util.List<java.lang.String> ignoreIds)
Gets a list of currently available Relays of IOs which are not used by any component.java.util.Optional<EdgeConfig.Component>
getComponent(java.lang.String id, java.lang.String factoryId)
Gets anOptional
of anEdgeConfig.Component
.EdgeConfig.Component
getComponentByConfig(EdgeConfig.Component component)
Searches a component with the given component configuration.<T extends OpenemsComponent>
java.util.List<T>getEnabledComponentsOfStartingId(java.lang.String id)
Gets the enabled Components with the starting id.<T extends OpenemsComponent>
java.util.List<T>getEnabledComponentsOfType(java.lang.Class<T> clazz)
Gets the enabled Components of a Type.java.util.List<NetworkInterface<?>>
getInterfaces()
Gets the interfaces of the currently active network settings.java.lang.String
getNextAvailableId(java.lang.String baseName, int startingNumber, java.util.List<EdgeConfig.Component> components)
Gets the next available id with the baseName starting with the given startingNumber.default java.lang.String
getNextAvailableId(java.lang.String baseName, java.util.List<EdgeConfig.Component> components)
Gets the next available id with the baseName.java.lang.String[]
getPreferredRelays(java.util.List<java.lang.String> ignoreIds, int[] relays4Channel, int[] relays8Channel)
Gets the preferred relays.EdgeConfig.Component
getScheduler()
Gets the scheduler Component.java.util.List<java.lang.String>
getSchedulerIds()
Gets the current id's in the scheduler.java.util.List<java.lang.String>
insertSchedulerOrder(java.util.List<java.lang.String> actualOrder, java.util.List<java.lang.String> insertOrder)
Inserts the insertOrder into the actual Order.void
removeIdsInSchedulerIfExisting(User user, java.util.List<java.lang.String> removedIds)
removes the given id s from the scheduler if they exist in the scheduler.java.util.List<java.lang.String>
removeIdsWhichNotExist(java.util.List<java.lang.String> ids, java.util.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, java.util.List<InterfaceConfiguration> ips, java.util.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, java.util.List<NetworkInterface<?>> interfaces)
updates the interfaces in the Host configuration.void
updateScheduler(User user, java.util.List<java.lang.String> schedulerExecutionOrder, java.util.List<EdgeConfig.Component> components)
updates the execution order of the scheduler only adds or changes order of the given id s.
-
-
-
Method Detail
-
getInterfaces
java.util.List<NetworkInterface<?>> getInterfaces() throws OpenemsError.OpenemsNamedException
Gets the interfaces of the currently active network settings.- Returns:
- all interfaces in the host configuration
- Throws:
OpenemsError.OpenemsNamedException
- on error
-
anyComponentUses
boolean anyComponentUses(java.lang.String value, java.util.List<java.lang.String> ignoreIds)
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
-
getAllRelays
java.util.List<ComponentUtilImpl.Relay> getAllRelays()
Gets a list of current Relays. e. g. 'io0/Relay1'- Returns:
- a list of Relays
- Throws:
OpenemsError.OpenemsNamedException
- on error
-
getAvailableRelays
java.util.List<ComponentUtilImpl.Relay> getAvailableRelays()
Gets a list of currently available Relays of IOs which are not used by any component. e. g. 'io0/Relay1'- Returns:
- a list of available Relays
- Throws:
OpenemsError.OpenemsNamedException
- on error
-
getAvailableRelays
java.util.List<ComponentUtilImpl.Relay> getAvailableRelays(java.util.List<java.lang.String> ignoreIds)
Gets a list of currently available Relays of IOs which are not used by any component. like 'io0/Relay1'- Parameters:
ignoreIds
- the Component-IDs that should be ignored- Returns:
- a list of available Relays
- Throws:
OpenemsError.OpenemsNamedException
- on error
-
getAvailableRelays
java.util.List<java.lang.String> getAvailableRelays(java.lang.String ioId) throws OpenemsError.OpenemsNamedException
Gets a list of currently available Relays of given IO which are not used by any component. like 'io0/Relay1'- Parameters:
ioId
- the Component-ID of the DigitalOutput- Returns:
- a list of available Relays
- Throws:
OpenemsError.OpenemsNamedException
- if the io was not found
-
getAvailableRelays
java.util.List<java.lang.String> getAvailableRelays(java.lang.String ioId, java.util.List<java.lang.String> ignoreIds) throws OpenemsError.OpenemsNamedException
Gets a list of currently available Relays of given IO which are not used by any component. e. g. 'io0/Relay1'- Parameters:
ioId
- the Component-ID of the DigitalOutputignoreIds
- the Component-IDs that should be ignored- Returns:
- a list of available Relays
- Throws:
OpenemsError.OpenemsNamedException
- if the io was not found
-
getComponentByConfig
EdgeConfig.Component getComponentByConfig(EdgeConfig.Component component)
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
<T extends OpenemsComponent> java.util.List<T> getEnabledComponentsOfStartingId(java.lang.String id)
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
<T extends OpenemsComponent> java.util.List<T> getEnabledComponentsOfType(java.lang.Class<T> clazz)
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
default java.lang.String getNextAvailableId(java.lang.String baseName, java.util.List<EdgeConfig.Component> components)
Gets the next available id with the baseName.- Parameters:
baseName
- like ess, meter without a numbercomponents
- the used components 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
java.lang.String getNextAvailableId(java.lang.String baseName, int startingNumber, java.util.List<EdgeConfig.Component> components)
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 fromcomponents
- the used components 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
java.lang.String[] getPreferredRelays(java.util.List<java.lang.String> ignoreIds, int[] relays4Channel, int[] relays8Channel)
Gets the preferred relays. If the default ports are 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 relayboard are returned.- Parameters:
ignoreIds
- the ids of the components that should be ignoredrelays4Channel
- the default ports on a 4-Channel Relayrelays8Channel
- the default ports on a 8-Channel Relay- Returns:
- the relays
-
updateInterfaces
void updateInterfaces(User user, java.util.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, java.util.List<java.lang.String> schedulerExecutionOrder, java.util.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, java.util.List<java.lang.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
java.util.List<java.lang.String> getSchedulerIds() throws OpenemsError.OpenemsNamedException
Gets the current id's in the scheduler.- Returns:
- the id's
- Throws:
OpenemsError.OpenemsNamedException
- on error
-
getScheduler
EdgeConfig.Component getScheduler() throws OpenemsError.OpenemsNamedException
Gets the scheduler Component.- Returns:
- the scheduler component
- Throws:
OpenemsError.OpenemsNamedException
- if more or no scheduler is available
-
removeIdsWhichNotExist
java.util.List<java.lang.String> removeIdsWhichNotExist(java.util.List<java.lang.String> ids, java.util.List<EdgeConfig.Component> components)
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
java.util.List<java.lang.String> insertSchedulerOrder(java.util.List<java.lang.String> actualOrder, java.util.List<java.lang.String> insertOrder)
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, java.util.List<InterfaceConfiguration> ips, java.util.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
java.util.Optional<EdgeConfig.Component> getComponent(java.lang.String id, java.lang.String factoryId)
Gets anOptional
of anEdgeConfig.Component
.- Parameters:
id
- the id of the componentfactoryId
- the factoryId of the component- Returns:
- the optional component
-
-