Skip to content

Commit

Permalink
Merge pull request #1001 from hmenke/thermostat
Browse files Browse the repository at this point in the history
Issue warning when attempting to overwrite thermostat
  • Loading branch information
rempferg committed Jan 31, 2017
2 parents 4440cfb + 9872b46 commit 8050e7d
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/tcl/thermostat_tcl.cpp
Expand Up @@ -560,6 +560,9 @@ int tclcommand_thermostat(ClientData data, Tcl_Interp *interp, int argc, char **
return tclcommand_thermostat_print_usage(interp, argc, argv); return tclcommand_thermostat_print_usage(interp, argc, argv);
} }
} }

auto thermo_switch_before = thermo_switch;

if ( ARG1_IS_S("off") ) if ( ARG1_IS_S("off") )
err = tclcommand_thermostat_parse_off(interp, argc, argv); err = tclcommand_thermostat_parse_off(interp, argc, argv);
else if ( ARG1_IS_S("langevin")) else if ( ARG1_IS_S("langevin"))
Expand Down Expand Up @@ -598,6 +601,18 @@ int tclcommand_thermostat(ClientData data, Tcl_Interp *interp, int argc, char **
Tcl_AppendResult(interp, "Unknown thermostat ", argv[1], "\n", (char *)NULL); Tcl_AppendResult(interp, "Unknown thermostat ", argv[1], "\n", (char *)NULL);
return tclcommand_thermostat_print_usage(interp, argc, argv); return tclcommand_thermostat_print_usage(interp, argc, argv);
} }

// If there is already a thermostat and we are not switching it off,
// issue a warning.
if ( thermo_switch_before != thermo_switch && // thermostat has changed
thermo_switch != THERMO_OFF && // it is not off now
thermo_switch_before != THERMO_OFF // it was not off before
)
{
fprintf(stderr, "WARNING: You are activating more than one thermostat!\n"
" This will NOT overwrite previous settings.\n");
}

return gather_runtime_errors(interp, err); return gather_runtime_errors(interp, err);
} }


Expand Down

0 comments on commit 8050e7d

Please sign in to comment.