本文整理汇总了Java中com.tinkerforge.BrickMaster类的典型用法代码示例。如果您正苦于以下问题:Java BrickMaster类的具体用法?Java BrickMaster怎么用?Java BrickMaster使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BrickMaster类属于com.tinkerforge包,在下文中一共展示了BrickMaster类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import com.tinkerforge.BrickMaster; //导入依赖的package包/类
public static void main(String args[]) throws Exception {
IPConnection ipcon = new IPConnection(); // Create IP connection
BrickMaster master = new BrickMaster(UID, ipcon); // Create device object
ipcon.connect(host, port); // Connect to brickd
// Don't use device before ipcon is connected
// Get voltage and current from stack (in mV/mA)
int voltage = master.getStackVoltage();
int current = master.getStackCurrent();
System.out.println("Stack Voltage: " + voltage/1000.0 + " V");
System.out.println("Stack Current: " + current/1000.0 + " A");
System.console().readLine("Press key to exit\n");
ipcon.disconnect();
}
示例2: stackCurrent
import com.tinkerforge.BrickMaster; //导入依赖的package包/类
@Override
public void stackCurrent(int current) {
LOG.trace("stackCurrent()");
Exchange exchange = null;
try {
exchange = createExchange();
// ADD HEADER
exchange.getIn().setHeader("fireBy", BrickMaster.CALLBACK_STACK_CURRENT);
exchange.getIn().setHeader("current", current);
// ADD BODY
exchange.getIn().setBody("stack_current");;
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: stackVoltage
import com.tinkerforge.BrickMaster; //导入依赖的package包/类
@Override
public void stackVoltage(int voltage) {
LOG.trace("stackVoltage()");
Exchange exchange = null;
try {
exchange = createExchange();
// ADD HEADER
exchange.getIn().setHeader("fireBy", BrickMaster.CALLBACK_STACK_VOLTAGE);
exchange.getIn().setHeader("voltage", voltage);
// ADD BODY
exchange.getIn().setBody("stack_voltage");;
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: usbVoltage
import com.tinkerforge.BrickMaster; //导入依赖的package包/类
@Override
public void usbVoltage(int voltage) {
LOG.trace("usbVoltage()");
Exchange exchange = null;
try {
exchange = createExchange();
// ADD HEADER
exchange.getIn().setHeader("fireBy", BrickMaster.CALLBACK_USB_VOLTAGE);
exchange.getIn().setHeader("voltage", voltage);
// ADD BODY
exchange.getIn().setBody("usb_voltage");;
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());
}
}
}
示例5: stackCurrentReached
import com.tinkerforge.BrickMaster; //导入依赖的package包/类
@Override
public void stackCurrentReached(int current) {
LOG.trace("stackCurrentReached()");
Exchange exchange = null;
try {
exchange = createExchange();
// ADD HEADER
exchange.getIn().setHeader("fireBy", BrickMaster.CALLBACK_STACK_CURRENT_REACHED);
exchange.getIn().setHeader("current", current);
// ADD BODY
exchange.getIn().setBody("stack_current_reached");;
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());
}
}
}
示例6: stackVoltageReached
import com.tinkerforge.BrickMaster; //导入依赖的package包/类
@Override
public void stackVoltageReached(int voltage) {
LOG.trace("stackVoltageReached()");
Exchange exchange = null;
try {
exchange = createExchange();
// ADD HEADER
exchange.getIn().setHeader("fireBy", BrickMaster.CALLBACK_STACK_VOLTAGE_REACHED);
exchange.getIn().setHeader("voltage", voltage);
// ADD BODY
exchange.getIn().setBody("stack_voltage_reached");;
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());
}
}
}
示例7: usbVoltageReached
import com.tinkerforge.BrickMaster; //导入依赖的package包/类
@Override
public void usbVoltageReached(int voltage) {
LOG.trace("usbVoltageReached()");
Exchange exchange = null;
try {
exchange = createExchange();
// ADD HEADER
exchange.getIn().setHeader("fireBy", BrickMaster.CALLBACK_USB_VOLTAGE_REACHED);
exchange.getIn().setHeader("voltage", voltage);
// ADD BODY
exchange.getIn().setBody("usb_voltage_reached");;
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());
}
}
}
示例8: deviceConnected
import com.tinkerforge.BrickMaster; //导入依赖的package包/类
@Override
public void deviceConnected(final TinkerforgeStackAgent satckAgent,
final Device device) {
if (TinkerforgeDevice.getDevice(device) == TinkerforgeDevice.Master) {
try {
final BrickMaster master = ((BrickMaster) device);
if (master.isWifiPresent()) {
master.setWifiPowerMode(BrickMaster.WIFI_POWER_MODE_LOW_POWER);
}
} catch (final Exception e) {
e.printStackTrace();
}
}
}
示例9: deviceDisconnected
import com.tinkerforge.BrickMaster; //导入依赖的package包/类
@Override
public void deviceDisconnected(
final TinkerforgeStackAgent tinkerforgeStackAgent,
final Device device) {
if (device instanceof BrickMaster) {
this.masterDisconnect((BrickMaster) device);
}
}
示例10: deviceConnected
import com.tinkerforge.BrickMaster; //导入依赖的package包/类
@Override
public void deviceConnected(final TinkerforgeStackAgent satckAgent,
final Device device) {
if (device instanceof BrickMaster) {
this.masterConnect((BrickMaster) device);
}
}
示例11: deviceConnected
import com.tinkerforge.BrickMaster; //导入依赖的package包/类
@Override
public void deviceConnected(
final TinkerforgeStackAgent tinkerforgeStackAgent,
final Device device) {
System.out.println("Device connected: "
+ TinkerforgeDevice.toString(device));
if (device instanceof BrickMaster) {
BrickMaster master = (BrickMaster) device;
this.masterConnect(master);
System.out.println(master);
}
}
示例12: deviceDisconnected
import com.tinkerforge.BrickMaster; //导入依赖的package包/类
@Override
public void deviceDisconnected(
final TinkerforgeStackAgent tinkerforgeStackAgent,
final Device device) {
if (device instanceof BrickMaster) {
this.masterDisconnect((BrickMaster) device);
}
}
示例13: deviceConnected
import com.tinkerforge.BrickMaster; //导入依赖的package包/类
@Override
public void deviceConnected(
final TinkerforgeStackAgent tinkerforgeStackAgent,
final Device device) {
if (device instanceof BrickMaster) {
this.masterConnect((BrickMaster) device);
}
}
示例14: deviceDisconnected
import com.tinkerforge.BrickMaster; //导入依赖的package包/类
@Override
public void deviceDisconnected(
final TinkerforgeStackAgent tinkerforgeStackAgent,
final Device device) {
System.out.println("Disconnection of device: " + device);
if (device instanceof BrickMaster) {
this.masterDisconnect((BrickMaster) device);
}
if (device instanceof BrickletMotionDetector) {
this.motionDetectorDisconnect((BrickletMotionDetector) device);
}
}
示例15: deviceConnected
import com.tinkerforge.BrickMaster; //导入依赖的package包/类
@Override
public void deviceConnected(
final TinkerforgeStackAgent tinkerforgeStackAgent,
final Device device) {
System.out.println("Connection of device: " + device);
if (device instanceof BrickMaster) {
this.masterConnect((BrickMaster) device);
}
if (device instanceof BrickletMotionDetector) {
this.motionDetectionConnect((BrickletMotionDetector) device);
}
}