Class: Tag

Tag

Provides methods for interacting with a single tag on an IO-Link sensor/actuator device. A tag represents all of the IO-Link data of a specific type (process data) or of a specific index and subindex (parameter data). A tag corresponds to a single "inputdata", "outputdata" or "parameterdata" element in the XML memory map file.

The tag can be read using read, or written using write.

If the value of a tag changes at the IO-Link device, the change will not be automatically sent. Instead, read must be called periodically, if it must be kept up to date. autoRead is available to make this easier.

Similarly, changes made to tags on the JavaScript client will not be written to the IO-Link device until write is called. autoWrite is available to simplify this.

Members


autoRead :int

Gets/sets the number of milliseconds between automatic reads of the tag.

Because changes are not automatically pushed from the IO-Link device to the JavaScipt client, read must be called periodically to keep the value of a tag in sync with the device. When this value is greater than 0, read will be called automatically using the specified interval.

Set to 0 to disable automatic reads.

Type:
  • int
Since:
  • 0.1 (WAT 2.4)
Default Value:
  • 0

autoWrite :bool

Gets/sets if automatic writing is enabled.

When automatic writing is enabled, every time the value of the tag (or the value of a property when the tag is a UDT) changes, the changed value will be written to the IO-Link device. If the changed value is a property of a UDT, the entire UDT will be written. This can be convenient when the application does not want to manage calls to write. However, if many properties change at once, or if a property value changes rapidly, this will result in many small write commands to the device which can be inefficient. In this case, the application should decide when and what is appropriate to write.

Type:
  • bool
Since:
  • 0.1 (WAT 2.4)
Default Value:
  • false

<readonly> data :cip.CIPVar

Gets a cip object that represent the value of the tag.

If the tag is a UDT type, this object will be a cip.UDT, and the properties will be available as children. If the tag is a primitive type, this object will be the corresponding cip type (e.g. cip.Number), where the value is typically accessible via the value property (e.g. cip.Number#value).

Type:
Since:
  • 0.1 (WAT 2.4)

<readonly> error :string

Gets a description of the last error that occurred.

Errors may occur during automatic or explicit reads/writes. errorChanged will be emitted whenever an error occurs, and the string is different from the previous error. Because this property only holds the value of the last error, it is typically only used during debugging, or in conjunction with errorChanged, which is often more useful.

Type:
  • string
Since:
  • 0.1 (WAT 2.4)

<readonly> obj :object

Gets an object representation of the tag. This must be used in WSAPI applications, in order to access the other members, methods and events of the tag (except for data).

Type:
  • object
Since:
  • 0.1 (WAT 2.4)
Example
// standard JavaScript application
device.inputData.read();
device.outputData.write();
var countValue = device.inputData.data.CountValue.v;
device.parameterData.VendorName.readSuccess.connect(onVendorNameReadSuccess);
device.parameterData.VendorName.read();
var vendorName = device.parameterData.VendorName.data.HoldingRegister1.v;

// equivalent WSAPI application
device.map.inputData.obj.read();
device.map.outputData.obj.write();
var countValue = device.map.inputData.data.CountValue.v;
device.map.parameterData.VendorName.obj.readSuccess.connect(onVendorNameReadSuccess);
device.map.parameterData.VendorName.obj.read();
var vendorName = device.map.parameterData.VendorName.data.HoldingRegister1.v;

Methods


read()

Reads the value of the entire tag

If it is desired to keep a tag value up to date with the value on the IO-Link device, this method must be called periodically. Alternatively, autoRead can be used.

When called (automatically or explicitly), either readSuccess or readFailure will be emitted to indicate that the read is complete.

Since:
  • 0.1 (WAT 2.4)
Example
device.inputData.read();
device.parameterData.VendorName.read();

write()

Writes the value of the entire tag

After a property has been locally changed, it must be written back to the IO-Link device using this function if it is desired to update the device. Alternatively, autoWrite can be used.

When called (automatically or explicitly), either writeSuccess or writeFailure will be emitted to indicate that the write is complete.

Since:
  • 0.1 (WAT 2.4)
Example
device.outputData.write();
device.parameterData.DebounceTime.write();

Events


autoReadChanged

Emitted when the automatic read time changes. See autoRead for more details.

Parameters:
Name Type Description
ms int

The number of milliseconds between automatic reads

Since:
  • 0.1 (WAT 2.4)

autoWriteChanged

Emitted when the automatic write flag changes. See autoWrite for more details.

Parameters:
Name Type Description
enabled bool

Whether automatic writing is enabled

Since:
  • 0.1 (WAT 2.4)

errorChanged

Emitted when an error occurs. See error for more details.

Parameters:
Name Type Description
description string

The error that occurred

Since:
  • 0.1 (WAT 2.4)

readFailure

Emitted after a failed read.

Parameters:
Name Type Description
description string

The error that occurred

Since:
  • 0.1 (WAT 2.4)

readSuccess

Emitted after a successful read.

Since:
  • 0.1 (WAT 2.4)

writeFailure

Emitted after a failed write.

Parameters:
Name Type Description
description string

The error that occurred

Since:
  • 0.1 (WAT 2.4)

writeSuccess

Emitted after a successful write.

Since:
  • 0.1 (WAT 2.4)