EMA Base Objects

A base set of objects is defined in the Ema package to support more complex objects. These base objects are described below and are used by the Riverbed analysis software objects described in following topics.

Symbol Object

The symbol object represents the mapping of a value to a symbolic name. Symbol object IDs are used by the symbol map list attribute of the properties object.

Table 6: Symbol Object Attributes

Name Type Default
symbol string (empty)
value poly¹

Note 1: value type determined at run time

Properties Object

When a user-defined attribute is added to a model or object, the object identifier of a properties object is a required argument. The properties object (listed in the following table) contains information about the added attribute’s name, type, symbol map, and other properties.

Table 7: Properties Object Attributes

Name Type Default
public name string (empty)
units string (empty)
default value poly¹
comments textlist
high limit double
low limit double
symbol map list array of object IDs²
flags integer³
data type integer⁴
count properties object ID⁵
handler library string⁶ (empty)
click handler string⁶ (empty)
confirm handler string⁶ (empty)
new value handler string⁶ (empty)
display handler string⁶ (empty)
list attribute definitions array of object IDs⁷

Note 1: value type determined at run time and must correspond to the type specified by the data type attribute Note 2: object IDs of symbol objects Note 3: valid types are described in Table 152 Properties Object Flags Symbolic Constants Note 4: valid types are EMAC_INTEGER, EMAC_DOUBLE, EMAC_STRING, EMAC_TOGGLE, EMAC_TOGGLE_DOUBLE, EMAC_COMPOUND, or EMAC_DATAFILE Note 5: object ID of properties object (only if data type is EMAC_COMPOUND) defining the properties of the count attribute of a compound object Note 6: These attributes indicate custom event-handler routines to override the standard interface for setting object attributes; see “Active Attributes“ on page 51 for more information. Note 7: object IDs of attribute definition objects of sub-objects (only if data type is EMAC_COMPOUND) defining the properties of each attribute of a compound object’s sub-object

Attribute Definition Object

An attribute definition maps an attribute name to its properties. Attribute definitions are used in the properties object to define the properties of a compound attribute’s sub-object attributes. In that context, the properties of each sub-object of a compound attribute contain a list of attribute definition objects. Each attribute definition object provides an attribute name, group, and its corresponding properties.

Table 8: Attribute Definition Object Attributes

Name Type Default
name string (empty)
group string (empty)
properties object ID¹

Note 1: object ID of properties object

Compound Value Object

When an attribute has a type EMAC_COMPOUND, its value is the object ID of a compound value object. The compound value object contains two attributes. The list attribute is an array of object IDs, where each ID identifies a compound object (described below) that is a sub-object of the compound value. The count attribute specifies explicitly how many compound objects are part of the compound value.

Table 9: Compound Value Object Attributes

Name Type Default
count integer
list array of object IDs¹ (empty)

Note 1: object IDs of compound objects

Compound Object

Compound objects are objects which contain no initial attributes. All of the attributes in compound objects are explicitly added with calls to the Ema_Object_Prom_Attr_Set() function. Compound objects represent the sub-objects of compound attribute value objects.

Examples of Compound Value Object Usage

This section provides an example (through C code fragments) of how EMA functions are used to construct EMA compound value objects. The compound attribute structure shown in the figure below will be constructed through EMA.

Figure 9: Compound Value Object

Compound value object

The first step in specifying a compound value object is allocating the object itself:

comp_val_objid = Ema_Object_Create (model_id, OBJ_ATTR_COMP_VALUE);

Next, the individual compound objects, or sub-objects, need to be allocated and set:

subobject0_objid = Ema_Object_Create (model_id, OBJ_ATTR_COMP_OBJ);
subobject1_objid = Ema_Object_Create (model_id, OBJ_ATTR_COMP_OBJ);

Each sub-object next gets the attributes that it needs added on. This is a two-step process, however, because new attributes added to an object require a properties object. Therefore, properties objects are created first:

attr0_props_objid = Ema_Object_Create (model_id, OBJ_ATTR_PROPS);
attr1_props_objid = Ema_Object_Create (model_id, OBJ_ATTR_PROPS);

