Download as pdf or txt
Download as pdf or txt
You are on page 1of 26

6—Process Editor

6 Process Editor
A process in the context of computer systems and communications networks
can be viewed as a series of logical operations performed on data, and the
conditions that cause these operations. Processes may be implemented in
terms of both hardware or software components.

OPNET process models describe the logic of real-world processes, such as:

• Communications protocols and algorithms

• Shared resource managers

• Queuing disciplines

• Specialized traffic generators

• Statistic collection mechanisms

• Operating systems

The Process Editor provides the necessary features for specifying process
models that consist of both graphical and textual components. It uses state
transition diagrams (STDs) to graphically depict the overall logical organization
of the process model. Icons within an STD are used to represent logical states,
and lines are used to represent transitions between states. The operations
performed by a process model are described in statements based on the C or
C++ languages; these statements can be associated with states, transitions, or
special blocks within the process model. Editing pads are used to enter the
statements associated with states and blocks.

The combination of graphical and text entry components within the Process
Editor has two key benefits:

• The graphical components allow you to visualize the modes of the process
and the flow of control between these modes. This representation assists
those responsible for maintaining the model by inherently documenting
certain aspects of its structure.

• The provision for direct entry of C or C++ statements ensures that there are
few limitations to the complexity and fidelity of the model.

ER-6-1 OPNET Modeler/Release 16.1


6—Process Editor

An example of a process model and an associated editing pad appears in the


following figure.

Figure 6-1 Example STD and Code Block

This section includes the following topics:

• Forced and Unforced State Status on page ER-6-3

• Process Editor Menus on page ER-6-4

• Toolbar Buttons on page ER-6-8

• Interfaces Menu Operations on page ER-6-9

• FSM Menu Operations on page ER-6-15

• Code Blocks Menu Operations on page ER-6-18

• Compile Menu Operations on page ER-6-24

For more information about the process modeling methodology, see


Chapter 5 Process Domain on page MC-5-1.

OPNET Modeler/Release 16.1 ER-6-2


6—Process Editor

Forced and Unforced State Status


States can either be forced (shown as green or black) or unforced (shown as
red or white). A forced state will execute its enter executives and exit executives,
then pass control to another state via a transition. An unforced state will execute
its enter executives and pause, allowing the simulation to turn its attention to
other entities and events in the model. A process enters an unforced state to
await further interrupts, such as arriving packets or a timer expiration.

For more information about forced and unforced states, see State Transition
Diagrams on page MC-5-22

ER-6-3 OPNET Modeler/Release 16.1


6—Process Editor

Process Editor Menus


The Process Editor provides operations for creating and working with process
models. You access these operations from the Process Editor menu bar, which
contains the following menus:

Table 6-1 Process Editor Menus


Menu Description Reference

File Contains operations that relate to high-level File Menu on page ER-2-2
functions such as opening and closing
projects, saving scenarios, importing
models, and printing graphics and reports.

Edit Contains operations that allow you to edit Edit Menu on page ER-2-5
the preferences that control program
operation and to manipulate text and
objects.

Interfaces Contains operations that allow you to edit a Interfaces Menu on


process model’s interfaces to other page ER-6-6
processes and to the project as a whole.

FSM Contains operations for creating a state FSM Menu on page ER-6-6
transition diagram of the finite state
machine that defines the process model.

Code Blocks Contains operations that allow you to Code Block Menu on
specify the C/C++ code that implements a page ER-6-7
process.

Compile Contains operations for processing the Compile Menu on


C/C++ code of a process model. page ER-6-8

Windows Lists all open editor windows and allows Windows Menu on
you to make one active. page ER-2-7

Help Provides access to context-sensitive help, Help Menu on page ER-2-8


the product documentation and tutorials,
and information about the program.

Note—The editor menus on your machine may vary from those described here,
particularly if there has been any UI customization or use of ETS.

OPNET Modeler/Release 16.1 ER-6-4


6—Process Editor

In addition to the menu bar menus, several pop-up menus are available within
the Process Editor:

• Workspace pop-up menu—contains zoom operations, as described in


Pop-Up Menus on page ER-3-24. It also contains these additional
operations:
— The No Zoom operation returns the display to the initial display: the zoom
level that existed when you first opened the model. The Process Editor
does not save zoom levels, so the initial display does not change from
one session to the next. The Project Editor, by contrast, does save zoom
levels, so it lacks the No Zoom operation.
— The Show/Hide Line Counts operation. This operation either shows or
hides a label under each state that lists the number of lines contained in
the state’s enter and exit executives. Showing line counts can be helpful
when you want to track down exactly which executive, in which state, has
the code you need to examine.
— The Clip Titles/Show Full Titles operation. This operation either truncates
the displayed titles of process states to the width of the state icons (the
default setting) or displays the full titles of all process states.

• Object pop-up menu—contains operations that allow you to


— edit object attributes (see Edit Attributes on page ITG-3-53)
— make the state the initial state
— make the state forced or unforced
— open the enter executives edit pad. You can also activate this operation
by double-clicking in the top half of a state icon or by clicking the enter
execs button in the attributes dialog box
— open the exit executives edit pad. You can also activate this operation by
double-clicking in the bottom half of a state icon or by clicking the exit
execs button in the attributes dialog box

Note—Changes to Enter or Exit Execs are not saved to disk until you save the
process model. Save the process model by selecting Save from the Process
Editor’s File menu.

There is also an operation available within the Process Editor that does not
appear on a menu:

• Move Label—moves a transition label. This operation is activated by


left-clicking on the label, then dragging it to a new location.

ER-6-5 OPNET Modeler/Release 16.1


6—Process Editor

Interfaces Menu
The Interfaces menu includes operations that allow you to edit a process
model’s interfaces to other processes and to the project as a whole.

Table 6-2 Interfaces Menu Summary


Menu item Description Reference

Model Attributes Defines attributes for the process model. Model Attributes on
These attributes are promoted to page ER-6-12
processor or queue modules at the node
level.

Process Interfaces Configures certain attributes of Process Interfaces on


processors and queues that rely on the page ER-6-14
process model at the node level.

ODB Labels Specifies descriptions of labels used in ODB Labels on


process model code, for display in ODB. page ER-6-13

Parallel Execution Opens a submenu for specifying the Parallel Execution


Support > process model’s support for parallel Support on
execution. page ER-6-13

Local Statistics Declares named statistics that are scoped Local Statistics on
to the queue or processor module and that page ER-6-12
the process computes and generates.

Global Statistics Declares named statistics that are scoped Global Statistics on
to the simulation as a whole and are page ER-6-10
computed and generated by this process
model. Global statistics usually represent
system-wide metrics.

Global Attributes Defines attributes that have a Global Attributes on


simulation-wide scope. These are the page ER-6-9
global attributes that the process model
expects to query during the simulation.

FSM Menu
The FSM menu includes operations for creating a state transition diagram of the
finite state machine that defines the process model.

Table 6-3 FSM Menu Summary


Menu item Description Reference

Create State Creates a new state within the process Create State on
model. page ER-6-15

Create Transition Creates transitions between states. Create Transition


on page ER-6-15

Set Initial State Sets the selected state in the process to Set Initial State on
be the initial one. page ER-6-17

OPNET Modeler/Release 16.1 ER-6-6


6—Process Editor

Code Block Menu


The Code Block menu includes operations that allow you to specify the C/C++
code that implements a process.

Note—Changes to code blocks are not saved until you save the process model.
Save the process model by selecting Save from the Process Editor’s File menu.

Table 6-4 Code Block Menu Summary


Menu item Description Reference

State Variables Defines variables that retain their value State Variables on
from one process invocation to the next. page ER-6-21

Temporary Variables Defines variables that retain their value Temporary Variables
only during the span of a single process on page ER-6-22
invocation.

Header Block Defines constants, macro expressions, Header Block on


