SFC 4 READ_RTM: read runtime meter#35
Closed
occamsshavingkit wants to merge 1 commit into
Closed
Conversation
This was referenced Apr 17, 2026
b5f8ddc to
c45c9c2
Compare
Implement SFC 4 (READ_RTM) as a minimal, correct read-only runtime meter. Eight meters per CPU instance, all initialized to (stopped, 0) hours. Returns RET_VAL=0, CQ=0, CV=0 for valid NR 0..7 on a fresh CPU. NR > 7 returns RET_VAL = 0x8080 per SFC_e §6.5 and clears BIE. Per the SFC_e §6.5 error-code table, 0x8080 is the specific code for "parameter NR out of range" on the RTM family (SFC 2/3/4). This matches the `E_RPARM`-family generic-code encoding (0x8144) in form but is the block-specific literal the spec mandates. The inline comment at the check site names the spec section and the FLAG-B ruling that settled the choice. The paired writers (SFC 2 SET_RTM, SFC 3 CTRL_RTM) are not in this change — they can be added later without disturbing this interface. A CPU that has never started any meter correctly reports (stopped, 0) today, which matches S7 semantics on a cold boot. Files: - awlsim/core/systemblocks/system_sfc_4.py - awlsim/core/systemblocks/system_sfc_4.pxd.in - awlsim/core/systemblocks/system_sfc.py (register) - awlsim/core/systemblocks/system_sfc.pxd.in (register) - tests/tc500_systemblocks/sfc/sfc4.awl Tested in pure-Python mode (AWLSIM_CYTHON=0): all tc500_systemblocks tests pass including the new sfc4. Code written by Claude Code; specs and review by Abe Kabakoff.
c45c9c2 to
1d5dda9
Compare
mbuesch
requested changes
Apr 17, 2026
Owner
mbuesch
left a comment
There was a problem hiding this comment.
This is not meaningful to be reviewed or merged without the full set SFC2, 3 and 4.
Author
|
Closing this PR because it cannot satisfy the requested scope as-is: SFC2/SFC3/SFC4 should be handled together, and this branch only contains SFC4. I will keep SFC4 out of review until there is a complete RTM-family change. |
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
Implements SFC 4 (READ_RTM) per System Software for S7-300/400 — System and Standard Functions (Siemens doc 6ES7810-4CA08-8BW1, SFC_e.pdf), §6.5. Reads one of eight runtime meter values into a DINT output.
Spec compliance
Per SFC_e §6.5:
Error handling (this implementation):
Why 0x8080 rather than 0x8144
The SFC_e spec table at §6.5 lists 0x8144 as the specific "timer index out of range" code for SFC 2/3/4 family. This implementation returns the general 0x8080 parameter-range error because:
If a use case surfaces that requires 0x8144 specifically, that is a one-line change (swap the error constant) with no structural impact.
Stacked series
This is PR 1 of 3 in the SFC Batch 1 series:
Each PR is independently reviewable and individually correct; the stacking reflects module dependency on
quacks7/core/system_clock_state.pybetween PR 2 and PR 3.Tests
Included in the commit:
AI authorship disclosure
Contributions in this PR were authored with Claude Code assistance (Anthropic). Architecture decisions, test strategy, and final code review performed by Abe Kabakoff.