use of org.eclipse.vorto.codegen.ble.model.blegatt.CharacteristicProperty in project vorto by eclipse.
the class ModelTransformer method transformProperty.
private void transformProperty(Service service, Property property) {
IMapped<Property> map = this.context.getMappedElement(property, "source");
if (map.hasAttribute("uuid")) {
String uuid = map.getAttributeValue("uuid", "");
Characteristic characteristic = null;
for (Characteristic ch : service.getCharacteristics()) {
if (ch.getUuid().equals(uuid)) {
characteristic = ch;
break;
}
}
if (characteristic == null) {
characteristic = this.factory.createCharacteristic();
characteristic.setUuid(uuid);
if (map.hasAttribute("name")) {
characteristic.setName(map.getAttributeValue("name", ""));
} else {
characteristic.setName(((FunctionblockModel) (property.eContainer().eContainer().eContainer())).getName() + property.getName());
}
service.getCharacteristics().add(characteristic);
}
if (Integer.valueOf(map.getAttributeValue("length", "0")) + Integer.valueOf(map.getAttributeValue("offset", "0")) > characteristic.getLength()) {
characteristic.setLength(Integer.valueOf(map.getAttributeValue("length", "0")) + Integer.valueOf(map.getAttributeValue("offset", "0")));
}
if (Utils.isReadable(property)) {
characteristic.setIsReadable(true);
}
if (Utils.isWritable(property)) {
characteristic.setIsWritable(true);
}
if (Utils.isEventable(property)) {
characteristic.setIsEventable(true);
}
if (map.hasAttribute("length") && map.hasAttribute("offset") && map.hasAttribute("datatype")) {
CharacteristicProperty cp = this.factory.createCharacteristicProperty();
cp.setDatatype(map.getAttributeValue("datatype", ""));
cp.setLength(Integer.parseInt(map.getAttributeValue("length", "0")));
cp.setOffset(Integer.parseInt(map.getAttributeValue("offset", "0")));
cp.setProperty(property);
characteristic.getProperties().add(cp);
}
}
}
Aggregations