From b371bca8019d413cdc8bc66d02443bd79c46a360 Mon Sep 17 00:00:00 2001 From: zolcsakgergo Date: Mon, 4 Mar 2024 16:13:39 +0100 Subject: [PATCH 01/22] ReadME modified --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index e26e034fc..002702739 100644 --- a/README.md +++ b/README.md @@ -62,3 +62,10 @@ The figure below illustrates this behavior using an example. 1. As the joystick remains at a positive value, the reference speed is incremented again. 1. However, it reaches the speed limit so in the next step it is not incremented even though the joystick still has a positive value. 1. Later, the joystick is set to a negative position for one time unit, making the reference speed to decrease as well. + + +# H1 + +## H2 + +## H3 \ No newline at end of file From a786227d27a23ae3a441dd6d0d455461a8de5380 Mon Sep 17 00:00:00 2001 From: zolcsakgergo Date: Mon, 4 Mar 2024 16:29:50 +0100 Subject: [PATCH 02/22] EmergencyBreak feat. implemented --- .../hu/bme/mit/train/controller/TrainControllerImpl.java | 7 +++++++ .../java/hu/bme/mit/train/interfaces/TrainController.java | 2 ++ 2 files changed, 9 insertions(+) diff --git a/train-controller/src/main/java/hu/bme/mit/train/controller/TrainControllerImpl.java b/train-controller/src/main/java/hu/bme/mit/train/controller/TrainControllerImpl.java index 06649d278..bf05e98e8 100644 --- a/train-controller/src/main/java/hu/bme/mit/train/controller/TrainControllerImpl.java +++ b/train-controller/src/main/java/hu/bme/mit/train/controller/TrainControllerImpl.java @@ -46,4 +46,11 @@ public void setJoystickPosition(int joystickPosition) { this.step = joystickPosition; } + + @Override + public void emergencyBreak() { + setSpeedLimit(0); + enforceSpeedLimit(); + } + } diff --git a/train-interfaces/src/main/java/hu/bme/mit/train/interfaces/TrainController.java b/train-interfaces/src/main/java/hu/bme/mit/train/interfaces/TrainController.java index c8adca066..5bca99613 100644 --- a/train-interfaces/src/main/java/hu/bme/mit/train/interfaces/TrainController.java +++ b/train-interfaces/src/main/java/hu/bme/mit/train/interfaces/TrainController.java @@ -9,5 +9,7 @@ public interface TrainController { void setSpeedLimit(int speedLimit); void setJoystickPosition(int joystickPosition); + + void emergencyBreak(); } From e866f9711dbfb560ef16d650e4ecbc053bb8ee82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolcs=C3=A1k=20Gerg=C5=91?= <80704855+zolcsakgergo@users.noreply.github.com> Date: Mon, 4 Mar 2024 16:13:22 +0100 Subject: [PATCH 03/22] Create gradle.yml --- .github/workflows/gradle.yml | 67 ++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 .github/workflows/gradle.yml diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml new file mode 100644 index 000000000..9ef4f99f3 --- /dev/null +++ b/.github/workflows/gradle.yml @@ -0,0 +1,67 @@ +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. +# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle + +name: Java CI with Gradle + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +jobs: + build: + + runs-on: ubuntu-latest + permissions: + contents: read + + steps: + - uses: actions/checkout@v4 + - name: Set up JDK 11 + uses: actions/setup-java@v4 + with: + java-version: '11' + distribution: 'temurin' + + # Configure Gradle for optimal use in GiHub Actions, including caching of downloaded dependencies. + # See: https://github.com/gradle/actions/blob/main/setup-gradle/README.md + - name: Setup Gradle + uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0 + + - name: Build with Gradle Wrapper + run: ./gradlew build + + # NOTE: The Gradle Wrapper is the default and recommended way to run Gradle (https://docs.gradle.org/current/userguide/gradle_wrapper.html). + # If your project does not have the Gradle Wrapper configured, you can use the following configuration to run Gradle with a specified version. + # + # - name: Setup Gradle + # uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0 + # with: + # gradle-version: '8.5' + # + # - name: Build with Gradle 8.5 + # run: gradle build + + dependency-submission: + + runs-on: ubuntu-latest + permissions: + contents: write + + steps: + - uses: actions/checkout@v4 + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: '17' + distribution: 'temurin' + + # Generates and submits a dependency graph, enabling Dependabot Alerts for all project dependencies. + # See: https://github.com/gradle/actions/blob/main/dependency-submission/README.md + - name: Generate and submit dependency graph + uses: gradle/actions/dependency-submission@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0 From d9b81d5b85ed8ae8f509673efcc4e1bb30fc4eb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolcs=C3=A1k=20Gerg=C5=91?= <80704855+zolcsakgergo@users.noreply.github.com> Date: Mon, 4 Mar 2024 16:17:46 +0100 Subject: [PATCH 04/22] Create maven.yml --- .github/workflows/maven.yml | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 .github/workflows/maven.yml diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml new file mode 100644 index 000000000..f7367e0d4 --- /dev/null +++ b/.github/workflows/maven.yml @@ -0,0 +1,35 @@ +# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven + +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +name: Java CI with Maven + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Set up JDK 11 + uses: actions/setup-java@v3 + with: + java-version: '11' + distribution: 'temurin' + cache: maven + - name: Build with Maven + run: mvn -B package --file pom.xml + + # Optional: Uploads the full dependency graph to GitHub to improve the quality of Dependabot alerts this repository can receive + - name: Update dependency graph + uses: advanced-security/maven-dependency-submission-action@571e99aab1055c2e71a1e2309b9691de18d6b7d6 From 4564e5aca812d3390e19902d73fa6ba07b5e5672 Mon Sep 17 00:00:00 2001 From: zolcsakgergo Date: Mon, 4 Mar 2024 16:53:40 +0100 Subject: [PATCH 05/22] changes on B --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 002702739..b2478c145 100644 --- a/README.md +++ b/README.md @@ -68,4 +68,8 @@ The figure below illustrates this behavior using an example. ## H2 -## H3 \ No newline at end of file +## H3 + +#### branch-a change + +#### branch-b change \ No newline at end of file From 17694830b4a7411f21fbf7c66ac1e752efd06222 Mon Sep 17 00:00:00 2001 From: zolcsakgergo Date: Mon, 4 Mar 2024 16:57:06 +0100 Subject: [PATCH 06/22] changes on A --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 002702739..e30744b6f 100644 --- a/README.md +++ b/README.md @@ -68,4 +68,6 @@ The figure below illustrates this behavior using an example. ## H2 -## H3 \ No newline at end of file +## H3 + +#### changes on A \ No newline at end of file From af60fd76ad50c5e15f078f961b77a25fa8a07748 Mon Sep 17 00:00:00 2001 From: zolcsakgergo Date: Mon, 4 Mar 2024 17:19:25 +0100 Subject: [PATCH 07/22] maven test --- .../main/java/hu/bme/mit/train/interfaces/TrainController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/train-interfaces/src/main/java/hu/bme/mit/train/interfaces/TrainController.java b/train-interfaces/src/main/java/hu/bme/mit/train/interfaces/TrainController.java index 5bca99613..0d89fc616 100644 --- a/train-interfaces/src/main/java/hu/bme/mit/train/interfaces/TrainController.java +++ b/train-interfaces/src/main/java/hu/bme/mit/train/interfaces/TrainController.java @@ -10,6 +10,6 @@ public interface TrainController { void setJoystickPosition(int joystickPosition); - void emergencyBreak(); + voiiid emergencyBreak(); } From 13b3ee157537739596b7e074be55c0bec3e234c9 Mon Sep 17 00:00:00 2001 From: zolcsakgergo Date: Mon, 4 Mar 2024 17:24:03 +0100 Subject: [PATCH 08/22] EmergencyBreak test --- .../java/hu/bme/mit/train/interfaces/TrainController.java | 2 +- .../test/java/hu/bme/mit/train/system/TrainSystemTest.java | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/train-interfaces/src/main/java/hu/bme/mit/train/interfaces/TrainController.java b/train-interfaces/src/main/java/hu/bme/mit/train/interfaces/TrainController.java index 0d89fc616..5bca99613 100644 --- a/train-interfaces/src/main/java/hu/bme/mit/train/interfaces/TrainController.java +++ b/train-interfaces/src/main/java/hu/bme/mit/train/interfaces/TrainController.java @@ -10,6 +10,6 @@ public interface TrainController { void setJoystickPosition(int joystickPosition); - voiiid emergencyBreak(); + void emergencyBreak(); } diff --git a/train-system/src/test/java/hu/bme/mit/train/system/TrainSystemTest.java b/train-system/src/test/java/hu/bme/mit/train/system/TrainSystemTest.java index 04ae3dac0..509428bae 100644 --- a/train-system/src/test/java/hu/bme/mit/train/system/TrainSystemTest.java +++ b/train-system/src/test/java/hu/bme/mit/train/system/TrainSystemTest.java @@ -50,5 +50,11 @@ public void OverridingJoystickPositionToNegative_SetsReferenceSpeedToZero() { Assert.assertEquals(0, controller.getReferenceSpeed()); } + + @Test + public void overrideSpeedLimit(){ + controller.emergencyBreak(); + Assert.assertEquals(0,controller.getReferenceSpeed); + } } From f17cb4e49e5dbdd8117791effc26240cdd061c2d Mon Sep 17 00:00:00 2001 From: zolcsakgergo Date: Mon, 4 Mar 2024 17:26:17 +0100 Subject: [PATCH 09/22] minor bugfix --- .../src/test/java/hu/bme/mit/train/system/TrainSystemTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/train-system/src/test/java/hu/bme/mit/train/system/TrainSystemTest.java b/train-system/src/test/java/hu/bme/mit/train/system/TrainSystemTest.java index 509428bae..ae2eb30ce 100644 --- a/train-system/src/test/java/hu/bme/mit/train/system/TrainSystemTest.java +++ b/train-system/src/test/java/hu/bme/mit/train/system/TrainSystemTest.java @@ -54,7 +54,7 @@ public void OverridingJoystickPositionToNegative_SetsReferenceSpeedToZero() { @Test public void overrideSpeedLimit(){ controller.emergencyBreak(); - Assert.assertEquals(0,controller.getReferenceSpeed); + Assert.assertEquals(0,controller.getReferenceSpeed()); } } From 8bf1c9bafcca3faf2872c0a8cba2ca36b0f72130 Mon Sep 17 00:00:00 2001 From: zolcsakgergo Date: Mon, 4 Mar 2024 17:41:41 +0100 Subject: [PATCH 10/22] tachograph impl. --- .../mit/train/controller/TrainControllerImpl.java | 15 +++++++++++++++ .../java/hu/bme/mit/train/system/TrainSystem.java | 15 +++++++++++++++ .../hu/bme/mit/train/system/TrainSystemTest.java | 15 ++++++++++++++- 3 files changed, 44 insertions(+), 1 deletion(-) diff --git a/train-controller/src/main/java/hu/bme/mit/train/controller/TrainControllerImpl.java b/train-controller/src/main/java/hu/bme/mit/train/controller/TrainControllerImpl.java index bf05e98e8..588c00497 100644 --- a/train-controller/src/main/java/hu/bme/mit/train/controller/TrainControllerImpl.java +++ b/train-controller/src/main/java/hu/bme/mit/train/controller/TrainControllerImpl.java @@ -1,6 +1,14 @@ package hu.bme.mit.train.controller; import hu.bme.mit.train.interfaces.TrainController; +import java.time.LocalDateTime; + +import java.time.LocalDate; + +import com.google.common.collect.HashBasedTable; +import com.google.common.collect.Table; + + public class TrainControllerImpl implements TrainController { @@ -53,4 +61,11 @@ public void emergencyBreak() { enforceSpeedLimit(); } + @Override + public Table getTable() { + Table tabla = new HashBasedTable().create(); + tabla.put((LocalDate).now(), user.getJoystickPosition(), controller.getReferenceSpeed()); + return tabla; + } + } diff --git a/train-system/src/main/java/hu/bme/mit/train/system/TrainSystem.java b/train-system/src/main/java/hu/bme/mit/train/system/TrainSystem.java index 4ef42638b..0b01baa9e 100644 --- a/train-system/src/main/java/hu/bme/mit/train/system/TrainSystem.java +++ b/train-system/src/main/java/hu/bme/mit/train/system/TrainSystem.java @@ -7,6 +7,11 @@ import hu.bme.mit.train.sensor.TrainSensorImpl; import hu.bme.mit.train.user.TrainUserImpl; +import java.time.LocalDateTime; + +import com.google.common.collect.HashBasedTable; +import com.google.common.collect.Table; + public class TrainSystem { private TrainController controller = new TrainControllerImpl(); @@ -25,4 +30,14 @@ public TrainUser getUser() { return user; } + Table tabla = HashBasedTable.create(); + + public Table getTable() { + return tabla; + } + + public void putTable(LocalDateTime time) { + tabla.put(time, user.getJoystickPosition(), controller.getReferenceSpeed()); + } + } diff --git a/train-system/src/test/java/hu/bme/mit/train/system/TrainSystemTest.java b/train-system/src/test/java/hu/bme/mit/train/system/TrainSystemTest.java index ae2eb30ce..ebae15fbe 100644 --- a/train-system/src/test/java/hu/bme/mit/train/system/TrainSystemTest.java +++ b/train-system/src/test/java/hu/bme/mit/train/system/TrainSystemTest.java @@ -9,14 +9,20 @@ import hu.bme.mit.train.interfaces.TrainUser; import hu.bme.mit.train.system.TrainSystem; +import java.time.LocalDate; +import java.time.LocalDateTime; + public class TrainSystemTest { TrainController controller; TrainSensor sensor; TrainUser user; - + TrainSystem system = new TrainSystem(); + + @Before public void before() { + TrainSystem system = new TrainSystem(); controller = system.getController(); sensor = system.getSensor(); @@ -56,5 +62,12 @@ public void overrideSpeedLimit(){ controller.emergencyBreak(); Assert.assertEquals(0,controller.getReferenceSpeed()); } + + @Test + public void tablaTest() { + LocalDateTime time = LocalDateTime.now(); + system.putTable(time); + Assert.assertEquals(true, system.getTable().containsRow(time)); + } } From 2fe11fca69a3ee04b45beeb92bbdbb5badcf330c Mon Sep 17 00:00:00 2001 From: zolcsakgergo Date: Mon, 4 Mar 2024 17:49:18 +0100 Subject: [PATCH 11/22] bugfix --- .../train/controller/TrainControllerImpl.java | 33 ++++++++++++------- 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/train-controller/src/main/java/hu/bme/mit/train/controller/TrainControllerImpl.java b/train-controller/src/main/java/hu/bme/mit/train/controller/TrainControllerImpl.java index 588c00497..5e9b11728 100644 --- a/train-controller/src/main/java/hu/bme/mit/train/controller/TrainControllerImpl.java +++ b/train-controller/src/main/java/hu/bme/mit/train/controller/TrainControllerImpl.java @@ -1,20 +1,31 @@ package hu.bme.mit.train.controller; -import hu.bme.mit.train.interfaces.TrainController; -import java.time.LocalDateTime; - import java.time.LocalDate; +import java.time.LocalDateTime; +import java.util.Timer; +import java.util.TimerTask; import com.google.common.collect.HashBasedTable; import com.google.common.collect.Table; - +import hu.bme.mit.train.interfaces.TrainController; public class TrainControllerImpl implements TrainController { private int step = 0; private int referenceSpeed = 0; private int speedLimit = 0; + private final Timer refSpeedUpdateTimer_v1; + + public TrainControllerImpl(){ + refSpeedUpdateTimer_v1 = new Timer(); + refSpeedUpdateTimer_v1.schedule(new TimerTask() { + @Override + public void run() { + followSpeed(); + } + } , 0, 1000); + } @Override public void followSpeed() { @@ -54,18 +65,16 @@ public void setJoystickPosition(int joystickPosition) { this.step = joystickPosition; } - @Override - public void emergencyBreak() { + public void setSpeedToNull(){ setSpeedLimit(0); - enforceSpeedLimit(); + enforceSpeedLimit(); } @Override - public Table getTable() { - Table tabla = new HashBasedTable().create(); - tabla.put((LocalDate).now(), user.getJoystickPosition(), controller.getReferenceSpeed()); - return tabla; + public void emergencyBreaking() { + setSpeedToNull(); } - + } + From 053b3c63a4e8786062b14004404885759b135b8e Mon Sep 17 00:00:00 2001 From: zolcsakgergo Date: Mon, 4 Mar 2024 17:53:05 +0100 Subject: [PATCH 12/22] bugfix --- .../src/main/java/hu/bme/mit/train/system/TrainSystem.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/train-system/src/main/java/hu/bme/mit/train/system/TrainSystem.java b/train-system/src/main/java/hu/bme/mit/train/system/TrainSystem.java index 0b01baa9e..3e0885736 100644 --- a/train-system/src/main/java/hu/bme/mit/train/system/TrainSystem.java +++ b/train-system/src/main/java/hu/bme/mit/train/system/TrainSystem.java @@ -35,9 +35,8 @@ public TrainUser getUser() { public Table getTable() { return tabla; } - + public void putTable(LocalDateTime time) { tabla.put(time, user.getJoystickPosition(), controller.getReferenceSpeed()); } - -} +} \ No newline at end of file From 232e3f0c21fae8290488a2694b0969ccfb64e206 Mon Sep 17 00:00:00 2001 From: zolcsakgergo Date: Mon, 4 Mar 2024 18:00:05 +0100 Subject: [PATCH 13/22] import bugfix --- pom.xml | 7 +++++++ train-controller/pom.xml | 9 +++++++++ train-interfaces/pom.xml | 8 ++++++++ train-sensor/pom.xml | 9 +++++++++ train-system/pom.xml | 7 +++++++ 5 files changed, 40 insertions(+) diff --git a/pom.xml b/pom.xml index 2be9fb5f5..36478a197 100644 --- a/pom.xml +++ b/pom.xml @@ -39,6 +39,13 @@ 0.8.7 test + + + com.google.guava + guava + 31.0.1-jre + + diff --git a/train-controller/pom.xml b/train-controller/pom.xml index 02d4370dc..1f2bcc442 100644 --- a/train-controller/pom.xml +++ b/train-controller/pom.xml @@ -17,6 +17,15 @@ hu.bme.mit.train.interfaces 0.5.0-SNAPSHOT + + + com.google.guava + guava + 31.0.1-jre + + + + \ No newline at end of file diff --git a/train-interfaces/pom.xml b/train-interfaces/pom.xml index 5ce3ab115..2496cf46a 100644 --- a/train-interfaces/pom.xml +++ b/train-interfaces/pom.xml @@ -10,4 +10,12 @@ hu.bme.mit.train 0.5.0-SNAPSHOT + + + com.google.guava + guava + 31.0.1-jre + + + \ No newline at end of file diff --git a/train-sensor/pom.xml b/train-sensor/pom.xml index 0b50214b9..35913fc50 100644 --- a/train-sensor/pom.xml +++ b/train-sensor/pom.xml @@ -36,5 +36,14 @@ 0.8.7 test + + + + com.google.guava + guava + 31.0.1-jre + + + \ No newline at end of file diff --git a/train-system/pom.xml b/train-system/pom.xml index bd8083c62..a44363c79 100644 --- a/train-system/pom.xml +++ b/train-system/pom.xml @@ -32,5 +32,12 @@ hu.bme.mit.train.user 0.5.0-SNAPSHOT + + + com.google.guava + guava + 31.0.1-jre + + \ No newline at end of file From cc39804f48b864f7848f33b4c77b11ff380ceb6a Mon Sep 17 00:00:00 2001 From: zolcsakgergo Date: Mon, 4 Mar 2024 18:01:28 +0100 Subject: [PATCH 14/22] pom bugfix --- pom.xml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/pom.xml b/pom.xml index 36478a197..3572bf3f3 100644 --- a/pom.xml +++ b/pom.xml @@ -40,12 +40,6 @@ test - - com.google.guava - guava - 31.0.1-jre - - From 1e4bf65c67572b200eaff0a35215b555b1d97445 Mon Sep 17 00:00:00 2001 From: zolcsakgergo Date: Mon, 4 Mar 2024 18:04:27 +0100 Subject: [PATCH 15/22] controller impl fix --- .../java/hu/bme/mit/train/controller/TrainControllerImpl.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/train-controller/src/main/java/hu/bme/mit/train/controller/TrainControllerImpl.java b/train-controller/src/main/java/hu/bme/mit/train/controller/TrainControllerImpl.java index 5e9b11728..da9e92e37 100644 --- a/train-controller/src/main/java/hu/bme/mit/train/controller/TrainControllerImpl.java +++ b/train-controller/src/main/java/hu/bme/mit/train/controller/TrainControllerImpl.java @@ -76,5 +76,4 @@ public void emergencyBreaking() { setSpeedToNull(); } -} - +} \ No newline at end of file From 03ff1b85b12715204e348d5eabeaa07f5f779fcf Mon Sep 17 00:00:00 2001 From: zolcsakgergo Date: Mon, 4 Mar 2024 18:08:04 +0100 Subject: [PATCH 16/22] formatting --- train-controller/pom.xml | 8 ++++---- train-interfaces/pom.xml | 12 ++++++------ train-sensor/pom.xml | 12 +++++------- train-system/pom.xml | 8 ++++---- 4 files changed, 19 insertions(+), 21 deletions(-) diff --git a/train-controller/pom.xml b/train-controller/pom.xml index 1f2bcc442..015bd622a 100644 --- a/train-controller/pom.xml +++ b/train-controller/pom.xml @@ -18,11 +18,11 @@ 0.5.0-SNAPSHOT - + com.google.guava - guava - 31.0.1-jre - + guava + 31.0.1-jre + diff --git a/train-interfaces/pom.xml b/train-interfaces/pom.xml index 2496cf46a..28d6a30c6 100644 --- a/train-interfaces/pom.xml +++ b/train-interfaces/pom.xml @@ -10,12 +10,12 @@ hu.bme.mit.train 0.5.0-SNAPSHOT - - - com.google.guava - guava + + + com.google.guava + guava 31.0.1-jre - - + + \ No newline at end of file diff --git a/train-sensor/pom.xml b/train-sensor/pom.xml index 35913fc50..e842b3542 100644 --- a/train-sensor/pom.xml +++ b/train-sensor/pom.xml @@ -36,13 +36,11 @@ 0.8.7 test - - - - com.google.guava - guava - 31.0.1-jre - + + com.google.guava + guava + 31.0.1-jre + diff --git a/train-system/pom.xml b/train-system/pom.xml index a44363c79..7196c448e 100644 --- a/train-system/pom.xml +++ b/train-system/pom.xml @@ -33,11 +33,11 @@ 0.5.0-SNAPSHOT - - com.google.guava - guava + + com.google.guava + guava 31.0.1-jre - + \ No newline at end of file From 2ebf18f631ae088fc59adcda61030fe67e2b4d19 Mon Sep 17 00:00:00 2001 From: zolcsakgergo Date: Mon, 4 Mar 2024 18:09:22 +0100 Subject: [PATCH 17/22] typo fix --- train-interfaces/pom.xml | 2 +- train-sensor/pom.xml | 2 +- train-system/pom.xml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/train-interfaces/pom.xml b/train-interfaces/pom.xml index 28d6a30c6..6bee696f1 100644 --- a/train-interfaces/pom.xml +++ b/train-interfaces/pom.xml @@ -12,7 +12,7 @@ - com.google.guava + com.google.guava guava 31.0.1-jre diff --git a/train-sensor/pom.xml b/train-sensor/pom.xml index e842b3542..a1b429c2c 100644 --- a/train-sensor/pom.xml +++ b/train-sensor/pom.xml @@ -37,7 +37,7 @@ test - com.google.guava + com.google.guava guava 31.0.1-jre diff --git a/train-system/pom.xml b/train-system/pom.xml index 7196c448e..8d93a09e6 100644 --- a/train-system/pom.xml +++ b/train-system/pom.xml @@ -34,7 +34,7 @@ - com.google.guava + com.google.guava guava 31.0.1-jre From 4221c516b7a01e1fb2f354c920f778eb068d1c8c Mon Sep 17 00:00:00 2001 From: zolcsakgergo Date: Mon, 4 Mar 2024 18:13:30 +0100 Subject: [PATCH 18/22] fixes --- .../train/controller/TrainControllerImpl.java | 26 +------------------ 1 file changed, 1 insertion(+), 25 deletions(-) diff --git a/train-controller/src/main/java/hu/bme/mit/train/controller/TrainControllerImpl.java b/train-controller/src/main/java/hu/bme/mit/train/controller/TrainControllerImpl.java index da9e92e37..5dc017d60 100644 --- a/train-controller/src/main/java/hu/bme/mit/train/controller/TrainControllerImpl.java +++ b/train-controller/src/main/java/hu/bme/mit/train/controller/TrainControllerImpl.java @@ -2,31 +2,14 @@ import java.time.LocalDate; import java.time.LocalDateTime; -import java.util.Timer; -import java.util.TimerTask; import com.google.common.collect.HashBasedTable; import com.google.common.collect.Table; - import hu.bme.mit.train.interfaces.TrainController; - public class TrainControllerImpl implements TrainController { - private int step = 0; private int referenceSpeed = 0; private int speedLimit = 0; - private final Timer refSpeedUpdateTimer_v1; - - public TrainControllerImpl(){ - refSpeedUpdateTimer_v1 = new Timer(); - refSpeedUpdateTimer_v1.schedule(new TimerTask() { - @Override - public void run() { - followSpeed(); - } - } , 0, 1000); - } - @Override public void followSpeed() { if (referenceSpeed < 0) { @@ -38,42 +21,35 @@ public void followSpeed() { referenceSpeed = 0; } } - enforceSpeedLimit(); } - @Override public int getReferenceSpeed() { return referenceSpeed; } - @Override public void setSpeedLimit(int speedLimit) { this.speedLimit = speedLimit; enforceSpeedLimit(); } - private void enforceSpeedLimit() { if (referenceSpeed > speedLimit) { referenceSpeed = speedLimit; } } - @Override public void setJoystickPosition(int joystickPosition) { this.step = joystickPosition; } - @Override public void setSpeedToNull(){ setSpeedLimit(0); enforceSpeedLimit(); } - @Override public void emergencyBreaking() { setSpeedToNull(); } - + } \ No newline at end of file From 56eeba84d376b60e8b310ce431c726894336e1e4 Mon Sep 17 00:00:00 2001 From: zolcsakgergo Date: Mon, 4 Mar 2024 18:16:09 +0100 Subject: [PATCH 19/22] abstract function override bugfix --- .../java/hu/bme/mit/train/interfaces/TrainController.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/train-interfaces/src/main/java/hu/bme/mit/train/interfaces/TrainController.java b/train-interfaces/src/main/java/hu/bme/mit/train/interfaces/TrainController.java index 5bca99613..00e5e9a34 100644 --- a/train-interfaces/src/main/java/hu/bme/mit/train/interfaces/TrainController.java +++ b/train-interfaces/src/main/java/hu/bme/mit/train/interfaces/TrainController.java @@ -1,5 +1,6 @@ package hu.bme.mit.train.interfaces; + public interface TrainController { void followSpeed(); @@ -9,7 +10,9 @@ public interface TrainController { void setSpeedLimit(int speedLimit); void setJoystickPosition(int joystickPosition); + + void setSpeedToNull(); - void emergencyBreak(); + void emergencyBreaking(); } From b75a5fbfcdcd5d3516ba48a0ae8cfad5d876cf95 Mon Sep 17 00:00:00 2001 From: zolcsakgergo Date: Mon, 4 Mar 2024 18:18:39 +0100 Subject: [PATCH 20/22] finished --- .../src/test/java/hu/bme/mit/train/system/TrainSystemTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/train-system/src/test/java/hu/bme/mit/train/system/TrainSystemTest.java b/train-system/src/test/java/hu/bme/mit/train/system/TrainSystemTest.java index ebae15fbe..5a4ed22b4 100644 --- a/train-system/src/test/java/hu/bme/mit/train/system/TrainSystemTest.java +++ b/train-system/src/test/java/hu/bme/mit/train/system/TrainSystemTest.java @@ -59,7 +59,7 @@ public void OverridingJoystickPositionToNegative_SetsReferenceSpeedToZero() { @Test public void overrideSpeedLimit(){ - controller.emergencyBreak(); + controller.emergencyBreaking(); Assert.assertEquals(0,controller.getReferenceSpeed()); } From 71b1b765f11e734710aec5f28042ecebff02cc5c Mon Sep 17 00:00:00 2001 From: Egi2018 Date: Mon, 18 Mar 2024 16:33:42 +0100 Subject: [PATCH 21/22] Idozitett futattatas --- .../train/controller/TrainControllerImpl.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/train-controller/src/main/java/hu/bme/mit/train/controller/TrainControllerImpl.java b/train-controller/src/main/java/hu/bme/mit/train/controller/TrainControllerImpl.java index 5dc017d60..9f8307834 100644 --- a/train-controller/src/main/java/hu/bme/mit/train/controller/TrainControllerImpl.java +++ b/train-controller/src/main/java/hu/bme/mit/train/controller/TrainControllerImpl.java @@ -10,6 +10,23 @@ public class TrainControllerImpl implements TrainController { private int step = 0; private int referenceSpeed = 0; private int speedLimit = 0; + private Timer time = new Timer(); + + public TrainControllerImpl (){ + + time.schedule(new TimerTask() { + @Override + public void run() { + ActivityName.this.runOnUiThread(new Runnable(){ + @Override + public void run() { + this.followSpeed(); + } + }); + } + }, 2000); + } + @Override public void followSpeed() { if (referenceSpeed < 0) { @@ -40,7 +57,7 @@ private void enforceSpeedLimit() { } @Override public void setJoystickPosition(int joystickPosition) { - this.step = joystickPosition; + this.step = joystickPosition; } @Override public void setSpeedToNull(){ From 293bf0288dadb2a6d074b3f17a762fe008e7fe12 Mon Sep 17 00:00:00 2001 From: zolcsakgergo Date: Mon, 18 Mar 2024 16:33:34 +0100 Subject: [PATCH 22/22] trainController implemented using Thread --- .../train/controller/TrainControllerImpl.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/train-controller/src/main/java/hu/bme/mit/train/controller/TrainControllerImpl.java b/train-controller/src/main/java/hu/bme/mit/train/controller/TrainControllerImpl.java index 5dc017d60..ca8478a17 100644 --- a/train-controller/src/main/java/hu/bme/mit/train/controller/TrainControllerImpl.java +++ b/train-controller/src/main/java/hu/bme/mit/train/controller/TrainControllerImpl.java @@ -10,6 +10,25 @@ public class TrainControllerImpl implements TrainController { private int step = 0; private int referenceSpeed = 0; private int speedLimit = 0; + private Thread t; + + public TrainControllerImpl(){ + t = new Thread() { + public void run(){ + t.run(); + try{ + followSpeed(); + thread.sleep(2000); + }catch (InterruptedException e){ + e.printStackTrace(); + } + } + }; + } + + + + @Override public void followSpeed() { if (referenceSpeed < 0) {