/** * * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated NOT */ @Override public void enable() { logger.trace("enabling"); int chipType = BrickletLEDStrip.CHIP_TYPE_WS2801; int frameDuration = 100; Long clockFrequency = null; tinkerforgeDevice = new BrickletLEDStrip(getUid(), getIpConnection()); if (tfConfig != null) { if (tfConfig.eIsSet(tfConfig.eClass().getEStructuralFeature("chiptype"))) { String chipTypeString = tfConfig.getChiptype(); if (chipTypeString.equalsIgnoreCase("ws2801")) { chipType = BrickletLEDStrip.CHIP_TYPE_WS2801; } else if (chipTypeString.equalsIgnoreCase("ws2811")) { chipType = BrickletLEDStrip.CHIP_TYPE_WS2811; } else if (chipTypeString.equalsIgnoreCase("ws2812")) { chipType = BrickletLEDStrip.CHIP_TYPE_WS2812; } else { logger.error("Unknown ChipType {}", chipTypeString); // TODO raise configuration error } } if (tfConfig.eIsSet(tfConfig.eClass().getEStructuralFeature("frameduration"))) { frameDuration = tfConfig.getFrameduration(); } if (tfConfig.eIsSet(tfConfig.eClass().getEStructuralFeature("clockfrequency"))) { clockFrequency = tfConfig.getClockfrequency(); } // config Handling for ColorMapping must be before adding the // subdevices because subdevices use the ColorMapping if (tfConfig.eIsSet( tfConfig .eClass() .getEStructuralFeature(ModelPackage.LED_STRIP_CONFIGURATION__COLOR_MAPPING))) { colorMapping = tfConfig.getColorMapping(); } if (tfConfig.eIsSet( tfConfig .eClass() .getEStructuralFeature(ModelPackage.LED_STRIP_CONFIGURATION__SUB_DEVICES))) { String[] subdevices = tfConfig.getSubDevices().trim().split("\\s+"); for (String subId : subdevices) { addSubdevice(subId); } } } logger.debug("chipType is {}", chipType); logger.debug("frameDuration is {}", frameDuration); logger.debug("colorMapping is {}", colorMapping); try { tinkerforgeDevice.setChipType(chipType); tinkerforgeDevice.setFrameDuration(frameDuration); if (clockFrequency != null) { logger.debug("clockFrequency is {}", clockFrequency); tinkerforgeDevice.setClockFrequency(clockFrequency); } else { logger.debug("clockFrequency is not set"); } } catch (TimeoutException e) { TinkerforgeErrorHandler.handleError(this, TinkerforgeErrorHandler.TF_TIMEOUT_EXCEPTION, e); } catch (NotConnectedException e) { TinkerforgeErrorHandler.handleError( this, TinkerforgeErrorHandler.TF_NOT_CONNECTION_EXCEPTION, e); } }