op_anim_mgp_arop()

Abstract

Adds a primitive to the specified macro that performs an arithmetic computation using the specified operand and result registers.

Syntax

op_anim_mgp_arop (anmid, opa_regid, operator, opb_regid, res_regid)
Argument Type Description
anmid Anmid macro ID
[This value is a numeric identifier which references an open animation macro, created via the KP op_anim_macro_create().]
opa_regid int macro drawing register ID for operand A
operator int arithmetic operator code
opb_regid int macro drawing register ID for operand B
res_regid int macro drawing register ID for operation result

Return Type

void

no return value

Example

/** Construct a macro which depicts a field within a packet. **/
mid = op_anim_macro_create ("pk field");

/* Draw a rectangle fixed at (X,Y) which has width(W) = no. bits(B) x 8 */
op_anim_mgp_reg_set (mid, OPC_ANIM_REG_C_INT, 8);
op_anim_mgp_arop (mid, OPC_ANIM_REG_B_INT, OPC_ANIM_AROP_MULTIPLY,
	OPC_ANIM_REG_C_INT, OPC_ANIM_REG_W_INT);
op_anim_mgp_rect_draw (mid, OPC_ANIM_COLOR_RED, OPC_ANIM_REG_X_INT,
	OPC_ANIM_REG_Y_INT, OPC_ANIM_REG_W_INT, 15);

/* Draw the field name at (L,Y) where L = X + (W / 2) */
op_anim_mgp_reg_set (mid, OPC_ANIM_REG_C_INT, 2);
op_anim_mgp_arop (mid, OPC_ANIM_REG_W_INT, OPC_ANIM_AROP_DIVIDE, OPC_ANIM_REG_C_INT,
	OPC_ANIM_REG_H_INT);
op_anim_mgp_arop (mid, OPC_ANIM_REG_X_INT, OPC_ANIM_AROP_ADD, OPC_ANIM_REG_H_INT,
	OPC_ANIM_REG_L_INT);
op_anim_mgp_text_draw (mid, OPC_ANIM_ALIGNH_CENTER | OPC_ANIM_ALIGNV_BOTTOM |
	OPC_ANIM_FONT_OPEN_10 | OPC_ANIM_COLOR_RED,
	OPC_ANIM_REG_L_INT, OPC_ANIM_REG_Y_INT, OPC_ANIM_REG_S_STR);

op_anim_macro_close (mid);

Details

The opa_regid, opb_regid, and res_regid arguments of this KP will accept macro register ID symbolic constants, as listed under “Animation Macro Register Identifier Symbolic Constants—Integer Values“ on page 8. The values of the registers specified by opa_regid and opb_regid are used as inputs to a computation (specified by the value of the operator argument), and the result is stored in the register specified by res_regid, as shown below:

<result> = <reg A> <op> <reg B>

where <op> is one of the arithmetic operators (add, subtract, multiply, divide), as represented by a symbolic constant OPC_ANIM_AROP_<op>, where <op> is ADD, SUBTRACT, MULTIPLY, or DIVIDE. The operator argument of this KP accepts only these arithmetic operator constants, and does not support drawing register references.

All registers specified for this KP must be numeric (i.e., either integer or double registers). The result of the operation is converted to the data type of the result register. If the operands are of the same data type, the operation is performed using that data type. If the operand data types are mixed, the integer operand is converted to a double, and the operation is performed using double values.

Purpose

Provides a mechanism for performing an arithmetic operation involving registers within the context of a macro. This is typically used to compute graphical offsets and positions based on macro input parameters stored in registers.

Errors

  • Recoverable Error: Animation macro ID (<anmid>) is [out-of-range] [unrecognized]. (former case due to anmid argument value that is invalid, latter case to destroyed macro)
  • Diagnostic Error: Animation operator code (<operator>) is out-of-range. (due to an invalid value for the operator argument)
  • Diagnostic Error: Animation macro register ID (<regid>) is out-of-range. (due to an invalid value for the opa_regid, opb_regid, or res_regid arguments)

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