include files, global variables, data page ER-6-20
structures, data types, and function
declarations for the process. Also
declares whether the process model will
be in C/C++.

Function Block Defines C/C++ functions that are Function Block on


associated with the process. page ER-6-19

Diagnostic Block Defines C/C++ statements that send Diagnostic Block on


diagnostic information to the standard page ER-6-18
output device.

Termination Block Defines C/C++ statements that run just Termination Block on
before a process is destroyed. page ER-6-23

ER-6-7 OPNET Modeler/Release 16.1


6—Process Editor

Compile Menu
The Compile menu includes operations for processing the C/C++ code of a
process model.

Table 6-5 Compile Menu Summary


Menu item Description Reference

Enable C++ Code When selected, causes the Process Editor Enable C++ Code
Generation to generate C++ code instead of C code. Generation on
page ER-6-25

Include Temporary When selected, causes temporary Include Temporary


Variables in variables to be generated in the Variables in
Termination Block termination block. Diagnostic/Termination
Block on page ER-6-25

Include Temporary When selected, causes temporary Include Temporary


Variables in variables to be generated in the diagnostic Variables in
Diagnostic Block block. Diagnostic/Termination
Block on page ER-6-25

Compile Code Generates the C or C++ source file and Compile Code on
object code for the process model; saves page ER-6-24
the model.

Compile Code Same as the Compile Code operation, but Compile Code
(Advanced) allows additional control over the (Advanced) on
compilation process and the types of page ER-6-25
object files created.

List Code Displays the C/C++ source file generated List Code on
by compiling the process model. page ER-6-26

Show Recent Opens an edit pad containing messages —


Compilation from the most recent compilation error log.
Messages

Toolbar Buttons
The Process Editor has toolbar buttons for frequently-used operations. For each
toolbar button—the name appears as a tooltip when you rest the cursor on the
button.

To configure the toolbar buttons, see Configuring the Toolbar on page ER-1-7.

OPNET Modeler/Release 16.1 ER-6-8


6—Process Editor

Interfaces Menu Operations


This section contains descriptions and procedures for using the operations
available from the Interfaces menu in the Process Editor. The items that appear
on this menu are described below in alphabetical order.

• Global Attributes on page ER-6-9

• Global Statistics on page ER-6-10

• Local Statistics on page ER-6-12

• Model Attributes on page ER-6-12

• ODB Labels on page ER-6-13

• Parallel Execution Support on page ER-6-13

• Process Interfaces on page ER-6-14

Global Attributes
This operation allows you to define new global attributes and to edit or delete
existing ones. Global attributes are not associated with any particular object, but
are scoped globally to the simulation as a whole. Typically, global attributes are
needed by an entire class of objects in a simulation, such as all of the processes
of a particular type. These processes share the global attribute and so are
guaranteed to agree on its value (as opposed to process model attributes, which
provide each process model instance with its own independent value).

A process can query global attributes by using the KP op_ima_sim_attr_get().


Declaration of the global attribute in the process model supports several
important mechanisms of other tools. In the Probe Editor, attribute probes can
be set to collect the values of global attributes as scalar values. In the Simulation
Sequence Editor, declared global attributes can be assigned values prior to
executing simulations, thus avoiding the need to obtain the value dynamically
as the process’s request is encountered by the Simulation Kernel.

For more information about global simulation attributes, see

• Modeling Concepts

• Discrete Event Simulation API

ER-6-9 OPNET Modeler/Release 16.1


6—Process Editor

Global Statistics
This operation declares named global statistics that can be recorded during
simulation and viewed as results. Global statistics are scoped to the simulation
as a whole, in contrast to local statistics, which are scoped to a particular queue
or processor. In other words, multiple processes, as well as pipeline stages, all
at different locations in the model’s system, can contribute to the same shared
statistic. This is done by referring to the statistic by name and obtaining a
statistic handle. See Chapter 1 Introduction on page DES-1-1 for more
information about statistic handles. Global statistics cannot be used as the
sources of statistic wires.

When you choose this operation, the Declare Global Statistics dialog box
appears. In this dialog box, you can create a new global statistic, delete an
existing statistic, or modify some aspects of a statistic. To sort the table, click in
a heading cell. Repeated clicks toggle the sort order.

Figure 6-2 Declare Global Statistics Dialog Box

OPNET Modeler/Release 16.1 ER-6-10


6—Process Editor

The following table lists the fields in the Declare Global Statistics dialog box.

Table 6-6 Declare Global Statistics Dialog Box—Fields


Name Description

Stat Name Name of the statistic defined by the process model.

Mode Number of dimensions. A single-mode statistic generates only one


independent series of values over time. A dimensioned-mode statistic
actually represents a set, or array, of single-mode statistics, each
independently managed and separately usable for probes and statistic
wires.
Each of the individual statistics in a dimensioned statistic shares the same
base name, but is distinguished by its index in the statistic array. This
scheme is useful when managing large quantities of similarly defined
statistics. For example, the performance statistics of a switch, with respect
to each of eight outgoing links, could be declared using dimensioned
statistics instead of individually declaring each one. This approach is more
scalable, allowing the process model to more easily track growth in the
node model simply by increasing the dimension of the statistic array.

Count The number of elements in a dimensioned statistic. Similar to the


dimension of an array.

Description Brief description of the statistic. Left-click to display the full description in
a text edit pad.

Group Group the statistic belongs to. This group is used to organize the statistic
in the hierarchy shown in the statistic browser.

Capture Mode Default capture mode for the statistic.


See Project Editor on page ER-3-1 for details about capture modes.

Draw Style Default draw style for the statistic.

Low Bound The lowest ordinate shown on a graph when the statistic is plotted. The
low and high bounds are considered when drawing graphs, although the
bounds are not absolute limits.
Most statistics do not collect negative values, so you can usually set this
value to 0. Built-in statistics have a low bound of 0.

High Bound The highest ordinate shown on a graph when the statistic is plotted, as
long as the actual results are less than the high bound value. If a value
collected for the statistic is higher than the high bound you set, the vertical
axis will be expanded so the highest data point can be graphed correctly.

For more information about global statistics, see

• Modeling Concepts

• Discrete Event Simulation API

ER-6-11 OPNET Modeler/Release 16.1


6—Process Editor

Local Statistics
This operation declares named statistics that can act as sources of statistic
wires at the node level, as well as node statistic probes defined in the Probe
Editor. Local statistics are scoped to the queue or process module in which a
process operates. In other words, each separate instance of the process model
can individually maintain a local statistic with the same name. These statistics
vary independently over time, can be separately probed, and can be used to
feed statistic wires.

When you choose this operation, the Declare Local Statistics dialog box
appears. In this dialog box, you can create a new local statistic, delete an
existing statistic, or modify some aspects of a statistic. To sort the table, click in
a heading cell. Repeated clicks toggle the sort order.

Figure 6-3 Declare Local Statistics Dialog Box

The fields in this table are the same as for the Declare Global Statistics dialog
box, as listed in Table 6-6 on page ER-6-11.

For more information about local statistics, see

• Modeling Concepts

• Discrete Event Simulation API

Model Attributes
This operation allows you to define new process model attributes and to edit or
delete existing ones.

Process model attributes are essentially “parameters” of the model, allowing


users of the model to control its behavior in predefined ways. Process model
attributes are automatically promoted to the node level, where they appear as
attributes of processor and queue modules.

OPNET Modeler/Release 16.1 ER-6-12


6—Process Editor

An important function of process model attributes is to generalize the


applicability of a process model. Specifically, rather than embed a fixed
characteristic into a process model (such as a “hardwired constant”), this same
characteristic can instead be represented by a process model attribute. Each
instance of the process model, or process, learns of its particular attribute
assignment when the simulation begins and adjusts its configuration or behavior
appropriately. In this way, the process model has achieved a greater degree of
reusability by supporting a broader set of applications. The alternative is to
create many process models that are nearly-identical except for a small number
of built-in characteristics. This is a less desirable approach because it entails
maintaining a larger implementation and requires continually duplicating
process models as slight variations become necessary. Furthermore, by using
process model attributes to parameterize behavior, simulation sequences can
automatically sequence through different scenarios simply by changing attribute
values.

For more information about process model attributes, see Process Domain on
page MC-5-1.

ODB Labels
This operation lets you associate descriptions with any labels used in a process
model. This information can be displayed in the OPNET Debugger. (See the
ODB command lmap on page DES-4-52.) The labels and descriptions you
define here should reflect the labels used in process model code. However,
there is no enforcement on the validity of the defined labels, nor do they affect
compilation of the process model or its use in ODB.

Parallel Execution Support


This submenu lets you specify whether or not the code in the current process
model is MT safe (and thus whether the events executed by the process model
can be executed in parallel).

The choices are:

• Support Parallel Execution—The process model is MT safe and can be run


in parallel.

• Does Not Support Parallel Execution—The process model is MT unsafe and


is always run sequentially.

• Model Safety Has Not Been Studied—MT safety is unknown. Whether the
code will be run in parallel or sequential mode is determined by the
parallel_sim.unknown_process_mt_safety_handling preference.

WARNING—Do not select the Support Parallel Execution option unless the
process model code is MT safe, as described in Making Models Parallel-Safe
on page MC-10-50.

ER-6-13 OPNET Modeler/Release 16.1


6—Process Editor

Process Interfaces
This operation allows you to set values for and specify the behavior of the
built-in attributes of queues and processors. The functions supported by this
operation are a subset of those supported by the node model interface for
built-in attributes of node objects. See Node Interfaces on page ER-5-7 for a
description of these functions.

Figure 6-4 Process Interfaces Dialog Box

A process model’s attribute interface is somewhat simpler than that of a node


model because, unlike a node model, a process model contains no objects that
promote attributes to the next modeling domain. The only attributes that a
process model promotes to the node level are process model attributes.
However, process model attributes are not affected by the process model
attribute interface, just as node model attributes are managed separately from
the node model attribute interface.

The process model attribute interface therefore applies only to control of built-in
attributes of queues and processors. This mechanism is useful to simplify the
attribute lists of queues and processors and to enforce particular attribute
settings that the process model relies on. For example, a process model
implementing a statistic collection process may rely on the receipt of an end
simulation interrupt. The process model developer can guarantee that a
processor module will provide this service by enabling and hiding the “endsim
intrpt” attribute of the processor via the process model attribute interface. By
hiding the attribute, the process model developer prevents its value from being
changed at the node level.

Not all built-in attributes of queues and processors can be controlled in this way.
For more information about specific built-in attributes that can be affected by
lower-level model attribute interfaces, see Modeling Concepts.

OPNET Modeler/Release 16.1 ER-6-14


6—Process Editor

FSM Menu Operations


This section contains descriptions and procedures for using the operations
available from the FSM menu in the Process Editor. The items that appear on
this menu are described below in alphabetical order.

• Create State on page ER-6-15

• Create Transition on page ER-6-15

• Set Initial State on page ER-6-17

Create State
This operation creates a new state within the process model being edited. If the
newly created state is the first state created in the process model, then the state
is set to be the initial state. This is indicated by the white arrow (black arrow on
monochrome monitors) to the left of the state. Newly created states are named
by default, but do not contain executive statements or have transitions. These
elements can be added via the state’s attribute menu (name and executives) or
via the Create Transition operation.

Newly created states are unforced by default. They appear red on color displays
and white on monochrome displays. Unforced states allow the process model
to release control back to the Simulation Kernel and “rest” while the Simulation
Kernel attends to other tasks. Forced states bypass the rest phase and force the
FSM to continue through and execute with no logical breaks.

For more information about forced versus unforced states, see Process Domain
on page MC-5-1.

Create Transition
This operation creates transitions between states in a process model. A
transition is depicted by an arc (or alternatively, a series of straight segments)
connecting two states, and defines the possible progress of the FSM from one
state to another. The beginning state of the transition is called the source state;
the ending state is the destination state.

A transition is characterized by its association with the two states, and by a


condition statement and an executive statement. The condition statement is
optional. It defines the conditions under which the transition will be traversed.
The executive statement is also optional. It contains actions that are
implemented if and when the transition is traversed. These executives are
edited via the transitions’s attribute menu.

For detailed information about transitions, see Process Editor on page ER-6-1.

ER-6-15 OPNET Modeler/Release 16.1


6—Process Editor

Multiple-Segment Transitions
It is possible to draw transitions with more than one line segment. The presence
of additional line segments does not affect the process model logic in any way.
If a transition has multiple line segments, you can use the mouse to move it to
a new location (the end segments change to reflect the new location).

Procedure 6-1 Drawing a Multi-Segment Transition

1 Choose FSM > Create Transition and left-click on the source state.

2 Left-click on the desired location of the first vertex. This location must be within the
Process Editor window and not over a state.

3 Continue left-clicking at each desired vertex.

➥ OPNET follows with a “rubber band” line extending from the last vertex to the
current location of the pointer.

4 Click on the destination state.

➥ The transition completes.

End of Procedure 6-1

Transition Drawing Styles


The transition’s drawing style can be either “line” or “spline”. Drawing style is
changed using the transition’s attribute menu. By default, the style is set to
“spline”. The spline style draws transitions so each vertex of the transition is
curved. The line style depicts the transition as a series of adjoining straight line
segments.

Moving Condition and Executive Statements


Sometimes OPNET places the condition/executive statements over the
transition, making them difficult to view. Moving the condition/executive labels
can improve the appearance of the model and make the association between
the transition and its statements more clear. To move a condition/executive
label, left-click on it, then drag it to a new position.

OPNET Modeler/Release 16.1 ER-6-16


6—Process Editor

Set Initial State


This operation specifies which state in the process is the initial state. The initial
state is indicated by a large arrow which appears to its left. OPNET
automatically assigns this status to the first state that it is created in a process
model, but you can use this operation to indicate a different initial state.

The initial state has the following uses and properties:

• It is used to set the initial values of key variables in the process. These
variables are initialized when the process is first “awakened”. Awakening
may occur at the beginning of the simulation if the “begsim interrupt” is
enabled on the module associated with the process. Otherwise, awakening
may occur when the first interrupt arrives at the process.

• The initial state of a process is usually executed only once in the course of
the simulation.

ER-6-17 OPNET Modeler/Release 16.1


6—Process Editor

Code Blocks Menu Operations


This section contains descriptions and procedures for using the operations
available from the Code Blocks menu in the Process Editor. The items that
appear on this menu are listed below in alphabetical order:

• Diagnostic Block on page ER-6-18

• Function Block on page ER-6-19

• Header Block on page ER-6-20

• State Variables on page ER-6-21

• Temporary Variables on page ER-6-22

• Termination Block on page ER-6-23

Note—Changes to code blocks are not saved until you select File > Save.

Diagnostic Block
This operation presents a dialog box that allows the diagnostic block to be
defined for a process model. The diagnostic block contains C or C++ language
statements that send diagnostic information to the standard output device.
Often, this is done by making calls to the standard I/O function printf() or to
OPNET KPs that print messages. Statements in the diagnostic block have full
access to the process’s state variables, but not the temporary variables.
Diagnostic statements can thus generate a report of the process’s internal state.

The diagnostic block procedure is called by the Simulation Kernel via the
OPNET simulation debugger (ODB). ODB is accessed by running a simulation
with the -debug command line flag, and is described in OPNET Simulation
Debugger (ODB) on page DES-3-1.

OPNET Modeler/Release 16.1 ER-6-18


6—Process Editor

The diagnostic block dialog box supports the addition, deletion, or modification
of C or C++ language statements. A typical diagnostic block editing pad is
shown in the following figure.

Figure 6-5 Diagnostic Block Edit Pad

Function Block
This operation presents a dialog box that allows a function block to be defined
for a process. The function block contains C or C++ language functions that are
associated with the process, and that can be called by any of the statements in
the process, including statements associated with states, transitions, and other
blocks.

ER-6-19 OPNET Modeler/Release 16.1


6—Process Editor

The function block supports the addition, deletion, or modification of any number
of C or C++ language functions. A typical function block dialog box is shown in
the following figure.

Figure 6-6 Function Block Edit Pad

Header Block
This operation presents a dialog box that allows you to define a header block for
the current process. The header block in process model definitions usually
contains one or more of the following elements:

• OPC_COMPILE_CPP (optional token denoting the use of C++)

• #include directives (for inclusion of C or C++ header files)

• #define directives (for constants and macros)

• struct data type definitions

• typedef data type definitions

• class definitions (for use with C++)

• extern variable declarations

• global variable declarations

• comments

The header block is primarily useful for declaring the symbolic constants,
macros, and data types that will be referenced within the process model
executive and conditional statements.

OPNET Modeler/Release 16.1 ER-6-20


6—Process Editor

The header block supports the addition, deletion, or modification of declarations


and preprocessor directives. A typical header block dialog box is shown below.

Figure 6-7 Header Block Edit Pad

If the process model is to be compiled as C++, the token OPC_COMPILE_CPP


might be included in the header file. If so, the line containing this token will not
appear in the generated code. (Normally, C++ compilation is indicated via the
Compile > Enable C++ Code Generation option.)

State Variables
This operation presents a table in which you can declare state variables for the
process. State variables are those variables that retain their value from one
process invocation to the next. They are distinct from temporary variables
(described in Temporary Variables on page ER-6-22), which retain their values
only during the span of a single process model invocation. For a more detailed
description of state variables, see Variables on page MC-5-33.

Figure 6-8 State Variables Table

ER-6-21 OPNET Modeler/Release 16.1


6—Process Editor

To sort the state variables table by type or name, click in a heading cell.
Repeated clicks toggle the sort order. To find a text string in the table, enter the
string in the field below the Name column and click the Find Next button. The
“Ignore case” checkbox controls case sensitivity for the find operation.

The Edit Ascii button opens an edit pad containing state variables in the variable
declaration syntax of the C or C++ language. In the edit pad, you can add,
delete, or modify state variable declarations. However, note that each state
variable declaration must be contained on a single line of the state variable
editing pad. Also, the name of each state variable must be immediately
preceded by a backslash character (“\”), as shown in the following figure.

Figure 6-9 State Variable Declarations

OPNET-defined data types

User-defined data types

C-defined data types

Temporary Variables
This operation presents a dialog box that allows temporary variables to be
declared for the process. Temporary variables are those variables that do not
retain their value from one invocation of the process to the next. They store
values only during the span of a single process invocation and are typically used
as “scratch” variables. Temporary variables can be accessed only in state
executives, as described in Variables on page MC-5-33.

OPNET Modeler/Release 16.1 ER-6-22


6—Process Editor

Temporary variables are distinct from state variables (see State Variables on
page ER-6-21), which retain their values from one process invocation to the
next. When the process is resumed later in the simulation, state variables still
have their previous value, whereas temporary variables do not. Temporary
variables are implemented in C or C++ language as automatic variables of the
process model function. They are declared according to the same rules which
C and C++ apply to automatic variables.

Temporary variables can be available only in the process code or included also
in the termination or diagnostic blocks. See Include Temporary Variables in
Diagnostic/Termination Block on page ER-6-25 for details.

The Temporary Variables dialog box allows for the addition, modification, or
deletion of temporary variable declarations. A typical Temporary Variables
dialog box is shown in the following figure.

Figure 6-10 Temporary Variables Edit Pad

Termination Block
This operation presents an edit pad that allows you to define the termination
block for a process model. The termination block contains C or C++ language
statements that execute just before a dynamic process is destroyed. For
example, if a dynamic process has allocated memory (such as lists), the
termination block can be used to deallocate the memory before the process is
destroyed. The termination block does not execute for root processes.

ER-6-23 OPNET Modeler/Release 16.1


6—Process Editor

The termination block is invoked by the Simulation Kernel via the


op_pro_destroy() Kernel Procedure, which is used to destroy dynamic
processes. By terminating dynamic processes that are no longer useful, you can
make memory available for other processes. For more information about this
KP, see op_pro_destroy() on page DES-14-11. For more information about root
and dynamic processes, see Chapter 5 Process Domain on page MC-5-1.

Compile Menu Operations


This section contains descriptions and procedures for using the operations
available from the Compile menu in the Process Editor. The items on this menu
are listed below in alphabetical order:

• Compile Code on page ER-6-24

• Compile Code (Advanced) on page ER-6-25

• Enable C++ Code Generation on page ER-6-25

• Include Temporary Variables in Diagnostic/Termination Block on


page ER-6-25

• List Code on page ER-6-26

Compile Code
This operation assembles all the separate code elements from the process
model (executives, code blocks, and so on) to create a single C or C++ source
code file for the process. It then uses the host machine’s C or C++ compiler to
generate object code, as specified by the current preference settings
(comp_target_type.development_sequential_32, comp_prog,
comp_flags_common, and so on).

OPNET Modeler/Release 16.1 ER-6-24


6—Process Editor

Compile Code (Advanced)


This operation compiles the process model as does the Compile Code
operation, but first provides a convenient interface (shown in the following
figure) for specifying the types of object file to produce, compiler settings, and
debugging support to include in the compiled code. You can save the settings
specified in this dialog box to your preferences for future use; if not saved, they
remain effective only until the Process Editor is closed.

Figure 6-11 Compilation of Process Model Dialog Box

When you click the Compile button, all the separate code elements from the
process model are assembled to create a single source code file for the
process. It then uses the host machine’s C or C++ compiler to produce one
object file for each target simulation kernel selected.

Enable C++ Code Generation


This option causes the Process Editor to use a C++ compiler and generate C++
code (*.pr.cpp file) instead of C code (*.pr.c file). Setting this option is
identical to putting the token OPC_COMPILE_CPP in the header block.

Note—You must use either this option (preferred) or the OPC_COMPILE_CPP


token if the process model code contains constructs specific to C++.

Include Temporary Variables in Diagnostic/Termination Block


These operations control whether temporary variables should appear only in the
definition of the process’ FSM function or also be generated in the diagnostic
block, termination block, or both.

ER-6-25 OPNET Modeler/Release 16.1


6—Process Editor

Although these operations provide a quick way to include all temporary


variables in the diagnostic or termination blocks, it is better to declare a variable
used in one of those blocks directly in that block. Variables declared in the
temporary variable text that are not used in a block where they are generated
will be flagged by some compilers as “unused variables”.

Note—Temporary variables generated in the FSM, diagnostic block, or


termination block are local to their respective functions. Values set in one
function are not seen by the others. Use state variables for values that need to
be shared between functions.

List Code
This operation presents a dialog box showing the C or C++ language source
code generated for the entire process. When a process model is created, you
enter C or C++ language instructions in the form of:

• Enter and exit executives for the states

• Conditional/executive transitions between states

• Variable, macro, and function definitions

Successful completion of this operation requires that the process model has
already been compiled using the Compile Code operation. When compiling the
model, all the separate elements of C or C++ code for the model are pulled
together into a single C or C++ source file. Then the host machine’s C or C++
compiler generates the object code for the process model.

When you choose the List Code operation, a dialog box displays containing the
C or C++ source code that was generated the last time the process model was
compiled. If any changes have been made to the model since then, they are
reflected in the displayed code.

Although you can edit the C or C++ code shown in the editing pad, the changes
do not have any effect on the process model. In other words, the edits do not
modify the state executives, transitions, or C or C++ code in the various blocks
of the process model.

OPNET Modeler/Release 16.1 ER-6-26

You might also like