Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- List of stuff to do
- 1. Change the on_message function to put the whole json destination-request message into the queue instead of just the station-id
- 2. Change the start of the main program loop (the while true) to expect/use the whole request message dictionary instead of the station-id string
- - This is important so you can put the whole request message into your journey-accept/journey-reject message
- 3. Find out what the error is that networkx throws when networkx.shortest_path() cannot find a route
- 4. Put a try except around the find_route() function line, so that you can catch when that routing error is thrown
- 5. If the routing error is thrown, create a journey-reject message and send it to the journey-status topic, and continue the loop
- - use the json library to do this, there's an example of decoding json strings in the on_message function, you need to encode
- 6. If no routing error is thrown, send a journey-accept message
- To test, run main.py, and then publish a journey-request to 'destination-request'
- an example request:
- {"msg-type":"destination-request","station-id":"S011","client-id":"1111111"}
- which in command line would be
- mosquitto_pub -t journey-requests -m {"msg-type":"destination-request","station-id":"S011","client-id":"1111111"}
- you can't have spaces in the json message in command line
- Use the sim/master git branch
- There's comments in the file that roughly explain where to do stuff
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement