本文整理匯總了Java中com.tinkerforge.BrickletPiezoSpeaker類的典型用法代碼示例。如果您正苦於以下問題:Java BrickletPiezoSpeaker類的具體用法?Java BrickletPiezoSpeaker怎麽用?Java BrickletPiezoSpeaker使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
BrickletPiezoSpeaker類屬於com.tinkerforge包,在下文中一共展示了BrickletPiezoSpeaker類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: PiezoSpeakerConsumer
import com.tinkerforge.BrickletPiezoSpeaker; //導入依賴的package包/類
public PiezoSpeakerConsumer(PiezoSpeakerEndpoint endpoint, Processor processor) throws Exception {
super(endpoint, processor);
device = new BrickletPiezoSpeaker(endpoint.getUid(),endpoint.getSharedConnection().getConnection());
endpoint.init(device);
if(endpoint.getCallback()==null || endpoint.getCallback().equals("")){
device.addBeepFinishedListener(this);
device.addMorseCodeFinishedListener(this);
}else{
String[] callbacks = endpoint.getCallback().split(",");
for (String callback : callbacks) {
if(callback.equals("BeepFinishedListener")) device.addBeepFinishedListener(this);
if(callback.equals("MorseCodeFinishedListener")) device.addMorseCodeFinishedListener(this);
}
}
}
示例2: beepFinished
import com.tinkerforge.BrickletPiezoSpeaker; //導入依賴的package包/類
@Override
public void beepFinished() {
LOG.trace("beepFinished()");
Exchange exchange = null;
try {
exchange = createExchange();
// ADD HEADER
exchange.getIn().setHeader("fireBy", BrickletPiezoSpeaker.CALLBACK_BEEP_FINISHED);
// ADD BODY
exchange.getIn().setBody("beep_finished");;
getProcessor().process(exchange);
} catch (Exception e) {
getExceptionHandler().handleException("Error processing exchange", exchange, e);
} finally {
if (exchange != null && exchange.getException() != null) {
getExceptionHandler().handleException("Error processing exchange", exchange, exchange.getException());
}
}
}
示例3: morseCodeFinished
import com.tinkerforge.BrickletPiezoSpeaker; //導入依賴的package包/類
@Override
public void morseCodeFinished() {
LOG.trace("morseCodeFinished()");
Exchange exchange = null;
try {
exchange = createExchange();
// ADD HEADER
exchange.getIn().setHeader("fireBy", BrickletPiezoSpeaker.CALLBACK_MORSE_CODE_FINISHED);
// ADD BODY
exchange.getIn().setBody("morse_code_finished");;
getProcessor().process(exchange);
} catch (Exception e) {
getExceptionHandler().handleException("Error processing exchange", exchange, e);
} finally {
if (exchange != null && exchange.getException() != null) {
getExceptionHandler().handleException("Error processing exchange", exchange, exchange.getException());
}
}
}
示例4: main
import com.tinkerforge.BrickletPiezoSpeaker; //導入依賴的package包/類
public static void main(String args[]) throws Exception {
IPConnection ipcon = new IPConnection(); // Create IP connection
BrickletPiezoSpeaker ps = new BrickletPiezoSpeaker(UID, ipcon); // Create device object
ipcon.connect(host, port); // Connect to brickd
// Don't use device before ipcon is connected
// Make 2 second beep with a frequency of 1kHz
ps.beep(2000, 1000);
System.console().readLine("Press key to exit\n");
}
示例5: main
import com.tinkerforge.BrickletPiezoSpeaker; //導入依賴的package包/類
public static void main(String args[]) throws Exception {
IPConnection ipcon = new IPConnection(); // Create IP connection
BrickletPiezoSpeaker ps = new BrickletPiezoSpeaker(UID, ipcon); // Create device object
ipcon.connect(host, port); // Connect to brickd
// Don't use device before ipcon is connected
// Morse SOS with a frequency of 2kHz
ps.morseCode("... --- ...", 2000);
System.console().readLine("Press key to exit\n");
}
示例6: deviceConnected
import com.tinkerforge.BrickletPiezoSpeaker; //導入依賴的package包/類
@Override
public void deviceConnected(
final TinkerforgeStackAgent tinkerforgeStackAgent,
final Device device) {
if (TinkerforgeDevice.getDevice(device) == TinkerforgeDevice.PiezoSpeaker) {
if (this.speaker == null) {
this.speaker = (BrickletPiezoSpeaker) device;
}
}
}
示例7: init
import com.tinkerforge.BrickletPiezoSpeaker; //導入依賴的package包/類
public void init(BrickletPiezoSpeaker device) throws Exception {
if(getInit()==null) return;
String[] initFunctions = getInit().split(",");
for (String function : initFunctions) {
callFunction(device, function, null, this);
}
}
示例8: callFunction
import com.tinkerforge.BrickletPiezoSpeaker; //導入依賴的package包/類
public Object callFunction(BrickletPiezoSpeaker device, String function, Message m, Endpoint e) throws Exception{
Object response = null;
switch (function) {
case "beep":
device.beep(
getValue(long.class, "duration", m, getDuration()),
getValue(int.class, "frequency", m, getFrequency())
);
break;
case "morseCode":
device.morseCode(
getValue(String.class, "morse", m, getMorse()),
getValue(int.class, "frequency2", m, getFrequency2())
);
break;
case "calibrate":
response = device.calibrate();
break;
case "getIdentity":
response = device.getIdentity();
break;
default: throw new Exception("unknown function '"+function+"'");
}
return response;
}
示例9: setTinkerforgeDevice
import com.tinkerforge.BrickletPiezoSpeaker; //導入依賴的package包/類
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
@Override
public void setTinkerforgeDevice(BrickletPiezoSpeaker newTinkerforgeDevice) {
BrickletPiezoSpeaker oldTinkerforgeDevice = tinkerforgeDevice;
tinkerforgeDevice = newTinkerforgeDevice;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET,
ModelPackage.MBRICKLET_PIEZO_SPEAKER__TINKERFORGE_DEVICE, oldTinkerforgeDevice, tinkerforgeDevice));
}
示例10: PiezoSpeakerProducer
import com.tinkerforge.BrickletPiezoSpeaker; //導入依賴的package包/類
public PiezoSpeakerProducer(PiezoSpeakerEndpoint endpoint) throws UnknownHostException, AlreadyConnectedException, IOException {
super(endpoint);
device = new BrickletPiezoSpeaker(endpoint.getUid(),endpoint.getSharedConnection().getConnection());
}
示例11: eSet
import com.tinkerforge.BrickletPiezoSpeaker; //導入依賴的package包/類
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
@Override
public void eSet(int featureID, Object newValue) {
switch (featureID) {
case ModelPackage.MBRICKLET_PIEZO_SPEAKER__LOGGER:
setLogger((Logger) newValue);
return;
case ModelPackage.MBRICKLET_PIEZO_SPEAKER__UID:
setUid((String) newValue);
return;
case ModelPackage.MBRICKLET_PIEZO_SPEAKER__POLL:
setPoll((Boolean) newValue);
return;
case ModelPackage.MBRICKLET_PIEZO_SPEAKER__ENABLED_A:
setEnabledA((AtomicBoolean) newValue);
return;
case ModelPackage.MBRICKLET_PIEZO_SPEAKER__TINKERFORGE_DEVICE:
setTinkerforgeDevice((BrickletPiezoSpeaker) newValue);
return;
case ModelPackage.MBRICKLET_PIEZO_SPEAKER__IP_CONNECTION:
setIpConnection((IPConnection) newValue);
return;
case ModelPackage.MBRICKLET_PIEZO_SPEAKER__CONNECTED_UID:
setConnectedUid((String) newValue);
return;
case ModelPackage.MBRICKLET_PIEZO_SPEAKER__POSITION:
setPosition((Character) newValue);
return;
case ModelPackage.MBRICKLET_PIEZO_SPEAKER__DEVICE_IDENTIFIER:
setDeviceIdentifier((Integer) newValue);
return;
case ModelPackage.MBRICKLET_PIEZO_SPEAKER__NAME:
setName((String) newValue);
return;
case ModelPackage.MBRICKLET_PIEZO_SPEAKER__BRICKD:
setBrickd((MBrickd) newValue);
return;
case ModelPackage.MBRICKLET_PIEZO_SPEAKER__SWITCH_STATE:
setSwitchState((OnOffValue) newValue);
return;
}
super.eSet(featureID, newValue);
}
示例12: eUnset
import com.tinkerforge.BrickletPiezoSpeaker; //導入依賴的package包/類
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case ModelPackage.MBRICKLET_PIEZO_SPEAKER__LOGGER:
setLogger(LOGGER_EDEFAULT);
return;
case ModelPackage.MBRICKLET_PIEZO_SPEAKER__UID:
setUid(UID_EDEFAULT);
return;
case ModelPackage.MBRICKLET_PIEZO_SPEAKER__POLL:
setPoll(POLL_EDEFAULT);
return;
case ModelPackage.MBRICKLET_PIEZO_SPEAKER__ENABLED_A:
setEnabledA(ENABLED_A_EDEFAULT);
return;
case ModelPackage.MBRICKLET_PIEZO_SPEAKER__TINKERFORGE_DEVICE:
setTinkerforgeDevice((BrickletPiezoSpeaker) null);
return;
case ModelPackage.MBRICKLET_PIEZO_SPEAKER__IP_CONNECTION:
setIpConnection(IP_CONNECTION_EDEFAULT);
return;
case ModelPackage.MBRICKLET_PIEZO_SPEAKER__CONNECTED_UID:
setConnectedUid(CONNECTED_UID_EDEFAULT);
return;
case ModelPackage.MBRICKLET_PIEZO_SPEAKER__POSITION:
setPosition(POSITION_EDEFAULT);
return;
case ModelPackage.MBRICKLET_PIEZO_SPEAKER__DEVICE_IDENTIFIER:
setDeviceIdentifier(DEVICE_IDENTIFIER_EDEFAULT);
return;
case ModelPackage.MBRICKLET_PIEZO_SPEAKER__NAME:
setName(NAME_EDEFAULT);
return;
case ModelPackage.MBRICKLET_PIEZO_SPEAKER__BRICKD:
setBrickd((MBrickd) null);
return;
case ModelPackage.MBRICKLET_PIEZO_SPEAKER__SWITCH_STATE:
setSwitchState(SWITCH_STATE_EDEFAULT);
return;
}
super.eUnset(featureID);
}
示例13: getTinkerforgeDevice
import com.tinkerforge.BrickletPiezoSpeaker; //導入依賴的package包/類
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
@Override
public BrickletPiezoSpeaker getTinkerforgeDevice() {
return tinkerforgeDevice;
}
示例14: enable
import com.tinkerforge.BrickletPiezoSpeaker; //導入依賴的package包/類
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated NOT
*/
@Override
public void enable() {
tinkerforgeDevice = new BrickletPiezoSpeaker(getUid(), getIpConnection());
}
示例15: createTinkerBrickletPiezoSpeakerFromString
import com.tinkerforge.BrickletPiezoSpeaker; //導入依賴的package包/類
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
public BrickletPiezoSpeaker createTinkerBrickletPiezoSpeakerFromString(EDataType eDataType, String initialValue) {
return (BrickletPiezoSpeaker) super.createFromString(eDataType, initialValue);
}