<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Recent changes to Conditional code</title><link>https://sourceforge.net/p/comframe/wiki/Conditional%2520code/</link><description>Recent changes to Conditional code</description><atom:link href="https://sourceforge.net/p/comframe/wiki/Conditional%20code/feed" rel="self"/><language>en</language><lastBuildDate>Wed, 18 May 2016 20:55:17 -0000</lastBuildDate><atom:link href="https://sourceforge.net/p/comframe/wiki/Conditional%20code/feed" rel="self" type="application/rss+xml"/><item><title>Conditional code modified by Peter Vranken</title><link>https://sourceforge.net/p/comframe/wiki/Conditional%2520code/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v2
+++ v3
@@ -1,150 +1 @@
-Conditional code generation versus generation of conditional code
-=================================================================
-
-Table of contents
-
-[TOC]
-
-In most use cases and particularly when working with attributes the code
-generation process will need to behave conditionally on the given data.
-Two techniques can be distinguished:
-
-- The code generator behaves conditionally and generates either the one or
-  the other code pattern. The generated code unconditionally has a
-  specific behavior
-- The code generator unconditionally generates a code pattern, which
-  behaves conditionally. This technique is comparable to the former one if
-  the condition is a C preprocessor condition; all behaviors are apparent
-  in the source file but at run time the generated code unconditionally has a
-  specific behavior, too
-
-The former technique is the better one as it means more meaningful, better
-readable code but it can not always be applied. The template engine has
-the restriction that only Boolean expressions can be used for conditional
-code generation. It is e.g. impossible to test the value of a numeric data
-element. It is easily possible to generate different code for received
-frames opposed to sent frames (in the data model the object *Frame* has the
-Boolean fields *isReceived* and *isSent*) but it is not directly possible to
-generate another specific behavior for a frame of 10 ms send period as
-for a frame of 100 ms period time.
-
-Conditional code generation
----------------------------
-
-The first technique doesn't need to be explained in detail, please look
-into the manual of the StringTemplate V4 engine; it's all based on the
-construct *&amp;lt;if(booleanExpression)&amp;gt;*. Please note, that
-- the Java *null* is a Boolean false to StringTemplate V4
-- the presence of a data element is a Boolean expression for StringTemplate V4.
-
-Both patterns are heavily used by the data model. Many fields are null by
-default and only reference meaningful Java objects if they apply.
-A list of objects, which is logically empty, will rather be a *null* value
-than an empty Java collection. An unset comment will rather be a *null* value
-than the empty string, etc. Here's an example how the code generator can
-conditionally handle frames with and without multiplexed signals:
-
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-&amp;lt;if(Pdu.muxSignalAry)&amp;gt;
-switch(&amp;lt;Pdu.muxSelector.name&amp;gt;)
-{
-    &amp;lt;Pdu.muxSignalAry:{muxS|case &amp;lt;muxS.muxValue=""&amp;gt;: return &amp;lt;muxS.s.name&amp;gt;;}&amp;gt;
-    default: assert(false); /* Invalid multiplexer switch value */
-}
-&amp;lt;else&amp;gt;
-    /* This PDU doesn't have multiplexed signals. No action needed here. */
-&amp;lt;endif&amp;gt;
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-The presence of a data element is used with Java *Map* objects. A map may
-be queried for any key; the template engine returns a Boolean false if the
-map doesn't contain an entry for the key. In particular, this is used for
-attributes, please find a detailed discussion at
-[Attributes in the network database]. Furthermore, *Special Signals* are
-built on maps: In many environments all or most PDUs contain signals with
-a common name and meaning, e.g. a signal *CRC*, which contains a check sum
-or *SQC*, which contains a PDU sequence counter. The user can specify a
-list of those signals, which are identified by name during the parsing
-process. Each PDU, which has a signal of specified name (or name pattern)
-will have a map containing the *Signal* object. (The key is a
-user-specified identifier.) In the template it can easily be tested if the
-PDU has a specific special signal. Related handling code can be generated;
-all fields of the *Signal* object can directly be accessed to do so.
-
-
-Generation of conditional code
-------------------------------
-
-Where direct (Boolean) decisions are impossible the same code pattern
-needs to be generated unconditionally. However, if appropriate C
-preprocessor constructs are generated the effect can still be the desired:
-Seeing data dependent specific behavior of the code without run-time
-decisions, where those are not required. Let's take the send period of
-regular frames as an example.
-
-The network database may have an attribute *sendPeriod* for (regular)
-frames. It be an integer value specifying the time in Milli seconds. The
-environment offers three tasks for sending frames at specific rates and
-the generated code should assign the frames to the best fitting task. Be
-the following code snippet part of the environment:
-
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-void sendFrameAt1ms(uint32 ID, uint8 dataAry[], uint8 DLC);
-void sendFrameAt10ms(uint32 ID, uint8 dataAry[], uint8 DLC);
-void sendFrameAt100ms(uint32 ID, uint8 dataAry[], uint8 DLC);
-
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-Conditional generation of frame dependent code is impossible as the
-attribute is neither a Boolean nor an enumeration. For generating the
-frame send code we can use the following snippet of a template:
-
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-extern uint8 tmpDataAry[8];
-pack_&amp;lt;frame.name&amp;gt;(tmpDataAry);
-#if 5 \&amp;gt; &amp;lt;frame.attribMap.sendPeriod&amp;gt;
-sendFrameAt1ms(&amp;lt;frame.id&amp;gt;, tmpDataAry, &amp;lt;frame.size&amp;gt;);
-#elif 50 \&amp;gt; &amp;lt;frame.attribMap.sendPeriod&amp;gt;
-sendFrameAt10ms(&amp;lt;frame.id&amp;gt;, tmpDataAry, &amp;lt;frame.size&amp;gt;);
-#elif 150 \&amp;gt; &amp;lt;frame.attribMap.sendPeriod&amp;gt;
-sendFrameAt100ms(&amp;lt;frame.id&amp;gt;, tmpDataAry, &amp;lt;frame.size&amp;gt;);
-#else
-# error Unsupported frame period time &amp;lt;frame.attribMap.sendPeriod&amp;gt; &amp;lt;\\&amp;gt;
-encountered. Code extension required
-#endif
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-This will generate C code, which looks stupid but does what we expect it
-to do. Here's a hypothetic example for two frames, *EngineTorque* with
-ID=127 and t=10 ms and *BatteryVoltage* with ID=678 and t=80 ms:
-
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-extern uint8 tmpDataAry[8];
-pack_EngineTorque(tmpDataAry);
-#if 5 &amp;gt; 10
-sendFrameAt1ms(127, tmpDataAry, 8);
-#elif 50 &amp;gt; 10
-sendFrameAt10ms(127, tmpDataAry, 8);
-#elif 150 &amp;gt; 10
-sendFrameAt100ms(127, tmpDataAry, 8);
-#else
-# error Unsupported frame period time 10 encountered. Code extension required
-#endif
-
-extern uint8 tmpDataAry[8];
-pack_BatteryVoltage(tmpDataAry);
-#if 5 &amp;gt; 80
-sendFrameAt1ms(678, tmpDataAry, 6);
-#elif 50 &amp;gt; 80
-sendFrameAt10ms(678, tmpDataAry, 6);
-#elif 150 &amp;gt; 80
-sendFrameAt100ms(678, tmpDataAry, 6);
-#else
-# error Unsupported frame period time 80 encountered. Code extension required
-#endif
-
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-The preprocessor condition is always predetermined true for exactly one
-case. Encountering such code a human programmer would frowningly discard
-all other cases but for auto-generated code it's still acceptable.
+[[include repo=code path=doc/wiki/ConditionalCode.md]]
&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Peter Vranken</dc:creator><pubDate>Wed, 18 May 2016 20:55:17 -0000</pubDate><guid>https://sourceforge.net2facb77af9426a7aa656e02d6c82e2228bb3b000</guid></item><item><title>Conditional code modified by Peter Vranken</title><link>https://sourceforge.net/p/comframe/wiki/Conditional%2520code/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v1
+++ v2
@@ -25,7 +25,7 @@
 element. It is easily possible to generate different code for received
 frames opposed to sent frames (in the data model the object *Frame* has the
 Boolean fields *isReceived* and *isSent*) but it is not directly possible to
-generate a another specific behavior for a frame of 10 ms send period as
+generate another specific behavior for a frame of 10 ms send period as
 for a frame of 100 ms period time.

 Conditional code generation
@@ -40,8 +40,9 @@
 Both patterns are heavily used by the data model. Many fields are null by
 default and only reference meaningful Java objects if they apply.
 A list of objects, which is logically empty, will rather be a *null* value
-than an empty Java collection. An unset comment will rather be a *null*
-than the empty string, etc.
+than an empty Java collection. An unset comment will rather be a *null* value
+than the empty string, etc. Here's an example how the code generator can
+conditionally handle frames with and without multiplexed signals:

 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 &amp;lt;if(Pdu.muxSignalAry)&amp;gt;
@@ -51,9 +52,8 @@
     default: assert(false); /* Invalid multiplexer switch value */
 }
 &amp;lt;else&amp;gt;
-    /* This PDU doesn't have multiplexed signals. */
+    /* This PDU doesn't have multiplexed signals. No action needed here. */
 &amp;lt;endif&amp;gt;
-
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 The presence of a data element is used with Java *Map* objects. A map may
@@ -80,13 +80,13 @@
 preprocessor constructs are generated the effect can still be the desired:
 Seeing data dependent specific behavior of the code without run-time
 decisions, where those are not required. Let's take the send period of
-regular frames as an example:
+regular frames as an example.

 The network database may have an attribute *sendPeriod* for (regular)
 frames. It be an integer value specifying the time in Milli seconds. The
-environment offers three tasks for sending frames at specific rates and the
-generated code will assign the frames to the best fitting tasks. Be the
-following code snippet part of the environment:
+environment offers three tasks for sending frames at specific rates and
+the generated code should assign the frames to the best fitting task. Be
+the following code snippet part of the environment:

 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 void sendFrameAt1ms(uint32 ID, uint8 dataAry[], uint8 DLC);
@@ -109,13 +109,14 @@
 #elif 150 \&amp;gt; &amp;lt;frame.attribMap.sendPeriod&amp;gt;
 sendFrameAt100ms(&amp;lt;frame.id&amp;gt;, tmpDataAry, &amp;lt;frame.size&amp;gt;);
 #else
-# error Unsupported frame period time &amp;lt;frame.attribMap.sendPeriod&amp;gt; encountered. Code extension required
+# error Unsupported frame period time &amp;lt;frame.attribMap.sendPeriod&amp;gt; &amp;lt;\\&amp;gt;
+encountered. Code extension required
 #endif
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 This will generate C code, which looks stupid but does what we expect it
-to do. Here's a hypothetic example for two frames, EngineTorque with ID=127 and t=10 ms and
-BatteryVoltage with ID=678 and t=80 ms:
+to do. Here's a hypothetic example for two frames, *EngineTorque* with
+ID=127 and t=10 ms and *BatteryVoltage* with ID=678 and t=80 ms:

 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 extern uint8 tmpDataAry[8];
@@ -144,6 +145,6 @@

 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

-The preprocessor condition is predetermined true always for exactly one
+The preprocessor condition is always predetermined true for exactly one
 case. Encountering such code a human programmer would frowningly discard
 all other cases but for auto-generated code it's still acceptable.
&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Peter Vranken</dc:creator><pubDate>Sat, 16 May 2015 21:32:51 -0000</pubDate><guid>https://sourceforge.net219d4557403b8f2460fdc64bbc67abcab6b19f95</guid></item><item><title>Conditional code modified by Peter Vranken</title><link>https://sourceforge.net/p/comframe/wiki/Conditional%2520code/</link><description>&lt;div class="markdown_content"&gt;&lt;h1 id="conditional-code-generation-versus-generation-of-conditional-code"&gt;Conditional code generation versus generation of conditional code&lt;/h1&gt;
&lt;p&gt;Table of contents&lt;/p&gt;
&lt;div class="toc"&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="#conditional-code-generation-versus-generation-of-conditional-code"&gt;Conditional code generation versus generation of conditional code&lt;/a&gt;&lt;ul&gt;
&lt;li&gt;&lt;a href="#conditional-code-generation"&gt;Conditional code generation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#generation-of-conditional-code"&gt;Generation of conditional code&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;p&gt;In most use cases and particularly when working with attributes the code&lt;br /&gt;
generation process will need to behave conditionally on the given data.&lt;br /&gt;
Two techniques can be distinguished:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The code generator behaves conditionally and generates either the one or&lt;br /&gt;
  the other code pattern. The generated code unconditionally has a&lt;br /&gt;
  specific behavior&lt;/li&gt;
