Below is an example report script for traversing the connections between components and an ECU System. 


Example Model


Example Meta Model


Example Report Script

<Report>
  <ApplyItemTemplates/>
    <!--ECU SYSTEM-->
    <ItemTemplate type="SBHC">
        <Context name="ecuSystem">
            <!--for signal interface-->
            <AddParts owner="main" sid="ITHP" part="Components" defobj="AbstractComponent" nodes="true"/>
            <AddParts owner="main" sid="ITWB" part="extSignals" defobj="extSignal" nodes="true"/>
            <AddParts owner="AbstractComponent" sid="ITWB" part="ports" defobj="signal" nodes="true"/>
            <AddParts owner="main" sid="ITHC" part="local_conns" defobj="local_conn"/>
            <AddParts owner="main" sid="IBC3" part="asblyConns" defobj="local_conns" refobj="signal"/>
            <AddParts owner="main" sid="IBC3" part="delegConns" defobj="extSignals" refobj="signal"/>
        </Context>
        <!-- -->
        <ForEachInContext name="ecuSystem" group="AbstractComponent">
            <ApplyTemplate name="HwComponentTemplate"/>
        </ForEachInContext>
        <!--  -->
    </ItemTemplate>
    <!--Static Templates-->
    <!--HW Component Template-->
    <Template name="HwComponentTemplate">
        <If>
            <!-- -->
            <Section title="Pinning table for #{Name}">
                <ApplyTemplate name="compPinning"/>
            </Section>
        </If>
    </Template>
    <!--HW Comp Pinning-->
    <Template name="compPinning">
        <Table autoMerge="True">
            <Columns>
                <DescriptionColumn width="auto" objectName="portDesc" caption="Pin description"/>
                <TextColumn width="auto" caption="Pin type" objectName="portDesc">#{Attribute:5PTZ}</TextColumn>
                <TextColumn width="auto" caption="Connector" objectName="portDesc">#{Attribute:5CON}</TextColumn>
                <TextColumn width="auto" caption="Pin number" objectName="portDesc">#{Attribute:5PIN}</TextColumn>
                <NameColumn objectName="port" width="120" caption="Pin name"/>
                <NameColumn objectName="other_port_node" width="auto" caption="Peripheral pin name"/>
                <NameColumn objectName="other_port_node_parent" width="auto" caption="Peripheral component name"/>
            </Columns>
            <ContextGoForwardToPart part="ports">
                <ContextGoForward>
                    <RowObject name="portDesc">
                        <ContextGoNodes>
                            <RowObject name="port">
                                <Row>
                                    <ContextGoRefObjBackToPart part="asblyConns">
                                        <Log>handle: #{Handle}</Log>
                                        <!-- New solution, store traversed part to avoid going back same track-->
                                        <Variable name="visitedPart" select="Handle" as="String"/>
                                        <Log>VisitedPart: #{?$visitedPart}</Log>
                                        <ContextGoForward>
                                            <IfPartTypeIs type="ITHC">
                                                <ContextGoForward>
                                                    <RowObject name="cid">
                                                        <ContextGoBackToPart part="local_conns">
                                                            <ContextGoBackToPart part="asblyConns">
                                                                <If test="not Handle = $visitedPart">
                                                                    <ContextGoRefObj>
                                                                        <IfPartTypeIs type="ITWB">
                                                                            <RowObject name="other_port_node">
                                                                                <ContextGoParent>
                                                                                    <RowObject name="other_port_node_parent">
                                                                                       
                                                                                    </RowObject>
                                                                                </ContextGoParent>
                                                                            </RowObject>
                                                                        </IfPartTypeIs>
                                                                    </ContextGoRefObj>
                                                                </If>
                                                            </ContextGoBackToPart>
                                                        </ContextGoBackToPart>
                                                    </RowObject>
                                                </ContextGoForward>
                                            </IfPartTypeIs>
                                        </ContextGoForward>
                                    </ContextGoRefObjBackToPart>
                                    <ContextGoRefObjBackToPart part="delegConns">
                                        <ContextGoForward>
                                            <IfPartTypeIs type="ITWB">
                                                <ContextGoForward>
                                                    <IfItemTypeIs type="CBWC">
                                                        <RowObject name="other_port_node">
                                                            <ContextGoBack part="extSignals">
                                                                <RowObject name="other_port_node_parent"/>
                                                            </ContextGoBack>
                                                        </RowObject>
                                                    </IfItemTypeIs>
                                                </ContextGoForward>
                                            </IfPartTypeIs>
                                        </ContextGoForward>
                                    </ContextGoRefObjBackToPart>
                                </Row>
                            </RowObject>
                        </ContextGoNodes>
                    </RowObject>
                </ContextGoForward>
            </ContextGoForwardToPart>
        </Table>
    </Template>
</Report>


Resulting Output

In the screenshot of the resulting report below, Part SID and Item.SID have been added to the structure tree display which is helpful information when both defining and viewing the report. 


What's Next?

Need to review the basics on traversing in a context tree? See SystemWeaver Query Language - Introductory Training. Also, check out the SystemWeaver Contexts section of the Help and visit SystemWeaver Forums for related topics.