op_sim_anim()
Abstract
Determines if the simulation is currently in animation mode.
Syntax
op_sim_anim ()
| Argument | Type | Description |
|---|---|---|
| no arguments |
Return Type
Boolean
Boolean value indicating if the simulation is configured to generate animation requests. This value is OPC_TRUE if animation is enabled, OPC_FALSE otherwise.
Example
/* If animation is not currently enabled, avoid doing unnecessary work. */
if (op_sim_anim ())
{
/* Open a full-size animation viewer. */
vid = op_anim_viewer_open_std ("Network Display", OPC_ANIM_LOCATION_FULL);
/* Load and draw a network model into viewer. */
op_anim_ime_nmod_draw (vid, OPC_ANIM_MODTYPE_NETWORK, "anet", "top",
OPC_ANIM_MOD_OPTION_NONE, OPC_ANIM_DEFPROPS);
/* Determine the name of the "animation" node. */
mod_objid = op_id_self ();
node_objid = op_topo_parent (mod_objid);
op_ima_obj_attr_get (node_objid, "name", node_name);
/* Change the icon of the "animation" node so that it is not seen. */
op_anim_ime_nobj_update (vid, OPC_ANIM_OBJTYPE_NODE, node_name,
OPC_ANIM_OBJ_ATTR_ICON, "blank", OPC_EOL);
}
Details
A simulation is in animation mode when it is executed with the anim_hist or anim_view environment attributes set to enable the generation of animation requests. The use of these attributes to enable simulations is illustrated in the following example command lines:
%example.sim -anim_hist my_anim
%example.sim -anim_view
If the generation of animation events is halted due to an error (e.g., the inability to communicate with the animation server), op_sim_anim() will return OPC_FALSE to indicate that animation is no longer active.
Purpose
This KP provides the capability to develop process models that have inherent animation capability while maintaining efficiency of the simulation. The intended use of the KP is to prevent Anim package calls and other animation-related computations from being carried out if animation is not currently active. Typically animation-related computations and calls will be grouped together in an if statement whose condition is (op_sim_anim() == OPC_TRUE).
By using this capability the user can develop models that provide built-in animation, but run near maximum efficiency when animation is not desired. No recompilation is necessary to switch between the two modes.
Errors
- No errors are trapped.
Reference
- Use the KP op_ima_sim_attr_get() to obtain the value of an arbitrary environment attribute
- Use the KP op_sim_debug() to determine if a simulation is in debug mode