This article introduces the 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 configuration and automatic layout and routing methods. 


Prerequisites



Configuring the View

A configurable chart is a Config item and is created using the config item Sandbox mode as described in Creating Config Item Views. By default, the Sandbox will include a few basic elements of a configuration to get you started, as shown below.  



Tip: A quick way to create a new graph is to copy a similar one that is already defined as described in Creating a New Config Item by Copying an Existing.


The basic building blocks of Graphs are Nodes (A) and Edges (B).



Example Configuration

<Graph>
    <ForEachPart type="3EFL">
        <Node>
            <DefObj>
                <ForEachPart type="3PEN">
                    <DefObj>
                        <Node/>
                    </DefObj>
                </ForEachPart>
            </DefObj>
        </Node>
    </ForEachPart>
    <ForEachPart type="XESX">
        <Node>
            <DefObj>
                <ForEachPart type="EXAC">
                    <DefObj>
                        <Node>
                            <Variable name="component" as="Item" select="."/>
                            <ForEachPart type="3E2F">
                                <DefObj>
                                    <Edge from="$component" to="."/>
                                </DefObj>
                            </ForEachPart>
                        </Node>
                    </DefObj>
                </ForEachPart>
            </DefObj>
        </Node>
    </ForEachPart>
</Graph>


Example Result


Explanation of the Configuration Elements

Nodes

Nodes are defined using the <Node/> tag (A). By default, the label of the node will be the object you have selected in the structure tree. The tag has 3 attributes: 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:

What's Next?

Interested in SystemWeaver Script Language training? You can also learn about the numerous scripting options in the SystemWeaver Script Language Reference Manual in the Help.