当前位置: 首页>>代码示例>>Java>>正文


Java Measurement类代码示例

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


Measurement类属于com.openxc.measurements包,在下文中一共展示了Measurement类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onServiceConnected

import com.openxc.measurements.Measurement; //导入依赖的package包/类
public void
        onServiceConnected(ComponentName className, IBinder service) {
    Log.i(TAG, "Bound to VehicleManager");
    mVehicleManager = ((VehicleManager.VehicleBinder) service)
            .getService();

    mIsBound = true;

    Integer gridPosition = getIntent().getExtras().getInt("pos");
    Class<? extends Measurement> measurementType = GridManager
            .getClass(gridPosition);
    mUpdateGraphTask = new GraphDataRetrieveTask(mVehicleManager,
            GrapherActivity.this, dataSeries, measurementType);
    mTimer = new Timer();
    mTimer.schedule(mUpdateGraphTask, 100, 1000);
}
 
开发者ID:openxc,项目名称:diagnostic-tool,代码行数:17,代码来源:GrapherActivity.java

示例2: receive

import com.openxc.measurements.Measurement; //导入依赖的package包/类
public void receive(Measurement measurement) {
    final EngineSpeed updated_value = (EngineSpeed) measurement;
    mEngineSpeed = updated_value.getValue().intValue();
    MainActivity.this.runOnUiThread(new Runnable() {
        public void run() {
            mEngineSpeedView.setText("" + mEngineSpeed);
        }
    });

    // Only calculate the vehicle state if the operation mode is set
    // to "Performance" OR if the efficiency shift point algorithm is
    // set to "Calculate" OR if the app is currently NOT calculating
    // the current vehicle state.
    if (mSharedPrefs.getBoolean("pref_calculation_mode", false) ||
            mSharedPrefs.getBoolean("pref_operation_mode", false) ||
            !mCalculating) {
        vehicleStateCalculation();
    }
}
 
开发者ID:openxc,项目名称:shiftknob-android,代码行数:20,代码来源:MainActivity.java

示例3: receive

import com.openxc.measurements.Measurement; //导入依赖的package包/类
public void receive(Measurement measurement) {
    final HeadlampStatus status = (HeadlampStatus) measurement;
    mHandler.post(new Runnable() {
        public void run() {
            if(status.getValue().booleanValue()) {
                if(!NightVisionActivity.isRunning()) {
                    Intent intent = new Intent(
                            VehicleMonitoringService.this,
                            NightVisionActivity.class);
                    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                    VehicleMonitoringService.this.startActivity(intent);
                }
            } else {
                sendBroadcast(new Intent(ACTION_VEHICLE_HEADLAMPS_OFF));
            }
        }
    });
}
 
开发者ID:openxc,项目名称:nightvision,代码行数:19,代码来源:VehicleMonitoringService.java

示例4: receive

import com.openxc.measurements.Measurement; //导入依赖的package包/类
@Override
public void receive(Measurement measurement) {
    // When we receive a new EngineSpeed value from the car, we want to
    // update the UI to display the new value. First we cast the generic
    // Measurement back to the type we know it to be, an EngineSpeed.
    final EngineSpeed speed = (EngineSpeed) measurement;
    // In order to modify the UI, we have to make sure the code is
    // running on the "UI thread" - Google around for this, it's an
    // important concept in Android.
    StarterActivity.this.runOnUiThread(new Runnable() {
        public void run() {
            // Finally, we've got a new value and we're running on the
            // UI thread - we set the text of the EngineSpeed view to
            // the latest value
            mEngineSpeedView.setText("Engine speed (RPM): "
                    + speed.getValue().doubleValue());
        }
    });
}
 
开发者ID:openxc,项目名称:openxc-starter,代码行数:20,代码来源:StarterActivity.java

示例5: receive

import com.openxc.measurements.Measurement; //导入依赖的package包/类
@Override
public void receive(Measurement measurement) {

    final EngineSpeed engineSpeed = (EngineSpeed) measurement;
    final float rpm = (float) engineSpeed.getValue().doubleValue();
    Log.i(TAG, "Engine Speed Simulation: " + rpm);
    mIgniteHandler.setRpmData(rpm);

    runOnUiThread(new Runnable() {
        @Override
        public void run() {
            mRpmView.speedTo(rpm, 500);
        }
    });
}
 
开发者ID:freeloki,项目名称:FordOpenXCHackathon,代码行数:16,代码来源:MainActivity.java

示例6: testConsistentAge

import com.openxc.measurements.Measurement; //导入依赖的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

示例7: register

import com.openxc.measurements.Measurement; //导入依赖的package包/类
public void register(Class<? extends Measurement> measurementType,
        Measurement.Listener listener) {
    try {
        // A bit of a hack to cache this measurement's ID field so we
        // can deserialize incoming measurements of this type. Why don't we
        // have a getId() in the Measurement interface? Ah, because it would
        // have to be static and you can't have static methods in an
        // interface. It would work if we were passed an instance of the
        // measurement in this function, but we don't really have that when
        // adding a listener.
        BaseMeasurement.getKeyForMeasurement(measurementType);
    } catch(UnrecognizedMeasurementTypeException e) { }

    mMeasurementTypeListeners.put(measurementType, listener);
}
 
开发者ID:bibhrajit,项目名称:openxc-androidStudio,代码行数:16,代码来源:MessageListenerSink.java

示例8: receive

import com.openxc.measurements.Measurement; //导入依赖的package包/类
@Override
public void receive(Measurement measurement) {
    if(measurement instanceof Latitude || measurement instanceof Longitude
            || measurement instanceof VehicleSpeed) {
        // To keep down the number of times we touch the Android location
        // system to update the location, only update if we have a change in
        // the measurements we use.
        updateLocation();
    }
}
 