The properties objects need to have values for their attributes specified:

prg_lptr = prg_list_create ();
Ema_Object_Attr_Set (model_id, attr0_props_objid,
	"units",								COMP_CONTENTS, 					"",
	"default value",								COMP_CONTENTS_TYPE,					EMAC_DOUBLE,
	"default value",								COMP_CONTENTS,					(double) 0,
	"comments",								COMP_CONTENTS,					prg_lptr,
	"high limit",								COMP_CONTENTS,					0.0,
	"low limit",								COMP_CONTENTS,					0.0,
	"symbol map list",								COMP_INTENDED,					EMAC_DISABLED,
	"flags",								COMP_CONTENTS,					EMAC_DEFC_AUTOASSIGN,
	"data type",								COMP_CONTENTS,					1,
	"count properties",								COMP_INTENDED,					EMAC_DISABLED,
	"list attribute definitions",								COMP_INTENDED,					EMAC_DISABLED,
	EMAC_EOL);

(A similar call for attr1_props_objid is not shown here.)

Next, with the properties of sub-object attributes ready, the attributes are added to each sub-object:

Ema_Object_Prom_Attr_Set (model_id, subobject0_objid, "attr0", attr0_props_objid);
Ema_Object_Prom_Attr_Set (model_id, subobject0_objid, "attr1", attr1_props_objid);
Ema_Object_Prom_Attr_Set (model_id, subobject1_objid, "attr0", attr0_props_objid);
Ema_Object_Prom_Attr_Set (model_id, subobject1_objid, "attr1", attr1_props_objid);

Values for the attributes on the sub-objects can now be provided:

Ema_Object_Attr_Set (model_id, subobject0_objid,
	"attr0", COMP_CONTENTS, 1.0,
	"attr1", COMP_CONTENTS, 2.2,
	EMAC_EOL);
Ema_Object_Attr_Set (model_id, subobject1_objid,
	"attr0", COMP_CONTENTS, 11.0,
	"attr1", COMP_CONTENTS, 12.2,
	EMAC_EOL);

Finally, the compound value object’s list and count attributes are set to include the sub-objects that have been created and defined:

Ema_Object_Attr_Set (model_id, comp_val_objid,
	"count",			COMP_CONTENTS,						2,
	"list",			COMP_ARRAY_CONTENTS(0),						subobject0_objid,
	"list",			COMP_ARRAY_CONTENTS(1),						subobject1_objid,
	EMAC_EOL);

Working with Symbol Maps

Building upon the previous example, symbol objects are introduced and used in setting a sub-object’s attribute value. In the following example, a symbol object will be created mapping the string “One” to the value 1.0. The properties object corresponding to attr0 is then modified to include the symbol object in its symbol map. Finally, the symbol is set as a value within subobject1.

First, the symbol object is created:

symbol_objid = Ema_Object_Create (model_id, OBJ_ATTR_SYMMAP);

The mapping from “One” to 1.0 is specified in the symbol object’s attributes:

Ema_Object_Attr_Set (model_id, symbol_objid,
	"symbol",			COMP_CONTENTS,						"One",
	"value",			COMP_CONTENTS_TYPE,						EMAC_DOUBLE,
	"value",			COMP_CONTENTS,						1.0,
	EMAC_EOL);

In the preceding code, note that, because the value attribute of a symbol object is of type poly, COMP_CONTENTS_TYPE is used to make the type of the value actually being set on the attribute explicit.

The properties object for attr0 is modified to include the symbol object:

Ema_Object_Attr_Set (model_id, attr0_props_objid,
	"symbol map list",					COMP_ARRAY_CONTENTS(0),						symbol_objid,
	EMAC_EOL);

Finally, the value of attr0 of subobject1 is set to a symbolic value. The code pertaining to the creation of the compound value object did not have to be modified:

Ema_Object_Attr_Set (model_id, subobject1_objid,
	"attr0",			COMP_CONTENTS_SYMBOL,						"One",
	EMAC_EOL);

本站文档由 北京智网畅联科技有限公司 整理、翻译并提供 · 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