Although SystemWeaver uses a strong meta model to avoid inconsistencies there are still possibilities that this can happen. For example, a receive port may not have a send signal, or you might want to check that items being used are coming from a specific sub-set of items. This article presents some generic and easy-to-follow examples of the use of expressions to perform checks. 


all ... satisfy ...

Checks whether all objects in a set satisfy a given condition.


Example

All items of type function have a responsible person, where the responsible person is an attribute of type User with SID = RESP. The result of this check will be true if all functions have a responsible person and false if one or more function(s) have no assigned responsible person.


XML

all /IURQ satisfy @RESP.Name !=''

Result

When all items satisfy the condition:

true


When at least one item does not satisfy the condition:

false


any ... satisfies ...

Checks whether any object, i.e., at least one object, in a set satisfies a given condition.


Example

At least one item of type function has a responsible person, where the responsible person is an attribute of type User with SID = RESP. The result of this check will be true if at least one function has a responsible person and false if all functions have no assigned responsible person.


XML

any /IURQ satisfies @RESP.Name !=''


Result

When there is at least one item that satisfies the condition:

true


When there are no items that satisfy the condition:

false


Example

To condition selection of items based on, e.g., ASIL values.


XML

any /ITFC satisfies @26AS in ['C', 'D']

Result

When there are no items that satisfy the condition:

false



if ... then ... else ...

If the condition after the if keyword evaluates to true, the value after the then keyword is returned, or else the value after the else keyword is returned.


Note: An empty list evaluates to false.


Example

If an item of type Function has a responsible person, where the responsible person is an attribute of type User with SID = RESP, then print out 'Responsible person assigned'. Otherwise, print out 'No assigned person'. The result of this check will be a string with one of two possible values 'Responsible person assigned' or 'No assigned person' depending on the if condition result which is true/false.


XML

if @RESP.Name != '' then 'Responsible person assigned'  else  'No assigned person'

Result

When the if condition returns true:

Responsible person assigned


When the if condition returns false:

No assigned person


in Operator

Checks whether an object or a list of objects exists in another list of objects.


Note: The in operator is version sensitive. If different versions of an item exist in the list being checked, the result will be false. To check for any version, the AncestorHandle can be addedas shown in example 2 below.


Examples

For example, if items of type function, which are parts of a function structure, allocated under design function structure. The result of this check will be True or False depending on whether the "in" condition fulfilled or not.


Example 1 XML 

/PTUR/IURQ in /3VDA/ITFD/ITAP/RFEA


Example 1 Result

When the in condition is fulfilled:

true


When the in condition is NOT fulfilled:

false



Example 2 XML 

Handling the occurrence of different item versions using AncestorHandle.

/PTUR/IURQ.Select(AncestorHandle) in /3VDA/ITFD/ITAP/RFEA.Select(AncestorHandle)


Example 2 Result

When the in condition is fulfilled, in this case we are using AncestorHandle to make sure that any version of an item exists:

true



Choose

Defines conditional reporting using several options. 

Several When tags can be used and each work like nested Ifs. Only the first When expression that is fulfilled will be reported. If no When expression is fulfilled, the Otherwise statement will be used.


Examples

For example, if we want to check that all functions in a function structure have been assigned to a responsible person.

Note that in When-expression one can use filter, i.e., <When filter="F1"> and/or path query i.e., <When test="..pathQuery...">


Example 1 XML 

<Report>
    <ForEach select="/IURQ">
        <Choose>      
            <When test="@RESP.Name !=''">
                <Text>#{? Name + ' -assigned to: ' + @RESP.Name }</Text>
            </When>
            <Otherwise>
                <Text>#{? Name + ' -not assigned' }</Text>
            </Otherwise>
        </Choose>  
    </ForEach>
</Report>

Example 1 Result

Example 2 XML 

Check that all functions in a function structure have descriptions. If they do, print out the descriptions. Otherwise, print out an error message 'Error: No descriptions !! '.

<Report>
    <Filter name="F1">
        <DescriptionIsEmpty/>
    </Filter>

    <ForEach select="/IURQ">
        <Choose>
            <When filter="F1">
                <Section title="#{Name}">
                    <Text font="Bold">Error: No description !!</Text>
                </Section>
            </When>
            <Otherwise>
                <Section title="#{Name}">
                    <Description/>
                </Section>
            </Otherwise>
        </Choose>
    </ForEach>
</Report>

Example 2 Result