Tom Sawyer doesn't render properly control path using Fork/Join

Hello,

I tried to see the action diagram for the Lesson 17 and I was not able to see properly the action flow when fork/join are used.

then I tried a simpler example, and even here it seems that the basic concept of fork/join is not working.

Am I doing something wrong?

Hi Paolo!

You can get the visualisation to work correctly by moving the model around a bit. I have referred to Slide 40 of Into to the SysML v2 Language-Textual Notation slides from the official SysML v2 GitHub when refactoring the model.

These are the main changes I did:

  1. Moved the add1 and add2 action definitions out of the ordering section syntax.
  2. Added then joinNode after those action definitions (the node can be called whatever, not necessarily joinNode).
  3. In the ordering section, change from then join; to just join joinNode;.

You can find the model under the screenshot (I put it in an expandable section to avoid clutter). I hope this helps!

SysMLv2 model
    private import ScalarValues::*;

    action def Add {
        in attribute x : Integer;
        out attribute r : Integer;
    }
    action def Sum {
        in attribute a : Integer;
        in attribute b : Integer;
        out attribute total : Integer;
    }
    action def ProcessDataParallel {
        in attribute data1 : Integer;
        in attribute data2 : Integer;
        out attribute result : Integer;

        attribute add1Result : Integer;
        attribute add2Result : Integer;

        // Moved this action definition out of the ordering section
        action add1 : Add {
            in attribute redefines x = data1;
            out attribute redefines r = add1Result;
        }
        then joinNode;

        // Moved this action definition out of the ordering section
        action add2 : Add {
            in attribute redefines x = data2;
            out attribute redefines r = add2Result;
        }
        then joinNode;

        // Ordering section
        first start;
        then fork;
            then add1;
            then add2;
        join joinNode; // Created a "joinNode" and removed "then" from "then join;"
        then action sum : Sum {
            // You could move out the `sum` action definition as well, but this works too
            in attribute redefines a = add1Result;
            in attribute redefines b = add2Result;
        }

        flow add1.r to sum.a;
        flow add2.r to sum.b;
        flow data1 to add1.x;
        flow data2 to add2.x;
        flow sum.total to result;
    }
}

Hi Simonas,

thanks for the suggestion, it works now.

The solution you proposed (the fact to define action outside the Ordering part, and to have a joinNOde after each action definition) is something expected or shall be considered a temporary workaround?

Since this way is the only one I can find described among the official SysML v2 specification documents, I would assume that this is how it is expected to be used in the long term.

Here is the same example using the joinNode in the SysML v2 Release GitHub: SysML-v2-Release/sysml/src/training/17. Control/Fork Join Example.sysml at master · Systems-Modeling/SysML-v2-Release · GitHub