Search in sources :

Example 6 with Output

use of org.eclipse.smarthome.automation.type.Output in project smarthome by eclipse.

the class LightsTriggerType method initialize.

public static LightsTriggerType initialize() {
    Output state = new Output(StateConditionType.INPUT_CURRENT_STATE, String.class.getName(), "State", "Indicates the state of Lights", null, null, null);
    List<Output> output = new ArrayList<Output>();
    output.add(state);
    return new LightsTriggerType(output);
}
Also used : Output(org.eclipse.smarthome.automation.type.Output) ArrayList(java.util.ArrayList)

Example 7 with Output

use of org.eclipse.smarthome.automation.type.Output in project smarthome by eclipse.

the class ModuleTypeRegistryMockup method createTriggerType.

private TriggerType createTriggerType() {
    List<Output> outputs = new ArrayList<Output>(3);
    outputs.add(createOutput("out1", new String[] { "tagA" }));
    outputs.add(createOutput("out2", new String[] { "tagB", "tagC" }));
    outputs.add(createOutput("out3", new String[] { "tagA", "tagB", "tagC" }));
    TriggerType t = new TriggerType(TRIGGER_TYPE, null, outputs);
    return t;
}
Also used : TriggerType(org.eclipse.smarthome.automation.type.TriggerType) Output(org.eclipse.smarthome.automation.type.Output) ArrayList(java.util.ArrayList)

Example 8 with Output

use of org.eclipse.smarthome.automation.type.Output in project smarthome by eclipse.

the class ModuleTypeI18nUtil method getLocalizedOutputs.

public static List<Output> getLocalizedOutputs(TranslationProvider i18nProvider, List<Output> outputs, Bundle bundle, String uid, Locale locale) {
    List<Output> loutputs = new ArrayList<Output>();
    if (outputs != null) {
        for (Output output : outputs) {
            String outputName = output.getName();
            String olabel = ModuleTypeI18nUtil.getOutputLabel(i18nProvider, bundle, uid, outputName, output.getLabel(), locale);
            String odescription = ModuleTypeI18nUtil.getOutputDescription(i18nProvider, bundle, uid, outputName, output.getDescription(), locale);
            loutputs.add(new Output(outputName, output.getType(), olabel, odescription, output.getTags(), output.getReference(), output.getDefaultValue()));
        }
    }
    return loutputs;
}
Also used : Output(org.eclipse.smarthome.automation.type.Output) ArrayList(java.util.ArrayList)

Example 9 with Output

use of org.eclipse.smarthome.automation.type.Output in project smarthome by eclipse.

the class AirConditionerTriggerType method initialize.

public static TriggerType initialize() {
    List<Output> output = new ArrayList<Output>();
    Output state = new Output(StateConditionType.INPUT_CURRENT_STATE, String.class.getName(), "State", "Indicates if the Air Conditioner is switched On or Off.", null, null, null);
    Output temperature = new Output(TemperatureConditionType.INPUT_CURRENT_TEMPERATURE, Integer.class.getName(), "Temperature", "Indicates the current room temperature", null, null, null);
    output.add(state);
    output.add(temperature);
    return new AirConditionerTriggerType(output);
}
Also used : Output(org.eclipse.smarthome.automation.type.Output) ArrayList(java.util.ArrayList)

Example 10 with Output

use of org.eclipse.smarthome.automation.type.Output in project smarthome by eclipse.

the class ConnectionValidator method checkCompatibility.

/**
 * This method checks the compatibility of data types of the input and connected output. Throws
 * exception if they are incompatible.
 *
 * @param msg message should be extended with an information and thrown as exception when validation fails.
 * @param connection that should be validated
 * @param input that should be validated
 * @param outputs list with outputs of the module connected to the given input
 * @throws IllegalArgumentException when validation fails.
 */
private static void checkCompatibility(String msg, Connection connection, Input input, List<Output> outputs) {
    String outputName = connection.getOutputName();
    if (outputs != null && !outputs.isEmpty()) {
        for (Output output : outputs) {
            if (output.getName().equals(outputName)) {
                if (input.getType().equals("*")) {
                    return;
                } else {
                    try {
                        Class<?> outputType = Class.forName(output.getType());
                        Class<?> inputType = Class.forName(input.getType());
                        if (inputType.isAssignableFrom(outputType)) {
                            return;
                        } else {
                            throw new IllegalArgumentException(msg + " Incompatible types : \"" + output.getType() + "\" and \"" + input.getType() + "\".");
                        }
                    } catch (ClassNotFoundException e) {
                        if (output.getType().equals(input.getType())) {
                            return;
                        } else {
                            throw new IllegalArgumentException(msg + " Incompatible types : \"" + output.getType() + "\" and \"" + input.getType() + "\".");
                        }
                    }
                }
            }
        }
        throw new IllegalArgumentException(msg + " Output with name \"" + outputName + "\" not exists in the Module with ID \"" + connection.getOuputModuleId() + "\"");
    }
}
Also used : Output(org.eclipse.smarthome.automation.type.Output)

Aggregations

Output (org.eclipse.smarthome.automation.type.Output)11 ArrayList (java.util.ArrayList)5 HashMap (java.util.HashMap)3 LinkedHashMap (java.util.LinkedHashMap)3 StringTokenizer (java.util.StringTokenizer)2 Action (org.eclipse.smarthome.automation.Action)2 ActionType (org.eclipse.smarthome.automation.type.ActionType)2 Input (org.eclipse.smarthome.automation.type.Input)2 TriggerType (org.eclipse.smarthome.automation.type.TriggerType)2 Trigger (org.eclipse.smarthome.automation.Trigger)1 ActionHandler (org.eclipse.smarthome.automation.handler.ActionHandler)1 CompositeActionType (org.eclipse.smarthome.automation.type.CompositeActionType)1 CompositeTriggerType (org.eclipse.smarthome.automation.type.CompositeTriggerType)1