Overview
This course covers SystemWeaver Script Language with a focus on configurable graphs. A graph is made up of nodes (points) and edges (lines) according to the mathematical concept of graph theory. In the Graphs view, the nodes and edges are drawn into the view according to the style of the configuration and automatic layout and routing methods. Examples and exercises are provided.
Course Type
Suitable for class training or for self study.
Course Length
Approximately 2 hours to half-day course.
Prerequisites
- Completed the SystemWeaver Report Generation - Introductory Training course and the Path Query Language course.
- Familiarity with SystemWeaver concepts such as Items, Parts and Attributes, and also with the GUI and common operations of the swExplorer.
- Knowledge of XML.
- An installation of the SystemWeaver client (swExplorer).
- A training server (If the course leader has not set up a server for the class, you can set up your own server by following the instructions in Setting up a Test Server).
- The Script Language Training sqlite database. See Database for Script Training.
- Assignment of the SW Architect role in the server if you wish to save your training configurations.
Exercises
The answers to all exercises in this article can be found on the Script Training>Answers ribbon tab:
Note: This presentation does not cover GUI and view concepts.
Introduction
Graphs can be used to illustrate different relationships and connections in a comprehensive manner.
They are created via the graph editor. To access it, select an item in the tree, click on the View drop-down list, select Graphs and then select Sandbox:
The basic building blocks of Graphs are Nodes (A) and Edges (B).
Nodes
Below is a demonstration of how nodes are defined (A). By default, the caption of the node will be the object you have selected in the structure tree. This can be changed by using the attribute ”caption” (B).
Nodes can be placed inside other nodes to form a hierarchy:
<Graph> <Node> <ForEachPart type="XESX"> <DefObj> <Node/> </DefObj> </ForEachPart> </Node> </Graph>
Custom node styles are also available.
Exercise 1 - Two Node Groups
- Open Item x0400000000000292.
- Select Vehicle Architecture and open the graph editor.
- Create a graph with two ”groups” of nodes, one for the Software and one for the End To End Functions.
Expected result:
Tip: See Finding SystemWeaver Type Identifiers (SIDs) for how to find the SIDs you will need.
Edges
Edges have a direction and are established between two items or parts that have been added as nodes to the graph. The tag defines one or many edges to be included (drawn) as a line between each pair of nodes. The attribute “to” defines the node the edge is pointing to. The attribute “from” defines the node the edge is pointing from. Below is a demonstration of how edges are defined.
Exercise 2 - Edges
- Open Item x0400000000000292.
- Select Vehicle Architecture and open the graph editor.
Using Exercise 1 as a starting point, add edges from the Application Components to the End To End Functions that they realize.
Expected result:
InPort and OutPort
InPorts and OutPorts are used to easily model the implicit connection concept used in SystemWeaver. In this case there is no need to define edges. The graph itself will identify the edges based on the InPort and OutPort elements. An InPort(A) is added to indicate incoming communication. An OutPort
(B) is added to indicate outgoing communication.
Below is a configuration showing how to use OutPort and InPort. The attribute ”connection” indicates what item or part is used to identify the connection. In this example, an OutPort will generate an edge to an InPort that has the same item or part as the connection object.
<Graph> <ForEachPart type="XESX"> <Node> <DefObj> <ForEachPart type="EXAC"> <DefObj> <Node> <ForEachPart type="ITOS"> <DefObj> <OutPort connection="."/> </DefObj> </ForEachPart> <ForEachPart type="ITIS"> <DefObj> <InPort connection="."/> </DefObj> </ForEachPart> </Node> </DefObj> </ForEachPart> </DefObj> </Node> </ForEachPart> </Graph>
Exercise 3 - InPorts and OutPorts
- Open Item x0400000000000292.
- Select Vehicle Architecture and open the graph editor.
- Use Exercise 2 as your starting point. Add InPorts and OutPorts for the respective ports in the Application Components.
Expected result:
NodeStyle
A NodeStyle is used to define templates for how nodes should look. When a node is created, it is possible to assign a style to it with the ”style” attribute. The available attributes are:
- fillColor
- fillColor2
- borderThickness
- borderColor
- borderType
The below picture illustrates the attributes for the NodeStyle named "component" and their effects on the appearance of a node.
<Graph> <NodeStyles> <NodeStyle name="component" fillColor="Green" fillColor2="Yellow" borderThickness="5" borderColor="Red" borderType="dash"/> </NodeStyles> <Node style="component"/> </Graph>
For more information on defining colors, see the XML Tag Reference - Graph specific section of the Help.
Exercise 4 - NodeStyle
- Open Item x0400000000000292.
- Select Vehicle Architecture and open the graph editor.
- Use Exercise 3 as your starting point. Add some style to your graph by using <NodeStyles>.
Example:
EdgeStyle
An EdgeStyle is used to define templates for how edges should look. When an edge is created, it is possible to assign a style to it with the ”style” attribute. The available attributes are:
- color
- thickness
- lineType
- fromArrowType
- toArrowType
The below example illustrates the attributes and their effects on the appearance of an edge.
<Graph> <EdgeStyles> <EdgeStyle name="realization" color="Red" thickness="3" lineType="dashdotdot" fromArrowType="Circle" toArrowType="Triangle"/> </EdgeStyles> <Node/> <Variable name="vehicleSpecification" as="Item" select="."/> <ForEachPart type="XESX"> <DefObj> <Node/> <Edge style="realization" from="$vehicleSpecification" to="." /> </DefObj> </ForEachPart> </Graph>
Exercise 5 - EdgeStyle
- Open Item x0400000000000292.
- Select Vehicle Architecture and open the graph editor.
Use Exercise 4 as your starting point. Add some more style to your graph by using <EdgeStyles>.
Example:
ObjIcons
If you want to display the icon used in the SystemWeaver metadata in the graph nodes, you can use ObjIcons to do that in the Options tag declared directly below the Graph tag.
What's Next?
We hope that you are pleased with this course and feel ready to configure graphs. You can extend your knowledge by practicing the numerous scripting options described in the SystemWeaver Script Language Reference section in the Help or by browsing our how-to articles on the Support Portal.