这学期开始学OPNET,之前图书馆借了几本书看;也在网上下载了陈敏的那本OPNET网络仿真的电子书,大家好像比较推荐这本。这星期基本不看那些中文的书了,发现OPNET自带help里的文档写的非常详细,尤其是刚开始的Tutorials里的那些例子应该认真学学,很多中文图书也有这些例子,当然是自带的help讲解的清楚!
今天开始做第二个例子,basic processes,看到了几个我以前疑惑或者不清楚的方面的解释,摘抄下来:
Transition—A change of state in response to an event.
You can use an FSM to control module behavior because you can attach fragments of
C/C++ code to states and transitions.
Simulations are made up of events. Process models respond to events and can schedule
new ones.
When an event occurs that affects a module, the Simulation Kernel passes control to
the module‘s process model via an interrupt. The process model responds to the event,
changing state and executing related code, and then returns control to the Simulation
Kernel (invocation 1). -个人觉得这句话非常重要
Give each state a unique name that describes its function. -这句话意义不大,但个人觉得这是给状态命名时基本的命名规则,在很多其他领域一样如此
An unforced (red) state is one that returns control of the simulation to the Simulation
Kernel after executing its enter executives. A forced (green) state is one that does not
return control, but instead immediately executes the exit executives and transitions to another state. -对强制状态和非强制状态的解释,其实很简单,很多中文书上都有,但是觉得英语表述的特别准确.........
There are two types of transitions, unconditional (a solid line) and conditional. When a
transitionis conditional, the transition must evaluate to true before control passes from the
source state to the destination state. -控制权的转移..
You may be wondering why you included a transition from idle back to itself and
named that transition default. As the simulation executes, the Simulation Kernel manages
a list of events to take place. As each event reaches the top (or head) of that list, it becomes
an interrupt. Interrupts are often delivered to specific modules, and this occurrence is what
activates the module‘s process model.
When the process model you are building is in the idle state, it transitions to the
arrival state if the ARRIVAL condition is true. Shortly, you will define ARRIVAL to evaluate
to true if the interrupt delivered to the module is a packet arrival interrupt.If it is a different
type of interrupt, however, there must be a transition that the process model can follow. The
default transition handles these different interrupt types.
In Proto-C, macros often replace more complicated expressions in transition conditions
and executives. The use of macros saves space and simplifies the task of interpreting an FSM diagram.
#define ARRIVAL (op_intrpt_type () == OPC_INTRPT_STRM)
The ARRIVAL condition defined above tests if the current interrupt (which caused the
FSM to awaken and execute) occurred due to an arriving packet. It compares the value
returned by the Kernel Procedure op_intrpt_type() with the constant of OPC_INTRPT_STRM.
If the comparison evaluates to true, this indicates that the interrupt is due to a packet
arrivingon an input stream.
You can declare variables in three places. Variables declared in the temporary variable block do not retain their values between invocations of the FSM. Variables declared in the
state variables block retain their values from invocation to invocation. Variables declared
inside a state‘s executive are only defined while that executive is executed.
Statistics save values of interest for later analysis. When creating a statistic, you must
declare that statistic in the process model that records it.
本文出自 “希尔伯特空间” 博客,请务必保留此出处http://8122234.blog.51cto.com/8112234/1380663