use of com.tinkerforge.BrickDC in project openhab1-addons by openhab.
the class MBrickDCImpl method setTinkerforgeDevice.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
@Override
public void setTinkerforgeDevice(BrickDC newTinkerforgeDevice) {
BrickDC oldTinkerforgeDevice = tinkerforgeDevice;
tinkerforgeDevice = newTinkerforgeDevice;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, ModelPackage.MBRICK_DC__TINKERFORGE_DEVICE, oldTinkerforgeDevice, tinkerforgeDevice));
}
use of com.tinkerforge.BrickDC in project openhab1-addons by openhab.
the class MBrickDCImpl method enable.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated NOT
*/
@Override
public void enable() {
tinkerforgeDevice = new BrickDC(uid, ipConnection);
if (tfConfig != null) {
logger.debug("found tfConfig");
if (tfConfig.eIsSet(tfConfig.eClass().getEStructuralFeature("acceleration"))) {
setAcceleration(tfConfig.getAcceleration());
}
if (tfConfig.eIsSet(tfConfig.eClass().getEStructuralFeature("pwmFrequency"))) {
setPwmFrequency(tfConfig.getPwmFrequency());
}
if (tfConfig.eIsSet(tfConfig.eClass().getEStructuralFeature("driveMode"))) {
setDriveMode(DCDriveMode.get(tfConfig.getDriveMode()));
}
if (tfConfig.eIsSet(tfConfig.eClass().getEStructuralFeature("threshold"))) {
setThreshold(tfConfig.getThreshold());
}
if (tfConfig.eIsSet(tfConfig.eClass().getEStructuralFeature("callbackPeriod"))) {
setCallbackPeriod(tfConfig.getCallbackPeriod());
}
}
try {
tinkerforgeDevice.setPWMFrequency(pwmFrequency);
if (driveMode == DCDriveMode.BRAKE) {
tinkerforgeDevice.setDriveMode(BrickDC.DRIVE_MODE_DRIVE_BRAKE);
} else if (driveMode == DCDriveMode.COAST) {
tinkerforgeDevice.setDriveMode(BrickDC.DRIVE_MODE_DRIVE_COAST);
}
tinkerforgeDevice.setCurrentVelocityPeriod((int) callbackPeriod);
listener = new VelocityListener();
tinkerforgeDevice.addCurrentVelocityListener(listener);
tinkerforgeDevice.enable();
handleVelocity(tinkerforgeDevice.getVelocity(), false);
} catch (TimeoutException e) {
TinkerforgeErrorHandler.handleError(this, TinkerforgeErrorHandler.TF_TIMEOUT_EXCEPTION, e);
} catch (NotConnectedException e) {
TinkerforgeErrorHandler.handleError(this, TinkerforgeErrorHandler.TF_NOT_CONNECTION_EXCEPTION, e);
}
}
Aggregations