/** * Copyright (c) 2010-2016 by the respective copyright holders. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ /** */ package org.openhab.binding.tinkerforge.internal.model.impl; import java.lang.reflect.InvocationTargetException; import java.util.Collection; import java.util.concurrent.atomic.AtomicBoolean; import org.eclipse.emf.common.notify.Notification; import org.eclipse.emf.common.notify.NotificationChain; import org.eclipse.emf.common.util.EList; import org.eclipse.emf.ecore.EClass; import org.eclipse.emf.ecore.InternalEObject; import org.eclipse.emf.ecore.impl.ENotificationImpl; import org.eclipse.emf.ecore.impl.MinimalEObjectImpl; import org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList; import org.eclipse.emf.ecore.util.EcoreUtil; import org.eclipse.emf.ecore.util.InternalEList; import org.openhab.binding.tinkerforge.internal.LoggerConstants; import org.openhab.binding.tinkerforge.internal.TinkerforgeErrorHandler; import org.openhab.binding.tinkerforge.internal.model.BrickletColorConfiguration; import org.openhab.binding.tinkerforge.internal.model.BrickletColorDevice; import org.openhab.binding.tinkerforge.internal.model.ColorColor; import org.openhab.binding.tinkerforge.internal.model.ColorColorTemperature; import org.openhab.binding.tinkerforge.internal.model.ColorIlluminance; import org.openhab.binding.tinkerforge.internal.model.ColorLed; import org.openhab.binding.tinkerforge.internal.model.MBrickd; import org.openhab.binding.tinkerforge.internal.model.MBrickletColor; import org.openhab.binding.tinkerforge.internal.model.MSubDevice; import org.openhab.binding.tinkerforge.internal.model.MSubDeviceHolder; import org.openhab.binding.tinkerforge.internal.model.MTFConfigConsumer; import org.openhab.binding.tinkerforge.internal.model.ModelFactory; import org.openhab.binding.tinkerforge.internal.model.ModelPackage; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.tinkerforge.BrickletColor; import com.tinkerforge.IPConnection; import com.tinkerforge.NotConnectedException; import com.tinkerforge.TimeoutException; /** * <!-- begin-user-doc --> * An implementation of the model object '<em><b>MBricklet Color</b></em>'. * <!-- end-user-doc --> * <p> * The following features are implemented: * </p> * <ul> * <li>{@link org.openhab.binding.tinkerforge.internal.model.impl.MBrickletColorImpl#getLogger <em>Logger</em>}</li> * <li>{@link org.openhab.binding.tinkerforge.internal.model.impl.MBrickletColorImpl#getUid <em>Uid</em>}</li> * <li>{@link org.openhab.binding.tinkerforge.internal.model.impl.MBrickletColorImpl#isPoll <em>Poll</em>}</li> * <li>{@link org.openhab.binding.tinkerforge.internal.model.impl.MBrickletColorImpl#getEnabledA <em>Enabled A</em>} * </li> * <li>{@link org.openhab.binding.tinkerforge.internal.model.impl.MBrickletColorImpl#getTinkerforgeDevice * <em>Tinkerforge Device</em>}</li> * <li>{@link org.openhab.binding.tinkerforge.internal.model.impl.MBrickletColorImpl#getIpConnection <em>Ip * Connection</em>}</li> * <li>{@link org.openhab.binding.tinkerforge.internal.model.impl.MBrickletColorImpl#getConnectedUid <em>Connected * Uid</em>}</li> * <li>{@link org.openhab.binding.tinkerforge.internal.model.impl.MBrickletColorImpl#getPosition <em>Position</em>}</li> * <li>{@link org.openhab.binding.tinkerforge.internal.model.impl.MBrickletColorImpl#getDeviceIdentifier <em>Device * Identifier</em>}</li> * <li>{@link org.openhab.binding.tinkerforge.internal.model.impl.MBrickletColorImpl#getName <em>Name</em>}</li> * <li>{@link org.openhab.binding.tinkerforge.internal.model.impl.MBrickletColorImpl#getBrickd <em>Brickd</em>}</li> * <li>{@link org.openhab.binding.tinkerforge.internal.model.impl.MBrickletColorImpl#getMsubdevices * <em>Msubdevices</em>}</li> * <li>{@link org.openhab.binding.tinkerforge.internal.model.impl.MBrickletColorImpl#getTfConfig <em>Tf Config</em>} * </li> * <li>{@link org.openhab.binding.tinkerforge.internal.model.impl.MBrickletColorImpl#getDeviceType <em>Device Type</em>} * </li> * <li>{@link org.openhab.binding.tinkerforge.internal.model.impl.MBrickletColorImpl#getGain <em>Gain</em>}</li> * <li>{@link org.openhab.binding.tinkerforge.internal.model.impl.MBrickletColorImpl#getIntegrationTime <em>Integration * Time</em>}</li> * </ul> * * @generated */ public class MBrickletColorImpl extends MinimalEObjectImpl.Container implements MBrickletColor { /** * The default value of the '{@link #getLogger() <em>Logger</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @see #getLogger() * @generated * @ordered */ protected static final Logger LOGGER_EDEFAULT = null; /** * The cached value of the '{@link #getLogger() <em>Logger</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @see #getLogger() * @generated * @ordered */ protected Logger logger = LOGGER_EDEFAULT; /** * The default value of the '{@link #getUid() <em>Uid</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @see #getUid() * @generated * @ordered */ protected static final String UID_EDEFAULT = null; /** * The cached value of the '{@link #getUid() <em>Uid</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @see #getUid() * @generated * @ordered */ protected String uid = UID_EDEFAULT; /** * The default value of the '{@link #isPoll() <em>Poll</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @see #isPoll() * @generated * @ordered */ protected static final boolean POLL_EDEFAULT = true; /** * The cached value of the '{@link #isPoll() <em>Poll</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @see #isPoll() * @generated * @ordered */ protected boolean poll = POLL_EDEFAULT; /** * The default value of the '{@link #getEnabledA() <em>Enabled A</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @see #getEnabledA() * @generated * @ordered */ protected static final AtomicBoolean ENABLED_A_EDEFAULT = null; /** * The cached value of the '{@link #getEnabledA() <em>Enabled A</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @see #getEnabledA() * @generated * @ordered */ protected AtomicBoolean enabledA = ENABLED_A_EDEFAULT; /** * The cached value of the '{@link #getTinkerforgeDevice() <em>Tinkerforge Device</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @see #getTinkerforgeDevice() * @generated * @ordered */ protected BrickletColor tinkerforgeDevice; /** * The default value of the '{@link #getIpConnection() <em>Ip Connection</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @see #getIpConnection() * @generated * @ordered */ protected static final IPConnection IP_CONNECTION_EDEFAULT = null; /** * The cached value of the '{@link #getIpConnection() <em>Ip Connection</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @see #getIpConnection() * @generated * @ordered */ protected IPConnection ipConnection = IP_CONNECTION_EDEFAULT; /** * The default value of the '{@link #getConnectedUid() <em>Connected Uid</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @see #getConnectedUid() * @generated * @ordered */ protected static final String CONNECTED_UID_EDEFAULT = null; /** * The cached value of the '{@link #getConnectedUid() <em>Connected Uid</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @see #getConnectedUid() * @generated * @ordered */ protected String connectedUid = CONNECTED_UID_EDEFAULT; /** * The default value of the '{@link #getPosition() <em>Position</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @see #getPosition() * @generated * @ordered */ protected static final char POSITION_EDEFAULT = '\u0000'; /** * The cached value of the '{@link #getPosition() <em>Position</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @see #getPosition() * @generated * @ordered */ protected char position = POSITION_EDEFAULT; /** * The default value of the '{@link #getDeviceIdentifier() <em>Device Identifier</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @see #getDeviceIdentifier() * @generated * @ordered */ protected static final int DEVICE_IDENTIFIER_EDEFAULT = 0; /** * The cached value of the '{@link #getDeviceIdentifier() <em>Device Identifier</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @see #getDeviceIdentifier() * @generated * @ordered */ protected int deviceIdentifier = DEVICE_IDENTIFIER_EDEFAULT; /** * The default value of the '{@link #getName() <em>Name</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @see #getName() * @generated * @ordered */ protected static final String NAME_EDEFAULT = null; /** * The cached value of the '{@link #getName() <em>Name</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @see #getName() * @generated * @ordered */ protected String name = NAME_EDEFAULT; /** * The cached value of the '{@link #getMsubdevices() <em>Msubdevices</em>}' containment reference list. * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @see #getMsubdevices() * @generated * @ordered */ protected EList<BrickletColorDevice> msubdevices; /** * The cached value of the '{@link #getTfConfig() <em>Tf Config</em>}' containment reference. * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @see #getTfConfig() * @generated * @ordered */ protected BrickletColorConfiguration tfConfig; /** * The default value of the '{@link #getDeviceType() <em>Device Type</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @see #getDeviceType() * @generated * @ordered */ protected static final String DEVICE_TYPE_EDEFAULT = "bricklet_color"; /** * The cached value of the '{@link #getDeviceType() <em>Device Type</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @see #getDeviceType() * @generated * @ordered */ protected String deviceType = DEVICE_TYPE_EDEFAULT; /** * The default value of the '{@link #getGain() <em>Gain</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @see #getGain() * @generated * @ordered */ protected static final Short GAIN_EDEFAULT = new Short((short) 3); /** * The cached value of the '{@link #getGain() <em>Gain</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @see #getGain() * @generated * @ordered */ protected Short gain = GAIN_EDEFAULT; /** * The default value of the '{@link #getIntegrationTime() <em>Integration Time</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @see #getIntegrationTime() * @generated * @ordered */ protected static final Short INTEGRATION_TIME_EDEFAULT = new Short((short) 3); /** * The cached value of the '{@link #getIntegrationTime() <em>Integration Time</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @see #getIntegrationTime() * @generated * @ordered */ protected Short integrationTime = INTEGRATION_TIME_EDEFAULT; /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated */ protected MBrickletColorImpl() { super(); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated */ @Override protected EClass eStaticClass() { return ModelPackage.Literals.MBRICKLET_COLOR; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated */ @Override public Logger getLogger() { return logger; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated */ @Override public void setLogger(Logger newLogger) { Logger oldLogger = logger; logger = newLogger; if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, ModelPackage.MBRICKLET_COLOR__LOGGER, oldLogger, logger)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated */ @Override public String getUid() { return uid; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated */ @Override public void setUid(String newUid) { String oldUid = uid; uid = newUid; if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, ModelPackage.MBRICKLET_COLOR__UID, oldUid, uid)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated */ @Override public boolean isPoll() { return poll; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated */ @Override public void setPoll(boolean newPoll) { boolean oldPoll = poll; poll = newPoll; if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, ModelPackage.MBRICKLET_COLOR__POLL, oldPoll, poll)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated */ @Override public AtomicBoolean getEnabledA() { return enabledA; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated */ @Override public void setEnabledA(AtomicBoolean newEnabledA) { AtomicBoolean oldEnabledA = enabledA; enabledA = newEnabledA; if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, ModelPackage.MBRICKLET_COLOR__ENABLED_A, oldEnabledA, enabledA)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated */ @Override public BrickletColor getTinkerforgeDevice() { return tinkerforgeDevice; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated */ @Override public void setTinkerforgeDevice(BrickletColor newTinkerforgeDevice) { BrickletColor oldTinkerforgeDevice = tinkerforgeDevice; tinkerforgeDevice = newTinkerforgeDevice; if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, ModelPackage.MBRICKLET_COLOR__TINKERFORGE_DEVICE, oldTinkerforgeDevice, tinkerforgeDevice)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated */ @Override public IPConnection getIpConnection() { return ipConnection; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated */ @Override public void setIpConnection(IPConnection newIpConnection) { IPConnection oldIpConnection = ipConnection; ipConnection = newIpConnection; if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, ModelPackage.MBRICKLET_COLOR__IP_CONNECTION, oldIpConnection, ipConnection)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated */ @Override public String getConnectedUid() { return connectedUid; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated */ @Override public void setConnectedUid(String newConnectedUid) { String oldConnectedUid = connectedUid; connectedUid = newConnectedUid; if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, ModelPackage.MBRICKLET_COLOR__CONNECTED_UID, oldConnectedUid, connectedUid)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated */ @Override public char getPosition() { return position; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated */ @Override public void setPosition(char newPosition) { char oldPosition = position; position = newPosition; if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, ModelPackage.MBRICKLET_COLOR__POSITION, oldPosition, position)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated */ @Override public int getDeviceIdentifier() { return deviceIdentifier; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated */ @Override public void setDeviceIdentifier(int newDeviceIdentifier) { int oldDeviceIdentifier = deviceIdentifier; deviceIdentifier = newDeviceIdentifier; if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, ModelPackage.MBRICKLET_COLOR__DEVICE_IDENTIFIER, oldDeviceIdentifier, deviceIdentifier)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated */ @Override public String getName() { return name; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated */ @Override public void setName(String newName) { String oldName = name; name = newName; if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, ModelPackage.MBRICKLET_COLOR__NAME, oldName, name)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated */ @Override public MBrickd getBrickd() { if (eContainerFeatureID() != ModelPackage.MBRICKLET_COLOR__BRICKD) return null; return (MBrickd) eContainer(); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated */ public MBrickd basicGetBrickd() { if (eContainerFeatureID() != ModelPackage.MBRICKLET_COLOR__BRICKD) return null; return (MBrickd) eInternalContainer(); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated */ public NotificationChain basicSetBrickd(MBrickd newBrickd, NotificationChain msgs) { msgs = eBasicSetContainer((InternalEObject) newBrickd, ModelPackage.MBRICKLET_COLOR__BRICKD, msgs); return msgs; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated */ @Override public void setBrickd(MBrickd newBrickd) { if (newBrickd != eInternalContainer() || (eContainerFeatureID() != ModelPackage.MBRICKLET_COLOR__BRICKD && newBrickd != null)) { if (EcoreUtil.isAncestor(this, newBrickd)) throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); NotificationChain msgs = null; if (eInternalContainer() != null) msgs = eBasicRemoveFromContainer(msgs); if (newBrickd != null) msgs = ((InternalEObject) newBrickd).eInverseAdd(this, ModelPackage.MBRICKD__MDEVICES, MBrickd.class, msgs); msgs = basicSetBrickd(newBrickd, msgs); if (msgs != null) msgs.dispatch(); } else if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, ModelPackage.MBRICKLET_COLOR__BRICKD, newBrickd, newBrickd)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated */ @Override public EList<BrickletColorDevice> getMsubdevices() { if (msubdevices == null) { msubdevices = new EObjectContainmentWithInverseEList<BrickletColorDevice>(BrickletColorDevice.class, this, ModelPackage.MBRICKLET_COLOR__MSUBDEVICES, ModelPackage.MSUB_DEVICE__MBRICK) { private static final long serialVersionUID = 1L; @Override public Class<?> getInverseFeatureClass() { return MSubDevice.class; } }; } return msubdevices; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated */ @Override public BrickletColorConfiguration getTfConfig() { return tfConfig; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated */ public NotificationChain basicSetTfConfig(BrickletColorConfiguration newTfConfig, NotificationChain msgs) { BrickletColorConfiguration oldTfConfig = tfConfig; tfConfig = newTfConfig; if (eNotificationRequired()) { ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, ModelPackage.MBRICKLET_COLOR__TF_CONFIG, oldTfConfig, newTfConfig); if (msgs == null) msgs = notification; else msgs.add(notification); } return msgs; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated */ @Override public void setTfConfig(BrickletColorConfiguration newTfConfig) { if (newTfConfig != tfConfig) { NotificationChain msgs = null; if (tfConfig != null) msgs = ((InternalEObject) tfConfig).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - ModelPackage.MBRICKLET_COLOR__TF_CONFIG, null, msgs); if (newTfConfig != null) msgs = ((InternalEObject) newTfConfig).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - ModelPackage.MBRICKLET_COLOR__TF_CONFIG, null, msgs); msgs = basicSetTfConfig(newTfConfig, msgs); if (msgs != null) msgs.dispatch(); } else if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, ModelPackage.MBRICKLET_COLOR__TF_CONFIG, newTfConfig, newTfConfig)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated */ @Override public String getDeviceType() { return deviceType; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated */ @Override public Short getGain() { return gain; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated */ @Override public void setGain(Short newGain) { Short oldGain = gain; gain = newGain; if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, ModelPackage.MBRICKLET_COLOR__GAIN, oldGain, gain)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated */ @Override public Short getIntegrationTime() { return integrationTime; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated */ @Override public void setIntegrationTime(Short newIntegrationTime) { Short oldIntegrationTime = integrationTime; integrationTime = newIntegrationTime; if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, ModelPackage.MBRICKLET_COLOR__INTEGRATION_TIME, oldIntegrationTime, integrationTime)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated NOT */ @Override public void initSubDevices() { ModelFactory factory = ModelFactory.eINSTANCE; ColorColor color = factory.createColorColor(); color.setUid(getUid()); String subIdColor = "color"; color.setSubId(subIdColor); logger.debug("{} addSubDevice {}", LoggerConstants.TFINIT, subIdColor); color.init(); color.setMbrick(this); ColorColorTemperature temperature = factory.createColorColorTemperature(); temperature.setUid(getUid()); String subIdTemperature = "temperature"; temperature.setSubId(subIdTemperature); logger.debug("{} addSubDevice {}", LoggerConstants.TFINIT, subIdTemperature); temperature.init(); temperature.setMbrick(this); ColorIlluminance illuminance = factory.createColorIlluminance(); illuminance.setUid(getUid()); String subIdIlluminance = "illuminance"; illuminance.setSubId(subIdIlluminance); logger.debug("{} addSubDevice {}", LoggerConstants.TFINIT, subIdIlluminance); illuminance.init(); illuminance.setMbrick(this); ColorLed led = factory.createColorLed(); led.setUid(getUid()); String subIdLed = "led"; led.setSubId(subIdLed); logger.debug("{} addSubDevice {}", LoggerConstants.TFINIT, subIdLed); led.init(); led.setMbrick(this); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated NOT */ @Override public void init() { setEnabledA(new AtomicBoolean()); logger = LoggerFactory.getLogger(MBrickletColorImpl.class); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated NOT */ @Override public void enable() { if (tfConfig != null) { if (tfConfig.eIsSet(tfConfig.eClass().getEStructuralFeature("gain"))) { Short gainConfig = tfConfig.getGain(); switch (gainConfig) { case 0: this.gain = 0; break; case 1: this.gain = 1; break; case 2: this.gain = 2; break; default: logger.error("invalid gain value {}; using default gain", gainConfig); break; } } if (tfConfig.eIsSet(tfConfig.eClass().getEStructuralFeature("integrationTime"))) { Short integrationTimeConfig = tfConfig.getIntegrationTime(); switch (integrationTimeConfig) { case 0: this.integrationTime = 0; break; case 1: this.integrationTime = 1; break; case 2: this.integrationTime = 2; break; case 3: this.integrationTime = 3; break; case 4: this.integrationTime = 4; break; default: logger.error("invalid integrationTime value {}; using default integrationTime", integrationTimeConfig); break; } } } try { tinkerforgeDevice = new BrickletColor(getUid(), getIpConnection()); tinkerforgeDevice.setConfig(gain, integrationTime); } catch (TimeoutException e) { TinkerforgeErrorHandler.handleError(this, TinkerforgeErrorHandler.TF_TIMEOUT_EXCEPTION, e); } catch (NotConnectedException e) { TinkerforgeErrorHandler.handleError(this, TinkerforgeErrorHandler.TF_NOT_CONNECTION_EXCEPTION, e); } } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated NOT */ @Override public void disable() { tinkerforgeDevice = null; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated */ @SuppressWarnings("unchecked") @Override public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { switch (featureID) { case ModelPackage.MBRICKLET_COLOR__BRICKD: if (eInternalContainer() != null) msgs = eBasicRemoveFromContainer(msgs); return basicSetBrickd((MBrickd) otherEnd, msgs); case ModelPackage.MBRICKLET_COLOR__MSUBDEVICES: return ((InternalEList<InternalEObject>) (InternalEList<?>) getMsubdevices()).basicAdd(otherEnd, msgs); } return super.eInverseAdd(otherEnd, featureID, msgs); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated */ @Override public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { switch (featureID) { case ModelPackage.MBRICKLET_COLOR__BRICKD: return basicSetBrickd(null, msgs); case ModelPackage.MBRICKLET_COLOR__MSUBDEVICES: return ((InternalEList<?>) getMsubdevices()).basicRemove(otherEnd, msgs); case ModelPackage.MBRICKLET_COLOR__TF_CONFIG: return basicSetTfConfig(null, msgs); } return super.eInverseRemove(otherEnd, featureID, msgs); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated */ @Override public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) { switch (eContainerFeatureID()) { case ModelPackage.MBRICKLET_COLOR__BRICKD: return eInternalContainer().eInverseRemove(this, ModelPackage.MBRICKD__MDEVICES, MBrickd.class, msgs); } return super.eBasicRemoveFromContainerFeature(msgs); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated */ @Override public Object eGet(int featureID, boolean resolve, boolean coreType) { switch (featureID) { case ModelPackage.MBRICKLET_COLOR__LOGGER: return getLogger(); case ModelPackage.MBRICKLET_COLOR__UID: return getUid(); case ModelPackage.MBRICKLET_COLOR__POLL: return isPoll(); case ModelPackage.MBRICKLET_COLOR__ENABLED_A: return getEnabledA(); case ModelPackage.MBRICKLET_COLOR__TINKERFORGE_DEVICE: return getTinkerforgeDevice(); case ModelPackage.MBRICKLET_COLOR__IP_CONNECTION: return getIpConnection(); case ModelPackage.MBRICKLET_COLOR__CONNECTED_UID: return getConnectedUid(); case ModelPackage.MBRICKLET_COLOR__POSITION: return getPosition(); case ModelPackage.MBRICKLET_COLOR__DEVICE_IDENTIFIER: return getDeviceIdentifier(); case ModelPackage.MBRICKLET_COLOR__NAME: return getName(); case ModelPackage.MBRICKLET_COLOR__BRICKD: if (resolve) return getBrickd(); return basicGetBrickd(); case ModelPackage.MBRICKLET_COLOR__MSUBDEVICES: return getMsubdevices(); case ModelPackage.MBRICKLET_COLOR__TF_CONFIG: return getTfConfig(); case ModelPackage.MBRICKLET_COLOR__DEVICE_TYPE: return getDeviceType(); case ModelPackage.MBRICKLET_COLOR__GAIN: return getGain(); case ModelPackage.MBRICKLET_COLOR__INTEGRATION_TIME: return getIntegrationTime(); } return super.eGet(featureID, resolve, coreType); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated */ @SuppressWarnings("unchecked") @Override public void eSet(int featureID, Object newValue) { switch (featureID) { case ModelPackage.MBRICKLET_COLOR__LOGGER: setLogger((Logger) newValue); return; case ModelPackage.MBRICKLET_COLOR__UID: setUid((String) newValue); return; case ModelPackage.MBRICKLET_COLOR__POLL: setPoll((Boolean) newValue); return; case ModelPackage.MBRICKLET_COLOR__ENABLED_A: setEnabledA((AtomicBoolean) newValue); return; case ModelPackage.MBRICKLET_COLOR__TINKERFORGE_DEVICE: setTinkerforgeDevice((BrickletColor) newValue); return; case ModelPackage.MBRICKLET_COLOR__IP_CONNECTION: setIpConnection((IPConnection) newValue); return; case ModelPackage.MBRICKLET_COLOR__CONNECTED_UID: setConnectedUid((String) newValue); return; case ModelPackage.MBRICKLET_COLOR__POSITION: setPosition((Character) newValue); return; case ModelPackage.MBRICKLET_COLOR__DEVICE_IDENTIFIER: setDeviceIdentifier((Integer) newValue); return; case ModelPackage.MBRICKLET_COLOR__NAME: setName((String) newValue); return; case ModelPackage.MBRICKLET_COLOR__BRICKD: setBrickd((MBrickd) newValue); return; case ModelPackage.MBRICKLET_COLOR__MSUBDEVICES: getMsubdevices().clear(); getMsubdevices().addAll((Collection<? extends BrickletColorDevice>) newValue); return; case ModelPackage.MBRICKLET_COLOR__TF_CONFIG: setTfConfig((BrickletColorConfiguration) newValue); return; case ModelPackage.MBRICKLET_COLOR__GAIN: setGain((Short) newValue); return; case ModelPackage.MBRICKLET_COLOR__INTEGRATION_TIME: setIntegrationTime((Short) newValue); return; } super.eSet(featureID, newValue); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated */ @Override public void eUnset(int featureID) { switch (featureID) { case ModelPackage.MBRICKLET_COLOR__LOGGER: setLogger(LOGGER_EDEFAULT); return; case ModelPackage.MBRICKLET_COLOR__UID: setUid(UID_EDEFAULT); return; case ModelPackage.MBRICKLET_COLOR__POLL: setPoll(POLL_EDEFAULT); return; case ModelPackage.MBRICKLET_COLOR__ENABLED_A: setEnabledA(ENABLED_A_EDEFAULT); return; case ModelPackage.MBRICKLET_COLOR__TINKERFORGE_DEVICE: setTinkerforgeDevice((BrickletColor) null); return; case ModelPackage.MBRICKLET_COLOR__IP_CONNECTION: setIpConnection(IP_CONNECTION_EDEFAULT); return; case ModelPackage.MBRICKLET_COLOR__CONNECTED_UID: setConnectedUid(CONNECTED_UID_EDEFAULT); return; case ModelPackage.MBRICKLET_COLOR__POSITION: setPosition(POSITION_EDEFAULT); return; case ModelPackage.MBRICKLET_COLOR__DEVICE_IDENTIFIER: setDeviceIdentifier(DEVICE_IDENTIFIER_EDEFAULT); return; case ModelPackage.MBRICKLET_COLOR__NAME: setName(NAME_EDEFAULT); return; case ModelPackage.MBRICKLET_COLOR__BRICKD: setBrickd((MBrickd) null); return; case ModelPackage.MBRICKLET_COLOR__MSUBDEVICES: getMsubdevices().clear(); return; case ModelPackage.MBRICKLET_COLOR__TF_CONFIG: setTfConfig((BrickletColorConfiguration) null); return; case ModelPackage.MBRICKLET_COLOR__GAIN: setGain(GAIN_EDEFAULT); return; case ModelPackage.MBRICKLET_COLOR__INTEGRATION_TIME: setIntegrationTime(INTEGRATION_TIME_EDEFAULT); return; } super.eUnset(featureID); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated */ @Override public boolean eIsSet(int featureID) { switch (featureID) { case ModelPackage.MBRICKLET_COLOR__LOGGER: return LOGGER_EDEFAULT == null ? logger != null : !LOGGER_EDEFAULT.equals(logger); case ModelPackage.MBRICKLET_COLOR__UID: return UID_EDEFAULT == null ? uid != null : !UID_EDEFAULT.equals(uid); case ModelPackage.MBRICKLET_COLOR__POLL: return poll != POLL_EDEFAULT; case ModelPackage.MBRICKLET_COLOR__ENABLED_A: return ENABLED_A_EDEFAULT == null ? enabledA != null : !ENABLED_A_EDEFAULT.equals(enabledA); case ModelPackage.MBRICKLET_COLOR__TINKERFORGE_DEVICE: return tinkerforgeDevice != null; case ModelPackage.MBRICKLET_COLOR__IP_CONNECTION: return IP_CONNECTION_EDEFAULT == null ? ipConnection != null : !IP_CONNECTION_EDEFAULT.equals(ipConnection); case ModelPackage.MBRICKLET_COLOR__CONNECTED_UID: return CONNECTED_UID_EDEFAULT == null ? connectedUid != null : !CONNECTED_UID_EDEFAULT.equals(connectedUid); case ModelPackage.MBRICKLET_COLOR__POSITION: return position != POSITION_EDEFAULT; case ModelPackage.MBRICKLET_COLOR__DEVICE_IDENTIFIER: return deviceIdentifier != DEVICE_IDENTIFIER_EDEFAULT; case ModelPackage.MBRICKLET_COLOR__NAME: return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name); case ModelPackage.MBRICKLET_COLOR__BRICKD: return basicGetBrickd() != null; case ModelPackage.MBRICKLET_COLOR__MSUBDEVICES: return msubdevices != null && !msubdevices.isEmpty(); case ModelPackage.MBRICKLET_COLOR__TF_CONFIG: return tfConfig != null; case ModelPackage.MBRICKLET_COLOR__DEVICE_TYPE: return DEVICE_TYPE_EDEFAULT == null ? deviceType != null : !DEVICE_TYPE_EDEFAULT.equals(deviceType); case ModelPackage.MBRICKLET_COLOR__GAIN: return GAIN_EDEFAULT == null ? gain != null : !GAIN_EDEFAULT.equals(gain); case ModelPackage.MBRICKLET_COLOR__INTEGRATION_TIME: return INTEGRATION_TIME_EDEFAULT == null ? integrationTime != null : !INTEGRATION_TIME_EDEFAULT.equals(integrationTime); } return super.eIsSet(featureID); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated */ @Override public int eBaseStructuralFeatureID(int derivedFeatureID, Class<?> baseClass) { if (baseClass == MSubDeviceHolder.class) { switch (derivedFeatureID) { case ModelPackage.MBRICKLET_COLOR__MSUBDEVICES: return ModelPackage.MSUB_DEVICE_HOLDER__MSUBDEVICES; default: return -1; } } if (baseClass == MTFConfigConsumer.class) { switch (derivedFeatureID) { case ModelPackage.MBRICKLET_COLOR__TF_CONFIG: return ModelPackage.MTF_CONFIG_CONSUMER__TF_CONFIG; default: return -1; } } return super.eBaseStructuralFeatureID(derivedFeatureID, baseClass); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated */ @Override public int eDerivedStructuralFeatureID(int baseFeatureID, Class<?> baseClass) { if (baseClass == MSubDeviceHolder.class) { switch (baseFeatureID) { case ModelPackage.MSUB_DEVICE_HOLDER__MSUBDEVICES: return ModelPackage.MBRICKLET_COLOR__MSUBDEVICES; default: return -1; } } if (baseClass == MTFConfigConsumer.class) { switch (baseFeatureID) { case ModelPackage.MTF_CONFIG_CONSUMER__TF_CONFIG: return ModelPackage.MBRICKLET_COLOR__TF_CONFIG; default: return -1; } } return super.eDerivedStructuralFeatureID(baseFeatureID, baseClass); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated */ @Override public int eDerivedOperationID(int baseOperationID, Class<?> baseClass) { if (baseClass == MSubDeviceHolder.class) { switch (baseOperationID) { case ModelPackage.MSUB_DEVICE_HOLDER___INIT_SUB_DEVICES: return ModelPackage.MBRICKLET_COLOR___INIT_SUB_DEVICES; default: return -1; } } if (baseClass == MTFConfigConsumer.class) { switch (baseOperationID) { default: return -1; } } return super.eDerivedOperationID(baseOperationID, baseClass); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated */ @Override public Object eInvoke(int operationID, EList<?> arguments) throws InvocationTargetException { switch (operationID) { case ModelPackage.MBRICKLET_COLOR___INIT_SUB_DEVICES: initSubDevices(); return null; case ModelPackage.MBRICKLET_COLOR___INIT: init(); return null; case ModelPackage.MBRICKLET_COLOR___ENABLE: enable(); return null; case ModelPackage.MBRICKLET_COLOR___DISABLE: disable(); return null; } return super.eInvoke(operationID, arguments); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated */ @Override public String toString() { if (eIsProxy()) return super.toString(); StringBuffer result = new StringBuffer(super.toString()); result.append(" (logger: "); result.append(logger); result.append(", uid: "); result.append(uid); result.append(", poll: "); result.append(poll); result.append(", enabledA: "); result.append(enabledA); result.append(", tinkerforgeDevice: "); result.append(tinkerforgeDevice); result.append(", ipConnection: "); result.append(ipConnection); result.append(", connectedUid: "); result.append(connectedUid); result.append(", position: "); result.append(position); result.append(", deviceIdentifier: "); result.append(deviceIdentifier); result.append(", name: "); result.append(name); result.append(", deviceType: "); result.append(deviceType); result.append(", gain: "); result.append(gain); result.append(", integrationTime: "); result.append(integrationTime); result.append(')'); return result.toString(); } } // MBrickletColorImpl