Commit 4527b01d authored by Steffen Lackner's avatar Steffen Lackner
Browse files

[code] send initial machine information to scheduler

parent a7774e02
......@@ -44,7 +44,7 @@ void JsonProtocolWriter::append_requested_call(double date)
_events.PushBack(event, _alloc);
}
void JsonProtocolWriter::append_simulation_begins(int nb_resources,
void JsonProtocolWriter::append_simulation_begins(Machines & machines,
const Document & configuration,
double date)
{
......@@ -62,9 +62,21 @@ void JsonProtocolWriter::append_simulation_begins(int nb_resources,
config.CopyFrom(configuration, _alloc);
Value data(rapidjson::kObjectType);
data.AddMember("nb_resources", Value().SetInt(nb_resources), _alloc);
data.AddMember("nb_resources", Value().SetInt(machines.nb_machines()), _alloc);
data.AddMember("config", config, _alloc);
Value resources(rapidjson::kArrayType);
resources.Reserve(machines.nb_machines(), _alloc);
for (const Machine * machine : machines.machines())
{
Value machine_doc(rapidjson::kObjectType);
machine_doc.AddMember("id", Value().SetInt(machine->id), _alloc);
machine_doc.AddMember("name", Value().SetString(machine->name.c_str(), _alloc), _alloc);
machine_doc.AddMember("state", Value().SetString(machine_state_to_string(machine->state).c_str(), _alloc), _alloc);
resources.PushBack(machine_doc, _alloc);
}
data.AddMember("resources_data", Value().CopyFrom(resources, _alloc), _alloc);
Value event(rapidjson::kObjectType);
event.AddMember("timestamp", Value().SetDouble(date), _alloc);
event.AddMember("type", Value().SetString("SIMULATION_BEGINS"), _alloc);
......
......@@ -9,6 +9,7 @@
#include <rapidjson/writer.h>
#include "machine_range.hpp"
#include "machines.hpp"
#include "ipp.hpp"
struct BatsimContext;
......@@ -75,7 +76,7 @@ public:
* @param[in] configuration The simulation configuration
* @param[in] date The event date. Must be greater than or equal to the previous event.
*/
virtual void append_simulation_begins(int nb_resources,
virtual void append_simulation_begins(Machines & machines,
const rapidjson::Document & configuration,
double date) = 0;
......@@ -193,7 +194,7 @@ public:
* @param[in] configuration The simulation configuration
* @param[in] date The event date. Must be greater than or equal to the previous event.
*/
void append_simulation_begins(int nb_resources,
void append_simulation_begins(Machines & machines,
const rapidjson::Document & configuration,
double date);
......
......@@ -33,7 +33,7 @@ int server_process(int argc, char *argv[])
// Let's tell the Decision process that the simulation is about to begin
// (and that some data can be read from the data storage)
context->proto_writer->append_simulation_begins(context->machines.nb_machines(),
context->proto_writer->append_simulation_begins(context->machines,
context->config_file, MSG_get_clock());
RequestReplyProcessArguments * req_rep_args = new RequestReplyProcessArguments;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment