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/Developer b/Developer
new file mode 100644
index 000000000..e69de29bb
diff --git a/README.md b/README.md
index e26e034fc..c47570df8 100644
--- a/README.md
+++ b/README.md
@@ -62,3 +62,12 @@ 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.
+
+
+### Change readme
+1. Line one
+2. Branch-B supremacy
+2. Line not the one you need
+3. Line three
+[where does it lead to](www.imgur.com/a/G6rU8)
+*Asterisk*
diff --git a/pom.xml b/pom.xml
index 2be9fb5f5..bf1e14ce9 100644
--- a/pom.xml
+++ b/pom.xml
@@ -39,6 +39,14 @@
0.8.7
test
+
+
+
+ com.google.guava
+ guava
+ 33.0.0-jre
+
+
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..43ac663f9 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,20 @@
package hu.bme.mit.train.controller;
import hu.bme.mit.train.interfaces.TrainController;
+import java.util.Timer;
+import java.util.TimerTask;
public class TrainControllerImpl implements TrainController {
private int step = 0;
private int referenceSpeed = 0;
private int speedLimit = 0;
+ TimerTask task = new TimerTask(){
+ public void run(){
+ followSpeed();
+ }
+ };
+ Timer timer = null;
@Override
public void followSpeed() {
@@ -19,7 +27,10 @@ public void followSpeed() {
referenceSpeed = 0;
}
}
-
+ if(timer == null){
+ timer = new Timer();
+ timer.schedule(task, 0, 500);
+ }
enforceSpeedLimit();
}
@@ -43,7 +54,14 @@ private void enforceSpeedLimit() {
@Override
public void setJoystickPosition(int joystickPosition) {
- this.step = joystickPosition;
+ this.step = joystickPosition;
+ }
+
+ @Override
+ public void emergencyBrake(){
+ if(step < -10){
+ referenceSpeed = 0;
+ }
}
}
diff --git a/train-controller/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/train-controller/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst
new file mode 100644
index 000000000..fd81f58cf
--- /dev/null
+++ b/train-controller/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst
@@ -0,0 +1,2 @@
+hu/bme/mit/train/controller/TrainControllerImpl.class
+hu/bme/mit/train/controller/TrainControllerImpl$1.class
diff --git a/train-controller/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/train-controller/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst
new file mode 100644
index 000000000..ef45cbc94
--- /dev/null
+++ b/train-controller/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst
@@ -0,0 +1 @@
+/home/cloud/ReteLabMIT2/train-controller/src/main/java/hu/bme/mit/train/controller/TrainControllerImpl.java
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..e4e11ab92 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,4 +10,6 @@ public interface TrainController {
void setJoystickPosition(int joystickPosition);
+ void emergencyBrake();
+
}
diff --git a/train-interfaces/src/main/java/hu/bme/mit/train/interfaces/TrainSensor.java b/train-interfaces/src/main/java/hu/bme/mit/train/interfaces/TrainSensor.java
index 298173025..7027f9798 100644
--- a/train-interfaces/src/main/java/hu/bme/mit/train/interfaces/TrainSensor.java
+++ b/train-interfaces/src/main/java/hu/bme/mit/train/interfaces/TrainSensor.java
@@ -1,4 +1,6 @@
package hu.bme.mit.train.interfaces;
+import com.google.common.collect.Table;
+import java.time.LocalTime;
public interface TrainSensor {
@@ -6,4 +8,13 @@ public interface TrainSensor {
void overrideSpeedLimit(int speedLimit);
+ LocalTime getCurrentTime();
+
+ int getJoystickPosition();
+
+ int getReferenceSpeed();
+
+ void addToTable();
+
+ int getTableSize();
}
diff --git a/train-interfaces/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/train-interfaces/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst
new file mode 100644
index 000000000..248759f35
--- /dev/null
+++ b/train-interfaces/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst
@@ -0,0 +1,3 @@
+hu/bme/mit/train/interfaces/TrainController.class
+hu/bme/mit/train/interfaces/TrainSensor.class
+hu/bme/mit/train/interfaces/TrainUser.class
diff --git a/train-interfaces/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/train-interfaces/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst
new file mode 100644
index 000000000..d4a6e4df1
--- /dev/null
+++ b/train-interfaces/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst
@@ -0,0 +1,3 @@
+/home/cloud/yjrrbk/ReteLabMIT2/train-interfaces/src/main/java/hu/bme/mit/train/interfaces/TrainSensor.java
+/home/cloud/yjrrbk/ReteLabMIT2/train-interfaces/src/main/java/hu/bme/mit/train/interfaces/TrainController.java
+/home/cloud/yjrrbk/ReteLabMIT2/train-interfaces/src/main/java/hu/bme/mit/train/interfaces/TrainUser.java
diff --git a/train-sensor/src/main/java/hu/bme/mit/train/sensor/TrainSensorImpl.java b/train-sensor/src/main/java/hu/bme/mit/train/sensor/TrainSensorImpl.java
index 4a640d1dd..3813d12f0 100644
--- a/train-sensor/src/main/java/hu/bme/mit/train/sensor/TrainSensorImpl.java
+++ b/train-sensor/src/main/java/hu/bme/mit/train/sensor/TrainSensorImpl.java
@@ -4,11 +4,16 @@
import hu.bme.mit.train.interfaces.TrainSensor;
import hu.bme.mit.train.interfaces.TrainUser;
+import com.google.common.collect.Table;
+import com.google.common.collect.HashBasedTable;
+import java.time.LocalTime;
+
public class TrainSensorImpl implements TrainSensor {
private TrainController controller;
private TrainUser user;
private int speedLimit = 5;
+ private Table table = HashBasedTable.create();
public TrainSensorImpl(TrainController controller, TrainUser user) {
this.controller = controller;
@@ -26,4 +31,29 @@ public void overrideSpeedLimit(int speedLimit) {
controller.setSpeedLimit(speedLimit);
}
+ @Override
+ public LocalTime getCurrentTime(){
+ return LocalTime.now();
+ }
+
+ @Override
+ public int getJoystickPosition(){
+ return user.getJoystickPosition();
+ }
+
+ @Override
+ public int getReferenceSpeed(){
+ return controller.getReferenceSpeed();
+ }
+
+ @Override
+ public void addToTable(){
+ table.put(getCurrentTime(), getJoystickPosition(), getReferenceSpeed());
+ }
+
+ @Override
+ public int getTableSize(){
+ return table.size();
+ }
+
}
diff --git a/train-sensor/src/test/java/hu/bme/mit/train/sensor/TrainSensorTest.java b/train-sensor/src/test/java/hu/bme/mit/train/sensor/TrainSensorTest.java
index ae5dee21b..c28cca4a4 100644
--- a/train-sensor/src/test/java/hu/bme/mit/train/sensor/TrainSensorTest.java
+++ b/train-sensor/src/test/java/hu/bme/mit/train/sensor/TrainSensorTest.java
@@ -5,15 +5,20 @@
import org.junit.Test;
import static org.mockito.Mockito.*;
+import com.google.common.collect.HashBasedTable;
+import com.google.common.collect.Table;
+import java.time.LocalTime;
+
public class TrainSensorTest {
+ /*
@Before
public void before() {
- // TODO Add initializations
+
}
@Test
- public void ThisIsAnExampleTestStub() {
- // TODO Delete this and add test cases based on the issues
- }
+ public void TableRowAddedTest() {
+
+ }*/
}
diff --git a/train-sensor/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/train-sensor/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst
new file mode 100644
index 000000000..5c6a37510
--- /dev/null
+++ b/train-sensor/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst
@@ -0,0 +1 @@
+hu/bme/mit/train/sensor/TrainSensorImpl.class
diff --git a/train-sensor/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/train-sensor/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst
new file mode 100644
index 000000000..c609fe074
--- /dev/null
+++ b/train-sensor/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst
@@ -0,0 +1 @@
+/home/cloud/yjrrbk/ReteLabMIT2/train-sensor/src/main/java/hu/bme/mit/train/sensor/TrainSensorImpl.java
diff --git a/train-sensor/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst b/train-sensor/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst
new file mode 100644
index 000000000..0ad3f3de4
--- /dev/null
+++ b/train-sensor/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst
@@ -0,0 +1 @@
+hu/bme/mit/train/sensor/TrainSensorTest.class
diff --git a/train-sensor/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst b/train-sensor/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst
new file mode 100644
index 000000000..3969807bf
--- /dev/null
+++ b/train-sensor/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst
@@ -0,0 +1 @@
+/home/cloud/ReteLabMIT2/train-sensor/src/test/java/hu/bme/mit/train/sensor/TrainSensorTest.java
diff --git a/train-sensor/target/surefire-reports/TEST-hu.bme.mit.train.sensor.TrainSensorTest.xml b/train-sensor/target/surefire-reports/TEST-hu.bme.mit.train.sensor.TrainSensorTest.xml
new file mode 100644
index 000000000..83944a414
--- /dev/null
+++ b/train-sensor/target/surefire-reports/TEST-hu.bme.mit.train.sensor.TrainSensorTest.xml
@@ -0,0 +1,64 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/train-sensor/target/surefire-reports/hu.bme.mit.train.sensor.TrainSensorTest.txt b/train-sensor/target/surefire-reports/hu.bme.mit.train.sensor.TrainSensorTest.txt
new file mode 100644
index 000000000..14a3e545e
--- /dev/null
+++ b/train-sensor/target/surefire-reports/hu.bme.mit.train.sensor.TrainSensorTest.txt
@@ -0,0 +1,4 @@
+-------------------------------------------------------------------------------
+Test set: hu.bme.mit.train.sensor.TrainSensorTest
+-------------------------------------------------------------------------------
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.105 sec
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..a7aa66ad5 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,18 @@ public void OverridingJoystickPositionToNegative_SetsReferenceSpeedToZero() {
Assert.assertEquals(0, controller.getReferenceSpeed());
}
-
+ @Test
+ public void EmergencyBrakeFunctions(){
+ controller.setJoystickPosition(-10);
+ controller.emergencyBrake();
+ Assert.assertEquals(0, controller.getReferenceSpeed());
+ }
+
+ @Test
+ public void TableRowAddedTest() {
+ sensor.addToTable();
+ Assert.assertEquals(1, sensor.getTableSize());
+ sensor.addToTable();
+ Assert.assertEquals(2, sensor.getTableSize());
+ }
}
diff --git a/train-system/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/train-system/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst
new file mode 100644
index 000000000..104d0eff5
--- /dev/null
+++ b/train-system/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst
@@ -0,0 +1 @@
+hu/bme/mit/train/system/TrainSystem.class
diff --git a/train-system/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/train-system/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst
new file mode 100644
index 000000000..4f8770c3f
--- /dev/null
+++ b/train-system/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst
@@ -0,0 +1 @@
+/home/cloud/ReteLabMIT2/train-system/src/main/java/hu/bme/mit/train/system/TrainSystem.java
diff --git a/train-system/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst b/train-system/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst
new file mode 100644
index 000000000..f347beb05
--- /dev/null
+++ b/train-system/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst
@@ -0,0 +1 @@
+hu/bme/mit/train/system/TrainSystemTest.class
diff --git a/train-system/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst b/train-system/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst
new file mode 100644
index 000000000..0df0d9e41
--- /dev/null
+++ b/train-system/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst
@@ -0,0 +1 @@
+/home/cloud/ReteLabMIT2/train-system/src/test/java/hu/bme/mit/train/system/TrainSystemTest.java
diff --git a/train-system/target/surefire-reports/TEST-hu.bme.mit.train.system.TrainSystemTest.xml b/train-system/target/surefire-reports/TEST-hu.bme.mit.train.system.TrainSystemTest.xml
new file mode 100644
index 000000000..9428d0f86
--- /dev/null
+++ b/train-system/target/surefire-reports/TEST-hu.bme.mit.train.system.TrainSystemTest.xml
@@ -0,0 +1,67 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/train-system/target/surefire-reports/hu.bme.mit.train.system.TrainSystemTest.txt b/train-system/target/surefire-reports/hu.bme.mit.train.system.TrainSystemTest.txt
new file mode 100644
index 000000000..276aeb512
--- /dev/null
+++ b/train-system/target/surefire-reports/hu.bme.mit.train.system.TrainSystemTest.txt
@@ -0,0 +1,4 @@
+-------------------------------------------------------------------------------
+Test set: hu.bme.mit.train.system.TrainSystemTest
+-------------------------------------------------------------------------------
+Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.123 sec
diff --git a/train-user/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/train-user/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst
new file mode 100644
index 000000000..f84f69174
--- /dev/null
+++ b/train-user/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst
@@ -0,0 +1 @@
+hu/bme/mit/train/user/TrainUserImpl.class
diff --git a/train-user/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/train-user/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst
new file mode 100644
index 000000000..8664864ab
--- /dev/null
+++ b/train-user/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst
@@ -0,0 +1 @@
+/home/cloud/yjrrbk/ReteLabMIT2/train-user/src/main/java/hu/bme/mit/train/user/TrainUserImpl.java