COE ABQ 5.9: Add action to change run timestep
Notes for Willard from Phil, 2-15-2017
This action is equivalent to changing the timestep in the run control dialog.
Settings:
(1) Create new rwScript ActionType
enum ActionType
{
... ... ...
SET_RUN_RANGE, << SIMILAR TO
SET_RUN_TIMESTEP << PERHAPS ADD
... ... ...
};
Bifurcate "SET_RUN_RANGE" things:
static const QString SET_RUN_RANGE_STR("Set Run Range");
static const QString SET_RUN_RANGE_FULL_STR("Set the run range to: %1 -- %2");
static const QString SET_RUN_RANGE_EXPL_STR(
"Set the run range (start and end dates)");
static const QString SET_RUN_RANGE_XML_STR("SetRunRange");
Case in:
rwScript::Action::Action(ActionType actionType);
METHOD: initSetRunRange();
... perhaps: initSetRunTimestep();
Cases in:
const QString& rwScript::actionTypeAsString(ActionType actionType)
const QString& rwScript::actionTypeXMLString(ActionType actionType)
Case in:
QString rwScript::Action::displayText(bool useRichText) const;
METHOD: displayTextSetRunRange();
... perhaps: displayTextSetRunTimestep();
Case in:
rwScript::ExecutionStatus rwScript::Action::execute (QString& explanation) const;
METHOD:
ExecutionStatus executeSetRunRange(QString& explanation) const;
... perhaps: executeSetRunTimestep();
--------------
(2) Create new rwSettings for the new ActionType (i.e. perhaps "SetRunTimestep")
Reference, SetRunRange rwSetting Identifiers (a similar script action):
It doesn't look like we've had any rwSettings to select a timestep size. That is, one of these enumerated types:
Utils/DeltaTime.hpp:
enum DeltaTime::TimeUnit { Hours, Days, Weeks, Months, Years, MaxUnit };
The following class provides the strings that we use for the supported Run Timestep Sizes:
- QtRun/TimestepList.hpp -- utility class. See Below.
We could either define a new rwTextSetting ValueType OR use a rwEnumSetting. BOTH would show a combo box in the Q3GUI/rwSettingTree's incell editor. The former is better enapsulated, and a tad better for future use, I think. Well, actually, the additional work isn't warranted. Creating a custom incell editor for enumerated types which are known apriori isn't something we've been doing. With that, we have something like these new rwSetting Identifiers:
Note that basic properties for these new rwSetting Identifiers are set up in this ginormous function. Look for the SET_RUN_RANGE Identifiers, and put your new ones after those:
TimestepList utilities for the SET_RUN_TIMESTEP_SIZE options list -- this first method is in my modified code (below). The 2nd one already existed:
Modified Source Code: Use in rwScript::initSetRunTimestep:
Use in rwScript::executeSetRunTimestep:
|
Execution:
The "Synchronize Timestep Change" dialog's "Continue" button calls this private method:
This is how I think we should do the first step with this somewhat complex algorithm. I do want to try to preserve the "diff history" of these function to the extent possible, at least initially. (Though we should, probably move it to down to Sim before finishing, but probably after reviewing the resulting diffs with the working code).
If you will, please pick up these three source files in the QtRun library:
This provides the global public method which you can use from rwScript::executeSetRunTimestep().
// static utility static QStringList changeRunParamAndSyncSlots( const RunParam& origRunParam, const RunParam& newRunParam, bool doSyncSlots, // Synchronize Objects with New Timestep bool doAggregation, // Aggregate Input Data to the New Timestep bool excludeDiffIntervals, // Exclude Slots with Timesteps Diff than Orig bool failOnNan); // NaNs in Input Source Data Produce ErrorSee how it is called in the modified method:
---void SyncTimeChangeDlg::applyChanges() const;