Server
Typedefs
-
using json = nlohmann::json
Functions
-
int exec(std::string i_cmd)
Executes the given command.
- Parameters:
i_cmd – The command to be executed.
- Returns:
The exit status of the command.
-
void exitSimulationThread()
Function to exit the simulation thread.
This function sets the shouldExit flag of the simulator object to true, indicating that the simulation should be terminated as soon as possible.
- Returns:
void
-
void checkSimThreadActive()
Checks if the simulation thread is active. If the simulator is preparing, calculating, or resetting, the simulation is considered running. If the simulation thread is joinable, it is joined and the simulation is considered not running.
- Returns:
void
-
bool canRunThread()
Checks if a simulation thread can be run.
- Returns:
true if the simulation thread can be run, false otherwise.
-
void updateData()
Updates the data related to CPU and RAM usage.
This function checks if it is time to update the data and if so, it retrieves the CPU usage and RAM usage. The updated data is stored in the respective variables.
- Returns:
void
-
int main(int i_argc, char *i_argv[])
Main function for the tsunami_lab server program.
- Returns:
Exit code (0 for success, non-zero for errors).
Variables
-
int m_PORT = 8080
Port for the server.
-
bool m_EXIT = false
Exit flag.
-
std::thread m_simulationThread
Thread object which will be used to run simulation tasks.
-
std::thread m_updateThread
Thread object which will be used to update system info.
-
std::atomic<bool> m_stopUpdating = false
Flag to stop updating.
-
bool m_isSimulationRunning = false
Flag to check if simulation is running.
-
std::chrono::time_point m_lastDataUpdate = std::chrono::high_resolution_clock::now()
Last update time point.
-
int m_dataUpdateFrequency = 10
Lata update frequency in ms.
-
tsunami_lab::systeminfo::SystemInfo l_systemInfo
System info object.
-
double l_usedRAM = 0
Amount of used RAM.
-
double l_totalRAM = 0
Total amount of RAM.
-
std::vector<float> l_cpuUsage
CPU usage vector.