Web-based application racing team simulation. this application demonstrate how to achieve 1ms looping in JavaScript with web worker (by default JavaScript setInterval just can achieve 10ms). every 1ms car simulation will send vehicle status through websocket.
And in other side Team Racing can monitor the vehicle status in realtime (with 10ms refresh rate).
For public User/ Client, can get the last 5 minutes history data from database.
This web application can work for multi car simulator & multi dashboard
This application consist of 3 component
- Car Connector
- Team Dashboard
- Client
Components used to create a simulated car with random Speed, Brake, and Gear positions
Components used to Monitor race data sending from the car in realtime
Components used to view data by Public/ Client
Make sure the machine you want to use to run this web application has access to the PostgreSQL database
- Create a Database with the name mercedesteam
- Create a Schema with the name mercedesteam
- Edit file scr/main/resources/application.properties with your Database Host
spring.datasource.url=jdbc:postgresql://{db_host}/mercedesteam - Edit file scr/main/resources/application.properties with your Database credential
spring.datasource.username={your_username} spring.datasource.password={your_password} - Edit file pom.xml and add PostgreSQL Dependency
<dependency> <groupId>org.postgresql</groupId> <artifactId>postgresql</artifactId> <scope>runtime</scope> </dependency>
Make sure the machine you want to use to run this web application has access to the MySQL database
- Create a Database/Schema with the name mercedesteam
- Edit file scr/main/resources/application.properties and comment all PostgreSQL configuration section :
## Postgres #spring.datasource.driver-class-name = org.postgresql.Driver #spring.datasource.platform=postgres #spring.datasource.url=jdbc:postgresql://192.168.56.102:5432/mercedesteam #spring.datasource.username=postgres #spring.datasource.password=postgres #spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQL10Dialect
- Edit file scr/main/resources/application.properties and uncomment all MySQL configuration section :
# MySQL spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5Dialect spring.jpa.properties.hibernate.dialect.storage_engine=myisam spring.datasource.url=jdbc:mysql://${MYSQL_HOST:localhost}:3306/mercedesteam spring.datasource.username=admin spring.datasource.password=Admin0011* spring.datasource.driver-class-name =com.mysql.cj.jdbc.Driver
- Edit file scr/main/resources/application.properties with your Database Host
spring.datasource.url=jdbc:mysql://{db_host}:3306/mercedesteam - Edit file scr/main/resources/application.properties with your Database credential
spring.datasource.username={your_username} spring.datasource.password={your_password}
- Edit file pom.xml and add MySQL Dependency
<dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <scope>runtime</scope> </dependency>
For Windows 10 user please use PowerShell
- Goto project root folder
cd {your_directory}/mercedes-team - Clean java build directory
./mvnw clean - Install & download all dependency
./mvnw install - Run the web application
./mvnw spring-boot:run - Open localhost:7076 in your browser
- You will have 3 button. Car Connector, Team Dashboard, and Client
- Open car connector by clicking Car Connector on Homepage or open directly in browser at localhost:7076/car
- Make a car simulation to the connector by entering the vehicle id ex. lewis
- Click connect, and you will see the car instrument will generate value for speed, brake, and gear
- Open Team Dashboard by clicking Team Dashboard on Homepage or open directly in browser at localhost:7076/dashboard
- Connect with the car you want to monitor by entering the vehicle id and click connect
- Once connected you will see the car status in realtime
- To view all data history, you can click history button
- Open Client Component by Click Client on Homepage or open directly in browser at localhost:7076/client
- To get the data history you need to enter the vehicle id
- Click get button
- *note this will only be able to access the last 5 minutes history data, and max 2 hours after the data is created
For further reference, please consider the following sections:
- Official Apache Maven documentation
- Spring Boot Maven Plugin Reference Guide
- Create an OCI image
- Thymeleaf
- Spring Boot DevTools
- Spring Web
- Spring Data JPA
- WebSocket
The following guides illustrate how to use some features concretely: