use of org.openhab.binding.tinkerforge.internal.model.MSubDeviceHolder in project openhab1-addons by openhab.
the class MBrickdImpl method addDevice.
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated NOT
*/
@SuppressWarnings("unchecked")
private void addDevice(String uid, String connectedUid, int deviceIdentifier) {
logger.debug("{} addDevice called for uid: {}", LoggerConstants.TFINIT, uid);
if (getDevice(uid) != null) {
logger.debug("{} device already exists. uid: {}", LoggerConstants.TFINIT, uid);
} else {
ModelFactory factory = ModelFactory.eINSTANCE;
MDevice<?> mDevice = null;
if (deviceIdentifier == BrickletTemperature.DEVICE_IDENTIFIER) {
logger.debug("{} addDevice temperature", LoggerConstants.TFINIT);
mDevice = factory.createMBrickletTemperature();
mDevice.setDeviceIdentifier(BrickletTemperature.DEVICE_IDENTIFIER);
} else if (deviceIdentifier == BrickletHumidity.DEVICE_IDENTIFIER) {
logger.debug("{} addDevice humidity", LoggerConstants.TFINIT);
mDevice = factory.createMBrickletHumidity();
mDevice.setDeviceIdentifier(BrickletHumidity.DEVICE_IDENTIFIER);
} else if (deviceIdentifier == BrickServo.DEVICE_IDENTIFIER) {
logger.debug("{} addDevice BrickServo", LoggerConstants.TFINIT);
mDevice = factory.createMBrickServo();
mDevice.setDeviceIdentifier(BrickServo.DEVICE_IDENTIFIER);
} else if (deviceIdentifier == BrickletDualRelay.DEVICE_IDENTIFIER) {
logger.debug("{} addDevice BrickletDualRelayBricklet", LoggerConstants.TFINIT);
mDevice = factory.createMDualRelayBricklet();
mDevice.setDeviceIdentifier(BrickletDualRelay.DEVICE_IDENTIFIER);
} else if (deviceIdentifier == BrickletIndustrialQuadRelay.DEVICE_IDENTIFIER) {
logger.debug("{} addDevice BrickletIndustrialQuadRelayBricklet", LoggerConstants.TFINIT);
mDevice = factory.createMIndustrialQuadRelayBricklet();
mDevice.setDeviceIdentifier(BrickletIndustrialQuadRelay.DEVICE_IDENTIFIER);
} else if (deviceIdentifier == BrickletBarometer.DEVICE_IDENTIFIER) {
logger.debug("{} addDevice BrickletBarometer", LoggerConstants.TFINIT);
mDevice = factory.createMBrickletBarometer();
mDevice.setDeviceIdentifier(BrickletBarometer.DEVICE_IDENTIFIER);
} else if (deviceIdentifier == BrickletAmbientLight.DEVICE_IDENTIFIER) {
logger.debug("{} addDevice AmbientLight", LoggerConstants.TFINIT);
mDevice = factory.createMBrickletAmbientLight();
mDevice.setDeviceIdentifier(BrickletAmbientLight.DEVICE_IDENTIFIER);
} else if (deviceIdentifier == BrickletAmbientLightV2.DEVICE_IDENTIFIER) {
logger.debug("{} addDevice AmbientLighV2", LoggerConstants.TFINIT);
mDevice = factory.createMBrickletAmbientLightV2();
mDevice.setDeviceIdentifier(BrickletAmbientLightV2.DEVICE_IDENTIFIER);
} else if (deviceIdentifier == BrickletDistanceIR.DEVICE_IDENTIFIER) {
logger.debug("{} addDevice DistanceIR", LoggerConstants.TFINIT);
mDevice = factory.createMBrickletDistanceIR();
mDevice.setDeviceIdentifier(BrickletDistanceIR.DEVICE_IDENTIFIER);
} else if (deviceIdentifier == BrickDC.DEVICE_IDENTIFIER) {
logger.debug("{} addDevice BrickDC", LoggerConstants.TFINIT);
mDevice = factory.createMBrickDC();
mDevice.setDeviceIdentifier(BrickDC.DEVICE_IDENTIFIER);
} else if (deviceIdentifier == BrickletLCD20x4.DEVICE_IDENTIFIER) {
logger.debug("addDevice BrickletLCD20x4");
mDevice = factory.createMBrickletLCD20x4();
mDevice.setDeviceIdentifier(BrickletLCD20x4.DEVICE_IDENTIFIER);
} else if (deviceIdentifier == BrickletIndustrialDigitalIn4.DEVICE_IDENTIFIER) {
logger.debug("addDevice BrickletIndustrialDigitalIn4");
mDevice = factory.createMBrickletIndustrialDigitalIn4();
mDevice.setDeviceIdentifier(BrickletIndustrialDigitalIn4.DEVICE_IDENTIFIER);
} else if (deviceIdentifier == BrickletIO16.DEVICE_IDENTIFIER) {
logger.debug("addDevice BrickletIO16");
mDevice = factory.createMBrickletIO16();
mDevice.setDeviceIdentifier(BrickletIO16.DEVICE_IDENTIFIER);
} else if (deviceIdentifier == BrickletRemoteSwitch.DEVICE_IDENTIFIER) {
logger.debug("addDevice BrickletRemoteSwitch");
mDevice = factory.createMBrickletRemoteSwitch();
mDevice.setDeviceIdentifier(BrickletRemoteSwitch.DEVICE_IDENTIFIER);
} else if (deviceIdentifier == BrickletMotionDetector.DEVICE_IDENTIFIER) {
logger.debug("addDevice BrickletMotionDetector");
mDevice = factory.createMBrickletMotionDetector();
mDevice.setDeviceIdentifier(BrickletMotionDetector.DEVICE_IDENTIFIER);
} else if (deviceIdentifier == BrickletMultiTouch.DEVICE_IDENTIFIER) {
logger.debug("addDevice BrickletMultiTouch");
mDevice = factory.createMBrickletMultiTouch();
mDevice.setDeviceIdentifier(BrickletMultiTouch.DEVICE_IDENTIFIER);
} else if (deviceIdentifier == BrickletTemperatureIR.DEVICE_IDENTIFIER) {
logger.debug("addDevice BrickletTemperatureIR");
mDevice = factory.createMBrickletTemperatureIR();
mDevice.setDeviceIdentifier(BrickletTemperatureIR.DEVICE_IDENTIFIER);
} else if (deviceIdentifier == BrickletSoundIntensity.DEVICE_IDENTIFIER) {
logger.debug("addDevice BrickletSoundIntensity");
mDevice = factory.createMBrickletSoundIntensity();
mDevice.setDeviceIdentifier(BrickletSoundIntensity.DEVICE_IDENTIFIER);
} else if (deviceIdentifier == BrickletMoisture.DEVICE_IDENTIFIER) {
logger.debug("addDevice BrickletMoisture");
mDevice = factory.createMBrickletMoisture();
mDevice.setDeviceIdentifier(BrickletMoisture.DEVICE_IDENTIFIER);
} else if (deviceIdentifier == BrickletDistanceUS.DEVICE_IDENTIFIER) {
logger.debug("addDevice BrickletDistanceUS");
mDevice = factory.createMBrickletDistanceUS();
mDevice.setDeviceIdentifier(BrickletDistanceUS.DEVICE_IDENTIFIER);
} else if (deviceIdentifier == BrickletVoltageCurrent.DEVICE_IDENTIFIER) {
logger.debug("addDevice BrickletVoltageCurrent");
mDevice = factory.createMBrickletVoltageCurrent();
mDevice.setDeviceIdentifier(BrickletVoltageCurrent.DEVICE_IDENTIFIER);
} else if (deviceIdentifier == BrickletTilt.DEVICE_IDENTIFIER) {
logger.debug("addDevice BrickletTilt");
mDevice = factory.createMBrickletTilt();
mDevice.setDeviceIdentifier(BrickletTilt.DEVICE_IDENTIFIER);
} else if (deviceIdentifier == BrickletIO4.DEVICE_IDENTIFIER) {
logger.debug("addDevice BrickletIO4");
mDevice = factory.createMBrickletIO4();
mDevice.setDeviceIdentifier(BrickletIO4.DEVICE_IDENTIFIER);
} else if (deviceIdentifier == BrickletHallEffect.DEVICE_IDENTIFIER) {
logger.debug("addDevice BrickletHallEffect");
mDevice = factory.createMBrickletHallEffect();
mDevice.setDeviceIdentifier(BrickletHallEffect.DEVICE_IDENTIFIER);
} else if (deviceIdentifier == BrickletIndustrialDigitalOut4.DEVICE_IDENTIFIER) {
logger.debug("addDevice BrickletIndustrilaDigitalOut4");
mDevice = factory.createMBrickletIndustrialDigitalOut4();
mDevice.setDeviceIdentifier(BrickletIndustrialDigitalOut4.DEVICE_IDENTIFIER);
} else if (deviceIdentifier == BrickletSegmentDisplay4x7.DEVICE_IDENTIFIER) {
logger.debug("addDevice BrickletSegmentDisplay4x7");
mDevice = factory.createMBrickletSegmentDisplay4x7();
mDevice.setDeviceIdentifier(BrickletSegmentDisplay4x7.DEVICE_IDENTIFIER);
} else if (deviceIdentifier == BrickletLEDStrip.DEVICE_IDENTIFIER) {
logger.debug("addDevice BrickletLEDStrip");
mDevice = factory.createMBrickletLEDStrip();
mDevice.setDeviceIdentifier(BrickletLEDStrip.DEVICE_IDENTIFIER);
} else if (deviceIdentifier == BrickletJoystick.DEVICE_IDENTIFIER) {
logger.debug("addDevice BrickletJoystick");
mDevice = factory.createMBrickletJoystick();
mDevice.setDeviceIdentifier(BrickletJoystick.DEVICE_IDENTIFIER);
} else if (deviceIdentifier == BrickletLinearPoti.DEVICE_IDENTIFIER) {
logger.debug("addDevice BrickletLinearPoti");
mDevice = factory.createMBrickletLinearPoti();
mDevice.setDeviceIdentifier(BrickletLinearPoti.DEVICE_IDENTIFIER);
} else if (deviceIdentifier == BrickletDualButton.DEVICE_IDENTIFIER) {
logger.debug("addDevice BrickletDualButton");
mDevice = factory.createMBrickletDualButton();
mDevice.setDeviceIdentifier(BrickletDualButton.DEVICE_IDENTIFIER);
} else if (deviceIdentifier == BrickletPTC.DEVICE_IDENTIFIER) {
logger.debug("addDevice BrickletPTC");
mDevice = factory.createMBrickletPTC();
mDevice.setDeviceIdentifier(BrickletPTC.DEVICE_IDENTIFIER);
} else if (deviceIdentifier == BrickletIndustrialDual020mA.DEVICE_IDENTIFIER) {
logger.debug("addDevice BrickletIndustrialDual020mA");
mDevice = factory.createMBrickletIndustrialDual020mA();
mDevice.setDeviceIdentifier(BrickletIndustrialDual020mA.DEVICE_IDENTIFIER);
} else if (deviceIdentifier == BrickletSolidStateRelay.DEVICE_IDENTIFIER) {
logger.debug("addDevice BrickletSolidStateRelay");
mDevice = factory.createMBrickletSolidStateRelay();
mDevice.setDeviceIdentifier(BrickletSolidStateRelay.DEVICE_IDENTIFIER);
} else if (deviceIdentifier == BrickletPiezoSpeaker.DEVICE_IDENTIFIER) {
logger.debug("addDevice BrickletPiezoSpeaker");
mDevice = factory.createMBrickletPiezoSpeaker();
mDevice.setDeviceIdentifier(BrickletPiezoSpeaker.DEVICE_IDENTIFIER);
} else if (deviceIdentifier == BrickletRotaryEncoder.DEVICE_IDENTIFIER) {
logger.debug("addDevice BrickletRotaryEncoder");
mDevice = factory.createMBrickletRotaryEncoder();
mDevice.setDeviceIdentifier(BrickletRotaryEncoder.DEVICE_IDENTIFIER);
} else if (deviceIdentifier == BrickletDustDetector.DEVICE_IDENTIFIER) {
logger.debug("addDevice BrickletDustDetector");
mDevice = factory.createMBrickletDustDetector();
mDevice.setDeviceIdentifier(BrickletDustDetector.DEVICE_IDENTIFIER);
} else if (deviceIdentifier == BrickletLoadCell.DEVICE_IDENTIFIER) {
logger.debug("addDevice BrickletLoadCell");
mDevice = factory.createMBrickletLoadCell();
mDevice.setDeviceIdentifier(BrickletLoadCell.DEVICE_IDENTIFIER);
} else if (deviceIdentifier == BrickletColor.DEVICE_IDENTIFIER) {
logger.debug("addDevice BrickletColor");
mDevice = factory.createMBrickletColor();
mDevice.setDeviceIdentifier(BrickletColor.DEVICE_IDENTIFIER);
} else if (deviceIdentifier == BrickletIndustrialDualAnalogIn.DEVICE_IDENTIFIER) {
logger.debug("addDevice BrickletIndustrialDualAnalogIn");
mDevice = factory.createMBrickletIndustrialDualAnalogIn();
mDevice.setDeviceIdentifier(BrickletIndustrialDualAnalogIn.DEVICE_IDENTIFIER);
} else if (deviceIdentifier == BrickletAnalogIn.DEVICE_IDENTIFIER) {
logger.debug("addDevice BrickletAnalogIn");
mDevice = factory.createMBrickletAnalogIn();
mDevice.setDeviceIdentifier(BrickletAnalogIn.DEVICE_IDENTIFIER);
} else if (deviceIdentifier == BrickletAnalogInV2.DEVICE_IDENTIFIER) {
logger.debug("addDevice BrickletAnalogInV2");
mDevice = factory.createMBrickletAnalogInV2();
mDevice.setDeviceIdentifier(BrickletAnalogInV2.DEVICE_IDENTIFIER);
} else if (deviceIdentifier == BrickletLaserRangeFinder.DEVICE_IDENTIFIER) {
logger.debug("addDevice BrickletLaserRangeFinder");
mDevice = factory.createMBrickletLaserRangeFinder();
mDevice.setDeviceIdentifier(BrickletLaserRangeFinder.DEVICE_IDENTIFIER);
} else if (deviceIdentifier == BrickletAccelerometer.DEVICE_IDENTIFIER) {
logger.debug("addDevice BrickletAccelerometer");
mDevice = factory.createMBrickletAccelerometer();
mDevice.setDeviceIdentifier(BrickletAccelerometer.DEVICE_IDENTIFIER);
} else if (deviceIdentifier == BrickletOLED128x64.DEVICE_IDENTIFIER) {
logger.debug("addDevice BrickletOLED128x64");
mDevice = factory.createMBrickletOLED128x64();
mDevice.setDeviceIdentifier(BrickletOLED128x64.DEVICE_IDENTIFIER);
} else if (deviceIdentifier == BrickletOLED64x48.DEVICE_IDENTIFIER) {
logger.debug("addDevice BrickletOLED64x48");
mDevice = factory.createMBrickletOLE64x48();
mDevice.setDeviceIdentifier(BrickletOLED64x48.DEVICE_IDENTIFIER);
} else if (deviceIdentifier == BrickletThermocouple.DEVICE_IDENTIFIER) {
logger.debug("addDevice BrickletThermocouple");
mDevice = factory.createMBrickletThermocouple();
mDevice.setDeviceIdentifier(BrickletThermocouple.DEVICE_IDENTIFIER);
} else if (deviceIdentifier == BrickletUVLight.DEVICE_IDENTIFIER) {
logger.debug("addDevice BrickletUVLight");
mDevice = factory.createMBrickletUVLight();
mDevice.setDeviceIdentifier(BrickletUVLight.DEVICE_IDENTIFIER);
} else if (deviceIdentifier == BrickletCO2.DEVICE_IDENTIFIER) {
logger.debug("addDevice BrickletCO2");
mDevice = factory.createMBrickletCO2();
mDevice.setDeviceIdentifier(BrickletCO2.DEVICE_IDENTIFIER);
} else if (deviceIdentifier == BrickletAnalogOutV2.DEVICE_IDENTIFIER) {
logger.debug("addDevice BrickletAnalogOutV2");
mDevice = factory.createMBrickletAnalogOutV2();
mDevice.setDeviceIdentifier(BrickletAnalogOutV2.DEVICE_IDENTIFIER);
}
if (mDevice != null) {
mDevice.setIpConnection(getIpConnection());
logger.debug("{} addDevice uid: {}", LoggerConstants.TFINIT, uid);
mDevice.setUid(uid);
mDevice.setConnectedUid(connectedUid);
mDevice.init();
// be aware this triggers the notifier
mDevice.setBrickd(this);
if (mDevice instanceof MSubDeviceHolder) {
logger.debug("{} initSubDevices uid: {}", LoggerConstants.TFINIT, uid);
((MSubDeviceHolder<MSubDevice<?>>) mDevice).initSubDevices();
}
}
}
}
use of org.openhab.binding.tinkerforge.internal.model.MSubDeviceHolder 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());
}
}
use of org.openhab.binding.tinkerforge.internal.model.MSubDeviceHolder 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