Search in sources :

Example 1 with MBrickd

use of org.openhab.binding.tinkerforge.internal.model.MBrickd in project openhab1-addons by openhab.

the class MBrickStepperImpl method setBrickd.

/**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     *
     * @generated
     */
@Override
public void setBrickd(MBrickd newBrickd) {
    if (newBrickd != eInternalContainer() || (eContainerFeatureID() != ModelPackage.MBRICK_STEPPER__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.MBRICK_STEPPER__BRICKD, newBrickd, newBrickd));
    }
}
Also used : NotificationChain(org.eclipse.emf.common.notify.NotificationChain) ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl) MBrickd(org.openhab.binding.tinkerforge.internal.model.MBrickd)

Example 2 with MBrickd

use of org.openhab.binding.tinkerforge.internal.model.MBrickd in project openhab1-addons by openhab.

the class MBrickletThermocoupleImpl method setBrickd.

/**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     *
     * @generated
     */
@Override
public void setBrickd(MBrickd newBrickd) {
    if (newBrickd != eInternalContainer() || (eContainerFeatureID() != ModelPackage.MBRICKLET_THERMOCOUPLE__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_THERMOCOUPLE__BRICKD, newBrickd, newBrickd));
    }
}
Also used : NotificationChain(org.eclipse.emf.common.notify.NotificationChain) ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl) MBrickd(org.openhab.binding.tinkerforge.internal.model.MBrickd)

Example 3 with MBrickd

use of org.openhab.binding.tinkerforge.internal.model.MBrickd in project openhab1-addons by openhab.

the class MBrickletUVLightImpl method setBrickd.

/**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     *
     * @generated
     */
@Override
public void setBrickd(MBrickd newBrickd) {
    if (newBrickd != eInternalContainer() || (eContainerFeatureID() != ModelPackage.MBRICKLET_UV_LIGHT__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_UV_LIGHT__BRICKD, newBrickd, newBrickd));
    }
}
Also used : NotificationChain(org.eclipse.emf.common.notify.NotificationChain) ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl) MBrickd(org.openhab.binding.tinkerforge.internal.model.MBrickd)

Example 4 with MBrickd

use of org.openhab.binding.tinkerforge.internal.model.MBrickd in project openhab1-addons by openhab.

the class TinkerforgeBinding method initializeTFDevices.

/**
     * Adds or removes a device to / from the Ecosystem. Notifications from {@link MBrickd} are used
     * for adding devices (not sub devices) and removing of devices and their corresponding sub
     * devices.
     *
     * Notifications from {@link MSubDeviceHolder} for adding sub devices.
     *
     * @param notification The {@link Notification} for add and remove events to the {@link Ecosystem}
     *            .
     */
private void initializeTFDevices(Notification notification) {
    logger.trace("{} notifier {}", LoggerConstants.TFINIT, notification.getNotifier());
    if (notification.getNotifier() instanceof MBrickd) {
        logger.debug("{} notifier is Brickd", LoggerConstants.TFINIT);
        int featureID = notification.getFeatureID(MBrickd.class);
        if (featureID == ModelPackage.MBRICKD__MDEVICES) {
            if (notification.getEventType() == Notification.ADD) {
                MDevice<?> mDevice = (MDevice<?>) notification.getNewValue();
                addMDevice(mDevice, mDevice.getUid(), null);
            } else if (notification.getEventType() == Notification.ADD_MANY) {
                logger.debug("{} Notifier: add many called: ", LoggerConstants.TFINIT);
            } else if (notification.getEventType() == Notification.REMOVE) {
                logger.debug("{} Notifier: remove called: ", LoggerConstants.TFINIT);
                if (notification.getOldValue() instanceof MBaseDevice) {
                    logger.debug("{} Notifier: remove called for MBaseDevice", LoggerConstants.TFINIT);
                    MBaseDevice mDevice = (MBaseDevice) notification.getOldValue();
                    String uid = mDevice.getUid();
                    String subId = null;
                    if (searchConfiguredItemName(uid, subId) != null) {
                        logger.debug("{} Notifier: removing device: uid {} subid {}", LoggerConstants.TFINIT, uid, subId);
                        postUpdate(uid, subId, UnDefValue.UNDEF);
                    }
                } else {
                    logger.debug("{} unknown notification from mdevices {}", LoggerConstants.TFINIT, notification);
                }
            }
        } else {
            logger.debug("{} Notifier: unknown feature {}", LoggerConstants.TFINIT, notification.getFeature());
        }
    } else if (notification.getNotifier() instanceof MSubDeviceHolder<?>) {
        int featureID = notification.getFeatureID(MSubDeviceHolder.class);
        if (featureID == ModelPackage.MSUB_DEVICE_HOLDER__MSUBDEVICES) {
            logger.debug("{} MSubdevices Notifier called", LoggerConstants.TFINITSUB);
            if (notification.getEventType() == Notification.ADD) {
                MSubDevice<?> mSubDevice = (MSubDevice<?>) notification.getNewValue();
                addMDevice(mSubDevice, mSubDevice.getUid(), mSubDevice.getSubId());
            }
            if (notification.getEventType() == Notification.REMOVE) {
                logger.debug("{} remove notification from subdeviceholder", LoggerConstants.TFINIT);
                logger.debug("{} Notifier: remove called for MSubDevice", LoggerConstants.TFINIT);
                MSubDevice<?> mDevice = (MSubDevice<?>) notification.getOldValue();
                String uid = mDevice.getUid();
                String subId = mDevice.getSubId();
                if (searchConfiguredItemName(uid, subId) != null) {
                    logger.debug("{} Notifier: removing device: uid {} subid {}", LoggerConstants.TFINIT, uid, subId);
                    postUpdate(uid, subId, UnDefValue.UNDEF);
                }
            }
        }
    } else {
        logger.debug("{} unhandled notifier {}", LoggerConstants.TFINIT, notification.getNotifier());
    }
}
Also used : MSubDeviceHolder(org.openhab.binding.tinkerforge.internal.model.MSubDeviceHolder) MBrickd(org.openhab.binding.tinkerforge.internal.model.MBrickd) MBaseDevice(org.openhab.binding.tinkerforge.internal.model.MBaseDevice) MSubDevice(org.openhab.binding.tinkerforge.internal.model.MSubDevice) MDevice(org.openhab.binding.tinkerforge.internal.model.MDevice)

