📄 x-event3.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><html><head><link rel="STYLESHEET" type="text/css" href="wrs.css"><title> Event-Base API </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="x-event.html"><img border="0" alt="[Index]" src="icons/index.gif"></a><a href="x-event.html"><img border="0" alt="[Top]" src="icons/top.gif"></a><a href="x-event2.html"><img border="0" alt="[Prev]" src="icons/prev.gif"></a><a href="x-event4.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="83715">D.3 Tcl API</a></i></h3></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="83716"> </a>The Tcl programming interface provides a special command to load an event base into memory and to instantiate extra commands that allow the event base and its associated contexts to be manipulated directly from the command line. This procedure is written in C++ and uses the WindView C++ API to access the event base. The event-base library initializes a Tcl interpreter and then adds its own commands to the interpreter. </p><dd><p class="Body"><a name="85797"> </a>The syntax for <b class="symbol_lc">wvEventBaseLoad</b> is as follows: </p><dl class="margin"><dd><pre class="Code2"><b><a name="85799">wvEventBaseLoad "<i class="textVariable">filename</i>" <i class="textVariable">eventBaseRootName</i> </a></b></pre></dl><dd><p class="Body"><a name="87151"> </a>It returns a special handle which represents the event base. It also creates a number of new commands which work directly on the loaded event base and its task contexts; these commands start with the string specified by <i class="textVariable">eventBaseRootName</i>. The returned handle must be saved so it can be used with the command <b class="symbol_lc">wvCoordsCreate</b> to instantiate a coordinates object for navigating around the event base.</p><dd><p class="Body"><a name="87152"> </a>To load the event base <b class="file">logfile.wvr</b> with the root name <b class="symbol_lc">eb</b> and save the handle to the constant <b class="symbol_lc">ebHandle</b>, enter the following:</p><dl class="margin"><dd><pre class="Code2"><b><a name="85848">set ebHandle [wvEventBaseLoad "logfile.wvr" eb]</a></b></pre></dl></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H4"><i><a name="84353">Event-Base Commands</a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="84355"> </a>If the event-base root name is <b class="symbol_lc">eb</b> then a command <b class="command">eb</b> is created, plus one extra command for each task-context identified by the context name. For example, if there is a context called <b class="task">tFtpdTask</b>, it is accessible through the command <b class="command">eb.tFtpdTask</b>. </p><dd><p class="Body"><a name="84361"> </a>The event-base commands accept the following extra command arguments:</p></dl><dl class="margin"><dd><div class="Item"><a name="84363"> </a><b class="command">names</b> </div><dl class="margin"><dl class="margin"><dl class="margin"><dd><div class="Indent3"><a name="85424"> </a>returns a list of all context names.</><br></dl></dl></dl><dd><div class="Item"><a name="84364"> </a><b class="command">interval</b> </div><dl class="margin"><dl class="margin"><dl class="margin"><dd><div class="Indent3"><a name="85425"> </a>returns a 2-element list containing the start and end timestamps.</><br></dl></dl></dl><dd><div class="Item"><a name="84365"> </a><b class="command">destroy</b> </div><dl class="margin"><dl class="margin"><dl class="margin"><dd><div class="Indent3"><a name="85435"> </a>removes all the context commands and frees all memory allocated for the event base.</><br></dl></dl></dl></dl><dl class="margin"><dd><p class="Body"><a name="85436"> </a>The context commands accept the following arguments:</p></dl><dl class="margin"><dd><div class="Item"><a name="85437"> </a><b class="command">taskId</b> </div><dl class="margin"><dl class="margin"><dl class="margin"><dd><div class="Indent3"><a name="85427"> </a>returns the task VxWorks ID.</><br></dl></dl></dl><dd><div class="Item"><a name="85440"> </a><b class="command">priority</b> </div><dl class="margin"><dl class="margin"><dl class="margin"><dd><div class="Indent3"><a name="85441"> </a>returns the task priority.</><br></dl></dl></dl><dd><div class="Item"><a name="85442"> </a><b class="command">index time</b> </div><dl class="margin"><dl class="margin"><dl class="margin"><dd><div class="Indent3"><a name="85429"> </a>returns the index of the nearest event to the given time.</><br></dl></dl></dl><dd><div class="Item"><a name="84372"> </a><b class="command">events</b> </div><dl class="margin"><dl class="margin"><dl class="margin"><dd><div class="Indent3"><a name="85430"> </a>returns <i class="textVariable">M</i>, the number of events in the context, numbered 0...<i class="textVariable">M</i>-1.</><br></dl></dl></dl><dd><div class="Item"><a name="84373"> </a><b class="command">N</b> </div><dl class="margin"><dl class="margin"><dl class="margin"><dd><div class="Indent3"><a name="85431"> </a>returns a list representing the <i class="textVariable">N</i>th event in the context where <i class="textVariable">N</i> is an integer between 0 and <i class="textVariable">M</i>-1. Optional formatting of the output of this command is available via the <b class="symbol_lc">-format</b> option.</><br></dl></dl></dl></dl><dl class="margin"><dd><p class="Body"><a name="84376"> </a>The default string format of an event returned by the <i class="textVariable">N</i> context command is:</p><dl class="margin"><dd><pre class="Code2"><b><a name="84378">eventName timeStamp argList state</a></b></pre></dl><dd><p class="Body"><a name="84380"> </a>where <b class="symbol_lc">argList</b> is a Tcl list with each item in the list being a name:value pair and state is a hexadecimal value representing the <i class="term">wind state bits</i> defined in <i class="textVariable">installDir</i><b class="file">/host/include/wvapi.h</b>. </p></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H4"><i><a name="85891">Alternative Output Formats</a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="85894"> </a>The output of an event record can be reformatted if the default style is inadequate for your needs. For example, the event parameters can be omitted or the timestamp can be printed first. In the context <i class="textVariable">N</i> command described above, an optional <b class="symbol_lc">-format</b> <i class="textVariable">formatString</i> can be appended. The <i class="textVariable">formatString</i> argument is a string containing literal characters and %-escaped field specifiers. The field specifiers can take the following values: </p></dl><dl class="margin"><dd><div class="Item"><a name="85901"> </a><b class="symbol_lc">%n</b> </div><dl class="margin"><dl class="margin"><dl class="margin"><dd><div class="Indent3"><a name="86182"> </a>event name </><br></dl></dl></dl><dd><div class="Item"><a name="85902"> </a><b class="symbol_lc">%t</b> </div><dl class="margin"><dl class="margin"><dl class="margin"><dd><div class="Indent3"><a name="86183"> </a>time stamp </><br></dl></dl></dl><dd><div class="Item"><a name="85903"> </a><b class="symbol_lc">%s</b> </div><dl class="margin"><dl class="margin"><dl class="margin"><dd><div class="Indent3"><a name="86186"> </a>task state after the occurrence of the event </><br></dl></dl></dl><dd><div class="Item"><a name="85904"> </a><b class="symbol_lc">%1. . .%7</b> </div><dl class="margin"><dl class="margin"><dl class="margin">
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -