Class: Bits

Bits

Class for accessing multiple bits from a parent object as a number. Bits may be defined as a signed or unsigned number in the memory map.

NOTE: This is only for attributes that aren't 8, 16, or 32 bits in size, which are better accessed using Number.

For example, if bits 5-7 of a byte are to be extracted into a distinct value, this class could be used.

Members


<readonly> numBits :number

Gets the number of bits used by this attribute.

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

value :number

Gets/sets the value of the bits. cip.CIPVar#readOnly must be false in order to be able to write to this property.

Also accessible using the shorter named property 'v'.

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

Methods


clear(val)

Clears the bits selected by val, the other bits remain unchanged. Same as value &= ~val. Can be connected to a signal.

Parameters:
Name Type Description
val number

The bits to clear.

Since:
  • 1.3 (WAT 1.4)

set(val)

Sets the bits selected by val, the other bits remain unchanged. Same as value |= val. Can be connected to a signal.

Parameters:
Name Type Description
val number

The bits to set.

Since:
  • 1.3 (WAT 1.4)

setValue(val)

Sets the value of the Bits. Same as writting to value, but can also be connected to a signal from another object.

Parameters:
Name Type Description
val number

The new value.

Since:
  • 1.3 (WAT 1.4)

toggle(val)

Toggles the bits selected by val. Same as value ^= val. Can be connected to a signal.

Parameters:
Name Type Description
val number

The bits to toggle.

Since:
  • 1.3 (WAT 1.4)

Events


valueChanged

Fires when the value changes as a result of a field bus update.

Parameters:
Name Type Description
newValue number

The new value of the bits

Since:
  • 1.0 (WAT 1.0)