<commit_before>﻿#include "TraCIServer.h"
#include "programmer.h"
#include <thread>
#include "storage.h"
#include "Constants.h"
#include "VehicleManager.h"
#include "Exceptions.h"
#include "Network.h"
#include "Subscriptions.h"
#include <windows.h>

/*
 * This class abstracts a server for the TraCI protocol.
 * It binds to and listens on a port for incoming TraCI commands, and replies with the appropiate data.
 */


/**
 * \brief Standard constructor.
 * \param port The port on which the server should listen for incoming requests.
 */
traci_api::TraCIServer::TraCIServer(int port): ssocket(port), running(false), port(port)
{
    ssocket.set_blocking(true);
}


traci_api::TraCIServer::~TraCIServer()
{
    VehicleManager::deleteInstance();
    debugPrint("Server succesfully shut down");
}

/**
 * \brief Starts this instance, binding it to a port and awaiting connections. This method is blocking, and as such should be run in a separate thread.
 */
void traci_api::TraCIServer::run()
{
    running = true;
    std::string version_str = "Paramics TraCI plugin v" + std::string(PLUGIN_VERSION) + " on Paramics v" + std::to_string(qpg_UTL_parentProductVersion());
    infoPrint(version_str);
    debugPrint("Simulation start time: " + std::to_string(qpg_CFG_simulationTime()));
    infoPrint("Awaiting connections on port " + std::to_string(port));
    infoPrint("Timestep size: " + std::to_string(static_cast<int>(qpg_CFG_timeStep() * 1000.0f)));
    ssocket.accept();
    infoPrint("Accepted connection");
    this->waitForCommands();
}

/**
 * \brief Closes the socket, severing all connections.
 */
void traci_api::TraCIServer::close()
{
    debugPrint("Closing connections");
    running = false;
    ssocket.close();
}<commit_msg>added starting time info on plugin load<commit_after>﻿#include "TraCIServer.h"
#include "programmer.h"
#include <thread>
#include "storage.h"
#include "Constants.h"
#include "VehicleManager.h"
#include "Exceptions.h"
#include "Network.h"
#include "Subscriptions.h"
#include <windows.h>

/*
 * This class abstracts a server for the TraCI protocol.
 * It binds to and listens on a port for incoming TraCI commands, and replies with the appropiate data.
 */


/**
 * \brief Standard constructor.
 * \param port The port on which the server should listen for incoming requests.
 */
traci_api::TraCIServer::TraCIServer(int port): ssocket(port), running(false), port(port)
{
    ssocket.set_blocking(true);
}


traci_api::TraCIServer::~TraCIServer()
{
    VehicleManager::deleteInstance();
    debugPrint("Server succesfully shut down");
}

/**
 * \brief Starts this instance, binding it to a port and awaiting connections. This method is blocking, and as such should be run in a separate thread.
 */
void traci_api::TraCIServer::run()
{
    running = true;
    std::string version_str = "Paramics TraCI plugin v" + std::string(PLUGIN_VERSION) + " on Paramics v" + std::to_string(qpg_UTL_parentProductVersion());
    infoPrint(version_str);
    debugPrint("Simulation start time: " + std::to_string(qpg_CFG_simulationTime()));
    infoPrint("Awaiting connections on port " + std::to_string(port));
    infoPrint("Timestep size: " + std::to_string(static_cast<int>(qpg_CFG_timeStep() * 1000.0f)) + "ms");
    infoPrint("Simulation start time: " + std::to_string(Simulation::getInstance()->getCurrentTimeMilliseconds()) + "ms");
    ssocket.accept();
    infoPrint("Accepted connection");
    this->waitForCommands();
}

/**
 * \brief Closes the socket, severing all connections.
 */
void traci_api::TraCIServer::close()
{
    debugPrint("Closing connections");
    running = false;
    ssocket.close();
}
{'fraction_non_alphanumeric': 0.13441451346893898, 'fraction_numerical': 0.002748763056624519, 'mean_word_length': 4.985197368421052, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3802253', 'n_tokens_mistral': 1177, 'n_tokens_neox': 1150, 'n_words': 308}