All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.bidib.wizard.api.service.node.SwitchingNodeService Maven / Gradle / Ivy

There is a newer version: 2.0.29
Show newest version
package org.bidib.wizard.api.service.node;

import java.util.List;
import java.util.Map;

import org.bidib.api.json.types.NodeAddress;
import org.bidib.jbidibc.messages.enums.LcMacroState;
import org.bidib.jbidibc.messages.enums.LcOutputType;
import org.bidib.jbidibc.messages.exception.InvalidConfigurationException;
import org.bidib.jbidibc.messages.port.PortConfigValue;
import org.bidib.wizard.api.model.Accessory;
import org.bidib.wizard.api.model.Macro;
import org.bidib.wizard.api.model.SwitchingNodeInterface;
import org.bidib.wizard.model.ports.GenericPort;
import org.bidib.wizard.model.ports.Port;
import org.bidib.wizard.model.ports.event.PortEvent;

import io.reactivex.rxjava3.disposables.Disposable;
import io.reactivex.rxjava3.functions.Action;
import io.reactivex.rxjava3.functions.Consumer;
import io.reactivex.rxjava3.functions.Predicate;

/**
 * The {@code SwitchingNodeService} offers methods to control a switching node.
 */
public interface SwitchingNodeService {

    /**
     * Query all accessories of the node.
     * 
     * @param connectionId
     *            the connection id
     * @param nodeAddress
     *            the node address
     * @return the list of accessories
     */
    List queryAllAccessories(String connectionId, final NodeAddress nodeAddress);

    /**
     * Query all accessories of the node.
     * 
     * @param connectionId
     *            the connection id
     * @param node
     *            the node
     * @return the list of accessories
     */
    List queryAllAccessories(String connectionId, final SwitchingNodeInterface node);

    /**
     * Reload the accessory from the node.
     * 
     * @param connectionId
     *            the connection id
     * @param node
     *            the node
     * @param accessory
     *            the accessory
     */
    void reloadAccessory(String connectionId, SwitchingNodeInterface node, Accessory accessory);

    /**
     * Store accessory on the node.
     * 
     * @param connectionId
     *            the connection id
     * @param node
     *            the node
     * @param accessory
     *            the accessory
     */
    void saveAccessory(String connectionId, SwitchingNodeInterface node, Accessory accessory);

    /**
     * Set the accessory to the aspect.
     * 
     * @param connectionId
     *            the connection id
     * @param node
     *            the node
     * @param accessory
     *            the accessory
     * @param aspect
     *            the aspect
     */
    void setAccessoryAspect(String connectionId, final SwitchingNodeInterface node, Accessory accessory, int aspect);

    /**
     * Query the state of the accessory.
     * 
     * @param connectionId
     *            the connection id
     * @param node
     *            the node
     * @param accessories
     *            the accessories
     */
    void queryAccessoryState(String connectionId, final SwitchingNodeInterface node, List accessories);

    /**
     * Set the port status.
     * 
     * @param connectionId
     *            the connection id
     * @param nodeAddress
     *            the node address
     * @param port
     *            the port
     */
    void setPortStatus(String connectionId, NodeAddress nodeAddress, Port port);

    /**
     * Set the port status.
     * 
     * @param connectionId
     *            the connection id
     * @param node
     *            the node
     * @param port
     *            the port
     */
    void setPortStatus(String connectionId, SwitchingNodeInterface node, Port port);

    /**
     * Query the port status.
     * 
     * @param connectionId
     *            the connection id
     * @param nodeAddress
     *            the node address
     * @param ports
     *            the ports to query
     */
    void queryPortStatus(String connectionId, NodeAddress nodeAddress, List> ports);

    /**
     * Query all ports of the node.
     * 
     * @param connectionId
     *            the connection id
     * @param nodeAddress
     *            the node address
     * @return the list of ports
     */
    List> queryAllPorts(String connectionId, NodeAddress nodeAddress);

    /**
     * Query all generic ports of the node.
     * 
     * @param connectionId
     *            the connection id
     * @param nodeAddress
     *            the node address
     * @return the list of generic ports
     */
    List queryAllGenericPorts(String connectionId, NodeAddress nodeAddress);

    /**
     * Get the port from the cache of the node.
     * 
     * @param connectionId
     *            the connection id
     * @param nodeAddress
     *            the node address
     * @param lcOutputType
     *            the port type
     * @param portNumber
     *            the port number
     * @return the port instance
     */
    Port getPort(String connectionId, final NodeAddress nodeAddress, LcOutputType lcOutputType, int portNumber);

    /**
     * Get the port from the cache of the node.
     * 
     * @param connectionId
     *            the connection id
     * @param node
     *            the node
     * @param lcOutputType
     *            the port type
     * @param portNumber
     *            the port number
     * @return the port instance
     */
    Port getPort(String connectionId, final SwitchingNodeInterface node, LcOutputType lcOutputType, int portNumber);

    /**
     * Set the port configuration on the node.
     * 
     * @param connectionId
     *            the connection id
     * @param nodeAddress
     *            the node address
     * @param port
     *            the port
     */
    void setPortConfig(String connectionId, final NodeAddress nodeAddress, Port port);

    /**
     * Set the port configuration on the node.
     * 
     * @param connectionId
     *            the connection id
     * @param node
     *            the node
     * @param port
     *            the port
     */
    void setPortConfig(String connectionId, final SwitchingNodeInterface node, Port port);

    /**
     * Set the port configuration on the node.
     * 
     * @param connectionId
     *            the connection id
     * @param node
     *            the node
     * @param port
     *            the port
     * @param newPortType
     *            the new port type, {@code null} if the port type is not changed
     * @param values
     *            the new configuration values
     */
    void setPortConfig(
        String connectionId, final SwitchingNodeInterface node, Port port, LcOutputType newPortType,
        Map> values);

    /**
     * Set the port configuration on the node.
     * 
     * @param connectionId
     *            the connection id
     * @param node
     *            the node
     * @param genericPort
     *            the generic port
     * @param newPortType
     *            the new port type, {@code null} if the port type is not changed
     * @param values
     *            the new configuration values
     */
    void setPortConfig(
        String connectionId, final SwitchingNodeInterface node, GenericPort genericPort, LcOutputType newPortType,
        Map> values);

    /**
     * Set the port configuration on the node.
     * 
     * @param connectionId
     *            the connection id
     * @param nodeAddress
     *            the nodeAddress
     * @param portType
     *            the port type
     * @param newPortType
     *            the new port type, {@code null} if the port type is not changed
     * @param values
     *            the new configuration values
     */
    void setPortConfig(
        String connectionId, final NodeAddress nodeAddress, LcOutputType portType, int portNumber,
        LcOutputType newPortType, Map> values);

    /**
     * Query all macros of the node.
     * 
     * @param connectionId
     *            the connection id
     * @param nodeAddress
     *            the node address
     * @return the list of macros
     */
    List queryAllMacros(String connectionId, final NodeAddress nodeAddress);

    /**
     * Query all macros of the node.
     * 
     * @param connectionId
     *            the connection id
     * @param node
     *            the node
     * @return the list of macros
     */
    List queryAllMacros(String connectionId, final SwitchingNodeInterface node);

    /**
     * Transfer the macro to the node and store in permanent memory.
     * 
     * @param connectionId
     *            the connection id
     * @param node
     *            the node
     * @param macro
     *            the macro
     */
    LcMacroState saveMacro(String connectionId, final SwitchingNodeInterface node, final Macro macro);

    /**
     * Get the content (the macro points) of the macro.
     * 
     * @param connectionId
     *            the connection id
     * @param node
     *            the node
     * @param macro
     *            the current macro instance
     * @return the provided macro instance with the content retrieved from the device
     * @throws InvalidConfigurationException
     *             if the conversion of the received data into the LcMacro failed
     */
    Macro getMacroContent(String connectionId, final SwitchingNodeInterface node, final Macro macro);

    /**
     * Load the macro with the specified macro id from the node.
     * 
     * @param connectionId
     *            the connection id
     * @param node
     *            the node
     * @param macro
     *            the macro
     */
    LcMacroState reloadMacro(String connectionId, final SwitchingNodeInterface node, final Macro macro);

    /**
     * Start the macro.
     * 
     * @param connectionId
     *            the connection id
     * @param node
     *            the node
     * @param macro
     *            the macro
     * @param transferBeforeStart
     *            transfer the macro before start
     * @return the macro state
     */
    LcMacroState startMacro(
        String connectionId, final SwitchingNodeInterface node, final Macro macro, boolean transferBeforeStart);

    /**
     * Stop the macro.
     * 
     * @param connectionId
     *            the connection id
     * @param node
     *            the node
     * @param macro
     *            the macro
     * @return the new macro state
     */
    LcMacroState stopMacro(String connectionId, final SwitchingNodeInterface node, final Macro macro);

    /**
     * Transfer the macro to the node but don't store in permanent memory.
     * 
     * @param node
     *            the node
     * @param macro
     *            the macro
     */
    void transferMacro(String connectionId, final SwitchingNodeInterface node, final Macro macro);

    /**
     * Subscribe to port events.
     * 
     * @param onNext
     *            the data handler
     * @param onError
     *            the error handler
     * @param onComplete
     *            the complete action
     * @return the disposable
     */
    Disposable subscribePortEvents(
        String connectionId, final Consumer onNext, final Consumer onError,
        final Action onComplete, final Predicate predicate);

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy