Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Internal state transitions incorrectly list Entry actions in DOT graph export #547

Open
peitschie opened this issue Oct 11, 2023 · 2 comments

Comments

@peitschie
Copy link

From my understanding (backed up by the test below), the Entry actions are not invoked for InternalTransitions, however, the DOT graph export includes this against the internal transition name for some reason.

states

I've thrown together a quick test demonstrating this:

        [Test]
        public void GenerateGraph_InternalTransitions()
        {
            int onEntry = 0;
            int onInternal = 0;

            const string on = "On";
            const string off = "Off";
            const char a = 'a';
            const char space = ' ';

            // Instantiate a new state machine in the 'off' state
            var onOffSwitch = new StateMachine<string, char>(off);

            // Configure state machine with the Configure method, supplying the state to be configured as a parameter
            onOffSwitch.Configure(off)
                .OnEntry(() => onEntry++)
                .InternalTransition(a, () => onInternal++)
                .Permit(space, on);

            onOffSwitch.Configure(on).Permit(space, off);

            var graph = UmlDotGraph.Format(onOffSwitch.GetInfo());
            Console.WriteLine(graph);

            Assert.That(onEntry, Is.EqualTo(0));
            Assert.That(onInternal, Is.EqualTo(0));

            onOffSwitch.Fire(a);

            Assert.That(onEntry, Is.EqualTo(0));
            Assert.That(onInternal, Is.EqualTo(1));
        }

This outputs a graph like this:

digraph {
compound=true;
node [shape=Mrecord]
rankdir="LR"
"Off" [label="Off|entry / Function"];
"On" [label="On"];

"Off" -> "Off" [style="solid", label="a / Function [Function]"];
"Off" -> "On" [style="solid", label=" "];
"On" -> "Off" [style="solid", label=" "];
 init [label="", shape=point];
 init -> "Off"[style = "solid"]
}
@HenningNT
Copy link
Contributor

The DOT graph code is incorrectly drawing the internal transition as an re-entrant transition.

@bruceahaines
Copy link

This looks like the same as #587 and should be fixed with PR #589

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

No branches or pull requests

3 participants