From e6025f6bcb7616bd745f36542ab95f7be9ccdaeb Mon Sep 17 00:00:00 2001 From: MaximZaitsev Date: Thu, 14 Jul 2016 12:39:06 +0300 Subject: [PATCH] maked car control client --- desktop_clients/CarCtl/build.gradle | 22 + .../CarCtl/src/main/java/CarControl.kt | 50 + desktop_clients/CarCtl/src/main/java/Main.kt | 65 + .../CarCtl/src/main/java/client/Client.kt | 35 + .../src/main/java/client/ClientHandler.kt | 51 + .../src/main/java/client/ClientInitializer.kt | 19 + .../src/main/java/proto/car/RouteP.java | 1709 +++++++++++++++++ 7 files changed, 1951 insertions(+) create mode 100644 desktop_clients/CarCtl/src/main/java/CarControl.kt create mode 100644 desktop_clients/CarCtl/src/main/java/client/Client.kt create mode 100644 desktop_clients/CarCtl/src/main/java/client/ClientHandler.kt create mode 100644 desktop_clients/CarCtl/src/main/java/client/ClientInitializer.kt create mode 100644 desktop_clients/CarCtl/src/main/java/proto/car/RouteP.java diff --git a/desktop_clients/CarCtl/build.gradle b/desktop_clients/CarCtl/build.gradle index 5b732c169ed..e37adb63a01 100644 --- a/desktop_clients/CarCtl/build.gradle +++ b/desktop_clients/CarCtl/build.gradle @@ -17,11 +17,33 @@ apply plugin: 'kotlin' sourceCompatibility = 1.5 +task getDeps(type: Copy) { + from sourceSets.main.compileClasspath + into 'build/libs' +} + +build.dependsOn getDeps + repositories { mavenCentral() } +jar { + manifest { + attributes("Implementation-Title": "Gradle", + "Implementation-Version": version, + "Class-Path": "jsap-2.1.jar kotlin-runtime-1.0.3.jar kotlin-stdlib-1.0.3.jar netty-all-4.1.2.Final.jar protobuf-java-3.0.0-beta-3.jar", + "Main-Class": "MainKt") + } + +} + dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + compile "io.netty:netty-all:4.1.2.Final" + compile "com.google.protobuf:protobuf-java:3.0.0-beta-3" + compile group: "com.martiansoftware",name:"jsap",version:"2.1" + + testCompile group: 'junit', name: 'junit', version: '4.11' } diff --git a/desktop_clients/CarCtl/src/main/java/CarControl.kt b/desktop_clients/CarCtl/src/main/java/CarControl.kt new file mode 100644 index 00000000000..fb5ee6684fa --- /dev/null +++ b/desktop_clients/CarCtl/src/main/java/CarControl.kt @@ -0,0 +1,50 @@ +import io.netty.buffer.Unpooled +import io.netty.handler.codec.http.* +import proto.car.RouteP +import proto.car.RouteP.Direction.Command + +/** + * Created by user on 7/14/16. + */ +class CarControl constructor(host: String, port: Int) { + + val host: String; + val port: Int + + init { + this.host = host; + this.port = port; + } + + + fun executeCommand(direction: Char) { + + val directionBuilder = RouteP.Direction.newBuilder() + when (direction) { + 'f' -> { + directionBuilder.setCommand(Command.forward) + } + 'b' -> { + directionBuilder.setCommand(Command.backward) + } + 'r' -> { + directionBuilder.setCommand(Command.right) + } + 'l' -> { + directionBuilder.setCommand(Command.left) + } + 's' -> { + directionBuilder.setCommand(Command.stop) + } + } + val request = DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, "/control", Unpooled.copiedBuffer(directionBuilder.build().toByteArray())); + request.headers().set(HttpHeaderNames.HOST, host) + request.headers().set(HttpHeaderNames.CONNECTION, HttpHeaderValues.CLOSE) + request.headers().setInt(HttpHeaderNames.CONTENT_LENGTH, request.content().readableBytes()) + request.headers().set(HttpHeaderNames.CONTENT_TYPE, "text/plain; charset=UTF-8") + + client.Client.sendRequest(request, host, port) + } +} + + diff --git a/desktop_clients/CarCtl/src/main/java/Main.kt b/desktop_clients/CarCtl/src/main/java/Main.kt index 87baef293df..4a38b38ac3c 100644 --- a/desktop_clients/CarCtl/src/main/java/Main.kt +++ b/desktop_clients/CarCtl/src/main/java/Main.kt @@ -1,3 +1,68 @@ +import com.martiansoftware.jsap.FlaggedOption +import com.martiansoftware.jsap.JSAP +import java.util.* + /** * Created by user on 7/14/16. */ + +val correctDirectionValues: Array = arrayOf('f', 'b', 'l', 'r', 's'); + +fun main(args: Array) { + val jsap: JSAP = JSAP() + setOptions(jsap) + val config = jsap.parse(args) + if (!config.success() || config.getBoolean("help")) { + println(jsap.getHelp()) + return + } + + val host = config.getString("host") + val port = config.getInt("port") + val direction = config.getChar("direction") + + val carControl = CarControl(host, port) + if (direction.equals('t', true)) { + initTextInterface(carControl) + } else if (correctDirectionValues.contains(direction)) { + carControl.executeCommand(direction) + } else { + println("incorrect direction.") + println(jsap.getHelp()) + } +} + +fun initTextInterface(carControl: CarControl) { + val helpMessage = "type f, b, l, r, s for command forward, backward, left, right, stop. to exit type q or quit "; + println(helpMessage) + val scanner = Scanner(System.`in`) + while (scanner.hasNext()) { + val nextLine = scanner.nextLine() + if (nextLine.equals("q", true) || nextLine.equals("quit", true)) { + return + } else if (nextLine.length != 1) { + println("incorrect argument \"$nextLine\"") + println(helpMessage) + } else { + val directionChar = nextLine.get(0) + if (!correctDirectionValues.contains(directionChar)) { + println("incorrect argument \"$nextLine\"") + println(helpMessage) + } else { + carControl.executeCommand(directionChar) + } + } + } +} + +fun setOptions(jsap: JSAP) { + val opthost = FlaggedOption("host").setStringParser(JSAP.STRING_PARSER).setRequired(true).setShortFlag('h').setLongFlag("host") + val optPort = FlaggedOption("port").setStringParser(JSAP.INTEGER_PARSER).setDefault("8888").setRequired(false).setShortFlag('p').setLongFlag("port") + val optHelp = FlaggedOption("help").setStringParser(JSAP.BOOLEAN_PARSER).setRequired(false).setDefault("false").setLongFlag("help") + val optDirection = FlaggedOption("direction").setStringParser(JSAP.CHARACTER_PARSER).setRequired(false).setDefault("t").setShortFlag('d') + optDirection.setHelp("move direction: available values - one symbol:\n\"f (forward),b (backward),l (left),r (right),s (stop)\". example: -d f\nwithout argument used default \"t\" - running text interface") + jsap.registerParameter(opthost) + jsap.registerParameter(optPort) + jsap.registerParameter(optHelp) + jsap.registerParameter(optDirection) +} diff --git a/desktop_clients/CarCtl/src/main/java/client/Client.kt b/desktop_clients/CarCtl/src/main/java/client/Client.kt new file mode 100644 index 00000000000..577d96d00b5 --- /dev/null +++ b/desktop_clients/CarCtl/src/main/java/client/Client.kt @@ -0,0 +1,35 @@ +package client + +import io.netty.bootstrap.Bootstrap +import io.netty.channel.nio.NioEventLoopGroup +import io.netty.channel.socket.nio.NioSocketChannel +import io.netty.handler.codec.http.HttpRequest +import java.net.ConnectException + +/** + * Created by user on 7/8/16. + */ +object Client { + + fun sendRequest(request: HttpRequest, host: String, port: Int): Int { + val group = NioEventLoopGroup() + try { + val bootstrap: Bootstrap = Bootstrap() + bootstrap.group(group).channel(NioSocketChannel().javaClass).handler(ClientInitializer()) + val channelFuture = bootstrap.connect(host, port).sync() + val channel = channelFuture.channel() + channel.writeAndFlush(request) + channel.closeFuture().sync() + } catch (e: InterruptedException) { + println("interrupted before request done") + return 2 + } catch (e: ConnectException) { + println("connection error to $host:$port") + return 1 + } finally { + group.shutdownGracefully() + } + return ClientHandler.requestResult.code + } + +} \ No newline at end of file diff --git a/desktop_clients/CarCtl/src/main/java/client/ClientHandler.kt b/desktop_clients/CarCtl/src/main/java/client/ClientHandler.kt new file mode 100644 index 00000000000..4d015b2e63a --- /dev/null +++ b/desktop_clients/CarCtl/src/main/java/client/ClientHandler.kt @@ -0,0 +1,51 @@ +package client + +import io.netty.channel.ChannelHandlerContext +import io.netty.channel.SimpleChannelInboundHandler +import io.netty.handler.codec.http.HttpContent + +/** + * Created by user on 7/8/16. + */ +class ClientHandler : SimpleChannelInboundHandler { + + object requestResult { + var code: Int = -1 + } + + constructor() + + var contentBytes: ByteArray = ByteArray(0); + + override fun channelReadComplete(ctx: ChannelHandlerContext) { + + var resultCode: Int = 0 +// try { +// val uploadResult: Carkot.UploadResult = Carkot.UploadResult.parseFrom(contentBytes) +// resultCode = uploadResult.resultCode +// } catch (e: InvalidProtocolBufferException) { +// e.printStackTrace() +// +// resultCode = 2 +// } + synchronized(requestResult, { + requestResult.code = resultCode + }) + ctx.close() + } + + override fun channelRead0(ctx: ChannelHandlerContext?, msg: Any?) { + if (msg is HttpContent) { + val contentsBytes = msg.content(); + contentBytes = ByteArray(contentsBytes.capacity()) + contentsBytes.readBytes(contentBytes) + } + } + + override fun exceptionCaught(ctx: ChannelHandlerContext?, cause: Throwable) { + cause.printStackTrace() + if (ctx != null) { + ctx.close() + } + } +} \ No newline at end of file diff --git a/desktop_clients/CarCtl/src/main/java/client/ClientInitializer.kt b/desktop_clients/CarCtl/src/main/java/client/ClientInitializer.kt new file mode 100644 index 00000000000..9110caba152 --- /dev/null +++ b/desktop_clients/CarCtl/src/main/java/client/ClientInitializer.kt @@ -0,0 +1,19 @@ +package client + +import io.netty.channel.ChannelInitializer +import io.netty.channel.socket.SocketChannel +import io.netty.handler.codec.http.HttpClientCodec + +/** + * Created by user on 7/8/16. + */ +class ClientInitializer : ChannelInitializer { + + constructor() + + override fun initChannel(ch: SocketChannel) { + val p = ch.pipeline() + p.addLast(HttpClientCodec()) + p.addLast(ClientHandler()) + } +} \ No newline at end of file diff --git a/desktop_clients/CarCtl/src/main/java/proto/car/RouteP.java b/desktop_clients/CarCtl/src/main/java/proto/car/RouteP.java new file mode 100644 index 00000000000..199ce4b07a3 --- /dev/null +++ b/desktop_clients/CarCtl/src/main/java/proto/car/RouteP.java @@ -0,0 +1,1709 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: route.proto + +package proto.car; + +public final class RouteP { + private RouteP() {} + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + } + public interface RouteOrBuilder extends + // @@protoc_insertion_point(interface_extends:carkot.Route) + com.google.protobuf.MessageOrBuilder { + + /** + * repeated .carkot.Route.WayPoint way_points = 1; + */ + java.util.List + getWayPointsList(); + /** + * repeated .carkot.Route.WayPoint way_points = 1; + */ + proto.car.RouteP.Route.WayPoint getWayPoints(int index); + /** + * repeated .carkot.Route.WayPoint way_points = 1; + */ + int getWayPointsCount(); + /** + * repeated .carkot.Route.WayPoint way_points = 1; + */ + java.util.List + getWayPointsOrBuilderList(); + /** + * repeated .carkot.Route.WayPoint way_points = 1; + */ + proto.car.RouteP.Route.WayPointOrBuilder getWayPointsOrBuilder( + int index); + } + /** + * Protobuf type {@code carkot.Route} + */ + public static final class Route extends + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:carkot.Route) + RouteOrBuilder { + // Use Route.newBuilder() to construct. + private Route(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + private Route() { + wayPoints_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); + } + private Route( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + int mutable_bitField0_ = 0; + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!input.skipField(tag)) { + done = true; + } + break; + } + case 10: { + if (!((mutable_bitField0_ & 0x00000001) == 0x00000001)) { + wayPoints_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000001; + } + wayPoints_.add(input.readMessage(proto.car.RouteP.Route.WayPoint.parser(), extensionRegistry)); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000001) == 0x00000001)) { + wayPoints_ = java.util.Collections.unmodifiableList(wayPoints_); + } + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return proto.car.RouteP.internal_static_carkot_Route_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return proto.car.RouteP.internal_static_carkot_Route_fieldAccessorTable + .ensureFieldAccessorsInitialized( + proto.car.RouteP.Route.class, proto.car.RouteP.Route.Builder.class); + } + + public interface WayPointOrBuilder extends + // @@protoc_insertion_point(interface_extends:carkot.Route.WayPoint) + com.google.protobuf.MessageOrBuilder { + + /** + * optional double distance = 2; + */ + double getDistance(); + + /** + * optional double angle_delta = 3; + */ + double getAngleDelta(); + } + /** + * Protobuf type {@code carkot.Route.WayPoint} + */ + public static final class WayPoint extends + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:carkot.Route.WayPoint) + WayPointOrBuilder { + // Use WayPoint.newBuilder() to construct. + private WayPoint(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + private WayPoint() { + distance_ = 0D; + angleDelta_ = 0D; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); + } + private WayPoint( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + int mutable_bitField0_ = 0; + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!input.skipField(tag)) { + done = true; + } + break; + } + case 17: { + + distance_ = input.readDouble(); + break; + } + case 25: { + + angleDelta_ = input.readDouble(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return proto.car.RouteP.internal_static_carkot_Route_WayPoint_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return proto.car.RouteP.internal_static_carkot_Route_WayPoint_fieldAccessorTable + .ensureFieldAccessorsInitialized( + proto.car.RouteP.Route.WayPoint.class, proto.car.RouteP.Route.WayPoint.Builder.class); + } + + public static final int DISTANCE_FIELD_NUMBER = 2; + private double distance_; + /** + * optional double distance = 2; + */ + public double getDistance() { + return distance_; + } + + public static final int ANGLE_DELTA_FIELD_NUMBER = 3; + private double angleDelta_; + /** + * optional double angle_delta = 3; + */ + public double getAngleDelta() { + return angleDelta_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (distance_ != 0D) { + output.writeDouble(2, distance_); + } + if (angleDelta_ != 0D) { + output.writeDouble(3, angleDelta_); + } + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (distance_ != 0D) { + size += com.google.protobuf.CodedOutputStream + .computeDoubleSize(2, distance_); + } + if (angleDelta_ != 0D) { + size += com.google.protobuf.CodedOutputStream + .computeDoubleSize(3, angleDelta_); + } + memoizedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + public static proto.car.RouteP.Route.WayPoint parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static proto.car.RouteP.Route.WayPoint parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static proto.car.RouteP.Route.WayPoint parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static proto.car.RouteP.Route.WayPoint parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static proto.car.RouteP.Route.WayPoint parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseWithIOException(PARSER, input); + } + public static proto.car.RouteP.Route.WayPoint parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static proto.car.RouteP.Route.WayPoint parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseDelimitedWithIOException(PARSER, input); + } + public static proto.car.RouteP.Route.WayPoint parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static proto.car.RouteP.Route.WayPoint parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseWithIOException(PARSER, input); + } + public static proto.car.RouteP.Route.WayPoint parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(proto.car.RouteP.Route.WayPoint prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code carkot.Route.WayPoint} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:carkot.Route.WayPoint) + proto.car.RouteP.Route.WayPointOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return proto.car.RouteP.internal_static_carkot_Route_WayPoint_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return proto.car.RouteP.internal_static_carkot_Route_WayPoint_fieldAccessorTable + .ensureFieldAccessorsInitialized( + proto.car.RouteP.Route.WayPoint.class, proto.car.RouteP.Route.WayPoint.Builder.class); + } + + // Construct using proto.car.RouteP.Route.WayPoint.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + distance_ = 0D; + + angleDelta_ = 0D; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return proto.car.RouteP.internal_static_carkot_Route_WayPoint_descriptor; + } + + public proto.car.RouteP.Route.WayPoint getDefaultInstanceForType() { + return proto.car.RouteP.Route.WayPoint.getDefaultInstance(); + } + + public proto.car.RouteP.Route.WayPoint build() { + proto.car.RouteP.Route.WayPoint result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public proto.car.RouteP.Route.WayPoint buildPartial() { + proto.car.RouteP.Route.WayPoint result = new proto.car.RouteP.Route.WayPoint(this); + result.distance_ = distance_; + result.angleDelta_ = angleDelta_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof proto.car.RouteP.Route.WayPoint) { + return mergeFrom((proto.car.RouteP.Route.WayPoint)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(proto.car.RouteP.Route.WayPoint other) { + if (other == proto.car.RouteP.Route.WayPoint.getDefaultInstance()) return this; + if (other.getDistance() != 0D) { + setDistance(other.getDistance()); + } + if (other.getAngleDelta() != 0D) { + setAngleDelta(other.getAngleDelta()); + } + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + proto.car.RouteP.Route.WayPoint parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (proto.car.RouteP.Route.WayPoint) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private double distance_ ; + /** + * optional double distance = 2; + */ + public double getDistance() { + return distance_; + } + /** + * optional double distance = 2; + */ + public Builder setDistance(double value) { + + distance_ = value; + onChanged(); + return this; + } + /** + * optional double distance = 2; + */ + public Builder clearDistance() { + + distance_ = 0D; + onChanged(); + return this; + } + + private double angleDelta_ ; + /** + * optional double angle_delta = 3; + */ + public double getAngleDelta() { + return angleDelta_; + } + /** + * optional double angle_delta = 3; + */ + public Builder setAngleDelta(double value) { + + angleDelta_ = value; + onChanged(); + return this; + } + /** + * optional double angle_delta = 3; + */ + public Builder clearAngleDelta() { + + angleDelta_ = 0D; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + + // @@protoc_insertion_point(builder_scope:carkot.Route.WayPoint) + } + + // @@protoc_insertion_point(class_scope:carkot.Route.WayPoint) + private static final proto.car.RouteP.Route.WayPoint DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new proto.car.RouteP.Route.WayPoint(); + } + + public static proto.car.RouteP.Route.WayPoint getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public WayPoint parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new WayPoint(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public proto.car.RouteP.Route.WayPoint getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public static final int WAY_POINTS_FIELD_NUMBER = 1; + private java.util.List wayPoints_; + /** + * repeated .carkot.Route.WayPoint way_points = 1; + */ + public java.util.List getWayPointsList() { + return wayPoints_; + } + /** + * repeated .carkot.Route.WayPoint way_points = 1; + */ + public java.util.List + getWayPointsOrBuilderList() { + return wayPoints_; + } + /** + * repeated .carkot.Route.WayPoint way_points = 1; + */ + public int getWayPointsCount() { + return wayPoints_.size(); + } + /** + * repeated .carkot.Route.WayPoint way_points = 1; + */ + public proto.car.RouteP.Route.WayPoint getWayPoints(int index) { + return wayPoints_.get(index); + } + /** + * repeated .carkot.Route.WayPoint way_points = 1; + */ + public proto.car.RouteP.Route.WayPointOrBuilder getWayPointsOrBuilder( + int index) { + return wayPoints_.get(index); + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + for (int i = 0; i < wayPoints_.size(); i++) { + output.writeMessage(1, wayPoints_.get(i)); + } + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + for (int i = 0; i < wayPoints_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, wayPoints_.get(i)); + } + memoizedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + public static proto.car.RouteP.Route parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static proto.car.RouteP.Route parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static proto.car.RouteP.Route parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static proto.car.RouteP.Route parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static proto.car.RouteP.Route parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseWithIOException(PARSER, input); + } + public static proto.car.RouteP.Route parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static proto.car.RouteP.Route parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseDelimitedWithIOException(PARSER, input); + } + public static proto.car.RouteP.Route parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static proto.car.RouteP.Route parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseWithIOException(PARSER, input); + } + public static proto.car.RouteP.Route parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(proto.car.RouteP.Route prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code carkot.Route} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:carkot.Route) + proto.car.RouteP.RouteOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return proto.car.RouteP.internal_static_carkot_Route_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return proto.car.RouteP.internal_static_carkot_Route_fieldAccessorTable + .ensureFieldAccessorsInitialized( + proto.car.RouteP.Route.class, proto.car.RouteP.Route.Builder.class); + } + + // Construct using proto.car.RouteP.Route.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + getWayPointsFieldBuilder(); + } + } + public Builder clear() { + super.clear(); + if (wayPointsBuilder_ == null) { + wayPoints_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + } else { + wayPointsBuilder_.clear(); + } + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return proto.car.RouteP.internal_static_carkot_Route_descriptor; + } + + public proto.car.RouteP.Route getDefaultInstanceForType() { + return proto.car.RouteP.Route.getDefaultInstance(); + } + + public proto.car.RouteP.Route build() { + proto.car.RouteP.Route result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public proto.car.RouteP.Route buildPartial() { + proto.car.RouteP.Route result = new proto.car.RouteP.Route(this); + int from_bitField0_ = bitField0_; + if (wayPointsBuilder_ == null) { + if (((bitField0_ & 0x00000001) == 0x00000001)) { + wayPoints_ = java.util.Collections.unmodifiableList(wayPoints_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.wayPoints_ = wayPoints_; + } else { + result.wayPoints_ = wayPointsBuilder_.build(); + } + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof proto.car.RouteP.Route) { + return mergeFrom((proto.car.RouteP.Route)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(proto.car.RouteP.Route other) { + if (other == proto.car.RouteP.Route.getDefaultInstance()) return this; + if (wayPointsBuilder_ == null) { + if (!other.wayPoints_.isEmpty()) { + if (wayPoints_.isEmpty()) { + wayPoints_ = other.wayPoints_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureWayPointsIsMutable(); + wayPoints_.addAll(other.wayPoints_); + } + onChanged(); + } + } else { + if (!other.wayPoints_.isEmpty()) { + if (wayPointsBuilder_.isEmpty()) { + wayPointsBuilder_.dispose(); + wayPointsBuilder_ = null; + wayPoints_ = other.wayPoints_; + bitField0_ = (bitField0_ & ~0x00000001); + wayPointsBuilder_ = + com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? + getWayPointsFieldBuilder() : null; + } else { + wayPointsBuilder_.addAllMessages(other.wayPoints_); + } + } + } + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + proto.car.RouteP.Route parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (proto.car.RouteP.Route) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private java.util.List wayPoints_ = + java.util.Collections.emptyList(); + private void ensureWayPointsIsMutable() { + if (!((bitField0_ & 0x00000001) == 0x00000001)) { + wayPoints_ = new java.util.ArrayList(wayPoints_); + bitField0_ |= 0x00000001; + } + } + + private com.google.protobuf.RepeatedFieldBuilder< + proto.car.RouteP.Route.WayPoint, proto.car.RouteP.Route.WayPoint.Builder, proto.car.RouteP.Route.WayPointOrBuilder> wayPointsBuilder_; + + /** + * repeated .carkot.Route.WayPoint way_points = 1; + */ + public java.util.List getWayPointsList() { + if (wayPointsBuilder_ == null) { + return java.util.Collections.unmodifiableList(wayPoints_); + } else { + return wayPointsBuilder_.getMessageList(); + } + } + /** + * repeated .carkot.Route.WayPoint way_points = 1; + */ + public int getWayPointsCount() { + if (wayPointsBuilder_ == null) { + return wayPoints_.size(); + } else { + return wayPointsBuilder_.getCount(); + } + } + /** + * repeated .carkot.Route.WayPoint way_points = 1; + */ + public proto.car.RouteP.Route.WayPoint getWayPoints(int index) { + if (wayPointsBuilder_ == null) { + return wayPoints_.get(index); + } else { + return wayPointsBuilder_.getMessage(index); + } + } + /** + * repeated .carkot.Route.WayPoint way_points = 1; + */ + public Builder setWayPoints( + int index, proto.car.RouteP.Route.WayPoint value) { + if (wayPointsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureWayPointsIsMutable(); + wayPoints_.set(index, value); + onChanged(); + } else { + wayPointsBuilder_.setMessage(index, value); + } + return this; + } + /** + * repeated .carkot.Route.WayPoint way_points = 1; + */ + public Builder setWayPoints( + int index, proto.car.RouteP.Route.WayPoint.Builder builderForValue) { + if (wayPointsBuilder_ == null) { + ensureWayPointsIsMutable(); + wayPoints_.set(index, builderForValue.build()); + onChanged(); + } else { + wayPointsBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .carkot.Route.WayPoint way_points = 1; + */ + public Builder addWayPoints(proto.car.RouteP.Route.WayPoint value) { + if (wayPointsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureWayPointsIsMutable(); + wayPoints_.add(value); + onChanged(); + } else { + wayPointsBuilder_.addMessage(value); + } + return this; + } + /** + * repeated .carkot.Route.WayPoint way_points = 1; + */ + public Builder addWayPoints( + int index, proto.car.RouteP.Route.WayPoint value) { + if (wayPointsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureWayPointsIsMutable(); + wayPoints_.add(index, value); + onChanged(); + } else { + wayPointsBuilder_.addMessage(index, value); + } + return this; + } + /** + * repeated .carkot.Route.WayPoint way_points = 1; + */ + public Builder addWayPoints( + proto.car.RouteP.Route.WayPoint.Builder builderForValue) { + if (wayPointsBuilder_ == null) { + ensureWayPointsIsMutable(); + wayPoints_.add(builderForValue.build()); + onChanged(); + } else { + wayPointsBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * repeated .carkot.Route.WayPoint way_points = 1; + */ + public Builder addWayPoints( + int index, proto.car.RouteP.Route.WayPoint.Builder builderForValue) { + if (wayPointsBuilder_ == null) { + ensureWayPointsIsMutable(); + wayPoints_.add(index, builderForValue.build()); + onChanged(); + } else { + wayPointsBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .carkot.Route.WayPoint way_points = 1; + */ + public Builder addAllWayPoints( + java.lang.Iterable values) { + if (wayPointsBuilder_ == null) { + ensureWayPointsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, wayPoints_); + onChanged(); + } else { + wayPointsBuilder_.addAllMessages(values); + } + return this; + } + /** + * repeated .carkot.Route.WayPoint way_points = 1; + */ + public Builder clearWayPoints() { + if (wayPointsBuilder_ == null) { + wayPoints_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + } else { + wayPointsBuilder_.clear(); + } + return this; + } + /** + * repeated .carkot.Route.WayPoint way_points = 1; + */ + public Builder removeWayPoints(int index) { + if (wayPointsBuilder_ == null) { + ensureWayPointsIsMutable(); + wayPoints_.remove(index); + onChanged(); + } else { + wayPointsBuilder_.remove(index); + } + return this; + } + /** + * repeated .carkot.Route.WayPoint way_points = 1; + */ + public proto.car.RouteP.Route.WayPoint.Builder getWayPointsBuilder( + int index) { + return getWayPointsFieldBuilder().getBuilder(index); + } + /** + * repeated .carkot.Route.WayPoint way_points = 1; + */ + public proto.car.RouteP.Route.WayPointOrBuilder getWayPointsOrBuilder( + int index) { + if (wayPointsBuilder_ == null) { + return wayPoints_.get(index); } else { + return wayPointsBuilder_.getMessageOrBuilder(index); + } + } + /** + * repeated .carkot.Route.WayPoint way_points = 1; + */ + public java.util.List + getWayPointsOrBuilderList() { + if (wayPointsBuilder_ != null) { + return wayPointsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(wayPoints_); + } + } + /** + * repeated .carkot.Route.WayPoint way_points = 1; + */ + public proto.car.RouteP.Route.WayPoint.Builder addWayPointsBuilder() { + return getWayPointsFieldBuilder().addBuilder( + proto.car.RouteP.Route.WayPoint.getDefaultInstance()); + } + /** + * repeated .carkot.Route.WayPoint way_points = 1; + */ + public proto.car.RouteP.Route.WayPoint.Builder addWayPointsBuilder( + int index) { + return getWayPointsFieldBuilder().addBuilder( + index, proto.car.RouteP.Route.WayPoint.getDefaultInstance()); + } + /** + * repeated .carkot.Route.WayPoint way_points = 1; + */ + public java.util.List + getWayPointsBuilderList() { + return getWayPointsFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilder< + proto.car.RouteP.Route.WayPoint, proto.car.RouteP.Route.WayPoint.Builder, proto.car.RouteP.Route.WayPointOrBuilder> + getWayPointsFieldBuilder() { + if (wayPointsBuilder_ == null) { + wayPointsBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< + proto.car.RouteP.Route.WayPoint, proto.car.RouteP.Route.WayPoint.Builder, proto.car.RouteP.Route.WayPointOrBuilder>( + wayPoints_, + ((bitField0_ & 0x00000001) == 0x00000001), + getParentForChildren(), + isClean()); + wayPoints_ = null; + } + return wayPointsBuilder_; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + + // @@protoc_insertion_point(builder_scope:carkot.Route) + } + + // @@protoc_insertion_point(class_scope:carkot.Route) + private static final proto.car.RouteP.Route DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new proto.car.RouteP.Route(); + } + + public static proto.car.RouteP.Route getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public Route parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new Route(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public proto.car.RouteP.Route getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface DirectionOrBuilder extends + // @@protoc_insertion_point(interface_extends:carkot.Direction) + com.google.protobuf.MessageOrBuilder { + + /** + * optional .carkot.Direction.Command command = 1; + */ + int getCommandValue(); + /** + * optional .carkot.Direction.Command command = 1; + */ + proto.car.RouteP.Direction.Command getCommand(); + } + /** + * Protobuf type {@code carkot.Direction} + */ + public static final class Direction extends + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:carkot.Direction) + DirectionOrBuilder { + // Use Direction.newBuilder() to construct. + private Direction(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + private Direction() { + command_ = 0; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); + } + private Direction( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + int mutable_bitField0_ = 0; + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!input.skipField(tag)) { + done = true; + } + break; + } + case 8: { + int rawValue = input.readEnum(); + + command_ = rawValue; + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return proto.car.RouteP.internal_static_carkot_Direction_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return proto.car.RouteP.internal_static_carkot_Direction_fieldAccessorTable + .ensureFieldAccessorsInitialized( + proto.car.RouteP.Direction.class, proto.car.RouteP.Direction.Builder.class); + } + + /** + * Protobuf enum {@code carkot.Direction.Command} + */ + public enum Command + implements com.google.protobuf.ProtocolMessageEnum { + /** + * stop = 0; + */ + stop(0), + /** + * forward = 1; + */ + forward(1), + /** + * backward = 2; + */ + backward(2), + /** + * left = 3; + */ + left(3), + /** + * right = 4; + */ + right(4), + UNRECOGNIZED(-1), + ; + + /** + * stop = 0; + */ + public static final int stop_VALUE = 0; + /** + * forward = 1; + */ + public static final int forward_VALUE = 1; + /** + * backward = 2; + */ + public static final int backward_VALUE = 2; + /** + * left = 3; + */ + public static final int left_VALUE = 3; + /** + * right = 4; + */ + public static final int right_VALUE = 4; + + + public final int getNumber() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalArgumentException( + "Can't get the number of an unknown enum value."); + } + return value; + } + + /** + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static Command valueOf(int value) { + return forNumber(value); + } + + public static Command forNumber(int value) { + switch (value) { + case 0: return stop; + case 1: return forward; + case 2: return backward; + case 3: return left; + case 4: return right; + default: return null; + } + } + + public static com.google.protobuf.Internal.EnumLiteMap + internalGetValueMap() { + return internalValueMap; + } + private static final com.google.protobuf.Internal.EnumLiteMap< + Command> internalValueMap = + new com.google.protobuf.Internal.EnumLiteMap() { + public Command findValueByNumber(int number) { + return Command.forNumber(number); + } + }; + + public final com.google.protobuf.Descriptors.EnumValueDescriptor + getValueDescriptor() { + return getDescriptor().getValues().get(ordinal()); + } + public final com.google.protobuf.Descriptors.EnumDescriptor + getDescriptorForType() { + return getDescriptor(); + } + public static final com.google.protobuf.Descriptors.EnumDescriptor + getDescriptor() { + return proto.car.RouteP.Direction.getDescriptor().getEnumTypes().get(0); + } + + private static final Command[] VALUES = values(); + + public static Command valueOf( + com.google.protobuf.Descriptors.EnumValueDescriptor desc) { + if (desc.getType() != getDescriptor()) { + throw new java.lang.IllegalArgumentException( + "EnumValueDescriptor is not for this type."); + } + if (desc.getIndex() == -1) { + return UNRECOGNIZED; + } + return VALUES[desc.getIndex()]; + } + + private final int value; + + private Command(int value) { + this.value = value; + } + + // @@protoc_insertion_point(enum_scope:carkot.Direction.Command) + } + + public static final int COMMAND_FIELD_NUMBER = 1; + private int command_; + /** + * optional .carkot.Direction.Command command = 1; + */ + public int getCommandValue() { + return command_; + } + /** + * optional .carkot.Direction.Command command = 1; + */ + public proto.car.RouteP.Direction.Command getCommand() { + proto.car.RouteP.Direction.Command result = proto.car.RouteP.Direction.Command.forNumber(command_); + return result == null ? proto.car.RouteP.Direction.Command.UNRECOGNIZED : result; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (command_ != proto.car.RouteP.Direction.Command.stop.getNumber()) { + output.writeEnum(1, command_); + } + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (command_ != proto.car.RouteP.Direction.Command.stop.getNumber()) { + size += com.google.protobuf.CodedOutputStream + .computeEnumSize(1, command_); + } + memoizedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + public static proto.car.RouteP.Direction parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static proto.car.RouteP.Direction parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static proto.car.RouteP.Direction parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static proto.car.RouteP.Direction parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static proto.car.RouteP.Direction parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseWithIOException(PARSER, input); + } + public static proto.car.RouteP.Direction parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static proto.car.RouteP.Direction parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseDelimitedWithIOException(PARSER, input); + } + public static proto.car.RouteP.Direction parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static proto.car.RouteP.Direction parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseWithIOException(PARSER, input); + } + public static proto.car.RouteP.Direction parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(proto.car.RouteP.Direction prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code carkot.Direction} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:carkot.Direction) + proto.car.RouteP.DirectionOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return proto.car.RouteP.internal_static_carkot_Direction_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return proto.car.RouteP.internal_static_carkot_Direction_fieldAccessorTable + .ensureFieldAccessorsInitialized( + proto.car.RouteP.Direction.class, proto.car.RouteP.Direction.Builder.class); + } + + // Construct using proto.car.RouteP.Direction.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + command_ = 0; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return proto.car.RouteP.internal_static_carkot_Direction_descriptor; + } + + public proto.car.RouteP.Direction getDefaultInstanceForType() { + return proto.car.RouteP.Direction.getDefaultInstance(); + } + + public proto.car.RouteP.Direction build() { + proto.car.RouteP.Direction result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public proto.car.RouteP.Direction buildPartial() { + proto.car.RouteP.Direction result = new proto.car.RouteP.Direction(this); + result.command_ = command_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof proto.car.RouteP.Direction) { + return mergeFrom((proto.car.RouteP.Direction)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(proto.car.RouteP.Direction other) { + if (other == proto.car.RouteP.Direction.getDefaultInstance()) return this; + if (other.command_ != 0) { + setCommandValue(other.getCommandValue()); + } + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + proto.car.RouteP.Direction parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (proto.car.RouteP.Direction) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private int command_ = 0; + /** + * optional .carkot.Direction.Command command = 1; + */ + public int getCommandValue() { + return command_; + } + /** + * optional .carkot.Direction.Command command = 1; + */ + public Builder setCommandValue(int value) { + command_ = value; + onChanged(); + return this; + } + /** + * optional .carkot.Direction.Command command = 1; + */ + public proto.car.RouteP.Direction.Command getCommand() { + proto.car.RouteP.Direction.Command result = proto.car.RouteP.Direction.Command.forNumber(command_); + return result == null ? proto.car.RouteP.Direction.Command.UNRECOGNIZED : result; + } + /** + * optional .carkot.Direction.Command command = 1; + */ + public Builder setCommand(proto.car.RouteP.Direction.Command value) { + if (value == null) { + throw new NullPointerException(); + } + + command_ = value.getNumber(); + onChanged(); + return this; + } + /** + * optional .carkot.Direction.Command command = 1; + */ + public Builder clearCommand() { + + command_ = 0; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + + // @@protoc_insertion_point(builder_scope:carkot.Direction) + } + + // @@protoc_insertion_point(class_scope:carkot.Direction) + private static final proto.car.RouteP.Direction DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new proto.car.RouteP.Direction(); + } + + public static proto.car.RouteP.Direction getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public Direction parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new Direction(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public proto.car.RouteP.Direction getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_carkot_Route_descriptor; + private static final + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_carkot_Route_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_carkot_Route_WayPoint_descriptor; + private static final + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_carkot_Route_WayPoint_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_carkot_Direction_descriptor; + private static final + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_carkot_Direction_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + private static com.google.protobuf.Descriptors.FileDescriptor + descriptor; + static { + java.lang.String[] descriptorData = { + "\n\013route.proto\022\006carkot\"f\n\005Route\022*\n\nway_po" + + "ints\030\001 \003(\0132\026.carkot.Route.WayPoint\0321\n\010Wa" + + "yPoint\022\020\n\010distance\030\002 \001(\001\022\023\n\013angle_delta\030" + + "\003 \001(\001\"|\n\tDirection\022*\n\007command\030\001 \001(\0162\031.ca" + + "rkot.Direction.Command\"C\n\007Command\022\010\n\004sto" + + "p\020\000\022\013\n\007forward\020\001\022\014\n\010backward\020\002\022\010\n\004left\020\003" + + "\022\t\n\005right\020\004B\023\n\tproto.carB\006RoutePb\006proto3" + }; + com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = + new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { + public com.google.protobuf.ExtensionRegistry assignDescriptors( + com.google.protobuf.Descriptors.FileDescriptor root) { + descriptor = root; + return null; + } + }; + com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + }, assigner); + internal_static_carkot_Route_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_carkot_Route_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_carkot_Route_descriptor, + new java.lang.String[] { "WayPoints", }); + internal_static_carkot_Route_WayPoint_descriptor = + internal_static_carkot_Route_descriptor.getNestedTypes().get(0); + internal_static_carkot_Route_WayPoint_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_carkot_Route_WayPoint_descriptor, + new java.lang.String[] { "Distance", "AngleDelta", }); + internal_static_carkot_Direction_descriptor = + getDescriptor().getMessageTypes().get(1); + internal_static_carkot_Direction_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_carkot_Direction_descriptor, + new java.lang.String[] { "Command", }); + } + + // @@protoc_insertion_point(outer_class_scope) +}