• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java VehicleServiceException类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.openxc.remote.VehicleServiceException的典型用法代码示例。如果您正苦于以下问题:Java VehicleServiceException类的具体用法?Java VehicleServiceException怎么用?Java VehicleServiceException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



VehicleServiceException类属于com.openxc.remote包,在下文中一共展示了VehicleServiceException类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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");
    }
}
 
开发者ID:bibhrajit,项目名称:openxc-androidStudio,代码行数:40,代码来源:VehicleManager.java


示例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);
        }
    }
}
 
开发者ID:bibhrajit,项目名称:openxc-androidStudio,代码行数:21,代码来源:BluetoothPreferenceManager.java


示例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) {
                }
            }
        }
    };
}
 
开发者ID:bibhrajit,项目名称:openxc-androidStudio,代码行数:24,代码来源:VehicleInterfacePreferenceManager.java


示例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);
            }
        });
    }
}
 
开发者ID:bibhrajit,项目名称:openxc-androidStudio,代码行数:18,代码来源:MessageCountTask.java


示例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");
}
 
开发者ID:bibhrajit,项目名称:openxc-androidStudio,代码行数:11,代码来源:VehicleManagerTest.java


示例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);
}
 
开发者ID:bibhrajit,项目名称:openxc-androidStudio,代码行数:9,代码来源:VehicleManagerTest.java


示例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);
}
 
开发者ID:bibhrajit,项目名称:openxc-androidStudio,代码行数:13,代码来源:VehicleManagerTest.java


示例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);
}
 
开发者ID:bibhrajit,项目名称:openxc-androidStudio,代码行数:13,代码来源:VehicleManagerTest.java


示例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);
}
 
开发者ID:bibhrajit,项目名称:openxc-androidStudio,代码行数:13,代码来源:VehicleManagerTest.java


示例10: testRemoveWithoutListening

import com.openxc.remote.VehicleServiceException; //导入依赖的package包/类
@MediumTest
public void testRemoveWithoutListening()
        throws VehicleServiceException,
        UnrecognizedMeasurementTypeException {
    prepareServices();
    service.removeListener(VehicleSpeed.class, speedListener);
}
 
开发者ID:bibhrajit,项目名称:openxc-androidStudio,代码行数:8,代码来源:VehicleManagerTest.java


示例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);
}
 
开发者ID:bibhrajit,项目名称:openxc-androidStudio,代码行数:15,代码来源:VehicleManagerTest.java


示例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);
}
 
开发者ID:bibhrajit,项目名称:openxc-androidStudio,代码行数:13,代码来源:VehicleManagerTest.java


示例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());
    }
}
 
开发者ID:bibhrajit,项目名称:openxc-androidStudio,代码行数:11,代码来源:VehicleManagerTest.java


示例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.
}
 
开发者ID:bibhrajit,项目名称:openxc-androidStudio,代码行数:13,代码来源:VehicleManagerTest.java


示例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)));
}
 
开发者ID:bibhrajit,项目名称:openxc-androidStudio,代码行数:14,代码来源:VehicleManagerTest.java


示例16: testSetBluetoothPollingStatus

import com.openxc.remote.VehicleServiceException; //导入依赖的package包/类
@MediumTest
public void testSetBluetoothPollingStatus()
        throws VehicleServiceException {
    prepareServices();
    service.setVehicleInterface(BluetoothVehicleInterface.class,
            "00:01:02:03:04:05");
    service.setBluetoothPollingStatus(true);
    service.setBluetoothPollingStatus(false);
    // Nothing much we can assert becuase we can't easily check in on the
    // classes being instantiated in the remote service
}
 
开发者ID:bibhrajit,项目名称:openxc-androidStudio,代码行数:12,代码来源:VehicleManagerTest.java


示例17: testGetMessageCount

import com.openxc.remote.VehicleServiceException; //导入依赖的package包/类
@MediumTest
public void testGetMessageCount() throws VehicleServiceException {
    prepareServices();
    assertEquals(service.getMessageCount(), 0);
    source.inject("foo", 42.0);
    assertEquals(service.getMessageCount(), 1);
}
 
开发者ID:bibhrajit,项目名称:openxc-androidStudio,代码行数:8,代码来源:VehicleManagerTest.java


示例18: prepareServices

import com.openxc.remote.VehicleServiceException; //导入依赖的package包/类
private void prepareServices() {
    Intent startIntent = new Intent();
    startIntent.setClass(getContext(), VehicleManager.class);
    service = ((VehicleManager.VehicleBinder)
            bindService(startIntent)).getService();
    service.waitUntilBound();
    try {
        service.setVehicleInterface(TestVehicleInterface.class);
    } catch(VehicleServiceException e) { }
}
 
开发者ID:bibhrajit,项目名称:openxc-androidStudio,代码行数:11,代码来源:VehicleInterfaceTests.java


示例19: addOnVehicleInterfaceConnectedListener

import com.openxc.remote.VehicleServiceException; //导入依赖的package包/类
/**
 * Register a listener to receive a callback when the selected VI is
 * connected.
 *
 * @param listener The listener that should receive the callback.
 */
public void addOnVehicleInterfaceConnectedListener(
        ViConnectionListener listener) throws VehicleServiceException {
    if(mRemoteService != null) {
        try {
            mRemoteService.addViConnectionListener(listener);
        } catch(RemoteException e) {
            throw new VehicleServiceException(
                    "Unable to add connection status listener", e);
        }
    }
}
 
开发者ID:bibhrajit,项目名称:openxc-androidStudio,代码行数:18,代码来源:VehicleManager.java


示例20: getMessageCount

import com.openxc.remote.VehicleServiceException; //导入依赖的package包/类
/**
 * Read the number of messages received by the vehicle service.
 *
 * @throws VehicleServiceException if the listener is unable to be
 *      unregistered with the library internals - an exceptional situation
 *      that shouldn't occur.
 */
public int getMessageCount() throws VehicleServiceException {
    if(mRemoteService != null) {
        try {
            return mRemoteService.getMessageCount();
        } catch(RemoteException e) {
            throw new VehicleServiceException(
                    "Unable to retrieve message count", e);
        }
    } else {
        throw new VehicleServiceException(
                "Unable to retrieve message count");
    }
}
 
开发者ID:bibhrajit,项目名称:openxc-androidStudio,代码行数:21,代码来源:VehicleManager.java



注:本文中的com.openxc.remote.VehicleServiceException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Attribute类代码示例发布时间:2022-05-23
下一篇:
Java TimeStatistic类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap