Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2020
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. List of stuff to do
  2. 1. Change the on_message function to put the whole json destination-request message into the queue instead of just the station-id
  3. 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
  4. - This is important so you can put the whole request message into your journey-accept/journey-reject message
  5. 3. Find out what the error is that networkx throws when networkx.shortest_path() cannot find a route
  6. 4. Put a try except around the find_route() function line, so that you can catch when that routing error is thrown
  7. 5. If the routing error is thrown, create a journey-reject message and send it to the journey-status topic, and continue the loop
  8. - use the json library to do this, there's an example of decoding json strings in the on_message function, you need to encode
  9. 6. If no routing error is thrown, send a journey-accept message
  10.  
  11. To test, run main.py, and then publish a journey-request to 'destination-request'
  12. an example request:
  13. {"msg-type":"destination-request","station-id":"S011","client-id":"1111111"}
  14. which in command line would be
  15. mosquitto_pub -t journey-requests -m {"msg-type":"destination-request","station-id":"S011","client-id":"1111111"}
  16. you can't have spaces in the json message in command line
  17.  
  18. Use the sim/master git branch
  19.  
  20. There's comments in the file that roughly explain where to do stuff
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement