Skip to content

Conversation

@spahrenk
Copy link
Contributor

@spahrenk spahrenk commented Jan 3, 2024

Description

Replace the content in this section with:

  • Modifies HPWHsim to provide cross-platform conformity.
  • Changes the .csv output file pointer hw_pFCSV in dhwcalc from FILE* to std::ofstream*

Author Progress Checklist:

  • Open draft pull request
    • Make title clearly understandable in a standalone change log context
    • Assign yourself the issue
    • Add at least one label (enhancement, bug, or maintenance)
    • Link the issue(s) addressed by this PR (under "Development" in the sidebar menu)
  • Make code changes (if you haven't already)
  • Self-review of code
    • My code follows the style guidelines of this project
    • I have added comments to my code, particularly in hard-to-understand areas
    • I have only committed the necessary changes for this fix or feature
    • I have made corresponding changes to the documentation
    • My changes generate no new warnings
    • I have ensured that my fix is effective or that my feature works as intended by:
      • exercising the code changes in the test framework, and/or
      • manually verifying the changes (as explained in the the pull request description above)
    • My changes pass all local tests
    • My changes successfully passes CI checks
    • Add any unit test for proof and documentation.
    • Merge in main branch and address resulting conflicts and/or test failures.
  • Move pull request out of draft mode and assign reviewers
  • Iterate with reviewers until all changes are approved
    • Make changes in response to reviewer comments
    • Merge in main branch and address resulting conflicts and/or test failures.
    • Re-request review in GitHub

Reviewer Checklist:

  • Read the pull request description
  • Perform a code review on GitHub
  • Confirm all CI checks pass and there are no build warnings
  • Pull, build, and run automated tests locally
  • Perform manual tests of the fix or feature locally
  • Add any review comments, if applicable
  • Submit review in GitHub as either
    • Request changes, or
    • Approve
  • Iterate with author until all changes are approved

@spahrenk spahrenk self-assigned this Jan 3, 2024
@spahrenk spahrenk requested a review from chipbarnaby January 3, 2024 23:35
@spahrenk spahrenk marked this pull request as ready for review January 3, 2024 23:36
Copy link
Contributor

@chipbarnaby chipbarnaby left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I pulled this branch and tested it. It did not run correctly. I made the following changes:

  • Cleanup code: Added delete hw_pFCSV and eliminated close. the ofstream dtor closes if necessary (per documentation and verified in debugger).
  • CNRECS.def / dhwcalc.cpp: coded out defunct HPWH_DUMPSMALL; eliminated unused wh_pFCSV and wh_bWriteCSV.
  • dhwcalc.cpp: eliminated strsave on fName (= memory leak).
  • dhwcalc.cpp: added strtprintf() to << calls so formatting worked correctly.
  • ashppkgroom.rep: updated ref file (changed due to elimination of wh_pFCSV and wh_bWriteCSV.

Did a bunch of testing of error conditions. Functions reasonably well.

I question why this change is needed or useful. The fixes were necessitated by unilateral hpwhsim API change. I did some documentation study and debugger exploration and discovered that std::ofstream functionality devolves to FILE* and associated library functions (fopen, fclose, etc.). CSE has in general standardized on using these functions directly. Using streams appears to add bloat and overhead but not functionality.

Using fmt / std::format (as is now done in hpwhsim) is another story. I believe fmt is both faster and more powerful than printf-style, so transitioning to that makes sense.

@nealkruis nealkruis merged commit 197544e into main Jan 8, 2024
@nealkruis nealkruis deleted the cross-platform-updates-hpwhsim branch January 8, 2024 18:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants