Sinelabore Homepage

Tooling and validation#

A textual model needs no modeling tool — but two things are worth having next to the code generator: an editor that understands SysML v2 and validates while you type, and a way to see a model as a picture.

Editors#

SysIDE is a Visual Studio Code extension that provides syntax highlighting, navigation and live validation for .sysml files. It checks a model against the language itself, so it catches the class of problem the code generator cannot see — for example accessing a part feature from inside a state def (see States). If SysIDE complains about a model the generator accepted, SysIDE is usually right.

Diagrams from the textual model#

The generator draws a model instead of generating from it when it is called with -l svg, and needs nothing besides the jar.

java -cp "path/to/codegen/*" codegen.Main -p sysml2text -l svg \
     -t TrafficLight::TrafficLightSystem -o TrafficLightSystem tl.sysml

-t names what to draw — a part with a state machine is drawn as that machine, a part without one as its structure, and an action as its flow. Where one name means two things, say which with a prefix: state:, action: or part:. Naming something the model does not contain prints what it does contain, one kind per line.

For a structure drawing, -pc chooses which compartments a part box carries (all, none, or a list of attributes, enums, items, states, actions) and -pcd how far below the drawn part they still appear (all, or a number, 0 being the drawn part alone). The pictures on the overview page were made this way.

Because the drawing comes from the same parsed model the generator works on, it is also a check: if the picture does not show what you expect, the generated code will not do what you expect either.

Graphical tools#

Eclipse SySON is an open source graphical SysML v2 environment that can import textual models and show editable diagrams. It is heavier than an editor, but comfortable for browsing a model someone else wrote.

Which route fits depends on where the truth lives. If the .sysml file is the source — as it is when it feeds the code generator — drawing it with -l svg keeps the text in charge, because nothing takes ownership of the model on the way.

Importers differ in how much of the language they cover. A construct one tool accepts may still be rejected by another; new in a constructor expression (send new PortData(…) via p;) is one example. Where an alternative spelling exists, the simpler one usually travels better between tools — see Ports.