fix(pscad): reliable runs + working .psout reader (release 0.1.4)#48
Merged
Conversation
The PSCAD MCP could not run a simulation or read results end-to-end. This fixes the blocking issues and bumps powermcp to 0.1.4. - run_project: use non-blocking Project.start() + get_run_status polling (building/running/idle_or_finished) instead of the blocking run() that timed out under the 30s watchdog and wedged the single-worker executor. - data_tools: rewrite the results reader to the real mhi.psout 1.3 API (the old mhi.psout.open()/channels() API does not exist). Add list_output_channels and read_output_channels (listing, selective reads, summary stats, downsampling) so files with 100s of channels x 25k samples are usable; auto-locate the .psout via project.temp_folder. - get/set_project_settings: use Project.parameters() (project.settings does not exist), which enables setting PlotType=PSOUT etc. - executor: initialize COM once for the single worker (per-call CoInitialize/CoUninitialize invalidated mhi's cached WMI object); add an opt-in _timeout override for long load/build calls. - connection_manager: scrub NoDefaultCurrentDirectoryInExePath before launching PSCAD (it made PSCAD's EMTDC run batch fail to find its own solver), give attach a 120s timeout, and fall back to mhi.pscad.launch() when no attachable instance is running. - add build_project + get_build_messages for compile pre-flight; update tests. Verified end-to-end: ran data/MMC/MMC_HalfBridge_Bipole.pscx (5 s) through the MCP, producing a 42 MB .psout (364 channels) analyzed via the new reader. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The PSCAD MCP server could not run a simulation or read its results end-to-end. This PR fixes the blocking defects and bumps
powermcpto 0.1.4. Verified by runningPSCAD/data/MMC/MMC_HalfBridge_Bipole.pscx(a 5 s MMC-HVDC bipole) entirely through the MCP, producing a 42 MB.psout(364 channels) that the new reader analyzes.Fixes
run_projectnow usesProject.start()+get_run_statuspolling (building/running/idle_or_finished). The old blockingProject.run()timed out under the 30 s watchdog and held the single-worker executor for the whole run, so status polling was impossible.read_output_fileto the realmhi.psout1.3 API (the previousmhi.psout.open()/channels()/values()API does not exist). Addedlist_output_channelsandread_output_channels(listing, selective reads, summary stats, downsampling) so files with hundreds of channels x tens of thousands of samples are usable; the.psoutis auto-located viaProject.temp_folder.get/set_project_settingsnow useProject.parameters()(theproject.settingsattribute does not exist); this is what enables settingPlotType=PSOUT.CoInitialize/CoUninitializeinvalidated mhi's cached WMI object ("object invoked has disconnected from its clients") on the 2nd+ launch. Added an opt-in_timeoutoverride for long load/build calls.attach_localscrubsNoDefaultCurrentDirectoryInExePathbefore launching PSCAD (when set, PSCAD's generated EMTDC run batch cannot find its own solver: "<project>.exeis not recognized"), uses a 120 s attach timeout, and falls back tomhi.pscad.launch()when no attachable instance is running.build_projectandget_build_messagestools surface compiler/link errors before a long run.Tests
.psout.tests/unaffected (changes confined toPSCAD/).🤖 Generated with Claude Code