&lt;li&gt;The code generator unconditionally generates a code pattern, which&lt;br /&gt;
  behaves conditionally. This technique is comparable to the former one if&lt;br /&gt;
  the condition is a C preprocessor condition; all behaviors are apparent&lt;br /&gt;
  in the source file but at run time the generated code unconditionally has a&lt;br /&gt;
  specific behavior, too&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The former technique is the better one as it means more meaningful, better&lt;br /&gt;
readable code but it can not always be applied. The template engine has&lt;br /&gt;
the restriction that only Boolean expressions can be used for conditional&lt;br /&gt;
code generation. It is e.g. impossible to test the value of a numeric data&lt;br /&gt;
element. It is easily possible to generate different code for received&lt;br /&gt;
frames opposed to sent frames (in the data model the object &lt;em&gt;Frame&lt;/em&gt; has the&lt;br /&gt;
Boolean fields &lt;em&gt;isReceived&lt;/em&gt; and &lt;em&gt;isSent&lt;/em&gt;) but it is not directly possible to&lt;br /&gt;
generate a another specific behavior for a frame of 10 ms send period as&lt;br /&gt;
for a frame of 100 ms period time.&lt;/p&gt;
&lt;h2 id="conditional-code-generation"&gt;Conditional code generation&lt;/h2&gt;
&lt;p&gt;The first technique doesn't need to be explained in detail, please look&lt;br /&gt;
into the manual of the StringTemplate V4 engine; it's all based on the&lt;br /&gt;
construct &lt;em&gt;&amp;lt;if(booleanExpression)&amp;gt;&lt;/em&gt;. Please note, that&lt;br /&gt;
- the Java &lt;em&gt;null&lt;/em&gt; is a Boolean false to StringTemplate V4&lt;br /&gt;
- the presence of a data element is a Boolean expression for StringTemplate V4.&lt;/p&gt;
&lt;p&gt;Both patterns are heavily used by the data model. Many fields are null by&lt;br /&gt;
default and only reference meaningful Java objects if they apply.&lt;br /&gt;
A list of objects, which is logically empty, will rather be a &lt;em&gt;null&lt;/em&gt; value&lt;br /&gt;
than an empty Java collection. An unset comment will rather be a &lt;em&gt;null&lt;/em&gt;&lt;br /&gt;
than the empty string, etc.&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;if&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nt"&gt;Pdu&lt;/span&gt;&lt;span class="nc"&gt;.muxSignalAry&lt;/span&gt;&lt;span class="o"&gt;)&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;switch&lt;/span&gt;&lt;span class="o"&gt;(&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;Pdu&lt;/span&gt;&lt;span class="nc"&gt;.muxSelector.name&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;Pdu&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;muxSignalAry&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="err"&gt;{&lt;/span&gt;&lt;span class="n"&gt;muxS&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;case&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;muxS&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;muxValue&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;:&lt;/span&gt; &lt;span class="n"&gt;return&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;muxS&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;;}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;default&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nt"&gt;assert&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nt"&gt;false&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt; &lt;span class="c"&gt;/* Invalid multiplexer switch value */&lt;/span&gt;
&lt;span class="err"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;else&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="c"&gt;/* This PDU doesn't have multiplexed signals. */&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;endif&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The presence of a data element is used with Java &lt;em&gt;Map&lt;/em&gt; objects. A map may&lt;br /&gt;
be queried for any key; the template engine returns a Boolean false if the&lt;br /&gt;
map doesn't contain an entry for the key. In particular, this is used for&lt;br /&gt;
attributes, please find a detailed discussion at&lt;br /&gt;
&lt;a class="alink" href="/p/comframe/wiki/Attributes%20in%20the%20network%20database"&gt;[Attributes in the network database]&lt;/a&gt;. Furthermore, &lt;em&gt;Special Signals&lt;/em&gt; are&lt;br /&gt;
built on maps: In many environments all or most PDUs contain signals with&lt;br /&gt;
a common name and meaning, e.g. a signal &lt;em&gt;CRC&lt;/em&gt;, which contains a check sum&lt;br /&gt;
or &lt;em&gt;SQC&lt;/em&gt;, which contains a PDU sequence counter. The user can specify a&lt;br /&gt;
list of those signals, which are identified by name during the parsing&lt;br /&gt;
process. Each PDU, which has a signal of specified name (or name pattern)&lt;br /&gt;
will have a map containing the &lt;em&gt;Signal&lt;/em&gt; object. (The key is a&lt;br /&gt;
user-specified identifier.) In the template it can easily be tested if the&lt;br /&gt;
PDU has a specific special signal. Related handling code can be generated;&lt;br /&gt;
all fields of the &lt;em&gt;Signal&lt;/em&gt; object can directly be accessed to do so.&lt;/p&gt;
&lt;h2 id="generation-of-conditional-code"&gt;Generation of conditional code&lt;/h2&gt;
&lt;p&gt;Where direct (Boolean) decisions are impossible the same code pattern&lt;br /&gt;
needs to be generated unconditionally. However, if appropriate C&lt;br /&gt;
preprocessor constructs are generated the effect can still be the desired:&lt;br /&gt;
Seeing data dependent specific behavior of the code without run-time&lt;br /&gt;
decisions, where those are not required. Let's take the send period of&lt;br /&gt;
regular frames as an example:&lt;/p&gt;
&lt;p&gt;The network database may have an attribute &lt;em&gt;sendPeriod&lt;/em&gt; for (regular)&lt;br /&gt;
frames. It be an integer value specifying the time in Milli seconds. The&lt;br /&gt;
environment offers three tasks for sending frames at specific rates and the&lt;br /&gt;
generated code will assign the frames to the best fitting tasks. Be the&lt;br /&gt;
following code snippet part of the environment:&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;void sendFrameAt1ms(uint32 ID, uint8 dataAry[], uint8 DLC);
void sendFrameAt10ms(uint32 ID, uint8 dataAry[], uint8 DLC);
void sendFrameAt100ms(uint32 ID, uint8 dataAry[], uint8 DLC);
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Conditional generation of frame dependent code is impossible as the&lt;br /&gt;
attribute is neither a Boolean nor an enumeration. For generating the&lt;br /&gt;
frame send code we can use the following snippet of a template:&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;extern uint8 tmpDataAry[8];
pack_&amp;lt;frame.name&amp;gt;(tmpDataAry);
#if 5 \&amp;gt; &amp;lt;frame.attribMap.sendPeriod&amp;gt;
sendFrameAt1ms(&amp;lt;frame.id&amp;gt;, tmpDataAry, &amp;lt;frame.size&amp;gt;);
#elif 50 \&amp;gt; &amp;lt;frame.attribMap.sendPeriod&amp;gt;
sendFrameAt10ms(&amp;lt;frame.id&amp;gt;, tmpDataAry, &amp;lt;frame.size&amp;gt;);
#elif 150 \&amp;gt; &amp;lt;frame.attribMap.sendPeriod&amp;gt;
sendFrameAt100ms(&amp;lt;frame.id&amp;gt;, tmpDataAry, &amp;lt;frame.size&amp;gt;);
#else
# error Unsupported frame period time &amp;lt;frame.attribMap.sendPeriod&amp;gt; encountered. Code extension required
#endif
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This will generate C code, which looks stupid but does what we expect it&lt;br /&gt;
to do. Here's a hypothetic example for two frames, EngineTorque with ID=127 and t=10 ms and&lt;br /&gt;
BatteryVoltage with ID=678 and t=80 ms:&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;extern uint8 tmpDataAry[8];
pack_EngineTorque(tmpDataAry);
#if 5 &amp;gt; 10
sendFrameAt1ms(127, tmpDataAry, 8);
#elif 50 &amp;gt; 10
sendFrameAt10ms(127, tmpDataAry, 8);
#elif 150 &amp;gt; 10
sendFrameAt100ms(127, tmpDataAry, 8);
#else
# error Unsupported frame period time 10 encountered. Code extension required
#endif

extern uint8 tmpDataAry[8];
pack_BatteryVoltage(tmpDataAry);
#if 5 &amp;gt; 80
sendFrameAt1ms(678, tmpDataAry, 6);
#elif 50 &amp;gt; 80
sendFrameAt10ms(678, tmpDataAry, 6);
#elif 150 &amp;gt; 80
sendFrameAt100ms(678, tmpDataAry, 6);
#else
# error Unsupported frame period time 80 encountered. Code extension required
#endif
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The preprocessor condition is predetermined true always for exactly one&lt;br /&gt;
case. Encountering such code a human programmer would frowningly discard&lt;br /&gt;
all other cases but for auto-generated code it's still acceptable.&lt;/p&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Peter Vranken</dc:creator><pubDate>Sat, 16 May 2015 21:20:28 -0000</pubDate><guid>https://sourceforge.netb7edb0db07e54f2057ba0b4158aedd0495de0d52</guid></item></channel></rss>