本文整理汇总了Java中com.openxc.remote.VehicleServiceException类的典型用法代码示例。如果您正苦于以下问题:Java VehicleServiceException类的具体用法?Java VehicleServiceException怎么用?Java VehicleServiceException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
VehicleServiceException类属于com.openxc.remote包,在下文中一共展示了VehicleServiceException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setVehicleInterface
import com.openxc.remote.VehicleServiceException; //导入依赖的package包/类
/**
* Change the active vehicle interface to a new type using the given
* resource.
*
* To disable all vehicle interfaces, pass null to this function.
*
* The only valid VehicleInteface types are those included with the library
* - the vehicle service running in a remote process is the one to actually
* instantiate the interfaces. Interfaces added with this method will be
* available for all other OpenXC applications running in the system.
*
* @param vehicleInterfaceType A class implementing VehicleInterface that is
* included in the OpenXC library
* @param resource A descriptor or a resource necessary to initialize the
* interface. See the specific implementation of {@link VehicleService}
* to find the required format of this parameter.
*/
public void setVehicleInterface(
Class<? extends VehicleInterface> vehicleInterfaceType,
String resource) throws VehicleServiceException {
Log.i(TAG, "Setting VI to: " + vehicleInterfaceType);
String interfaceName = null;
if(vehicleInterfaceType != null) {
interfaceName = vehicleInterfaceType.getName();
}
if(mRemoteService != null) {
try {
mRemoteService.setVehicleInterface(interfaceName, resource);
} catch(RemoteException e) {
throw new VehicleServiceException(
"Unable to set vehicle interface", e);
}
} else {
Log.w(TAG, "Can't set vehicle interface, not connected to the " +
"VehicleService");
}
}
示例2: setBluetoothStatus
import com.openxc.remote.VehicleServiceException; //导入依赖的package包/类
private synchronized void setBluetoothStatus(boolean enabled) {
if(enabled) {
Log.i(TAG, "Enabling the Bluetooth vehicle interface");
String deviceAddress = getPreferenceString(
R.string.bluetooth_mac_key);
if(deviceAddress == null || deviceAddress.equals(
getString(R.string.bluetooth_mac_automatic_option))) {
deviceAddress = null;
Log.d(TAG, "No Bluetooth vehicle interface selected -- " +
"starting in automatic mode");
}
try {
getVehicleManager().setVehicleInterface(
BluetoothVehicleInterface.class, deviceAddress);
} catch(VehicleServiceException e) {
Log.e(TAG, "Unable to start Bluetooth interface", e);
}
}
}
示例3: createPreferenceListener
import com.openxc.remote.VehicleServiceException; //导入依赖的package包/类
protected PreferenceListener createPreferenceListener() {
return new PreferenceListener() {
private int[] WATCHED_PREFERENCE_KEY_IDS = {
R.string.vehicle_interface_key
};
protected int[] getWatchedPreferenceKeyIds() {
return WATCHED_PREFERENCE_KEY_IDS;
}
public void readStoredPreferences() {
String selectedVi = getPreferences().getString(
getString(R.string.vehicle_interface_key), "");
if(selectedVi.equals(getString(
R.string.disabled_interface_option_value))) {
try {
getVehicleManager().setVehicleInterface(null);
} catch(VehicleServiceException e) {
}
}
}
};
}
示例4: run
import com.openxc.remote.VehicleServiceException; //导入依赖的package包/类
public void run() {
int messageCount;
try {
messageCount = mVehicleManager.getMessageCount();
} catch(VehicleServiceException e) {
messageCount = 0;
}
final String messageText = Integer.toString(messageCount);
if(mActivity != null) {
mActivity.runOnUiThread(new Runnable() {
public void run() {
mMessageCountView.setText(messageText);
}
});
}
}
示例5: testListenForMessage
import com.openxc.remote.VehicleServiceException; //导入依赖的package包/类
@MediumTest
public void testListenForMessage() throws VehicleServiceException,
UnrecognizedMeasurementTypeException {
prepareServices();
service.addListener(new NamedVehicleMessage("foo").getKey(),
messageListener);
source.inject("foo", 42.0);
assertNotNull(messageReceived);
assertEquals(messageReceived.asNamedMessage().getName(), "foo");
}
示例6: testListenForMeasurement
import com.openxc.remote.VehicleServiceException; //导入依赖的package包/类
@MediumTest
public void testListenForMeasurement() throws VehicleServiceException,
UnrecognizedMeasurementTypeException {
prepareServices();
service.addListener(VehicleSpeed.class, speedListener);
source.inject(VehicleSpeed.ID, 42.0);
assertNotNull(speedReceived);
}
示例7: testAddListenersTwoMeasurements
import com.openxc.remote.VehicleServiceException; //导入依赖的package包/类
@MediumTest
public void testAddListenersTwoMeasurements()
throws VehicleServiceException,
UnrecognizedMeasurementTypeException {
prepareServices();
service.addListener(VehicleSpeed.class, speedListener);
service.addListener(SteeringWheelAngle.class, steeringWheelListener);
source.inject(VehicleSpeed.ID, 42.0);
source.inject(SteeringWheelAngle.ID, 12.1);
assertNotNull(steeringAngleReceived);
assertNotNull(speedReceived);
}
示例8: testRemoveMessageListener
import com.openxc.remote.VehicleServiceException; //导入依赖的package包/类
@MediumTest
public void testRemoveMessageListener() throws VehicleServiceException,
UnrecognizedMeasurementTypeException {
prepareServices();
MessageKey key = new NamedVehicleMessage("foo").getKey();
service.addListener(key, messageListener);
source.inject("foo", 42.0);
messageReceived = null;
service.removeListener(key, messageListener);
source.inject("foo", 42.0);
assertNull(messageReceived);
}
示例9: testRemoveMeasurementListener
import com.openxc.remote.VehicleServiceException; //导入依赖的package包/类
@MediumTest
public void testRemoveMeasurementListener() throws VehicleServiceException,
UnrecognizedMeasurementTypeException {
prepareServices();
service.addListener(VehicleSpeed.class, speedListener);
source.inject(VehicleSpeed.ID, 42.0);
service.removeListener(VehicleSpeed.class, speedListener);
speedReceived = null;
source.inject(VehicleSpeed.ID, 42.0);
TestUtils.pause(10);
assertNull(speedReceived);
}
示例10: testRemoveWithoutListening
import com.openxc.remote.VehicleServiceException; //导入依赖的package包/类
@MediumTest
public void testRemoveWithoutListening()
throws VehicleServiceException,
UnrecognizedMeasurementTypeException {
prepareServices();
service.removeListener(VehicleSpeed.class, speedListener);
}
示例11: testRemoveOneMeasurementListener
import com.openxc.remote.VehicleServiceException; //导入依赖的package包/类
@MediumTest
public void testRemoveOneMeasurementListener()
throws VehicleServiceException,
UnrecognizedMeasurementTypeException {
prepareServices();
service.addListener(VehicleSpeed.class, speedListener);
service.addListener(SteeringWheelAngle.class, steeringWheelListener);
source.inject(VehicleSpeed.ID, 42.0);
service.removeListener(VehicleSpeed.class, speedListener);
speedReceived = null;
source.inject(VehicleSpeed.ID, 42.0);
TestUtils.pause(10);
assertNull(speedReceived);
}
示例12: testConsistentAge
import com.openxc.remote.VehicleServiceException; //导入依赖的package包/类
@MediumTest
public void testConsistentAge()
throws UnrecognizedMeasurementTypeException,
NoValueException, VehicleServiceException, DataSourceException {
prepareServices();
source.inject(VehicleSpeed.ID, 42.0);
TestUtils.pause(1);
Measurement measurement = service.get(VehicleSpeed.class);
long age = measurement.getAge();
assertTrue("Measurement age (" + age + ") should be > 5ms",
age > 5);
}
示例13: testUsbInterfaceNotEnabledByDefault
import com.openxc.remote.VehicleServiceException; //导入依赖的package包/类
@MediumTest
public void testUsbInterfaceNotEnabledByDefault()
throws VehicleServiceException {
prepareServices();
// When testing on a 2.3.x emulator, no USB available.
if(android.os.Build.VERSION.SDK_INT >=
android.os.Build.VERSION_CODES.HONEYCOMB) {
assertThat(service.getActiveVehicleInterface(), nullValue());
}
}
示例14: testSetVehicleInterfaceByClass
import com.openxc.remote.VehicleServiceException; //导入依赖的package包/类
@MediumTest
public void testSetVehicleInterfaceByClass() throws VehicleServiceException {
prepareServices();
service.setVehicleInterface(NetworkVehicleInterface.class,
"localhost:8080");
assertEquals(service.getActiveVehicleInterface().getInterfaceClass(),
NetworkVehicleInterface.class);
// Not a whole lot we can test without an actual device attached and
// without being able to mock the interface class out in the remote
// process where the VehicleSevice runs, but at least we know this
// method didn't explode.
}
示例15: testSetBluetoothVehicleInterface
import com.openxc.remote.VehicleServiceException; //导入依赖的package包/类
@MediumTest
public void testSetBluetoothVehicleInterface()
throws VehicleServiceException {
prepareServices();
service.setVehicleInterface(BluetoothVehicleInterface.class,
"00:01:02:03:04:05");
// If the running on an emulator it will report that it doesn't have a
// Bluetooth adapter, and we will be unable to construct the
// BluetoothVehicleInterface interface.
// assertThat(service.getActiveSources(),
// hasItem(new VehicleInterfaceDescriptor(
// BluetoothVehicleInterface.class, false)));
}