public com.openxc.BinaryMessages.VehicleMessage buildPartial() { com.openxc.BinaryMessages.VehicleMessage result = new com.openxc.BinaryMessages.VehicleMessage(this); int from_bitField0_ = bitField0_; int to_bitField0_ = 0;
.computeMessageSize(2, getCanMessage()); .computeMessageSize(3, getSimpleMessage()); .computeMessageSize(4, getDiagnosticResponse()); .computeMessageSize(5, getControlCommand()); .computeMessageSize(6, getCommandResponse());
public static final com.google.protobuf.Descriptors.EnumDescriptor getDescriptor() { return com.openxc.BinaryMessages.VehicleMessage.getDescriptor().getEnumTypes().get(0); }
throws UnrecognizedMessageTypeException { BinaryMessages.CommandResponse response = binaryMessage.getCommandResponse(); CommandType commandType; if(response.hasType()) {
throws UnrecognizedMessageTypeException { BinaryMessages.ControlCommand command = binaryMessage.getControlCommand(); CommandType commandType; if(command.hasType()) {
private static NamedVehicleMessage deserializeNamedMessage( BinaryMessages.VehicleMessage binaryMessage) throws UnrecognizedMessageTypeException { BinaryMessages.SimpleMessage simpleMessage = binaryMessage.getSimpleMessage(); String name; if(simpleMessage.hasName()) {
result = result && (hasType() == other.hasType()); if (hasType()) { result = result && type_ == other.type_; result = result && (hasCanMessage() == other.hasCanMessage()); if (hasCanMessage()) { result = result && getCanMessage() .equals(other.getCanMessage()); result = result && (hasSimpleMessage() == other.hasSimpleMessage()); if (hasSimpleMessage()) { result = result && getSimpleMessage() .equals(other.getSimpleMessage()); result = result && (hasDiagnosticResponse() == other.hasDiagnosticResponse()); if (hasDiagnosticResponse()) { result = result && getDiagnosticResponse() .equals(other.getDiagnosticResponse()); result = result && (hasControlCommand() == other.hasControlCommand()); if (hasControlCommand()) { result = result && getControlCommand() .equals(other.getControlCommand()); result = result && (hasCommandResponse() == other.hasCommandResponse()); if (hasCommandResponse()) { result = result && getCommandResponse() .equals(other.getCommandResponse());
hash = (19 * hash) + getDescriptor().hashCode(); if (hasType()) { hash = (37 * hash) + TYPE_FIELD_NUMBER; hash = (53 * hash) + type_; if (hasCanMessage()) { hash = (37 * hash) + CAN_MESSAGE_FIELD_NUMBER; hash = (53 * hash) + getCanMessage().hashCode(); if (hasSimpleMessage()) { hash = (37 * hash) + SIMPLE_MESSAGE_FIELD_NUMBER; hash = (53 * hash) + getSimpleMessage().hashCode(); if (hasDiagnosticResponse()) { hash = (37 * hash) + DIAGNOSTIC_RESPONSE_FIELD_NUMBER; hash = (53 * hash) + getDiagnosticResponse().hashCode(); if (hasControlCommand()) { hash = (37 * hash) + CONTROL_COMMAND_FIELD_NUMBER; hash = (53 * hash) + getControlCommand().hashCode(); if (hasCommandResponse()) { hash = (37 * hash) + COMMAND_RESPONSE_FIELD_NUMBER; hash = (53 * hash) + getCommandResponse().hashCode(); if (hasTimestamp()) { hash = (37 * hash) + TIMESTAMP_FIELD_NUMBER; hash = (53 * hash) + com.google.protobuf.Internal.hashLong( getTimestamp());
private static DiagnosticResponse deserializeDiagnosticResponse( BinaryMessages.VehicleMessage binaryMessage) throws UnrecognizedMessageTypeException { BinaryMessages.DiagnosticResponse serializedResponse = binaryMessage.getDiagnosticResponse(); if(!serializedResponse.hasBus() || !serializedResponse.hasMessageId() || !serializedResponse.hasMode()) { throw new UnrecognizedMessageTypeException( "Diagnostic response missing one or more required fields"); } DiagnosticResponse response = new DiagnosticResponse( serializedResponse.getBus(), serializedResponse.getMessageId(), serializedResponse.getMode()); if(serializedResponse.hasPid()) { response.setPid(serializedResponse.getPid()); } if(serializedResponse.hasPayload()) { response.setPayload(serializedResponse.getPayload().toByteArray()); } if(serializedResponse.hasNegativeResponseCode()) { response.setNegativeResponseCode( DiagnosticResponse.NegativeResponseCode.get( serializedResponse.getNegativeResponseCode())); } if(serializedResponse.hasValue()) { response.setValue(serializedResponse.getValue()); } return response; }
public static MessageLite preSerialize(VehicleMessage message) throws SerializationException { if(message.hasExtras()) { throw new SerializationException("Messages with extras cannot be " + "serialized to the binary format - use JSON instead"); } BinaryMessages.VehicleMessage.Builder builder = BinaryMessages.VehicleMessage.newBuilder(); if(message instanceof CanMessage) { serializeCanMessage(builder, (CanMessage) message); } else if(message instanceof DiagnosticResponse) { serializeDiagnosticResponse(builder, (DiagnosticResponse) message); } else if(message instanceof Command) { serializeCommand(builder, (Command) message); } else if(message instanceof CommandResponse) { serializeCommandResponse(builder, (CommandResponse) message); } else if(message instanceof EventedSimpleVehicleMessage) { serializeEventedSimpleVehicleMessage(builder, (EventedSimpleVehicleMessage) message); } else if(message instanceof SimpleVehicleMessage) { serializeSimpleVehicleMessage(builder, (SimpleVehicleMessage) message); } else if(message instanceof NamedVehicleMessage) { serializeNamedVehicleMessage(builder, (NamedVehicleMessage) message); } else { serializeGenericVehicleMessage(builder, message); } return builder.build(); }
@Test public void deserializeNoErrors() throws IOException, UnrecognizedMessageTypeException { BinaryMessages.VehicleMessage.Builder builder = BinaryMessages.VehicleMessage.newBuilder(); builder.setType(BinaryMessages.VehicleMessage.Type.SIMPLE); BinaryMessages.SimpleMessage.Builder messageBuilder = BinaryMessages.SimpleMessage.newBuilder(); messageBuilder.setName(messageName); BinaryMessages.DynamicField.Builder fieldBuilder = BinaryMessages.DynamicField.newBuilder(); fieldBuilder.setType(BinaryMessages.DynamicField.Type.NUM); fieldBuilder.setNumericValue(42); messageBuilder.setValue(fieldBuilder); builder.setSimpleMessage(messageBuilder); BinaryMessages.VehicleMessage serialized = builder.build(); ByteArrayOutputStream output = new ByteArrayOutputStream(); serialized.writeTo(output); InputStream input = new ByteArrayInputStream(output.toByteArray()); try { message = (SimpleVehicleMessage) BinaryFormatter.deserialize(input); } catch(UnrecognizedMessageTypeException e) {} assertEquals(message.getName(), messageName); assertEquals(message.getValue(), value); }
public Builder mergeFrom(com.openxc.BinaryMessages.VehicleMessage other) { if (other == com.openxc.BinaryMessages.VehicleMessage.getDefaultInstance()) return this; if (other.hasType()) { setType(other.getType()); } if (other.hasCanMessage()) { mergeCanMessage(other.getCanMessage()); } if (other.hasSimpleMessage()) { mergeSimpleMessage(other.getSimpleMessage()); } if (other.hasDiagnosticResponse()) { mergeDiagnosticResponse(other.getDiagnosticResponse()); } if (other.hasControlCommand()) { mergeControlCommand(other.getControlCommand()); } if (other.hasCommandResponse()) { mergeCommandResponse(other.getCommandResponse()); } if (other.hasTimestamp()) { setTimestamp(other.getTimestamp()); } this.mergeUnknownFields(other.unknownFields); onChanged(); return this; }
public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { if (((bitField0_ & 0x00000001) == 0x00000001)) { output.writeEnum(1, type_); } if (((bitField0_ & 0x00000002) == 0x00000002)) { output.writeMessage(2, getCanMessage()); } if (((bitField0_ & 0x00000004) == 0x00000004)) { output.writeMessage(3, getSimpleMessage()); } if (((bitField0_ & 0x00000008) == 0x00000008)) { output.writeMessage(4, getDiagnosticResponse()); } if (((bitField0_ & 0x00000010) == 0x00000010)) { output.writeMessage(5, getControlCommand()); } if (((bitField0_ & 0x00000020) == 0x00000020)) { output.writeMessage(6, getCommandResponse()); } if (((bitField0_ & 0x00000040) == 0x00000040)) { output.writeUInt64(7, timestamp_); } unknownFields.writeTo(output); }
@Test(expected=UnrecognizedMessageTypeException.class) public void deserializeWellFormedButConfusedMessage() throws IOException, UnrecognizedMessageTypeException { // Build a simple message that's missing a name BinaryMessages.VehicleMessage.Builder builder = BinaryMessages.VehicleMessage.newBuilder(); builder.setType(BinaryMessages.VehicleMessage.Type.SIMPLE); BinaryMessages.SimpleMessage.Builder messageBuilder = BinaryMessages.SimpleMessage.newBuilder(); BinaryMessages.DynamicField.Builder fieldBuilder = BinaryMessages.DynamicField.newBuilder(); fieldBuilder.setType(BinaryMessages.DynamicField.Type.NUM); fieldBuilder.setNumericValue(42); messageBuilder.setValue(fieldBuilder); builder.setSimpleMessage(messageBuilder); BinaryMessages.VehicleMessage serialized = builder.build(); ByteArrayOutputStream output = new ByteArrayOutputStream(); serialized.writeTo(output); InputStream input = new ByteArrayInputStream(output.toByteArray()); BinaryFormatter.deserialize(input); }
public Builder newBuilderForType() { return newBuilder(); } public static Builder newBuilder() {
public com.openxc.BinaryMessages.VehicleMessage getDefaultInstanceForType() { return com.openxc.BinaryMessages.VehicleMessage.getDefaultInstance(); }
private static CanMessage deserializeCanMessage( BinaryMessages.VehicleMessage binaryMessage) { BinaryMessages.CanMessage canMessage = binaryMessage.getCanMessage(); return new CanMessage(canMessage.getBus(), canMessage.getId(), canMessage.getData().toByteArray()); }