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);
}
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;
}
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;
}
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);
}
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() + "\"");
}
}
Aggregations