Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Egon #350

Open
wants to merge 24 commits into
base: master
Choose a base branch
from
Open

Egon #350

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
@@ -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
35 changes: 35 additions & 0 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
@@ -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
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
<version>0.8.7</version>
<scope>test</scope>
</dependency>

</dependencies>

<build>
Expand Down
9 changes: 9 additions & 0 deletions train-controller/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@
<artifactId>hu.bme.mit.train.interfaces</artifactId>
<version>0.5.0-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>31.0.1-jre</version>
</dependency>

</dependencies>



</project>
Original file line number Diff line number Diff line change
@@ -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() {
Expand All @@ -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();
}

}
}
8 changes: 8 additions & 0 deletions train-interfaces/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,12 @@
<groupId>hu.bme.mit.train</groupId>
<version>0.5.0-SNAPSHOT</version>
</parent>
<dependencies>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>31.0.1-jre</version>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package hu.bme.mit.train.interfaces;


public interface TrainController {

void followSpeed();
Expand All @@ -10,4 +11,8 @@ public interface TrainController {

void setJoystickPosition(int joystickPosition);

void setSpeedToNull();

void emergencyBreaking();

}
7 changes: 7 additions & 0 deletions train-sensor/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,12 @@
<version>0.8.7</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>31.0.1-jre</version>
</dependency>


</dependencies>
</project>
7 changes: 7 additions & 0 deletions train-system/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,12 @@
<artifactId>hu.bme.mit.train.user</artifactId>
<version>0.5.0-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>31.0.1-jre</version>
</dependency>

</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -25,4 +30,13 @@ public TrainUser getUser() {
return user;
}

}
Table<LocalDateTime, Integer, Integer> tabla = HashBasedTable.create();

public Table<LocalDateTime, Integer, Integer> getTable() {
return tabla;
}

public void putTable(LocalDateTime time) {
tabla.put(time, user.getJoystickPosition(), controller.getReferenceSpeed());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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));
}

}