From 0137700473a9f5dbd5d49b7a5c75aee77b97fc72 Mon Sep 17 00:00:00 2001 From: Christopher LaChance Date: Tue, 20 Jun 2017 14:36:48 -0500 Subject: [PATCH] Revert "Removed default_port_flag and socket_init. " --- include/trick/MonteCarlo.hh | 10 ++++++++++ trick_source/sim_services/MonteCarlo/MonteCarlo.cpp | 5 +++-- .../sim_services/MonteCarlo/MonteCarlo_funcs.cpp | 10 ++++++++++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/include/trick/MonteCarlo.hh b/include/trick/MonteCarlo.hh index aa7537ec..4a7fc8ad 100644 --- a/include/trick/MonteCarlo.hh +++ b/include/trick/MonteCarlo.hh @@ -324,6 +324,9 @@ namespace Trick { /** Highest level of messages to report. */ Verbosity verbosity; /**< \n trick_units(--) */ + /** Default to false and randomly find port numbers. True, use the user provided port numbers. */ + bool default_port_flag; /**< \n trick_units(--) */ + /** Device over which connections are accepted. */ TCDevice listen_device; /**< \n trick_units(--) */ @@ -737,6 +740,13 @@ namespace Trick { #endif protected: + /** + * Initializes sockets. + * + * @return 0 on success + */ + int socket_init(TCDevice *listen_device); + /** * Initializes the master. * diff --git a/trick_source/sim_services/MonteCarlo/MonteCarlo.cpp b/trick_source/sim_services/MonteCarlo/MonteCarlo.cpp index 688e040c..af8b6a7f 100644 --- a/trick_source/sim_services/MonteCarlo/MonteCarlo.cpp +++ b/trick_source/sim_services/MonteCarlo/MonteCarlo.cpp @@ -11,6 +11,7 @@ Trick::MonteCarlo::MonteCarlo() : timeout(120), max_tries(2), verbosity(INFORMATIONAL), + default_port_flag(1), num_runs(0), actual_num_runs(0), num_results(0), @@ -28,8 +29,8 @@ Trick::MonteCarlo::MonteCarlo() : memset(&listen_device, 0, sizeof(TCDevice)) ; memset(&connection_device, 0, sizeof(TCDevice)) ; - listen_device.port = 0; - connection_device.port = 0; + listen_device.port = 7200; + connection_device.port = 7200; listen_device.disable_handshaking = TC_COMM_TRUE; connection_device.disable_handshaking = TC_COMM_TRUE; diff --git a/trick_source/sim_services/MonteCarlo/MonteCarlo_funcs.cpp b/trick_source/sim_services/MonteCarlo/MonteCarlo_funcs.cpp index 68f15400..a128956b 100644 --- a/trick_source/sim_services/MonteCarlo/MonteCarlo_funcs.cpp +++ b/trick_source/sim_services/MonteCarlo/MonteCarlo_funcs.cpp @@ -300,6 +300,14 @@ int Trick::MonteCarlo::shutdown() { return 0; } +/** @par Detailed Design: */ +int Trick::MonteCarlo::socket_init(TCDevice *in_listen_device) { + if (default_port_flag) { + in_listen_device->port = 0; + } + return tc_init(in_listen_device); +} + void Trick::MonteCarlo::handle_retry(MonteSlave& slave, MonteRun::ExitStatus exit_status) { if (max_tries <= 0 || slave.current_run->num_tries < max_tries) { // Add the run to the retry queue. @@ -521,12 +529,14 @@ void Trick::MonteCarlo::set_current_run(int run_num) { void Trick::MonteCarlo::set_listen_device_port(int port_number) { listen_device.port = port_number ; + default_port_flag = false ; } void Trick::MonteCarlo::set_connection_device_port(int port_number) { // This port is passed to slave as an argument, do not override if (is_master()) { connection_device.port = port_number ; + default_port_flag = false ; } }