2015-02-26 15:02:31 +00:00
|
|
|
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <libgen.h>
|
|
|
|
|
2015-06-01 15:28:29 +00:00
|
|
|
#include "trick/MonteCarlo.hh"
|
|
|
|
#include "trick/message_proto.h"
|
|
|
|
#include "trick/message_type.h"
|
|
|
|
#include "trick/tc_proto.h"
|
2015-02-26 15:02:31 +00:00
|
|
|
|
|
|
|
/** @par Detailed Design: */
|
|
|
|
int Trick::MonteCarlo::initialize_sockets() {
|
|
|
|
|
|
|
|
/** set tc_error to zero for TCDevices to turn off advisory messages. */
|
|
|
|
tc_error(&listen_device, 0);
|
|
|
|
tc_error(&connection_device, 0);
|
|
|
|
|
|
|
|
/** <ul><li> Initialize the sockets for communication with slaves. */
|
2017-06-21 13:59:22 +00:00
|
|
|
int return_value = tc_init(&listen_device);
|
2015-02-26 15:02:31 +00:00
|
|
|
if (return_value != TC_SUCCESS) {
|
2018-07-25 18:05:10 +00:00
|
|
|
if (verbosity >= MC_ERROR) {
|
2015-02-26 15:02:31 +00:00
|
|
|
message_publish(MSG_ERROR, "Monte [Master] Failed to initialize status communication socket.\n") ;
|
|
|
|
}
|
|
|
|
return return_value;
|
|
|
|
}
|
2017-03-23 17:22:40 +00:00
|
|
|
tc_blockio(&listen_device, TC_COMM_NOBLOCKIO);
|
2015-02-26 15:02:31 +00:00
|
|
|
|
|
|
|
/** <li> If no slaves were specified, add one on localhost. */
|
|
|
|
if (slaves.empty()) {
|
2018-07-25 18:05:10 +00:00
|
|
|
if (verbosity >= MC_ALL) {
|
2015-02-26 15:02:31 +00:00
|
|
|
message_publish(MSG_WARNING, "Monte [Master] No slaves specified. Adding localhost as the sole slave.\n") ;
|
|
|
|
}
|
|
|
|
add_slave(new MonteSlave());
|
|
|
|
}
|
|
|
|
return TC_SUCCESS ;
|
|
|
|
}
|