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

org.bidib.wizard.common.labels.WizardLabelFactory Maven / Gradle / Ivy

package org.bidib.wizard.common.labels;

import java.io.File;

import org.bidib.jbidibc.core.schema.bidib2.Accessory;
import org.bidib.jbidibc.core.schema.bidib2.FeedbackPort;
import org.bidib.jbidibc.core.schema.bidib2.InputKey;
import org.bidib.jbidibc.core.schema.bidib2.Macro;
import org.bidib.jbidibc.core.schema.bidib2.Node;
import org.bidib.jbidibc.core.schema.bidib2.OutputAnalog;
import org.bidib.jbidibc.core.schema.bidib2.OutputBacklight;
import org.bidib.jbidibc.core.schema.bidib2.OutputLight;
import org.bidib.jbidibc.core.schema.bidib2.OutputMotor;
import org.bidib.jbidibc.core.schema.bidib2.OutputServo;
import org.bidib.jbidibc.core.schema.bidib2.OutputSound;
import org.bidib.jbidibc.core.schema.bidib2.OutputSwitch;
import org.bidib.jbidibc.core.schema.bidib2.OutputSwitchPair;
import org.bidib.jbidibc.core.schema.bidibbase.DefaultLabelsActionType;
import org.bidib.jbidibc.core.schema.bidibbase.PortType;
import org.bidib.jbidibc.core.schema.bidiblabels.NodeLabels;
import org.bidib.jbidibc.messages.SoftwareVersion;
import org.bidib.jbidibc.messages.enums.PortModelEnum;
import org.bidib.wizard.api.model.Flag;
import org.bidib.wizard.api.model.PositionFeedbackPort;
import org.bidib.wizard.common.labels.DefaultWizardLabelFactory.DefaultLabelsApplied;
import org.bidib.wizard.common.labels.DefaultWizardLabelFactory.VersionedDefaultNodeLabelsWrapper;

public interface WizardLabelFactory {

    public enum LabelTypes {
        // @formatter:off
        accessory(Accessory.class), 
        analogPort(OutputAnalog.class, PortType.ANALOGOUT), 
        backlightPort(OutputBacklight.class, PortType.BACKLIGHT), 
        feedbackPort(FeedbackPort.class), 
        inputPort(InputKey.class, PortType.INPUT), 
        lightPort(OutputLight.class, PortType.LIGHT), 
        macro(Macro.class), 
        motorPort(OutputMotor.class, PortType.MOTOR), 
        node(Node.class), 
        servoPort(OutputServo.class, PortType.SERVO), 
        soundPort(OutputSound.class, PortType.SOUND), 
        switchPort(OutputSwitch.class, PortType.SWITCH), 
        switchPairPort(OutputSwitchPair.class, PortType.SWITCHPAIR), 
        flag(Flag.class), 
        feedbackPosition(PositionFeedbackPort.class);
        // @formatter:on

        private final Class portClazz;

        private final PortType portType;

        LabelTypes(final Class portClazz) {
            this(portClazz, null);
        }

        LabelTypes(final Class portClazz, PortType portType) {
            this.portClazz = portClazz;
            this.portType = portType;
        }

        public Class getPortClazz() {
            return portClazz;
        }

        public PortType getPortType() {
            return portType;
        }
    }

    /**
     * Load the labels. The class bits of the uniqueId are ignored.
     * 
     * @param uniqueId
     *            the uniqueId of the node
     * @param type
     *            the type of labels
     * @param searchRoot
     *            the search roots
     * @return the labels
     */
    NodeLabels loadLabels(Long uniqueId, String... searchRoot);

    /**
     * Save the labels.
     * 
     * @param uniqueId
     *            the uniqueId of the node
     */
    void saveLabels(Long uniqueId, String... searchRoot);

    /**
     * Delete the labels.
     * 
     * @param uniqueId
     *            the uniqueId of the node
     */
    void deleteLabels(Long uniqueId);

    /**
     * Get the default labels actionType.
     * 
     * @param uniqueId
     *            the uniqueId
     * @param searchRoot
     *            the search root
     * @return the default labels actionType
     */
    DefaultLabelsApplied getDefaultLabelsApplied(Long uniqueId, String... searchRoot);

    /**
     * @param uniqueId
     *            the unique id
     * @param softwareVersion
     *            the software version
     * @param lang
     *            the language
     * @param relevantPidBits
     *            the relevant PID bits
     * @param portModel
     *            the port model
     * @param defaultLabelsAction
     *            the action
     * @param searchRoot
     *            the search roots
     */
    void setDefaultLabelsApplied(
        long uniqueId, final SoftwareVersion softwareVersion, String lang, int relevantPidBits,
        final PortModelEnum portModel, DefaultLabelsActionType defaultLabelsAction, String... searchRoot);

    /**
     * Check if default labels for the node are available.
     * 
     * @param lang
     *            the language
     * @param uniqueId
     *            the uniqueId of the node
     * @param softwareVersion
     *            the software version
     * @param relevantPidBits
     *            the relevant PID bits
     * @return default labels available
     */
    VersionedDefaultNodeLabelsWrapper isDefaultLabelsAvailable(
        final String lang, Long uniqueId, final SoftwareVersion softwareVersion, int relevantPidBits);

    /**
     * Prepare default labels.
     * 
     * @param uniqueId
     *            the uniqueId of the node
     * @return the default node labels
     */
    NodeLabels prepareDefaultLabels(Long uniqueId);

    /**
     * Save the default labels to the provided file.
     * 
     * @param nodeLabels
     *            the default labels
     * @param file
     *            the file
     */
    void saveDefaultLabels(final NodeLabels nodeLabels, final File file);

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy