Search in sources :

Example 16 with ModelProperty

use of org.eclipse.vorto.repository.api.content.ModelProperty in project vorto by eclipse.

the class SpecWithTypeConversion method createFBSpec.

@Override
protected void createFBSpec() {
    FunctionblockModel buttonModel = new FunctionblockModel(ModelId.fromPrettyFormat("demo.fb.PushButton:1.0.0"), ModelType.Functionblock);
    ModelProperty digitalInputStateProperty = new ModelProperty();
    digitalInputStateProperty.setMandatory(true);
    digitalInputStateProperty.setName("sensor_value");
    digitalInputStateProperty.setType(PrimitiveType.STRING);
    digitalInputStateProperty.setTargetPlatformKey("iotbutton");
    digitalInputStateProperty.addStereotype(Stereotype.createWithXpath("type:convertDouble(/@lng[1])"));
    buttonModel.setStatusProperties(Arrays.asList(new ModelProperty[] { digitalInputStateProperty }));
    addFunctionblockProperty("button", buttonModel);
}
Also used : FunctionblockModel(org.eclipse.vorto.repository.api.content.FunctionblockModel) ModelProperty(org.eclipse.vorto.repository.api.content.ModelProperty)

Example 17 with ModelProperty

use of org.eclipse.vorto.repository.api.content.ModelProperty in project vorto by eclipse.

the class BleGattDeviceBuilder method build.

public BleGattDevice build() {
    this.device = new BleGattDevice();
    for (ModelProperty fbprop : infomodel.getFunctionblocks()) {
        FunctionblockModel fb = mappingSpec.getFunctionBlock(fbprop.getName());
        if ("blegatt".equals(fb.getTargetPlatformKey())) {
            BleGattService service = new BleGattService();
            Optional<Stereotype> stereotype = fb.getStereotype("source");
            if (stereotype.isPresent()) {
                String uuid = stereotype.get().getAttributes().get("uuid");
                if (uuid != null) {
                    service.setUuid(UUID.fromString(uuid));
                }
            }
            for (ModelProperty prop : fb.getConfigurationProperties()) {
                BleGattCharacteristic ch = buildCharacteristic(prop);
                if (ch.getUuid() != null) {
                    service.addCharacteristics(ch);
                }
            }
            for (ModelProperty prop : fb.getStatusProperties()) {
                BleGattCharacteristic ch = buildCharacteristic(prop);
                if (ch.getUuid() != null) {
                    service.addCharacteristics(ch);
                }
            }
            device.addService(service);
        }
    }
    return device;
}
Also used : FunctionblockModel(org.eclipse.vorto.repository.api.content.FunctionblockModel) ModelProperty(org.eclipse.vorto.repository.api.content.ModelProperty) Stereotype(org.eclipse.vorto.repository.api.content.Stereotype)

Example 18 with ModelProperty

use of org.eclipse.vorto.repository.api.content.ModelProperty in project vorto by eclipse.

the class MappingSpecificationSerializer method iterator.

public Iterator<IMappingSerializer> iterator() {
    List<IMappingSerializer> serializers = new ArrayList<IMappingSerializer>();
    for (ModelProperty fbProperty : specification.getInfoModel().getFunctionblocks()) {
        serializers.add(new FunctionblockMappingSerializer(specification, fbProperty.getName()));
    }
    serializers.add(new InformationModelMappingSerializer(specification));
    return serializers.iterator();
}
Also used : ArrayList(java.util.ArrayList) ModelProperty(org.eclipse.vorto.repository.api.content.ModelProperty) InformationModelMappingSerializer(org.eclipse.vorto.service.mapping.internal.serializer.InformationModelMappingSerializer) FunctionblockMappingSerializer(org.eclipse.vorto.service.mapping.internal.serializer.FunctionblockMappingSerializer)

Example 19 with ModelProperty

use of org.eclipse.vorto.repository.api.content.ModelProperty in project vorto by eclipse.

the class SpecGattConverter method createFBSpec.

