Mixin: CIPVar

CIPVar

Base class for accessing an attribute or group of attributes (for example, through specialization UDT).

Members


<readonly> attributes :Array.<cip.CIPVar>

Gets the attributes that are children of this attribute in an array.

Type:
Since:
  • 1.6 (WAT 2.2)

<readonly> lastUpdate :number

Gets the number of milliseconds since the last time that this attribute was changed. Writes to the attribute that do not change the value do not count.

This can be used to ensure that a memory map is current. For example, an application could change state to 'offline' if a heartbeat attribute has not changed for 10 seconds. This attribute also applies to UDT types, so it can be used to determine how long since the last update to any part of a class.

Type:
  • number
Since:
  • 1.3 (WAT 1.3)

<readonly> name :string

Gets the name of the attribute, as defined in the memory map.

Type:
  • string
Since:
  • 1.0 (WAT 1.0)

<readonly> readOnly :bool

Gets whether the attribute is read only.

NOTE: An attribute may be read only even if is it not explicitly defined as such in the memory map if the attribute is a member of a read only map (such as the EtherNet/IP output assembly).

Type:
  • bool
Since:
  • 1.0 (WAT 1.0)

<readonly> size :number

Gets the size of the attribute in bytes.

NOTE: An attribute may actually take up more room in the memory map than the size in order to maintain alignment of the following attributes.

Type:
  • number
Since:
  • 1.0 (WAT 1.0)

<readonly> type :string

Gets a string describing the type of the attribute.

Type:
  • string
Since:
  • 1.0 (WAT 1.0)

Methods


attribute(num)

Gets a child attribute of this attribute, if defined by the memory map. The order of child attributes follows the order that they are defined in the memory map. The first child is number 1.

This method may also be accessed using the short name 'a' instead of the full name 'attribute'.

This method is useful when using the class/instance/attribute methodology common in CIP.

Parameters:
Name Type Description
num number

The index of the attribute to get, starts at 1

Since:
  • 1.0 (WAT 1.0)
Returns:
Type
cip.CIPVar

attribute(name)

Like attribute(num), but looks up the object by name. This is useful if a property name collides with a built-in name. For example, if a UDT has an attribute called 'type', it will be hidden by the built-in property of the same name. To access the UDT attribute instead, use attribute("type").

If a direct attribute with the name supplied is not found, nested attributes will be then searched. This technique can be useful during debugging, however it is not recommended in final code since name collisions can create confusing results and may even change behaviour in future firmware releases.

If there are multiple direct attributes with the same name, only one will be returned, but which one is undefined.

This method may also be accessed using the short name 'a' instead of the full name 'attribute'.

Parameters:
Name Type Description
name string

The name of the attribute to get

Since:
  • 1.6 (WAT 2.2)
Returns:
Type
cip.CIPVar