use of org.eclipse.smarthome.binding.mqtt.generic.internal.convention.homie300.Property in project kie-wb-common by kiegroup.
the class SubProcessPropertyWriter method setProcessVariables.
public void setProcessVariables(BaseProcessVariables processVariables) {
String value = processVariables.getValue();
DeclarationList declarationList = DeclarationList.fromString(value);
List<Property> properties = process.getProperties();
declarationList.getDeclarations().forEach(decl -> {
VariableScope.Variable variable = variableScope.declare(this.process.getId(), decl.getIdentifier(), decl.getType());
if (!decl.getTags().isEmpty()) {
CustomElement.customTags.of(variable.getTypedIdentifier()).set(decl.getTags());
}
properties.add(variable.getTypedIdentifier());
this.itemDefinitions.add(variable.getTypeDeclaration());
});
}
use of org.eclipse.smarthome.binding.mqtt.generic.internal.convention.homie300.Property in project kie-wb-common by kiegroup.
the class ProcessPropertyWriter method setCaseFileVariables.
public void setCaseFileVariables(CaseFileVariables caseFileVariables) {
String value = caseFileVariables.getValue();
DeclarationList declarationList = DeclarationList.fromString(value);
List<Property> properties = process.getProperties();
declarationList.getDeclarations().forEach(decl -> {
VariableScope.Variable variable = variableScope.declare(this.process.getId(), CaseFileVariables.CASE_FILE_PREFIX + decl.getIdentifier(), decl.getType());
properties.add(variable.getTypedIdentifier());
this.itemDefinitions.add(variable.getTypeDeclaration());
});
}
use of org.eclipse.smarthome.binding.mqtt.generic.internal.convention.homie300.Property in project atlasmap by atlasmap.
the class BaseMarshallerTest method generatePropertyReferenceMapping.
protected AtlasMapping generatePropertyReferenceMapping() {
AtlasMapping mapping = generateAtlasMapping();
PropertyField inputField = new PropertyField();
inputField.setName("foo");
Mapping fm = (Mapping) mapping.getMappings().getMapping().get(0);
fm.getInputField().add(inputField);
Property p = new Property();
p.setName("foo");
p.setValue("bar");
mapping.setProperties(new Properties());
mapping.getProperties().getProperty().add(p);
return mapping;
}
use of org.eclipse.smarthome.binding.mqtt.generic.internal.convention.homie300.Property in project atlasmap by atlasmap.
the class BaseDefaultAtlasContextTest method populateProperty.
protected void populateProperty(String scope, String name, String value) {
Property p = new Property();
p.setScope(scope);
p.setName(name);
p.setValue(value);
session.getMapping().getProperties().getProperty().add(p);
}
use of org.eclipse.smarthome.binding.mqtt.generic.internal.convention.homie300.Property in project smarthome by eclipse.
the class HomieImplementationTests method parseHomieTree.
@SuppressWarnings("null")
@Test
public void parseHomieTree() throws InterruptedException, ExecutionException, TimeoutException {
// Create a Homie Device object. Because spied Nodes are required for call verification,
// the full Device constructor need to be used and a ChildMap object need to be created manually.
ChildMap<Node> nodeMap = new ChildMap<>();
Device device = spy(new Device(ThingChannelConstants.testHomieThing, callback, new DeviceAttributes(), nodeMap));
// Intercept creating a node in initialize()->start() and inject a spy'ed node.
doAnswer(this::createSpyNode).when(device).createNode(any());
// initialize the device, subscribe and wait.
device.initialize(baseTopic, deviceID, Collections.emptyList());
device.subscribe(connection, scheduler, 200).get();
assertThat(device.isInitialized(), is(true));
// Check device attributes
assertThat(device.attributes.homie, is("3.0"));
assertThat(device.attributes.name, is("Name"));
assertThat(device.attributes.state, is(ReadyState.ready));
assertThat(device.attributes.nodes.length, is(1));
verify(device, times(4)).attributeChanged(any(), any(), any(), any(), anyBoolean());
verify(callback).readyStateChanged(eq(ReadyState.ready));
verify(device).attributesReceived(any(), any(), anyInt());
// Expect 1 node
assertThat(device.nodes.size(), is(1));
// Check node and node attributes
Node node = device.nodes.get("testnode");
verify(node).subscribe(any(), any(), anyInt());
verify(node).attributesReceived(any(), any(), anyInt());
verify(node.attributes).subscribeAndReceive(any(), any(), anyString(), any(), anyInt());
assertThat(node.attributes.type, is("Type"));
assertThat(node.attributes.name, is("Testnode"));
// Expect 2 property
assertThat(node.properties.size(), is(3));
// Check property and property attributes
Property property = node.properties.get("temperature");
assertThat(property.attributes.settable, is(true));
assertThat(property.attributes.retained, is(true));
assertThat(property.attributes.name, is("Testprop"));
assertThat(property.attributes.unit, is("°C"));
assertThat(property.attributes.datatype, is(DataTypeEnum.float_));
assertThat(property.attributes.format, is("-100:100"));
verify(property).attributesReceived();
assertNotNull(property.getChannelState());
assertThat(property.getType().getState().getMinimum().intValue(), is(-100));
assertThat(property.getType().getState().getMaximum().intValue(), is(100));
// Check property and property attributes
Property propertyBell = node.properties.get("doorbell");
verify(propertyBell).attributesReceived();
assertThat(propertyBell.attributes.settable, is(false));
assertThat(propertyBell.attributes.retained, is(false));
assertThat(propertyBell.attributes.name, is("Doorbell"));
assertThat(propertyBell.attributes.datatype, is(DataTypeEnum.boolean_));
// The device->node->property tree is ready. Now subscribe to property values.
device.startChannels(connection, scheduler, 50, handler).get();
assertThat(propertyBell.getChannelState().isStateful(), is(false));
assertThat(propertyBell.getChannelState().getCache().getChannelState(), is(UnDefType.UNDEF));
assertThat(property.getChannelState().getCache().getChannelState(), is(new DecimalType(10)));
property = node.properties.get("testRetain");
WaitForTopicValue watcher = new WaitForTopicValue(embeddedConnection, propertyTestTopic + "/set");
// Watch the topic. Publish a retain=false value to MQTT
property.getChannelState().publishValue(OnOffType.OFF).get();
assertThat(watcher.waitForTopicValue(50), is("false"));
// Publish a retain=false value to MQTT.
property.getChannelState().publishValue(OnOffType.ON).get();
// This test is flaky if the MQTT broker does not get a time to "forget" this non-retained value
Thread.sleep(50);
// No value is expected to be retained on this MQTT topic
watcher = new WaitForTopicValue(embeddedConnection, propertyTestTopic + "/set");
assertNull(watcher.waitForTopicValue(50));
}
Aggregations