Skip to content

Conversation

walkie
Copy link
Contributor

@walkie walkie commented Nov 1, 2021

This extends the runtime interface to support querying essentially everything about a state machine compiled with runtime_support enabled. While the old interface (which is still present as a subset of the new one) essentially gave a snapshot of the currently running machine (current state and variable values), the new interface provides access to all of the structural information of the machine itself.

Here are the new capabilities:

  • for a machine: enumerate all of its states, variables, events, actions, and edges (potential transitions)
  • for any state: get its parent, enumerate its children, parameters, variables, handlers, and incoming and outgoing edges
  • for any edge: get its kind (transition/change-state), source, target, triggering event, and label

walkie added 15 commits October 21, 2021 13:31
This is a nice self-consistent waypoint, but it's a WIP. I'm about to do some refactoring and add more structural info (in particular, declared names) into the interface.

The code generator has not been updated yet, so the integration tests will fail with this version.
This change adds a hierarchy of structs that provides tons of static (naming, structural) information about all instances of a given state machine at runtime.

Unfortunately, while the interface and supporting methods compile, the tests don't because I can't actually instantiate this interface, in turn because didn't realize how limited Rust constants are... so I need to rethink my approach here. Committing this WIP since it's another decent waypoint. :-/
Finally settled on an interface that I can manually implement.

The CI tests will fail (actually, they won't even compile) since the Rust backend isn't updated to actually generate implementations of this interface, but the `frame_runtime` tests (with manual implementations) all pass.
`MachineInfo#events()` should now contains all events (i.e. including enter/exit events) generable by the system, while the new method `MachineInfo#interface()` contains only the events declared in the `-interface-` block.
This is a mostly complete extension of the code generator to implement the new and significantly expanded runtime interface. All that's left is transitions, which are the trickiest bit, but I've got a plan.

Compilation of generated code for tests will fail in the current state, and the tests will still need to be updated once code generation is finished.
This commit implements the new transition interface for standard transitions and change states. The only piece left is state-stack transitions.

I've disabled the state-stack tests for now and updated the remaining tests (and added one more), so CI should finally pass again!
This updates the codegen for state-stack transitions to work with the new runtime interface. This is the last piece of the puzzle for the new interface.

This restores the stack-stack tests and everything passes (phew!). Still have to do some dedicated testing of the new interface.
Only thing left to test is the runtime interface for state-stack transitions.
This revealed a bug in the general state stack implementation, so one of the tests is ignored. I'm about to fix that right now though.
@walkie walkie merged commit e8e283e into v0.7.0 Nov 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant