Interface ComponentUtil

    • Method Detail

      • 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 have
        ignoreIds - the id s of components which configuration should be ignored
        Returns:
        true if a component has the given String in its configuration
      • 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 DigitalOutput
        ignoreIds - 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 number
        components - 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 number
        startingNumber - the number at the end of the id to start from
        components - 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 ignored
        relays4Channel - the default ports on a 4-Channel Relay
        relays8Channel - the default ports on a 8-Channel Relay
        Returns:
        the relays
      • 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 user
        schedulerExecutionOrder - the execution order
        components - 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 user
        removedIds - the ip s that should be removed
        Throws:
        OpenemsError.OpenemsNamedException - on error
      • 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 list
        components - 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 order
        insertOrder - the order which should be inserted
        Returns:
        the complete order
      • getComponent

        java.util.Optional<EdgeConfig.Component> getComponent​(java.lang.String id,
                                                              java.lang.String factoryId)
        Gets an Optional of an EdgeConfig.Component.
        Parameters:
        id - the id of the component
        factoryId - the factoryId of the component
        Returns:
        the optional component