@Override
protected void createFBSpec() {
    FunctionblockModel buttonModel = new FunctionblockModel(ModelId.fromPrettyFormat("demo.fb.PushButton:1.0.0"), ModelType.Functionblock);
    ModelProperty digitalInputStateProperty = new ModelProperty();
    digitalInputStateProperty.setMandatory(true);
    digitalInputStateProperty.setName("sensor_value");
    digitalInputStateProperty.setType(PrimitiveType.STRING);
    digitalInputStateProperty.setTargetPlatformKey("iotbutton");
    digitalInputStateProperty.addStereotype(Stereotype.createWithXpath("button:convertSensorValue(conversion:byteArrayToInt(characteristics[@uuid='23-D1-13-EF-5F-78-23-15-DE-EF-12-12-0D-F0-00-00']/data, 3, 0, 0, 3))"));
    buttonModel.setStatusProperties(Arrays.asList(new ModelProperty[] { digitalInputStateProperty }));
    addFunctionblockProperty("button", buttonModel);
}
Also used : FunctionblockModel(org.eclipse.vorto.repository.api.content.FunctionblockModel) ModelProperty(org.eclipse.vorto.repository.api.content.ModelProperty)

Example 20 with ModelProperty

use of org.eclipse.vorto.repository.api.content.ModelProperty in project vorto by eclipse.

the class SpecWithByteArrayConverter method createFBSpec.

@Override
protected void createFBSpec() {
    FunctionblockModel buttonModel = new FunctionblockModel(ModelId.fromPrettyFormat("demo.fb.PushButton:1.0.0"), ModelType.Functionblock);
    ModelProperty digitalInputStateProperty = new ModelProperty();
    digitalInputStateProperty.setMandatory(true);
    digitalInputStateProperty.setName("sensor_value");
    digitalInputStateProperty.setType(PrimitiveType.STRING);
    digitalInputStateProperty.setTargetPlatformKey("iotbutton");
    digitalInputStateProperty.addStereotype(Stereotype.createWithXpath("button:convertSensorValue(conversion:byteArrayToInt(/data, 3, 0, 0, 3))"));
    buttonModel.setStatusProperties(Arrays.asList(new ModelProperty[] { digitalInputStateProperty }));
    addFunctionblockProperty("button", buttonModel);
}
Also used : FunctionblockModel(org.eclipse.vorto.repository.api.content.FunctionblockModel) ModelProperty(org.eclipse.vorto.repository.api.content.ModelProperty)

Aggregations

ModelProperty (org.eclipse.vorto.repository.api.content.ModelProperty)23 FunctionblockModel (org.eclipse.vorto.repository.api.content.FunctionblockModel)18 Infomodel (org.eclipse.vorto.repository.api.content.Infomodel)4 Stereotype (org.eclipse.vorto.repository.api.content.Stereotype)3 ArrayList (java.util.ArrayList)2 MappingRule (org.eclipse.vorto.core.api.model.mapping.MappingRule)2 ReferenceTarget (org.eclipse.vorto.core.api.model.mapping.ReferenceTarget)2 StereoTypeTarget (org.eclipse.vorto.core.api.model.mapping.StereoTypeTarget)2 ModelId (org.eclipse.vorto.repository.api.ModelId)2 EntityModel (org.eclipse.vorto.repository.api.content.EntityModel)2 FunctionblockData (org.eclipse.vorto.service.mapping.normalized.FunctionblockData)2 List (java.util.List)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Collectors (java.util.stream.Collectors)1 JXPathContext (org.apache.commons.jxpath.JXPathContext)1 JXPathInvalidAccessException (org.apache.commons.jxpath.JXPathInvalidAccessException)1 JXPathNotFoundException (org.apache.commons.jxpath.JXPathNotFoundException)1 BooleanPropertyAttribute (org.eclipse.vorto.core.api.model.datatype.BooleanPropertyAttribute)1 Entity (org.eclipse.vorto.core.api.model.datatype.Entity)1