2015-06-01 15:28:29 +00:00
|
|
|
#include "trick/MonteCarlo.hh"
|
|
|
|
#include "trick/tc_proto.h"
|
2015-02-26 15:02:31 +00:00
|
|
|
|
|
|
|
Trick::MonteCarlo * the_mc ;
|
|
|
|
|
|
|
|
Trick::MonteCarlo::MonteCarlo() :
|
|
|
|
enabled(false),
|
|
|
|
dry_run(false),
|
|
|
|
localhost_as_remote(false),
|
|
|
|
custom_slave_dispatch(false),
|
|
|
|
timeout(120),
|
|
|
|
max_tries(2),
|
2018-07-25 18:05:10 +00:00
|
|
|
verbosity(MC_INFORMATIONAL),
|
2015-02-26 15:02:31 +00:00
|
|
|
num_runs(0),
|
|
|
|
actual_num_runs(0),
|
|
|
|
num_results(0),
|
|
|
|
slave_id(0),
|
|
|
|
except_return(0)
|
|
|
|
{
|
|
|
|
the_mc = this;
|
|
|
|
|
|
|
|
slaves_head = NULL;
|
|
|
|
|
2016-07-06 19:56:05 +00:00
|
|
|
char hostname[_POSIX_HOST_NAME_MAX + 1];
|
|
|
|
gethostname(hostname, _POSIX_HOST_NAME_MAX);
|
2015-02-26 15:02:31 +00:00
|
|
|
machine_name = hostname;
|
|
|
|
|
|
|
|
memset(&listen_device, 0, sizeof(TCDevice)) ;
|
|
|
|
memset(&connection_device, 0, sizeof(TCDevice)) ;
|
|
|
|
|
2017-06-16 20:20:04 +00:00
|
|
|
listen_device.port = 0;
|
|
|
|
connection_device.port = 0;
|
2015-02-26 15:02:31 +00:00
|
|
|
|
|
|
|
listen_device.disable_handshaking = TC_COMM_TRUE;
|
|
|
|
connection_device.disable_handshaking = TC_COMM_TRUE;
|
|
|
|
|
|
|
|
tc_error(&listen_device, 0);
|
|
|
|
tc_error(&connection_device, 0);
|
|
|
|
|
|
|
|
int num_classes = 0;
|
|
|
|
class_map["monte_master_init"] = num_classes;
|
|
|
|
class_to_queue[num_classes++] = &master_init_queue;
|
|
|
|
|
|
|
|
class_map["monte_master_pre"] = num_classes;
|
|
|
|
class_to_queue[num_classes++] = &master_pre_queue;
|
|
|
|
|
|
|
|
class_map["monte_master_post"] = num_classes;
|
|
|
|
class_to_queue[num_classes++] = &master_post_queue;
|
|
|
|
|
|
|
|
class_map["monte_master_shutdown"] = num_classes;
|
|
|
|
class_to_queue[num_classes++] = &master_shutdown_queue;
|
|
|
|
|
|
|
|
class_map["monte_slave_init"] = num_classes;
|
|
|
|
class_to_queue[num_classes++] = &slave_init_queue;
|
|
|
|
|
|
|
|
class_map["monte_slave_pre"] = num_classes;
|
|
|
|
class_to_queue[num_classes++] = &slave_pre_queue;
|
|
|
|
|
|
|
|
class_map["monte_slave_post"] = num_classes;
|
|
|
|
class_to_queue[num_classes++] = &slave_post_queue;
|
|
|
|
|
|
|
|
class_map["monte_slave_shutdown"] = num_classes;
|
|
|
|
class_to_queue[num_classes++] = &slave_shutdown_queue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Trick::MonteCarlo::~MonteCarlo() {
|
|
|
|
/* tc_error allocates memory in the constructor */
|
|
|
|
free(listen_device.error_handler) ;
|
|
|
|
free(connection_device.error_handler) ;
|
|
|
|
listen_device.error_handler = NULL ;
|
|
|
|
connection_device.error_handler = NULL ;
|
|
|
|
}
|
|
|
|
|
|
|
|
|