op_sim_end()

Abstract

Terminates the simulation, closes off the vector output file, and prints several specified lines.

Syntax

op_sim_end (line0, line1, line2, line3)
Argument Type Description
line0 const char* message line #0
line1 const char* message line #1
line2 const char* message line #2
line3 const char* message line #3

Return Type

void

No return value (any code following a call to op_sim_end() will not be executed).

Example

Excerpt from: example model (models/std/hssb); process model (hssb_appl); state (INIT); enter execs.

/* Obtain self ID */
myid = op_id_self ();

/* Obtain the attribute values. */
op_ima_obj_attr_get (myid, "address", &my_address);
op_ima_obj_attr_get (myid, "average_interarrival_time", &ia_time);
op_ima_obj_attr_get (myid, "average_service_time", &service_time);
op_ima_obj_attr_get (myid, "ack_service_time", &ack_service_time);

op_ima_sim_attr_get (OPC_IMA_INTEGER, "number_of_nodes", &number_of_nodes);

ppid = op_topo_parent (myid);
op_ima_obj_attr_get (ppid, "name", name);

/* Verify the address. */
if (my_address > number_of_nodes)
	{
	op_sim_end ("err: appl process: address > number of nodes", "", "", "");
	/* The rest of the block will not be executed */
	}

Details

This KP terminates a simulation before its nominal duration has elapsed (as determined by the duration environment attribute). Because the simulation is ended, end-simulation interrupts are delivered to all other processors and queues that have the endsim intrpt attribute enabled. (The module that invoked this KP does not receive an end-simulation interrupt.)

When running a simulation from the graphical environment, only the first three of the four specified lines will be displayed in the message window, although all lines will be visible in the output that is simultaneously directed to the shell and the DES log.

Purpose

Provides a mechanism to conditionally terminate a simulation in a controlled manner, based on the dynamic status of the process(es) which can invoke this KP. This KP is most often used in two circumstances:

  • An abnormal error condition is trapped by simulation logic, making further simulation advancement unnecessary
  • A stopping condition is noticed by simulation logic, based on statistical convergence or other metrics of simulation completion status.

In either of these circumstances, it is usually important that the simulation end in a controlled manner, so that the vector and scalar output files which the simulation has been writing to are properly completed and closed.

Errors

  • Program Abort: Segmentation violation. (due to invalid or malformed message strings)

Reference

本站文档由 北京智网畅联科技有限公司 整理、翻译并提供 · Documentation compiled and provided by Beijing ZNetLink Technology Co., Ltd.

交流群 · QQ Group:OPNET/智网妙算网络仿真交流群(群号 486383494)

原文档 © 2017 Riverbed Technology · 本站为公益翻译,由 AI 辅助完成,请仔细甄别

Original documentation © 2017 Riverbed Technology. Community translation, AI-assisted. Contact: jiazequn@znetlink.com