Class: DF1PCCCClient

DF1PCCCClient

Provides methods and properties for managing a DF1 connection using PCCC.


Fires:
Example
var df1 = $wat.load('df1')[0];
var ui = $wat.load('ui')[0];
var client = df1.createPCCCClient(ui.serials[0]);
client.settings.serial.baud = 19200;
client.settings.dstId = 1;
client.settings.fullDuplex = true;
client.settings.mmap =
'<?xml version="1.0" encoding="UTF-8"?>' +
'<watmmap version="1.0">' +
  '<types>' +
    '<udt name="Type1" size="4">' +
      '<u32 name="propertyToRead" index="0"/>' +
    '</udt>' +
    '<udt name="Type2" size="4">' +
      '<u32 name="propertyToWrite" index="0"/>' +
    '</udt>' +
  '</types>' +
  '<map>' +
    '<pccc>' +
      '<Type1 name="objectToRead" addr="N7:90"/>' +
      '<Type2 name="objectToWrite" addr="N7:100"/>' +
    '</pccc>' +
  '</map>' +
'</watmmap>';

if (!client.load()) console.error('Failed to load memory map');
else if (!client.open()) console.error('Failed to open DF1 serial port');
else client.opened.connect(function() {
  // objectToRead and objectToWrite are objects defined in the memory map
  // The properties of objectToRead and objectToWrite that are defined in the
  // memory map are accessible via the 'data' property
  client.pccc.objectToRead.data.propertyToRead.valueChanged.connect(function(value) {
    console.log('Property value changed to: ' + value);
  });
  client.pccc.objectToRead.read();

  client.pccc.objectToWrite.data.propertyToWrite = 1234;
  client.pccc.objectToWrite.write();
});

Members


connected :bool

Returns true while PCCC communications are successful

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

connected :bool

Returns true while DF1 communications are successful

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

enabled :bool

Gets/sets whether DF1 is enabled. When enabled, DF1 communications will attempt to be established with a remote server. If the server responds, objects in a loaded memory map can be read and/or written as required by the application.

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

<readonly> pccc :df1.PCCCMap

Gets an object that contains the PCCC memory map. Until load is called successfully, this object will have no properties.

Type:
  • df1.PCCCMap
Since:
  • 1.0 (WAT 2.2)

port :Object

The serial port to be used for communications

Type:
  • Object
Since:
  • 1.0 (WAT 2.2)

<readonly> settings :df1.DF1PCCCSettings

Gets an object that can be used to read and write the DF1 settings. The values in this object must be configured prior to enabling DF1.

Type:
Since:
  • 1.0 (WAT 2.2)
See:

Methods


close()

Stops DF1 communications.

Since:
  • 1.0 (WAT 2.2)

load()

Attempts to load the memory map specified in the settings. If successful, the resulting memory map will be available in pccc.

Since:
  • 1.0 (WAT 2.2)
Returns:

True if the memory map was successfully parsed.

Type
bool

open()

Attempts to start DF1 communications on the specified serial port.

Since:
  • 1.0 (WAT 2.2)
Returns:

True if the port was successfully opened (does not indicate if communications have been successfully established).

Type
bool

Events


closed

Indicates that DF1 communications have been terminated. connectedChanged may also be used.

Since:
  • 1.0 (WAT 2.2)

connectedChanged

Indicates the connection state of DF1 has changed.

Parameters:
Name Type Description
connectionState bool
Since:
  • 1.0 (WAT 2.2)

error

Emitted whenever a communications error is encountered.

Parameters:
Name Type Description
errorDescription string
Since:
  • 1.0 (WAT 2.2)

opened

Indicates that DF1 communications have been successfully established. connectedChanged may also be used.

This event can be used to show the status of the DF1 connection.

Since:
  • 1.0 (WAT 2.2)