The JavaScript version is the initial prototype of the driver client. Currently it can be used to visualize a vehicle's trip and to track stop requests. However it has no connection to the bus' hardware.
The more recent Python version can be found here: https://github.com/STOP2/stop2-rpi
The project consists of two parts:
back
folder - Docker-module for providing data to frontendfront
folder - frontend JavaScript prototype
Code is in the src
folder:
Main.js
- EntrypointNetworkHandler.js
- Connection to the MQTT broker, STOP2 and HSL APIsUI.js
- User interfaceGeometry.js
- Calculates the vehicle's positionTrip.js
- Trip object (contains the list of stops & other data)Logger.js
- Error and debug logging logic
In the root of the front
folder, run the following commands:
npm install
- Install dependencieswebpack
- Bundle all of the code and the dependencies into a single JavaScript file,dist/bundle.js
. Remember to run this every time you edit the files
- Open
index.html
Docker-container with mosquitto listening to ports 1883 (MQTT) and 9001 (websocket).
In the project directory:
docker build -t mosquitto -f back/Dockerfile .
docker run -p 1883:1883 -p 9001:9001 mosquitto
Tests can be run locally (inside Docker):
docker run -t -v `pwd`:/build mosquitto /build/tests/integration.sh