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);
}
}
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));
}
}
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));
}
}
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;
}
Aggregations