Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
batsim
batsim
Commits
4527b01d
Commit
4527b01d
authored
Aug 18, 2017
by
Steffen Lackner
Browse files
[code] send initial machine information to scheduler
parent
a7774e02
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/protocol.cpp
View file @
4527b01d
...
...
@@ -44,7 +44,7 @@ void JsonProtocolWriter::append_requested_call(double date)
_events
.
PushBack
(
event
,
_alloc
);
}
void
JsonProtocolWriter
::
append_simulation_begins
(
int
nb_resourc
es
,
void
JsonProtocolWriter
::
append_simulation_begins
(
Machines
&
machin
es
,
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
);
...
...
src/protocol.hpp
View file @
4527b01d
...
...
@@ -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_resourc
es
,
virtual
void
append_simulation_begins
(
Machines
&
machin
es
,
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_resourc
es
,
void
append_simulation_begins
(
Machines
&
machin
es
,
const
rapidjson
::
Document
&
configuration
,
double
date
);
...
...
src/server.cpp
View file @
4527b01d
...
...
@@ -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
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment