From de1cb6740be0813c587f1c0bb71df2aad6181c6a Mon Sep 17 00:00:00 2001 From: Mrockwell2 <120338765+Mrockwell2@users.noreply.github.com> Date: Tue, 20 Aug 2024 10:47:05 -0500 Subject: [PATCH] Fixed the warning and error messages when toggling monte carlo (#1761) --- share/trick/sim_objects/default_trick_sys.sm | 2 +- .../trick/simcontrol/SimControlApplication.java | 17 +++++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/share/trick/sim_objects/default_trick_sys.sm b/share/trick/sim_objects/default_trick_sys.sm index 9f582db7..24a5c8da 100644 --- a/share/trick/sim_objects/default_trick_sys.sm +++ b/share/trick/sim_objects/default_trick_sys.sm @@ -465,9 +465,9 @@ class VariableServerSimObject : public Trick::SimObject { // monte carlo slave sim children, and the monte carlo master. // monte carlo slave parents do not reach initialization. {TRK} P0 ("initialization") trick_ret = vs.init() ; - {TRK} ("monte_master_init") trick_ret = vs.init() ; #ifndef TRICK_NO_MONTE_CARLO + {TRK} ("monte_master_init") trick_ret = vs.init() ; {TRK} P1 ("initialization") monte_carlo_disable_all_apps() ; #endif {TRK} P1 ("initialization") Trick::launch_all_external_applications(); diff --git a/trick_source/java/src/main/java/trick/simcontrol/SimControlApplication.java b/trick_source/java/src/main/java/trick/simcontrol/SimControlApplication.java index ab4aeb05..db542107 100644 --- a/trick_source/java/src/main/java/trick/simcontrol/SimControlApplication.java +++ b/trick_source/java/src/main/java/trick/simcontrol/SimControlApplication.java @@ -406,6 +406,7 @@ public class SimControlApplication extends TrickApplication implements PropertyC public void getInitializationPacket() { String simRunDir = null; String[] results = null; + boolean masterslave_enabled; try { String errMsg = "Error: SimControlApplication:getInitializationPacket()"; try { @@ -445,6 +446,10 @@ public class SimControlApplication extends TrickApplication implements PropertyC simState = new SimState(); + commandSimcom.put("trick.var_exists(\"trick_master_slave.master.num_slaves\")"); + results = commandSimcom.get().split("\t"); + masterslave_enabled = results[1].equals("1"); + commandSimcom.put("trick.var_set_client_tag(\"SimControl\")\n"); commandSimcom.put("trick.var_add(\"trick_sys.sched.sim_start\") \n" + "trick.var_add(\"trick_sys.sched.terminate_time\") \n" + @@ -452,9 +457,13 @@ public class SimControlApplication extends TrickApplication implements PropertyC "trick.var_add(\"trick_cmd_args.cmd_args.default_dir\") \n" + "trick.var_add(\"trick_cmd_args.cmd_args.cmdline_name\") \n" + "trick.var_add(\"trick_cmd_args.cmd_args.input_file\") \n" + - "trick.var_add(\"trick_cmd_args.cmd_args.run_dir\") \n" + - "trick.var_add(\"trick_master_slave.master.num_slaves\") \n" + - "trick.var_send() \n" + + "trick.var_add(\"trick_cmd_args.cmd_args.run_dir\") \n"); + + if (masterslave_enabled) { + commandSimcom.put("trick.var_add(\"trick_master_slave.master.num_slaves\") \n"); + } + + commandSimcom.put("trick.var_send() \n" + "trick.var_clear() \n"); results = commandSimcom.get().split("\t"); @@ -470,7 +479,7 @@ public class SimControlApplication extends TrickApplication implements PropertyC simStopTime = terminateTime/execTimeTicValue - simStartTime; } - slaveCount = Integer.parseInt(results[8]); + slaveCount = masterslave_enabled ? Integer.parseInt(results[8]) : 0; simRunDirField = new JTextField[slaveCount+1]; overrunField = new JTextField[slaveCount+1];