Example 5 with MBrickd

use of org.openhab.binding.tinkerforge.internal.model.MBrickd in project openhab1-addons by openhab.

the class TinkerforgeBinding method processTFDeviceValues.

/**
     * Processes change events from the {@link Ecosystem}. Sensor values from {@link MSensor} are
     * handled by {@link #processSensorValue(MSensor, Notification) processSensorValue}, actor values
     * from {@link MSwitchActore} are handled by
     * {@link #processSwitchActorValue(MSwitchActor, Notification) processSwitchActorValue}. (no add
     * or remove events, these are handled in {@link #initializeTFDevices(Notification)
     * initializeTFDevices}).
     *
     *
     * @param notification The {@link Notification} about changes to the {@link Ecosystem}.
     */
private void processTFDeviceValues(Notification notification) {
    if (notification.getNotifier() instanceof MSensor) {
        MSensor<?> sensor = (MSensor<?>) notification.getNotifier();
        int featureID = notification.getFeatureID(MSensor.class);
        if (featureID == ModelPackage.MSENSOR__SENSOR_VALUE) {
            processValue((MBaseDevice) sensor, notification);
        }
    } else if (notification.getNotifier() instanceof SetPointActor<?>) {
        SetPointActor<?> actor = (SetPointActor<?>) notification.getNotifier();
        int setpointFeatureID = notification.getFeatureID(SetPointActor.class);
        if (setpointFeatureID == ModelPackage.SET_POINT_ACTOR__PERCENT_VALUE) {
            processValue((MBaseDevice) actor, notification);
        }
    } else if (notification.getNotifier() instanceof MoveActor) {
        MoveActor actor = (MoveActor) notification.getNotifier();
        int moveFeatureID = notification.getFeatureID(MoveActor.class);
        if (moveFeatureID == ModelPackage.MOVE_ACTOR__DIRECTION) {
            processValue((MBaseDevice) actor, notification);
        }
    } else if (notification.getNotifier() instanceof MSwitchActor) {
        MSwitchActor switchActor = (MSwitchActor) notification.getNotifier();
        int featureID = notification.getFeatureID(MSwitchActor.class);
        if (featureID == ModelPackage.MSWITCH_ACTOR__SWITCH_STATE) {
            processValue((MBaseDevice) switchActor, notification);
        }
    } else if (notification.getNotifier() instanceof ProgrammableSwitchActor) {
        logger.trace("notification {}", notification);
        logger.trace("notifier {}", notification.getNotifier());
        ProgrammableSwitchActor switchActor = (ProgrammableSwitchActor) notification.getNotifier();
        // use the super type class for getting the featureID. Should not be necessary according to
        // the docs or I misunderstand it. But this approach works.
        int featureID = notification.getFeatureID(SwitchSensor.class);
        logger.trace("notification ProgrammableSwitchActor id {}", featureID);
        if (featureID == ModelPackage.PROGRAMMABLE_SWITCH_ACTOR__SWITCH_STATE) {
            logger.trace("ProgrammableSwitchActor switch state changed sending notification");
            processValue((MBaseDevice) switchActor, notification);
        }
    } else if (notification.getNotifier() instanceof DigitalActor) {
        DigitalActor actor = (DigitalActor) notification.getNotifier();
        int featureID = notification.getFeatureID(DigitalActor.class);
        if (featureID == ModelPackage.DIGITAL_ACTOR__DIGITAL_STATE) {
            processValue((MBaseDevice) actor, notification);
        }
    } else if (notification.getNotifier() instanceof ColorActor) {
        ColorActor actor = (ColorActor) notification.getNotifier();
        int featureID = notification.getFeatureID(ColorActor.class);
        if (featureID == ModelPackage.COLOR_ACTOR__COLOR) {
            processValue((MBaseDevice) actor, notification);
        }
    } else if (notification.getNotifier() instanceof DimmableActor<?>) {
        DimmableActor<?> actor = (DimmableActor<?>) notification.getNotifier();
        processValue((MBaseDevice) actor, notification);
    } else if (notification.getNotifier() instanceof MBrickd) {
        MBrickd brickd = (MBrickd) notification.getNotifier();
        int featureID = notification.getFeatureID(MBrickd.class);
        if (featureID == ModelPackage.MBRICKD__CONNECTED_COUNTER) {
            String subId = "connected_counter";
            processValue(brickd, notification, subId);
        } else if (featureID == ModelPackage.MBRICKD__IS_CONNECTED) {
            String subId = "isconnected";
            processValue(brickd, notification, subId);
        }
    } else // TODO hier muss noch was fuer die dimmer und rollershutter rein
    {
        logger.trace("{} ignored notifier {}", LoggerConstants.TFMODELUPDATE, notification.getNotifier());
    }
}
Also used : MSwitchActor(org.openhab.binding.tinkerforge.internal.model.MSwitchActor) MSensor(org.openhab.binding.tinkerforge.internal.model.MSensor) MBaseDevice(org.openhab.binding.tinkerforge.internal.model.MBaseDevice) MBrickd(org.openhab.binding.tinkerforge.internal.model.MBrickd) SetPointActor(org.openhab.binding.tinkerforge.internal.model.SetPointActor) ColorActor(org.openhab.binding.tinkerforge.internal.model.ColorActor) ProgrammableColorActor(org.openhab.binding.tinkerforge.internal.model.ProgrammableColorActor) SimpleColorActor(org.openhab.binding.tinkerforge.internal.model.SimpleColorActor) DigitalActor(org.openhab.binding.tinkerforge.internal.model.DigitalActor) MoveActor(org.openhab.binding.tinkerforge.internal.model.MoveActor) DimmableActor(org.openhab.binding.tinkerforge.internal.model.DimmableActor) ProgrammableSwitchActor(org.openhab.binding.tinkerforge.internal.model.ProgrammableSwitchActor)