开发者ID:bibhrajit,项目名称:openxc-androidStudio,代码行数:11,代码来源:VehicleLocationProvider.java

示例9: buildFromMessage

import com.openxc.measurements.Measurement; //导入依赖的package包/类
@Test
public void buildFromMessage()
        throws UnrecognizedMeasurementTypeException, NoValueException {
    VehicleSpeed measurement = new VehicleSpeed(value);
    Measurement deserializedMeasurement =
        BaseMeasurement.getMeasurementFromMessage(message);
    assertThat(deserializedMeasurement, instanceOf(VehicleSpeed.class));
    VehicleSpeed vehicleSpeed = (VehicleSpeed) deserializedMeasurement;
    assertThat(vehicleSpeed, equalTo(measurement));
}
 
开发者ID:bibhrajit,项目名称:openxc-androidStudio,代码行数:11,代码来源:BaseMeasurementTest.java

示例10: buildFromMessageWithInteger

import com.openxc.measurements.Measurement; //导入依赖的package包/类
@Test
public void buildFromMessageWithInteger()
        throws UnrecognizedMeasurementTypeException, NoValueException {
    message = new SimpleVehicleMessage(VehicleSpeed.ID, Integer.valueOf(42));
    VehicleSpeed measurement = new VehicleSpeed(value);
    Measurement deserializedMeasurement =
        BaseMeasurement.getMeasurementFromMessage(message);
    assertThat(deserializedMeasurement, instanceOf(VehicleSpeed.class));
    VehicleSpeed vehicleSpeed = (VehicleSpeed) deserializedMeasurement;
    assertThat(vehicleSpeed, equalTo(measurement));
}
 
开发者ID:bibhrajit,项目名称:openxc-androidStudio,代码行数:12,代码来源:BaseMeasurementTest.java

示例11: buildEventedFromMessage

import com.openxc.measurements.Measurement; //导入依赖的package包/类
@Test
public void buildEventedFromMessage()
        throws UnrecognizedMeasurementTypeException, NoValueException {
    VehicleDoorStatus measurement = new VehicleDoorStatus("driver", false);
    VehicleMessage eventedMessage = measurement.toVehicleMessage();
    Measurement deserializedMeasurement =
        BaseMeasurement.getMeasurementFromMessage(
                eventedMessage.asSimpleMessage());
    assertThat(deserializedMeasurement, instanceOf(VehicleDoorStatus.class));
    VehicleDoorStatus doorStatus = (VehicleDoorStatus) deserializedMeasurement;
    assertThat(doorStatus, equalTo(measurement));
}
 
开发者ID:bibhrajit,项目名称:openxc-androidStudio,代码行数:13,代码来源:BaseMeasurementTest.java

示例12: GraphDataRetrieveTask

import com.openxc.measurements.Measurement; //导入依赖的package包/类
public GraphDataRetrieveTask(VehicleManager vehicleService, Activity act,
        GraphViewSeries series, Class<? extends Measurement> measurementType) {
    mVehicleManager = vehicleService;
    mGraphSeries = series;
    mMeasurementType = measurementType;
    mActivity = act;
}
 
开发者ID:openxc,项目名称:diagnostic-tool,代码行数:8,代码来源:GraphDataRetrieveTask.java

示例13: receive

import com.openxc.measurements.Measurement; //导入依赖的package包/类
public void receive(Measurement measurement) {
    final WindshieldWiperStatus wiperStatus =
        (WindshieldWiperStatus) measurement;
    mHandler.post(new Runnable() {
        public void run() {
            mWiperStatusView.setText(wiperStatus.toString());
        }
    });
}
 
开发者ID:openxc,项目名称:diagnostic-tool,代码行数:10,代码来源:DashboardActivity.java

示例14: receive

import com.openxc.measurements.Measurement; //导入依赖的package包/类
public void receive(Measurement measurement) {
	final VehicleSpeed _speed = (VehicleSpeed) measurement;
   	final double speed = _speed.getValue().doubleValue() * 0.621371; //we need to convert km/h to mph
   	if(speed != last_speed) {
     PixelOpenXC.this.runOnUiThread(new Runnable() {
         public void run() {
         	String speedString = String.format("%.1f", speed);	
         	 mVehicleSpeedView.setText("Vehicle speed (mph): " + speedString);
         }
     });
        last_speed = speed;
   	}
}
 
开发者ID:openxc,项目名称:pixel-openxc-android,代码行数:14,代码来源:PixelOpenXC.java

示例15: receive

import com.openxc.measurements.Measurement; //导入依赖的package包/类
public void receive(Measurement measurement) {
    final TransmissionGearPosition status =
            (TransmissionGearPosition) measurement;

    mHandler.post(new Runnable() {
        public void run() {
            if(status.getValue().enumValue() ==
                    TransmissionGearPosition.GearPosition.REVERSE &&
                    !RearviewCameraActivity.isRunning()){
                startRearviewCameraActivity();
            } else if(status.getValue().enumValue() !=
                    TransmissionGearPosition.GearPosition.REVERSE &&
                    RearviewCameraActivity.isRunning()) {
                sendVehicleUnreversedBroadcast();
            }
        }

        private void startRearviewCameraActivity() {
            Intent intent = new Intent(
                    VehicleMonitoringService.this,
                    RearviewCameraActivity.class);
            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            VehicleMonitoringService.this.startActivity(intent);
        }

        private void sendVehicleUnreversedBroadcast() {
            Intent unreversedIntent = new Intent(
                    ACTION_VEHICLE_UNREVERSED);
            sendBroadcast(unreversedIntent);
        }
    });
}
 
开发者ID:openxc,项目名称:rearview-camera,代码行数:33,代码来源:VehicleMonitoringService.java


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