Documentation of UrbanFireXDT
Documentation of UrbanFireXDT
Loading...
Searching...
No Matches
Classes | Namespaces | Functions | Variables
python_module.hpp File Reference

Definition and implementation of functions that connect the C++ simulation with Python via pybind11. More...

#include <atomic>
#include <condition_variable>
#include <mutex>
#include <thread>
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
#include "cache_helper.hpp"
#include "components.h"
#include "global.h"
#include "setup_and_dataloading.h"
#include "simulation_logic.h"
#include "units.h"
Include dependency graph for python_module.hpp:

Go to the source code of this file.

Classes

struct  pyconn::SimulationEVState
 Represents the state of a single EV during a simulation time step. More...
 
struct  pyconn::SimulationControlUnitState
 Represents the state of a single control unit during a simulation time step. More...
 

Namespaces

namespace  pyconn
 

Functions

void pyconn::initialize_simulation (pybind11::dict args)
 Initializes and starts the simulation from Python.
 
unsigned long pyconn::get_next_timestep_id ()
 Returns the timestep ID of the next time step.
 
bool pyconn::simulation_finished ()
 Checks if the simulation reached its end.
 
SimulationControlUnitState pyconn::getState (unsigned long controlUnitID)
 Retrieves the state of a control unit.
 
void pyconn::sendCommands (unsigned long controlUnitID, pybind11::dict commands)
 Sends a control command to a given control unit.
 
void pyconn::run_one_step ()
 Executes a single simulation time step.
 
void pyconn::reset_simulation_to_start ()
 Resets the simulation and all internal states to the first time step.
 
void pyconn::vacuum ()
 Cleans up the simulation, finished the working thread and releases resources.
 

Variables

std::thread pyconn::g_sim_worker
 The worker thread for the simulation that is started by pyconn::initialize_simulation()
 
std::atomic< bool > pyconn::g_sim_started {false}
 States if the working thread for the simulation has been started.
 
std::atomic< bool > pyconn::g_sim_finished {false}
 States if the simulation has reached its final state (and cannot proceed anymore, or must be reseted to proceed)
 
std::atomic< bool > pyconn::g_simulation_main_part_started
 Flag indicating whether the simulation has finished the SAC planning and addition.
 
std::atomic< bool > pyconn::g_simulation_idling
 Flag indicating whether the simulation is currently idling or working.
 
std::mutex pyconn::g_mtx_simulation
 Mutex protecting synchronization between the simulation thread and Python calls.
 
std::condition_variable pyconn::g_cv_sim_state_update
 Condition variable to notify and to wait for changes in the simulation / python code state.
 
std::atomic< bool > pyconn::g_next_step_requested
 Flag indicating that a new simulation step should be executed.
 
std::atomic< bool > pyconn::g_worker_threads_shutdown_cmd {false}
 Flag indicating that all worker threads should shoutdown and the simulation should be finished. After that, no reset is possible anymore.
 
std::atomic< unsigned long > pyconn::g_atomic_next_tsID
 Shared variable indicating the next time step ID to be executed when calling pyconn::run_one_step()
 
std::atomic< bool > pyconn::g_restart_simulation {false}
 Flag indicating to restart the simulation after a reset of all internal states.
 
float pyconn::expansion_matrix_rel_freq [16][16] = {0}
 Variable storing the expansion matrix with relative frequencies - if using as stand-alone simulation, this is placed inside main and no global variable.
 
unsigned long pyconn::expansion_matrix_abs_freq [16][16] = {0}
 Variable storing the expansion matrix with absolute frequencies - if using as stand-alone simulation, this is placed inside main and no global variable.
 
unsigned long pyconn::scenario_id
 Variable storing the selected scenario ID - if using as stand-alone simulation, this is placed inside main and no global variable.
 

Detailed Description

Definition and implementation of functions that connect the C++ simulation with Python via pybind11.

This is a header-only file providing Python bindings to initialize, control, and finalize simulation runs from within Python.