#
msgid ""
msgstr ""
"Project-Id-Version: Modelica by Example 0.2.1\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2014-04-14 10:14-0400\n"
"PO-Revision-Date: 2014-10-03 22:20+0100\n"
"Last-Translator: Dongping Xie <dongping.xie.tud@gmail.com>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"

#: ../../source/behavior/discrete/when.rst:4
msgid "When"
msgstr "When语句"

#: ../../source/behavior/discrete/when.rst:8
msgid ""
"By using ``when``, we can express conditions we are interested in reacting "
"to and what we wish to do in response to them.  In this section, we'll "
"review the key ideas behind ``when`` statements.  A ``when`` statement has "
"the following general form:"
msgstr ""
"通过使用\\ ``when``\\ ，我们可以表达我们所感兴趣的条件判断以及对这些条件判断的回应。\ "
"在本节中，我们将回顾\\ ``when``\\ "
"语句背后的主要思想。\ "
"\\ ``when``\\ 语句的一般形式如下："

#: ../../source/behavior/discrete/when.rst:22
msgid "``if`` vs. ``when``"
msgstr "对比\\ ``if``\\ 和\\ ``when``\\ "

#: ../../source/behavior/discrete/when.rst:24
msgid ""
"In our discussion on :ref:`hysteresis`, we briefly discussed the difference "
"between an ``if`` statement and a ``when`` statement.  The statements in a "
"``when`` statement become active only for an instant when the triggering "
"conditional expression becomes true.  At all other times, the ``when`` "
"statement has no effect.  An ``if`` statement or ``if`` expression remains "
"active as long as the conditional expression is true.  If the ``if`` "
"statement or ``if`` expression includes an ``else`` clause then some branch "
"will always be active."
msgstr ""
"在前面对\\ :ref:`hysteresis`\\ 的讨论里，我们简要地讨论了\\ ``if``\\ 语句和\\ ``when``\\ "
"语句之间的区别。\ "
"在\\ ``when``\\ 语句内的代码仅会在触发条件表达式为真的一瞬间被激活。\ "
"在所有其它的时候，\\ ``when``\\ "
"语句不会有任何影响。\ "
"而\\ ``if``\\ 陈述或\\ ``if``\\ 表达式只要在条件表达式为真时，它们就有效。\ "
"倘若\\ ``if``\\ "
"陈述或\\ ``if``\\ 表达式包含了\\ ``else``\\ 子句，那么总会有一个分支有效。\ "

#: ../../source/behavior/discrete/when.rst:34
msgid "Expressions"
msgstr "表达式"

#: ../../source/behavior/discrete/when.rst:36
msgid ""
"Most of the time, the expression ``expr`` is going to be a conditional "
"expression and usually it will involve relational operators.  Typical "
"examples of expressions frequently used with a ``when`` statement would be "
"``time>=2.0``, ``x>=y+2``, ``phi<=prev_phi`` and so on. Recall from our "
"discussion of the :ref:`interval-measurement` speed estimation algorithm "
"that you should **almost always** put the ``pre`` operator around any "
"variables in ``expr`` that also appear inside the ``when`` statement."
msgstr ""
"大多数时候，\\ ``expr``\\ 表达式会是个条件表达式，而且通常会涉及关系运算符。\ "
"\\ ``when``\\ 语句常用的条件表达式有例如\\ "
"``time>=2.0``\\ 、\\ ``x>=y+2``\\ 、\\ ``phi<=prev_phi``\\ 等。\ "
"回忆前面在讨论\\ :ref"
":`interval-measurement`\\ 测算算法时，对于同时出现在\\ ``expr``\\ 以及\\ ``when``\\ "
"表达式里的变量，你\\ **几乎总要**\\ 在给这些变量加上\\ ``pre``\\ 操作符。\ "

#: ../../source/behavior/discrete/when.rst:45
msgid ""
"In the :ref:`bouncing-ball` example, we saw a case where ``expr`` was not a "
"(scalar) conditional expression, but rather a vector of conditional "
"expressions.  Recall from that discussion that the ``when`` statement "
"becomes active if **any** of the conditions in the vector of expressions "
"becomes true."
msgstr ""
"在\\ :ref:`bouncing-ball`\\ 的例子里，我们遇到过\\ ``expre``\\ "
"并非有一个（标量）条件表达式，而是由条件表达式向量组成的情况。\ "
"请回忆前面关于有向量形式条件语句的\\ ``when``\\ 语句的讨论：当向量中的\\ "
"**任何一个**\\ 条件变为真时，\\ ``when``\\ 语句就会被激活。\ "

#: ../../source/behavior/discrete/when.rst:52
msgid "Statements"
msgstr "语句"

#: ../../source/behavior/discrete/when.rst:54
msgid ""
"A ``when`` statement is used to define new values for some variables. These "
"new values can be assigned in one of two ways.  The first is by introducing "
"an equation of the form:"
msgstr "\\ ``when``\\ 语句的作用是为变量定义新的取值。\ "
"我们可以用两种方法定义新的取值。\ "
"第一种方法是通过将具有以下形式的公式："

#: ../../source/behavior/discrete/when.rst:62
msgid ""
"In this case, the variable ``var`` will be given the value of ``expr``.  "
"Within ``expr``, the ``pre`` operator should be used when referring to the "
"pre-event value for a variable.  Any variable assigned in this way is a "
"discrete variable.  This means that its value only changes during events.  "
"In other words, it will be a piecewise constant function.  Note, a variable "
"assigned in this way cannot be continuous over any interval in the "
"simulation."
msgstr ""
"在这种情况下，\\ ``var``\\ 将会等于\\ ``expr``\\ 的取值。\ "
"而\\ ``expr``\\ 里的\\ ``pre``\\ "
"操作符用于指代变量在事件前的取值。\ "
"任何以这种方式赋值的变量均为离散变量。\ "
"这意味着，这些变量的值仅在事件进行时发生变化。\ "
"换句话说，变量将是分段常数函数。\ "
"请注意，以这种方式赋值的变量不可能在仿真的任何时间间隔内都保持连续。\ "

#: ../../source/behavior/discrete/when.rst:70
msgid ""
"If you want to explicitly mark a variable as discrete, you can prefix it "
"with the ``discrete`` qualifier (as we saw in the :ref:`sample-and-hold` "
"example earlier in this chapter) although this is not strictly necessary.  "
"By adding the ``discrete`` qualifier you ensure that the variable's value "
"must be determined within a ``when`` statement."
msgstr ""
"虽然严格而言并非必须，但如果你想明确地将变量标记为离散，你可以用\\ ``discrete``\\ 限定词作为其前缀（正如我们在本章前面的\\ :ref"
":`sample-and-hold`\\ 所看到的例子一样）。\ "
"添加\\ ``discrete``\\ 限定词可以确保该变量的值必须由\\ "
"``when``\\ 语句来确定。\ "

#: ../../source/behavior/discrete/when.rst:79
msgid ""
"The other way a variable can be given a value within a ``when`` statement, "
"as demonstrated in the :ref:`bouncing-ball` example, is by using the "
"``reinit`` operator.  In that case, the statement within the ``when`` "
"statement will take the form:"
msgstr ""
"另一种在\\ ``when``\\ 变量里为变量赋值的方法，正如在\\ :ref:`bouncing-ball`\\ 的例子里一样，是通过使用\\ "
"``reinit``\\ 操作符。\ "
"在这种情况下，\\ ``when``\\ 语句内部的代码将会有如下形式："

#: ../../source/behavior/discrete/when.rst:88
msgid ""
"When using the ``reinit`` operator, the variable, ``var``, **must be a "
"state**.  In other words, its solution must arise from solving a "
"differential equation.  The use of ``reinit`` on such a variable has the "
"effect of stopping the integration process, changing the value of the state "
"(and any other states that have the ``reinit`` operator applied to them "
"within the same ``when`` statement) and then resuming integration using what"
" are effectively a new set of initial conditions.  The values of all other "
"states not re-initialized with the ``reinit`` operator remain unchanged."
msgstr ""
"在使用\\ ``reinit``\\ 操作符时，变量\\ ``var``\\ **必须是一个状态**\\ "
"。\ "
"换句话说，此变量必须是微分方程求解的结果。\ "
"在这样的变量里使用\\ ``reinit``\\ 会停止积分过程并改变该状态 （以及其它在同一个\\ "
"``when``\\ 语句里添加了\\ ``reinit``\\ 的）的值。\ "
"紧接着，积分实际上使用了一套新的初始条件重新开始。\ "
"而没有使用\\ "
"``reinit``\\ 操作符进行重新初始化的其他状态会保持不变。\ "

#: ../../source/behavior/discrete/when.rst:101
msgid "``algorithm`` Sections"
msgstr "``algorithm``\\ 区域"

#: ../../source/behavior/discrete/when.rst:103
msgid ""
"One final note about ``when`` statements is how they interact with the "
"\"single assignment\" rule in Modelica.  This rule, from the specification, "
"states that there must be exactly one equation used to determine the value "
"of each variable.  As we saw in the sections on :ref:`speed-measurement` and"
" :ref:`hysteresis`, it is sometimes necessary (or at least clearer) to "
"express behavior in terms of multiple assignments.  In those cases, if all "
"the assignments are included within a single ``algorithm`` section, they are"
" effectively combined into a single equation.  However, doing so will limit "
"the compiler's ability to perform symbolic manipulation and, therefore, may "
"impact simulation performance and/or reusability of the models."
msgstr ""
"最后要注意\\ ``when``\\ "
"语句如何与Modelica的“单赋值规则”产生关系。\ "
"Modelica规范中的这条规则规定了每一个变量的值都正好对应一个求值的方程。\ "
"正如\\ :ref"
":`speed-measurement`\\ 以及\\ :ref:`hysteresis`\\ "
"小节里提到的，有时我们需要用多个赋值语句来描述系统行为（或者说这样可以表达得更为清晰）。\ "
"在这些情况下，如果所有的赋值语句都被只被放在\\ "
"``algorithm``\\ "
"区域，那么这些语句实际上会被看成是一个等式。\ "
"但是，这样做会减弱编译器执行符号运算的能力，结果可能至少会影响仿真的性能和模型的可重用性中的一个。\ "

#: ../../source/behavior/discrete/when.rst:115
msgid ""
"It is also worth noting that if the semantics of an ``algorithm`` section "
"are needed during initialization, Modelica includes an ``initial algorithm``"
" section that is analogous to the ``initial equation`` section discussed in "
"the previous discussion on :ref:`initialization`.  The ``initial algorithm``"
" section will be applied only during the initialization phase to determine "
"initial conditions, just like an ``initial equation`` section, but the "
"``initial algorithm`` section will allow multiple assignments to the same "
"variable.  The same caveats apply with respect to symbolic manipulation."
msgstr ""
"值得注意的是，如果在初始化期间需要\\ ``algorithm``\\ 区域这种语义，Modelica包含了一种\\ ``initial "
"algorithm``\\ 区域来实现这种功能。\ "
"\\ ``initial algorithm``\\ 区域的作用可以类比前面在\\ "
":ref:`initialization`\\ 讨论过的\\ ``initial equation``\\ 区域。\ "
"正如\\ ``initial "
"equation``\\ 一样，\\ ``initial algorithm``\\ "
"只会在初始化阶段确定初始化条件时有效，但这种区域支持多次赋值。\ "
"前述关于符号操作的警告仍然有效。\ "
