use of org.eclipse.vorto.codegen.ble.model.blegatt.Service in project vorto by eclipse.
the class ModelTransformer method transformFunctionblock.
private void transformFunctionblock(FunctionblockModel fbm) {
IMapped<FunctionblockModel> map = this.context.getMappedElement(fbm, "Service");
if (map.hasAttribute("uuid")) {
String uuid = map.getAttributeValue("uuid", "");
Service service = null;
for (Service s : this.device.getServices()) {
if (s.getUuid().equals(uuid)) {
service = s;
break;
}
}
if (service == null) {
service = this.factory.createService();
service.setUuid(uuid);
if (map.hasAttribute("serviceName")) {
service.setName(map.getAttributeValue("serviceName", ""));
} else {
service.setName(fbm.getName());
}
this.device.getServices().add(service);
}
service.getFunctionblocks().add(fbm);
FunctionBlock fb = fbm.getFunctionblock();
if (fb.getStatus() != null) {
for (Property property : fb.getStatus().getProperties()) {
transformProperty(service, property);
}
}
if (fb.getConfiguration() != null) {
for (Property property : fb.getConfiguration().getProperties()) {
transformProperty(service, property);
}
}
if (fb.getFault() != null) {
for (Property property : fb.getFault().getProperties()) {
transformProperty(service, property);
}
}
}
}
use of org.eclipse.vorto.codegen.ble.model.blegatt.Service in project vorto by eclipse.
the class ModelTransformer method transform.
public Device transform() {
this.factory = ModelFactoryImpl.init();
this.device = this.factory.createDevice();
this.device.setName(this.infomodel.getName());
this.device.setInfomodel(this.infomodel);
IMapped<InformationModel> map = this.context.getMappedElement(infomodel, "DeviceInfoProfile");
if (map.hasAttribute("modelNumber")) {
String modelNumber = map.getAttributeValue("modelNumber", "0");
Service service = this.factory.createService();
service.setName("DeviceInformation");
service.setUuid("0000180a-0000-1000-8000-00805f9b34fb");
Characteristic characteristic = this.factory.createCharacteristic();
characteristic.setName("ModelNumber");
characteristic.setUuid("00002a24-0000-1000-8000-00805f9b34fb");
characteristic.setLength(modelNumber.length() / 2);
StringBuffer mnBuf = new StringBuffer();
mnBuf.append("{");
for (int i = 0; i < modelNumber.length(); i += 2) {
mnBuf.append("0x" + modelNumber.substring(i, i + 2));
if (i < modelNumber.length() - 2) {
mnBuf.append(", ");
}
}
mnBuf.append("}");
characteristic.setValue(mnBuf.toString());
service.getCharacteristics().add(characteristic);
this.device.getServices().add(service);
}
for (FunctionblockProperty property : infomodel.getProperties()) {
transformFunctionblock(property.getType());
}
return this.device;
}
Aggregations