Class: ToyopucGroup

ToyopucGroup

Provides access to a group of Toyopuc registers.

Members


autoRead :number

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

Because changes are not automatically pushed from the server to the client, read must be called periodically to keep the values in sync with the server. When this value is greater than 0, read will be called automatically using the specified interval.

Set to 0 to disable automatic reads.

Type:
  • number
Since:
  • 1.0 (WAT 2.3)
Default Value:
  • 0

autoWrite :bool

Gets/sets if automatic writing is enabled.

When automatic writing is enabled, every time the value of a register in the group changes, the changed value will be written to the server. 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 server which can be inefficient. In this case, the application should decide when and what is appropriate to write.

Type:
  • bool
Since:
  • 1.0 (WAT 2.3)
Default Value:
  • false

<readonly> regs :object

Gets an object that contains the registers specified when calling createGroup.

Children of this object will have user-defined names (according to the parameters passed to createGroup), and will be of type ToyopucRegister.

Type:
  • object
Since:
  • 1.0 (WAT 2.3)

Methods


read()

Reads the value of all registers in the group.

If it is desired to keep register values up to date with the values on the PLC, this method must be called periodically. Alternatively, toyopuc.ToyopucRegister#read can be used to read a single value or toyopuc.ToyopucGroup#autoRead can be used to call this automatically.

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

Since:
  • 1.0 (WAT 2.3)
Returns:

When true, indicates that a read request was started

Type
bool

write()

Writes the value of all registers in the group.

After one or more registers has been locally changed, all registers can be written to the PLC at once using this function. Alternatively, toyopuc.ToyopucRegister#write can be used to write a single register value.

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

Since:
  • 1.0 (WAT 2.3)
Returns:

When true, indicates that a write request was started

Type
bool

Events


error

Emitted when an error occurs when attempting a read or write operation.

Parameters:
Name Type Description
error string

A string describing the error that occurred.

Since:
  • 1.0 (WAT 2.3)

readFailure

Emitted after a failed read.

Parameters:
Name Type Description
description string

The error that occurred

Since:
  • 1.0 (WAT 2.3)

readSuccess

Emitted after a successful read.

Since:
  • 1.0 (WAT 2.3)

writeFailure

Emitted after a failed write.

Parameters:
Name Type Description
description string

The error that occurred

Since:
  • 1.0 (WAT 2.3)

writeSuccess

Emitted after a successful write.

Since:
  • 1.0 (WAT 2.3)