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

Exercises

The answers to all exercises can be found in the swExplorer ribbon tab Report Training>Answers under Graphs.


 

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. 


Bildresultat för exercise icon freeExercise 1 - Two Node Groups

  1. Open Item x0400000000000292.
  2. Select Vehicle Architecture and open the graph editor. 
  3. 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. 



Bildresultat för exercise icon freeExercise 2 - Edges

  1. Open Item x0400000000000292.
  2. Select Vehicle Architecture and open the graph editor. 
  3. 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>



Bildresultat för exercise icon freeExercise 3 - InPorts and OutPorts

  1. Open Item x0400000000000292.
  2. Select Vehicle Architecture and open the graph editor. 
  3. 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.


Bildresultat för exercise icon freeExercise 4 - NodeStyle

  1. Open Item x0400000000000292.
  2. Select Vehicle Architecture and open the graph editor. 
  3. 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>




Bildresultat för exercise icon freeExercise 5 - EdgeStyle

  1. Open Item x0400000000000292.
  2. Select Vehicle Architecture and open the graph editor. 
  3. 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.