Search in sources :

Example 6 with MBrickd

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

the class TinkerforgeBinding method connectBrickd.

/**
     * Searches for a brickd with the given {@code host} and {@code port} in the Ecosystem. If there
     * is no brickd found a new Brickd object is created, added to the Ecosystem an the IpConnection
     * to the Tinkerforge brickd is established and a device enumeration is triggert.
     *
     * @param host The host name or ip address of the TinkerForge brickd as String.
     * @param port The port of the TinkerForge brickd as int.
     * @param authkey
     */
private void connectBrickd(String host, int port, String authkey) {
    MBrickd brickd = tinkerforgeEcosystem.getBrickd(host, port);
    if (brickd == null) {
        brickd = modelFactory.createMBrickd();
        brickd.setHost(host);
        brickd.setPort(port);
        brickd.setAuthkey(authkey);
        brickd.setEcosystem(tinkerforgeEcosystem);
        tinkerforgeEcosystem.getMbrickds().add(brickd);
        brickd.init();
        brickd.connect();
        logger.debug("{} Tinkerforge new brickd for host: {}", LoggerConstants.TFINIT, host);
    } else {
        logger.debug("{} Tinkerforge found existing brickd for host: {}", LoggerConstants.TFINIT, host);
    }
}
Also used : MBrickd(org.openhab.binding.tinkerforge.internal.model.MBrickd)

Example 7 with MBrickd

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

the class MBrickletOLE64x48Impl method setBrickd.

/**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     *
     * @generated
     */
@Override
public void setBrickd(MBrickd newBrickd) {
    if (newBrickd != eInternalContainer() || (eContainerFeatureID() != ModelPackage.MBRICKLET_OLE6_4X48__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_OLE6_4X48__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 8 with MBrickd

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

the class MBrickletOLED128x64Impl method setBrickd.

/**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     *
     * @generated
     */
@Override
public void setBrickd(MBrickd newBrickd) {
    if (newBrickd != eInternalContainer() || (eContainerFeatureID() != ModelPackage.MBRICKLET_OLED12_8X64__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_OLED12_8X64__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 9 with MBrickd

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

the class EcosystemImpl method getDevices4GenericId.

/**
     * <!-- begin-user-doc --> <!-- end-user-doc -->
     * 
     * @generated NOT
     */
@Override
public EList<MSubDevice<?>> getDevices4GenericId(String uid, String genericId) {
    EList<MSubDevice<?>> genericDevicesList = new BasicEList<MSubDevice<?>>();
    EList<MBrickd> _mbrickds = getMbrickds();
    for (final MBrickd mbrickd : _mbrickds) {
        {
            final MBaseDevice mDevice = mbrickd.getDevice(uid);
            if (mDevice != null) {
                if (mDevice instanceof MSubDeviceHolder) {
                    final MSubDeviceHolder<?> mBrick = ((MSubDeviceHolder<?>) mDevice);
                    EList<?> _msubdevices = mBrick.getMsubdevices();
                    for (final Object mg : _msubdevices) {
                        if (mg instanceof GenericDevice) {
                            final GenericDevice mgenericdevice = ((GenericDevice) mg);
                            String _genericId = mgenericdevice.getGenericDeviceId();
                            if (_genericId.equals(genericId)) {
                                genericDevicesList.add(((MSubDevice<?>) mgenericdevice));
                            }
                        }
                    }
                }
            }
        }
    }
    return genericDevicesList;
}
Also used : MSubDeviceHolder(org.openhab.binding.tinkerforge.internal.model.MSubDeviceHolder) BasicEList(org.eclipse.emf.common.util.BasicEList) EObjectContainmentWithInverseEList(org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList) EList(org.eclipse.emf.common.util.EList) InternalEList(org.eclipse.emf.ecore.util.InternalEList) GenericDevice(org.openhab.binding.tinkerforge.internal.model.GenericDevice) BasicEList(org.eclipse.emf.common.util.BasicEList) MBrickd(org.openhab.binding.tinkerforge.internal.model.MBrickd) MBaseDevice(org.openhab.binding.tinkerforge.internal.model.MBaseDevice) MSubDevice(org.openhab.binding.tinkerforge.internal.model.MSubDevice) InternalEObject(org.eclipse.emf.ecore.InternalEObject)

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