<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html; charset=ISO-8859-1"
 http-equiv="Content-Type">
  <title></title>
</head>
<body text="#000000" bgcolor="#ffffff">
On 01/02/11 21:32, Daniel Balasubramanian wrote:
<blockquote
 cite="mid:7AB1C26C64423249964AB392C6EBF0E004B33CEF@discovery.isis.vanderbilt.edu"
 type="cite">
  <pre wrap="">Could you please give the following details:

-The code inside the guard.
-The packets that are being passed in to this rule?

Also, I'm not sure I understand what's happening; you say:

"Inserting this pattern into a case block behaves as expected."

Does it behave unexpectedly if you use a regular block as opposed to a case block?  </pre>
</blockquote>
Hi great-users and Daniel!<br>
<br>
While creating a bigger transformation project I came across some
behaviour which I did not expect.<br>
<br>
I've created a test transformation to contain three tests
for simple comparison. This is this rule which I want to test:<br>
<img alt="" src="cid:part1.04020704.00000103@vuw.ac.nz" height="221"
 width="521"><br>
The meta-model is kept very simple, a container, which can contain
containers and items. Items have a switch to be "ignored".<br>
<br>
Thus the guard code is: return (!Item.IgnoreThis());<br>
The Attribute Mapping code in this rule is:<br>
cout&lt;&lt;"executing AttributeMapping on
"&lt;&lt;Item.name()&lt;&lt;endl;<br>
<br>
The input model contains a container with ItemA (IgnoreThis=False),
ItemB (IgnoreThis=True) and a SubContainer.<br>
All necessary mga files are attached.<br>
<br>
Test 1 (upper branch):<br>
To observe the output packets I've connected another rule which writes
for each Item a line on the console.<br>
This is done by the AttributeMapping code:<br>
cout&lt;&lt;"After pattern rule: found Item
"&lt;&lt;Item.name()&lt;&lt;endl;<br>
<br>
I generate code, compile and execute the transformation in the cmd
window.<br>
<br>
Observed:<br>
The relevant
output reads like this:<br>
<blockquote type="cite">executing AttributeMapping on ItemA<br>
After pattern rule: found Item ItemA<br>
After pattern rule: found Item ItemB<br>
</blockquote>
The attribute mapping is executed once for ItemA, the guard becomes
true.<br>
But ItemA and ItemB are forwarded to the output and received by my
observer rule.<br>
The SubContainer is not observed, because it is not an Item (see Test
3).<br>
<br>
Expected:<br>
Considering the pseudo code for a rule in the technical manual (section
3.4):<br>
<blockquote type="cite">Function Name : ExecuteRule <br>
Inputs : 1. Rule rule (rule to execute) <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2. List of Packets inputs <br>
Outputs : 1. List of Packets outputs <br>
outputs = ExecuteRule(rule, inputs) <br>
{ <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; List of Packets matches <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; List of Packets outputs <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for each input in inputs <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { matches = PatternMatcher(rule, input) <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for each match in matches <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { if match doesn't satisfy guard <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; matches.Remove(match) <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for each match in matches <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { Effector(rule, match) <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; outputs.Add(match) <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return outputs <br>
} <br>
</blockquote>
The guard prevents forwarding, so Only ItemA should be forwarded. ItemB
should be prevented by the guard.<br>
The AttributeMapping is executed correctly only for ItemA.<br>
<br>
Test 2 (middle branch):<br>
Is similar to 1, but using this pattern&amp;guard inside a Case in a
Test
Block.<br>
There is no AttributeMapping inside a case structure.<br>
<br>
Observed:<br>
This output belongs to the middle branch:<br>
<blockquote type="cite">After test block: found Item ItemA</blockquote>
Only ItemA is forwarded.<br>
<br>
Expected:<br>
As observed, ItemB is not forwarded. <br>
<br>
Test 3 (lower branch):<br>
The last test focuses on the filtering effect of the itself pattern. So
I remove the Guard and the Attribute mapping. The rule's&nbsp; InputPort is
fed with the SubContainer. In addition to
this I change the rule, which receives the output packages, such that
it expects Containers.<br>
<br>
Observed:<br>
Output created by the lower branch.<br>
<blockquote type="cite">After pattern rule found container:SubContainer</blockquote>
So that pattern forwards the SubContainer, which is a Container Model
and not an Item.<br>
This behaviour could not be observed in the debugger. A breakpoint to
the start of the receiver rule is not hit.<br>
<br>
Expected:<br>
The pattern has an
Item bound to the input and output, so only Items should propagate
through the rule.<br>
<br>
---------------------------------------------------------<br>
<br>
The relevant software versions are:<br>
<br>
GME 10.11.24<br>
GReAT 1.7.5<br>
UDM 3.2.7<br>
Windows Vista Ultimate<br>
Visual Studio 2008<br>
<br>
Cheers, Achim<br>
</body>
</html>