Unit Conversion: Revisions to convertType API (e.g. for Flow <--> Volume) Bug Number: 5614 Release notes (y/n): no (not this detail) For Release Nums: 6.7 See this method call chart and detail: http://cadswes2.colorado.edu/~philw/2015/UnitConvert/UnitMgrConversionMethods.png http://cadswes2.colorado.edu/~philw/2015/UnitConvert/UnitMgrConvMeths-convertTypeDetail.png The two old public UnitMgr::convertType() methods explicitly supported _only_ these unit conversions: FLOW <<--->> VOLUME VELOCITY <<--->> LENGTH Both had a "secsInTimestep" parameter, which was needed. But one also had a "const DateTime& when" parameter, which is effectively never used. Both of these methods ultimately called the private doConversion() method, which itself will require some revision to address a Gnats 5614-related error when converting to "per month" units within an annual series. These methods were recoded, and no longer make use of doConversion(). This commit now provides these public methods: (1) Preferred: static double volumeFromFlow (double flow, seconds_t secs); static double flowFromVolume (double volume, seconds_t secs); static double lengthFromVelocity (double velocity, seconds_t secs); static double velocityFromLength (double length, seconds_t secs); // standard unit, unit type conversions static double convertType (double fromValue, unit_type fromType, unit_type toType, seconds_t secsInTimestep); (2) The two methods below are currently widely used, though unnecessarily. The bool (error sense) return value is virtually never checked (e.g. in EngrObjs), and the "scale" factor parameters are virtually always 1.0. In all of those cases, the methods above (in particular, the precise ones) should instead be used. static bool convertType (double fromValue, double fromScale, unit_type fromType, double& toValue, double toScale, unit_type toType, seconds_t secsInTimestep); // NOTE: 'when' is not used. This is just to support existing client code. static bool convertType (double fromValue, double fromScale, unit_type fromType, double& toValue, double toScale, unit_type toType, seconds_t secsInTimestep, const Date_Time& /*when*/); // when is NOT USED. RELATED CHANGE: The following SimObj methods with an optional offset parameter (default 0) were replaced by two overloaded methods. In both cases, by far, most uses had been without the default parameter. Providing a separate implementation for that affords a much more efficient implementation, and in one case, allows the return of a Date_Time value by constant reference rather than as a whole Date_Time structure value. OLD: Date_Time getTimestep(int offset = 0) const; NEW: Date_Time getTimestep(int offset) const; NEW: const Date_Time& getTimestep() const { return _currentTimestep; } OLD: seconds_t getStepSeconds(int offset = 0) const; NEW: seconds_t getStepSeconds(int offset) const; NEW: seconds_t getStepSeconds() const; // inlined ---