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
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
diff --git a/README.md b/README.md
index e26e034fc..527426c82 100644
--- a/README.md
+++ b/README.md
@@ -62,3 +62,15 @@ 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
+
+#### branch-a change
+
+#### branch-b change
+#### changes on A
diff --git a/pom.xml b/pom.xml
index 2be9fb5f5..3572bf3f3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -39,6 +39,7 @@
0.8.7
test
+
diff --git a/train-controller/pom.xml b/train-controller/pom.xml
index 02d4370dc..015bd622a 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-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..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
@@ -1,12 +1,31 @@
package hu.bme.mit.train.controller;
-import hu.bme.mit.train.interfaces.TrainController;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+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 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() {
@@ -19,31 +38,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;
+ this.step = joystickPosition;
+ }
+ @Override
+ public void setSpeedToNull(){
+ setSpeedLimit(0);
+ enforceSpeedLimit();
+ }
+ @Override
+ public void emergencyBreaking() {
+ setSpeedToNull();
}
-}
+}
\ No newline at end of file
diff --git a/train-interfaces/pom.xml b/train-interfaces/pom.xml
index 5ce3ab115..6bee696f1 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-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..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();
@@ -10,4 +11,8 @@ public interface TrainController {
void setJoystickPosition(int joystickPosition);
+ void setSpeedToNull();
+
+ void emergencyBreaking();
+
}
diff --git a/train-sensor/pom.xml b/train-sensor/pom.xml
index 0b50214b9..a1b429c2c 100644
--- a/train-sensor/pom.xml
+++ b/train-sensor/pom.xml
@@ -36,5 +36,12 @@
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..8d93a09e6 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
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..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
@@ -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,13 @@ 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());
+ }
+}
\ No newline at end of file
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..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
@@ -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();
@@ -50,5 +56,18 @@ public void OverridingJoystickPositionToNegative_SetsReferenceSpeedToZero() {
Assert.assertEquals(0, controller.getReferenceSpeed());
}
+
+ @Test
+ public void overrideSpeedLimit(){
+ controller.emergencyBreaking();
+ Assert.assertEquals(0,controller.getReferenceSpeed());
+ }
+
+ @Test
+ public void tablaTest() {
+ LocalDateTime time = LocalDateTime.now();
+ system.putTable(time);
+ Assert.assertEquals(true, system.getTable().containsRow(time));
+ }
}