Aggregations

MBrickd (org.openhab.binding.tinkerforge.internal.model.MBrickd)9 NotificationChain (org.eclipse.emf.common.notify.NotificationChain)5 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)5 MBaseDevice (org.openhab.binding.tinkerforge.internal.model.MBaseDevice)3 MSubDevice (org.openhab.binding.tinkerforge.internal.model.MSubDevice)2 MSubDeviceHolder (org.openhab.binding.tinkerforge.internal.model.MSubDeviceHolder)2 BasicEList (org.eclipse.emf.common.util.BasicEList)1 EList (org.eclipse.emf.common.util.EList)1 InternalEObject (org.eclipse.emf.ecore.InternalEObject)1 EObjectContainmentWithInverseEList (org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList)1 InternalEList (org.eclipse.emf.ecore.util.InternalEList)1 ColorActor (org.openhab.binding.tinkerforge.internal.model.ColorActor)1 DigitalActor (org.openhab.binding.tinkerforge.internal.model.DigitalActor)1 DimmableActor (org.openhab.binding.tinkerforge.internal.model.DimmableActor)1 GenericDevice (org.openhab.binding.tinkerforge.internal.model.GenericDevice)1 MDevice (org.openhab.binding.tinkerforge.internal.model.MDevice)1 MSensor (org.openhab.binding.tinkerforge.internal.model.MSensor)1 MSwitchActor (org.openhab.binding.tinkerforge.internal.model.MSwitchActor)1 MoveActor (org.openhab.binding.tinkerforge.internal.model.MoveActor)1 ProgrammableColorActor (org.openhab.binding.tinkerforge.internal.model.ProgrammableColorActor)1