/** * Convert a Measurement to a SimpleVehicleMessage and send it through the * active VehicleInterface. * * @param message The desired message to send to the vehicle. * @return true if the message was sent successfully on an interface. */ public boolean send(Measurement message) { return send(message.toVehicleMessage()); }
@Override public View getView(int position, View convertView, ViewGroup parent) { if(convertView == null) { convertView = LayoutInflater.from(mContext) .inflate(R.layout.dashboard_list_item, parent, false); } SimpleVehicleMessage message = getItem(position); TextView nameView = (TextView) convertView.findViewById(R.id.name); TextView valueView = (TextView) convertView.findViewById(R.id.value); try { Measurement measurement = BaseMeasurement.getMeasurementFromMessage(message); nameView.setText("" + measurement.getName(mContext)); valueView.setText("" + measurement.toString()); } catch(UnrecognizedMeasurementTypeException e) { nameView.setText("" + message.getName()); valueView.setText("" + message.getValue()); } catch(NoValueException e) { } return convertView; }
measurement.setTimestamp(simpleMessage.getTimestamp());
private void checkDeserializeSerialize(Measurement measurement) throws UnrecognizedMeasurementTypeException, NoValueException { SimpleVehicleMessage message = measurement.toVehicleMessage(); Measurement deserializedMeasurement = BaseMeasurement.getMeasurementFromMessage(message); assertThat(deserializedMeasurement, instanceOf(measurement.getClass())); assertThat(deserializedMeasurement, equalTo(measurement)); }