diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
new file mode 100644
index 000000000..b0d46cf4b
--- /dev/null
+++ b/.github/workflows/build.yml
@@ -0,0 +1,37 @@
+name: SonarCloud
+on:
+ push:
+ branches:
+ - master
+ pull_request:
+ types: [opened, synchronize, reopened]
+jobs:
+ build:
+ name: Build and analyze
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v3
+ with:
+ fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
+ - name: Set up JDK 17
+ uses: actions/setup-java@v3
+ with:
+ java-version: 17
+ distribution: 'zulu' # Alternative distribution options are available.
+ - name: Cache SonarCloud packages
+ uses: actions/cache@v3
+ with:
+ path: ~/.sonar/cache
+ key: ${{ runner.os }}-sonar
+ restore-keys: ${{ runner.os }}-sonar
+ - name: Cache Maven packages
+ uses: actions/cache@v3
+ with:
+ path: ~/.m2
+ key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
+ restore-keys: ${{ runner.os }}-m2
+ - name: Build and analyze
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
+ SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
+ run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=tothmd_base
\ No newline at end of file
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..1b03ffdb7 100644
--- a/README.md
+++ b/README.md
@@ -62,3 +62,13 @@ 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.
+
+# 3. feladat
+
+1. Ez az elso megjegyzes
+
+`Ez a masodik megjegyzes`
+
+## Ez a harmadik megjegyzes
+
+# 5. feladat branch-A
diff --git a/pom.xml b/pom.xml
index 2be9fb5f5..ff191d6b1 100644
--- a/pom.xml
+++ b/pom.xml
@@ -7,6 +7,8 @@
UTF-8
+ tothmd
+ https://sonarcloud.io
pom
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..66c72ad00 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,19 @@ public void setJoystickPosition(int joystickPosition) {
this.step = joystickPosition;
}
+ public void emergencyBreak(){
+ referenceSpeed = 0;
+ }
+
+ public void followJoystick(){
+ if(step < 0){
+ referenceSpeed -= 10;
+ }
+ else if(step > 0){
+ referenceSpeed += 10;
+ }
+ enforceSpeedLimit();
+ }
+
+
}
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..7f5a1ef4a
--- /dev/null
+++ b/train-controller/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst
@@ -0,0 +1 @@
+hu/bme/mit/train/controller/TrainControllerImpl.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..b13b01cc3
--- /dev/null
+++ b/train-controller/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst
@@ -0,0 +1 @@
+/home/cloud/base/train-controller/src/main/java/hu/bme/mit/train/controller/TrainControllerImpl.java
diff --git a/train-interfaces/pom.xml b/train-interfaces/pom.xml
index 5ce3ab115..b74a72ddd 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
+ 10.0.1
+
+
\ 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..374f49e03 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,7 @@ public interface TrainController {
void setJoystickPosition(int joystickPosition);
+ void emergencyBreak();
+
+
}
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..843a49ddb 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.*;
public interface TrainSensor {
@@ -6,4 +8,7 @@ public interface TrainSensor {
void overrideSpeedLimit(int speedLimit);
+ void recordData();
+
+ public Table getTachograph();
}
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..ca4e03d48
--- /dev/null
+++ b/train-interfaces/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst
@@ -0,0 +1,3 @@
+/home/cloud/base/train-interfaces/src/main/java/hu/bme/mit/train/interfaces/TrainUser.java
+/home/cloud/base/train-interfaces/src/main/java/hu/bme/mit/train/interfaces/TrainController.java
+/home/cloud/base/train-interfaces/src/main/java/hu/bme/mit/train/interfaces/TrainSensor.java
diff --git a/train-sensor/pom.xml b/train-sensor/pom.xml
index 0b50214b9..056698eaa 100644
--- a/train-sensor/pom.xml
+++ b/train-sensor/pom.xml
@@ -36,5 +36,10 @@
0.8.7
test
+
+ com.google.guava
+ guava
+ 10.0.1
+
\ No newline at end of file
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..06c9f51e2 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
@@ -3,12 +3,15 @@
import hu.bme.mit.train.interfaces.TrainController;
import hu.bme.mit.train.interfaces.TrainSensor;
import hu.bme.mit.train.interfaces.TrainUser;
+import com.google.common.collect.*;
+import java.time.*;
public class TrainSensorImpl implements TrainSensor {
private TrainController controller;
private TrainUser user;
private int speedLimit = 5;
+ private Table tachograph = HashBasedTable.create();
public TrainSensorImpl(TrainController controller, TrainUser user) {
this.controller = controller;
@@ -26,4 +29,14 @@ public void overrideSpeedLimit(int speedLimit) {
controller.setSpeedLimit(speedLimit);
}
+ @Override
+ public void recordData(){
+ tachograph.put(LocalTime.now(), user.getJoystickPosition() ,controller.getReferenceSpeed());
+ }
+
+ @Override
+ public Table getTachograph(){
+ return tachograph;
+ }
+
}
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..a99815748
--- /dev/null
+++ b/train-sensor/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst
@@ -0,0 +1 @@
+/home/cloud/base/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..e2a796968
--- /dev/null
+++ b/train-sensor/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst
@@ -0,0 +1 @@
+/home/cloud/base/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..b9d18d2bd
--- /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..7d8e0f52d
--- /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.177 sec
diff --git a/train-system/pom.xml b/train-system/pom.xml
index bd8083c62..43f10398e 100644
--- a/train-system/pom.xml
+++ b/train-system/pom.xml
@@ -32,5 +32,11 @@
hu.bme.mit.train.user
0.5.0-SNAPSHOT
+
+ com.google.guava
+ guava
+ 10.0.1
+
+
\ 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..7d7dc6cd5 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
@@ -25,4 +25,6 @@ public TrainUser getUser() {
return user;
}
+
+
}
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..ae863f311 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,32 @@ public void OverridingJoystickPositionToNegative_SetsReferenceSpeedToZero() {
Assert.assertEquals(0, controller.getReferenceSpeed());
}
+ @Test
+ public void EmergencyBreak(){
+ sensor.overrideSpeedLimit(10);
+ user.overrideJoystickPosition(7);
+ controller.emergencyBreak();
+ Assert.assertEquals(0, controller.getReferenceSpeed());
+ }
+
+ @Test
+ public void StartAfterEmergencyBreak(){
+ sensor.overrideSpeedLimit(10);
+ user.overrideJoystickPosition(7);
+ controller.emergencyBreak();
+ user.overrideJoystickPosition(13);
+ controller.followSpeed();
+
+ Assert.assertEquals(10, controller.getReferenceSpeed());
+ }
+
+ @Test
+ public void Tachograph(){
+ int before = sensor.getTachograph().size();
+ sensor.recordData();
+ int after = sensor.getTachograph().size();
+ Assert.assertTrue(before < after);
+ }
+
}
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..a872c23b6
--- /dev/null
+++ b/train-system/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst
@@ -0,0 +1 @@
+/home/cloud/base/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..656c56f34
--- /dev/null
+++ b/train-system/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst
@@ -0,0 +1 @@
+/home/cloud/base/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..fe77304c2
--- /dev/null
+++ b/train-system/target/surefire-reports/TEST-hu.bme.mit.train.system.TrainSystemTest.xml
@@ -0,0 +1,68 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ 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..8ead9630b
--- /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: 5, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.262 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..8cd6208d2
--- /dev/null
+++ b/train-user/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst
@@ -0,0 +1 @@
+/home/cloud/base/train-user/src/main/java/hu/bme/mit/train/user/TrainUserImpl.java