📄 c-trigger2.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><html><head><link rel="STYLESHEET" type="text/css" href="wrs.css"><title> Triggering </title></head><body bgcolor="FFFFFF"><p class="navbar" align="right"><a href="index.html"><img border="0" alt="[Contents]" src="icons/contents.gif"></a><a href="c-trigger.html"><img border="0" alt="[Index]" src="icons/index.gif"></a><a href="c-trigger.html"><img border="0" alt="[Top]" src="icons/top.gif"></a><a href="c-trigger1.html"><img border="0" alt="[Prev]" src="icons/prev.gif"></a><a href="c-trigger3.html"><img border="0" alt="[Next]" src="icons/next.gif"></a></p><font face="Helvetica, sans-serif" class="sans"><h3 class="H2"><i><a name="84207">6.2 The Triggering GUI</a></i></h3></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="84212"> </a>To work with triggering, click the <img class="figure" border="0" src="images/c-trigger0.gif"> button in the main tool bar. This brings up the <b class="guiLabel"><font face="Helvetica, sans-serif" size="-1" class="sans">Triggering</font></b> window, shown in <a href="c-trigger2.html#86434">Figure 6-1</a>. The <b class="guiLabel"><font face="Helvetica, sans-serif" size="-1" class="sans">Triggering</font></b> window allows you to define, modify, download, and control triggers. Until you set one or more triggers, the window displays only the legend "None." Even after you have defined a trigger, it appears as "not set." You must download it to the target before it is armed and ready to fire. <div class="frame"><h4 class="EntityTitle"><a name="86434"><font face="Helvetica, sans-serif" size="-1" class="sans">Figure 6-1: Triggering Window </font></a></h4><dl class="margin"><div class="Anchor"><a name="86460"> </a><img class="figure" border="0" src="images/c-triggera2.gif"></div></dl></div></p><dd><p class="Body"><a name="86420"> </a>To define a trigger, click the <img class="figure" border="0" src="images/c-triggera1.gif"> button at the left of the <b class="guiLabel"><font face="Helvetica, sans-serif" size="-1" class="sans">Triggering</font></b> tool bar. This brings up the <b class="guiLabel"><font face="Helvetica, sans-serif" size="-1" class="sans">Trigger Maintenance</font></b> dialog box, shown in <a href="c-trigger2.html#84255">Figure 6-2</a>. When you open the <b class="guiLabel"><font face="Helvetica, sans-serif" size="-1" class="sans">Trigger Maintenance</font></b> dialog box, the next available trigger number is shown in the first field. <div class="frame"><h4 class="EntityTitle"><a name="84255"><font face="Helvetica, sans-serif" size="-1" class="sans">Figure 6-2: Trigger Maintenance Dialog Box</font></a></h4><dl class="margin"><div class="Anchor"><a name="84260"> </a><img class="figure" border="0" src="images/c-triggera3.gif"></div></dl></div></p></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H4"><i><a name="84265">Specifying a Trigger </a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="84267"> </a>In most cases you should leave the <b class="guiLabel"><font face="Helvetica, sans-serif" size="-1" class="sans">Enabled</font></b> box checked. If you are going to chain this trigger and have it enabled by an earlier trigger or if you are going to start it from your code, uncheck this box. The remaining specification boxes allow you to narrow the circumstances under which your trigger will fire. </p><dd><p class="Body"><a name="84268"> </a>You can specify the type of event or a user event by selecting it from the <b class="guiLabel"><font face="Helvetica, sans-serif" size="-1" class="sans">Event Matches</font></b> drop-down menu. If you chose <b class="guiLabel"><font face="Helvetica, sans-serif" size="-1" class="sans">User Event</font></b>, the right hand field becomes active so you can enter the name of the user event. This user event is one you create using the <b class="routine"><i class="routine">trgEvent</i></b><b>( )</b> routine. (See the reference entry for <b class="routine"><i class="routine">trgEvent</i></b><b>( )</b> in <a href="wvGuideLOP.html#333"><i class="title">C. Library and Subroutine Reference</i></a>. For an example that uses <b class="routine"><i class="routine">trgEvent</i></b><b>( )</b>, see <a href="c-trigger3.html#85806">Example 6-6</a>.)</p><dd><p class="Body"><a name="84285"> </a>You can cause your trigger to fire on an event that occurs in any context, any task, a specific task, any ISR (interrupt service routine), or the system context. If you choose <b class="guiLabel"><font face="Helvetica, sans-serif" size="-1" class="sans">Specific Task</font></b> from the <b class="guiLabel"><font face="Helvetica, sans-serif" size="-1" class="sans">Context Matches</font></b> drop-down menu, you must fill in the task name in the right-hand field. If you choose <b class="guiLabel"><font face="Helvetica, sans-serif" size="-1" class="sans">Specific Object</font></b> from the <b class="guiLabel"><font face="Helvetica, sans-serif" size="-1" class="sans">Object Matches </font></b>drop-down menu, you must enter the object ID in the right-hand field.</p><dd><p class="Body"><a name="85317"> </a>At each potential triggering point, tests are performed to see if the criteria you have specified for event, context, and object conditions have been met. If they have, triggering proceeds to evaluate any additional criteria you may have set.</p><dd><p class="Body"><a name="84286"> </a>You can make your trigger conditional upon a variable or function taking a specific value or range of values. Change <b class="guiLabel"><font face="Helvetica, sans-serif" size="-1" class="sans">(unconditionally)</font></b> to <b class="guiLabel"><font face="Helvetica, sans-serif" size="-1" class="sans">conditional upon</font></b> and select <b class="guiLabel"><font face="Helvetica, sans-serif" size="-1" class="sans">Var</font></b> (variable) or <b class="guiLabel"><font face="Helvetica, sans-serif" size="-1" class="sans">Fn</font></b> (function) from the drop-down menu. Enter the variable or function name, select the matching criterion from the drop-down menu (<b class="guiLabel"><font face="Helvetica, sans-serif" size="-1" class="sans">==</font></b>, <b class="guiLabel"><font face="Helvetica, sans-serif" size="-1" class="sans"><=</font></b>, and so on), and enter the value to test in the last field.</p></dl></dl><dl class="margin"><dd><font face="Helvetica, sans-serif" size="-1" class="sans"><h5 class="HU"><i><a name="85283">Testing a Variable</a></i></h5></font><dl class="margin"><dd><p class="Body"><a name="85284"> </a>In order to fire your trigger when a variable takes a specified value, you must specify the following:<img class="figure" border="0" src="images/c-triggera7.gif"></p><dd><p class="Body"><a name="85286"> </a>where:</p></dl><dl class="margin"><dd><div class="Item"><a name="85288"> </a><b class="symbol_lc"><operand 1></b> </div><dl class="margin"><dl class="margin"><dl class="margin"><dl class="margin"><dd><div class="Indent4"><a name="85289"> </a>is a known, 32-bit identifier on the target (for example, <b class="symbol_lc">foo</b>)</div><br></dl></dl></dl></dl><dd><div class="Item"><a name="85290"> </a><i class="textVariable">operator</i> </div><dl class="margin"><dl class="margin"><dl class="margin"><dl class="margin"><dd><div class="Indent4"><a name="85291"> </a>is selected from the drop down list (<b>==</b>, <b>>=</b>, <b><</b>)</div><br></dl></dl></dl></dl><dd><div class="Item"><a name="85292"> </a><b class="symbol_lc"><operand 2></b> </div><dl class="margin"><dl class="margin"><dl class="margin"><dl class="margin"><dd><div class="Indent4"><a name="85293"> </a>is a 32-bit integer constant in either decimal or hexadecimal format (for example, 0x13579bde)</div><br></dl></dl></dl></dl></dl></dl><dl class="margin"><dd><p class="table" callout><table border="0" cellpadding="0" cellspacing="0"><tr valign="top"><td valign="top" width="40"><br><img border="0" alt="*" src="icons/warning.gif"></td><td><hr><div class="CalloutCell"><a name="87609"><b class="symbol_UC"><font face="Helvetica, sans-serif" size="-1" class="sans">WARNING: </font></b></a>The value to test, <b class="symbol_lc"><operand 2></b>, must be an integer.</div></td></tr><tr valign="top"><td></td><td><hr></td></tr><tr valign="middle"><td colspan="20"></td></tr></table></p callout></dl><dl class="margin"><dd><font face="Helvetica, sans-serif" size="-1" class="sans"><h5 class="HU"><i><a name="85538">Testing a Function </a></i></h5></font><dl class="margin"><dd><p class="Body"><a name="85539"> </a>In order to fire your trigger when a function takes a specified value, you must provide a function on the target which will be executed if all of the criteria specified for event, context, and object conditions have been met. Both the format and content of the function provided are important for correct operation. </p><dd><p class="Body"><a name="85540"> </a>The conditional function provided must be of the form </p><dl class="margin"><dd><pre class="Code2"><b><a name="87318">int condFunc (void) { int returnValue; /* * Function body. Must contain only code that can be executed in ISR * context. See VxWorks Programmer's Guide: Basic OS * Use of logMsg() and printf() are also prohibited. */ ... return (returnValue); }</a></b></pre></dl></dl></dl><dl class="margin"><dd><p class="table" callout><table border="0" cellpadding="0" cellspacing="0"><tr valign="top"><td valign="top" width="40"><br><img border="0" alt="*" src="icons/note.gif"></td><td><hr><div class="CalloutCell"><a name="87359"><b class="symbol_UC"><font face="Helvetica, sans-serif" size="-1" class="sans">NOTE: </font></b></a>The body of the function provided can contain any code desired, but must not contain any function calls which are not permitted in Interrupt Service Routine (ISR) context. This is because, depending on the criteria specified for event, context, and object conditions, the function provided may well be executed within an ISR.</div></td></tr><tr valign="top"><td></td><td><hr></td></tr><tr valign="middle"><td colspan="20"></td></tr></table></p callout><dd><p class="table" callout><table border="0" cellpadding="0" cellspacing="0"><tr valign="top"><td valign="top" width="40"><br><img border="0" alt="*" src="icons/warning.gif"></td><td><hr><div class="CalloutCell"><a name="87377"><b class="symbol_UC"><font face="Helvetica, sans-serif" size="-1" class="sans">WARNING: </font></b></a>The return value, <b class="symbol_lc"><operand 2></b>, must be an integer.</div></td></tr><tr valign="top"><td></td><td><hr></td></tr><tr valign="middle"><td colspan="20"></td></tr></table></p callout><dl class="margin"><dd><p class="Body"><a name="85548"> </a>Having provided a valid conditional function, it should be compiled for the target architecture and the resulting object module loaded onto the target. For example, if a function <b class="routine"><i class="routine">condFunc</i></b><b>( )</b> is contained in a C module called <b class="file">condFunc.c</b> and compiled into an object module <b class="file">condFunc.o</b>, the object module can be loaded on to the target from a Tornado shell using the following command:</p><dl class="margin"><dd><pre class="Code2"><b><a name="85549"></b><tt class="output">%</tt><b> ld < condFunc.o</a></b></pre></dl><dd><p class="Body"><a name="85550"> </a>If your function returns 1 under the conditions where you want your trigger to fire, you would specify the following: <img class="figure" border="0" src="images/c-trigger31.gif"></p><dd><p class="Body"><a name="85552"> </a>Here, <b class="guiLabel"><font face="Helvetica, sans-serif" size="-1" class="sans"><operand 1></font></b> is treated as a function name and <b class="guiLabel"><font face="Helvetica, sans-serif" size="-1" class="sans"><operand 2></font></b> is treated as a 32-bit integer constant.</p></dl><dd><p class="table" callout><table border="0" cellpadding="0" cellspacing="0"><tr valign="top"><td valign="top" width="40">
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -