Skip to content

GitLab

  • Menu
Projects Groups Snippets
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • D Desastres
  • Project information
    • Project information
    • Activity
    • Labels
    • Planning hierarchy
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 0
    • Issues 0
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Desastres
  • Desastres
  • Wiki
  • Api
  • how it works

how it works · Changes

Page history
joao.severo created page: api/how it works authored Oct 29, 2018 by João Vitor Bernardi Severo's avatar João Vitor Bernardi Severo
Hide whitespace changes
Inline Side-by-side
api/how-it-works.md 0 → 100644
View page @ bf3ec293
# Using API
## SetUp
The first step to run the simulation is to start the API with all its methods. Running the `start_simulation.py` file will start the simulation and use the flask module to run the simulation throughout the 'app' file.
Briefly,
1. The `start_simulation.py` file calls the 'app.py' file with the flask method.
2. On the `app.py` file, the `___init___.py` inside the src folder its called and uses the create_app method to run the socket app.
Then the simulation is up and running.
***
## Inside the files
There are some main files inside the communication folder (the folder that contains all the API files), they are:
1. listeners.py
3. emiters.py
> The other files are important and used by the API but very simple and could be replaced
The listeners file contains all the possible messages that the agents must send. Each method correspond to a possible call from the agent.
1. The 'handle_connection' method uses a method from the `prepare_action.py` file, wich will verify the action sent from the agent so then, if it passes the verification, will add to a list of actions and send to the simulation.
2. The 'respond_to_request' method will receive all the requests to connect with the API with two verifications, if the agent passes by both of them, it will be added to the agents list. A response will always be sent to the agents informing if their action was or wasn't done.
3. The 'respond_to_request_ready' get the simulation pre-step and send to all the agents that called this method.
All the previously methods uses the 'call_responses' method wich is a handler to send the correct response to the agents using the 'emiters.py' file.
The emiters file contains some methods that do the same stuff but with little changes. Each method in this file will send to the agents a response related to an event. The event is the name of the listener that the agent must have to receive the response. The response contains either the action was successfull or not in some cases, on others it contains the pre step of the simulation, but all they do is send the agents some kind of information.
The other files just do some kind of management to the API.
\ No newline at end of file
Clone repository
  • API
  • QuickStart
  • agents
  • agents
    • actions
    • agent
  • api
    • firstconnection
    • firstmessage
    • how it works
    • stepsmessages
  • Home
  • notes
  • requirements
  • setting enviroment
  • simulation
  • simulation
    • corearchitecture
View All Pages