This is project is to generate simulated real-time MQTT message for the Connected Vehicle Demo project.
You could setup routes in this project, please check the web project for configurations of icon and picture of vehicles.
File config.js is where we write the configuration:
const appConfig = {
//"trace","debug","info","warn","error"
"logLevel": "debug",
"mqtt": {
brokerUrl: "tcp://localhost:1883",
clientOptions: {
clientId: "connected-vehicle-data-generator",
username: "default",
password: "default",
}
},
"vehicles": [
{
route: "R41", // must be the id of one route
type: "HAUL",
number: 30,
speed: 50, // km/hour
IDPrefix: "HW", // the id will be from IDPrefix+"001" to IDPrefix+"number"
reportInterval: 2, // seconds
},
{
route: "R41",
type: "WATER",
number: 5,
speed: 25,
IDPrefix: "WT",
reportInterval: 3,
},
],
"routes": [
{
"id": "R41",
"coordinates": [
[119.670202,-23.359829],
[119.6686864,-23.3599466],
[119.6686864,-23.3599466],
// .....
],
},
],
}
- Modify the
mqtt
section to point to the same Solace broker with the web project vehicles
is a list of vehicle group objects, for each vehicle group you need specify:route
: The ID of the route. This data generator will move the vehicles along this routetype
: The web porject will show icon and picture of the vehicle based on it's typenumber
: How many vehicles will be simulatedspeed
: The unit of speed is km/hIDPrefix
: Each vehicle has a unique ID, start atIDPrefix
+"001" toIDPrefix
+"number". Don't use the sameIDPrefix
again in another groupreportInterval
: The data generator will send out a MQTT message of each vehicle in this group on everyreportInterval
seconds.
routes
is a list of route object, a route object consists of a uniqueid
and acoordinates
coordinates
is a list of position, a position is an array of two numbers, this first is longitude the second is latitude, just like thecoordinates
in the LineString of the The GeoJSON Format
- run
npm install
first to install all dependencies - run
node app.js
to start the generator
> node app.js
Init 30 HAUL vehicles on route R41
Init 5 WATER vehicles on route R41
Init 20 HAUL vehicles on route R07
Init 5 WATER vehicles on route R07
Connected, ready to send mqtt messages ...
Start all 60 vehicles
Press Ctrl+C to exit ...
- run
docker build . -t ichen/data-generator:0.0.1
to build the Docker image
- run below command to create the container
- run
docker start ichen-data-generator
to start the data generator
docker create --restart unless-stopped \
--mount type=bind,src=/home/ichen/mining-data-config.js,dst=/app/config.js \
--name=ichen-data-generator ichen/data-generator:0.0.1
You could use Map Polygon/Polyline Tool to draw a path on the map, then copy the "coordinates" into the config file.