From 9c2933a993f745493951ef5556509fcc0c8f3984 Mon Sep 17 00:00:00 2001 From: MaximZaitsev Date: Fri, 26 Aug 2016 10:45:38 +0300 Subject: [PATCH] fixed bugs --- car_srv/kotlinSrv/src/JSImport.kt | 7 --- .../control/emulator/ControllerEmulator.kt | 2 +- .../net/server/handlers/main/GetSonarData.kt | 3 +- .../src/net/server/handlers/rc/Control.kt | 18 ++------ car_srv/kotlinSrv/src/room/Room.kt | 44 +++++++++---------- 5 files changed, 28 insertions(+), 46 deletions(-) diff --git a/car_srv/kotlinSrv/src/JSImport.kt b/car_srv/kotlinSrv/src/JSImport.kt index 6e96ef0eb3d..0fcb4df056c 100644 --- a/car_srv/kotlinSrv/src/JSImport.kt +++ b/car_srv/kotlinSrv/src/JSImport.kt @@ -33,13 +33,6 @@ fun encodeProtoBuf(protoMessage: T): ByteArray { protoMessage.writeTo(codedOutput) } - is DirectionResponse -> { - val protoSize = protoMessage.getSizeNoTag() - routeBytes = ByteArray(protoSize) - val codedOutput = CodedOutputStream(routeBytes) - protoMessage.writeTo(codedOutput) - } - is RouteResponse -> { val protoSize = protoMessage.getSizeNoTag() routeBytes = ByteArray(protoSize) diff --git a/car_srv/kotlinSrv/src/control/emulator/ControllerEmulator.kt b/car_srv/kotlinSrv/src/control/emulator/ControllerEmulator.kt index 9e9b7df9b88..f108012cb97 100644 --- a/car_srv/kotlinSrv/src/control/emulator/ControllerEmulator.kt +++ b/car_srv/kotlinSrv/src/control/emulator/ControllerEmulator.kt @@ -123,7 +123,7 @@ class ControllerEmulator : Controller { continue } val currentDistance = Math.round(Math.sqrt(Math.pow(xIntersection - xSensor0, 2.0) - + Math.pow(yIntersection - ySensor0, 2.0))*100000) + + Math.pow(yIntersection - ySensor0, 2.0))) if (currentDistance < result) { result = currentDistance } diff --git a/car_srv/kotlinSrv/src/net/server/handlers/main/GetSonarData.kt b/car_srv/kotlinSrv/src/net/server/handlers/main/GetSonarData.kt index 8512aa95ccc..3351315f378 100644 --- a/car_srv/kotlinSrv/src/net/server/handlers/main/GetSonarData.kt +++ b/car_srv/kotlinSrv/src/net/server/handlers/main/GetSonarData.kt @@ -8,7 +8,7 @@ import control.Controller import encodeProtoBuf import net.server.handlers.AbstractHandler -class GetSonarData(val controller: Controller): AbstractHandler() { +class GetSonarData(val controller: Controller) : AbstractHandler() { val fromServerObjectBuilder = SonarRequest.BuilderSonarRequest(IntArray(0)) val toServerObjectBuilder = SonarResponse.BuilderSonarResponse(IntArray(0)) @@ -18,6 +18,7 @@ class GetSonarData(val controller: Controller): AbstractHandler() { if (McState.instance.isConnected()) { controller.executeRequestSensorData(message, callback) + return } println("mc is disconnected!") diff --git a/car_srv/kotlinSrv/src/net/server/handlers/rc/Control.kt b/car_srv/kotlinSrv/src/net/server/handlers/rc/Control.kt index cd453405220..d9c46af72b9 100644 --- a/car_srv/kotlinSrv/src/net/server/handlers/rc/Control.kt +++ b/car_srv/kotlinSrv/src/net/server/handlers/rc/Control.kt @@ -1,21 +1,11 @@ package net.server.handlers.rc -import CodedInputStream import DirectionRequest -import DirectionResponse -import control.emulator.ControllerEmulator.MoveDirection -import encodeProtoBuf import net.server.handlers.AbstractHandler -class Control : AbstractHandler { +class Control() : AbstractHandler() { - val fromServerObjectBuilder: DirectionRequest.BuilderDirectionRequest - val toServerObjectBuilder: DirectionResponse.BuilderDirectionResponse - - constructor() : super() { - this.fromServerObjectBuilder = DirectionRequest.BuilderDirectionRequest(DirectionRequest.Command.fromIntToCommand(0), 0) - this.toServerObjectBuilder = DirectionResponse.BuilderDirectionResponse(0) - } + val request = DirectionRequest.BuilderDirectionRequest(DirectionRequest.Command.fromIntToCommand(0), 0, false) override fun getBytesResponse(data: ByteArray, callback: (b: ByteArray) -> Unit) { //TODO now this handler don't make nothing. need fix:) @@ -41,8 +31,6 @@ class Control : AbstractHandler { // } // else -> MoveDirection.STOP // } - val resultCode: Int = 0 - val resultMessage = toServerObjectBuilder.setCode(resultCode).build() - callback.invoke(encodeProtoBuf(resultMessage)) + callback.invoke(ByteArray(0)) } } \ No newline at end of file diff --git a/car_srv/kotlinSrv/src/room/Room.kt b/car_srv/kotlinSrv/src/room/Room.kt index 8c61465fe87..f64e78fc697 100644 --- a/car_srv/kotlinSrv/src/room/Room.kt +++ b/car_srv/kotlinSrv/src/room/Room.kt @@ -13,16 +13,16 @@ object Room { */ -// val upLine = Line(0.0, 1.0, -300.0) -// val leftLine = Line(1.0, 0.0, 150.0) -// val bottomLine = Line(0.0, 1.0, 20.0) -// val rightLine = Line(1.0, 0.0, -200.0) -// -// val walls = listOf(Wall(upLine, 200, -150, 300, 300), -// Wall(leftLine, -150, -150, 300, -20), -// Wall(bottomLine, -150, 200, -20, -20), -// Wall(rightLine, 200, 200, -20, 300) -// ) + val upLine = Line(0.0, 1.0, -300.0) + val leftLine = Line(1.0, 0.0, 150.0) + val bottomLine = Line(0.0, 1.0, 20.0) + val rightLine = Line(1.0, 0.0, -200.0) + + val walls = listOf(Wall(upLine, 200, -150, 300, 300), + Wall(leftLine, -150, -150, 300, -20), + Wall(bottomLine, -150, 200, -20, -20), + Wall(rightLine, 200, 200, -20, 300) + ) /* @@ -57,17 +57,17 @@ object Room { */ - val upLine = Line(0.0, 1.0, -300.0) - val leftLine = Line(1.0, 0.0, 150.0) - val bottomLine = Line(0.0, 1.0, 20.0) - val rightLine = Line(-1.2, 1.0, 140.0) - val rightLine2 = Line(1.0, 1.0, -350.0) - - val walls = listOf(Wall(upLine, 200, -150, 300, 300), - Wall(leftLine, -150, -150, 300, -20), - Wall(bottomLine, -150, 100, -20, -20), - Wall(rightLine, 100, 200, -20, 100), - Wall(rightLine2, 200, 200, 100, 300) - ) +// val upLine = Line(0.0, 1.0, -300.0) +// val leftLine = Line(1.0, 0.0, 150.0) +// val bottomLine = Line(0.0, 1.0, 20.0) +// val rightLine = Line(-1.2, 1.0, 140.0) +// val rightLine2 = Line(1.0, 1.0, -350.0) +// +// val walls = listOf(Wall(upLine, 200, -150, 300, 300), +// Wall(leftLine, -150, -150, 300, -20), +// Wall(bottomLine, -150, 100, -20, -20), +// Wall(rightLine, 100, 200, -20, 100), +// Wall(rightLine2, 200, 200, 100, 300) +// ) } \ No newline at end of file