This object is the base JavaScript interface for all CommandFusion Pluggable Modules. Each module can have various sets of ports, the exact set of which is configured for each instance at the time the object is created or discovered on the network.

Do not instantiate this object directly. Devices supporting modules (DIN-MOD4 and MOD4) automatically create the interfaces according to the modules physically inserted in the slots.
Members

<static> COMPORT_CONFIGURATION_CHANGE :String

Event fired when a module's COM ports configuration changes. This event is fired after each individual IO port's CFLink.RS232Port.CONFIGURATION_CHANGE event is fired, to allow your code to perform any necessary global update (i.e. GUI update) Your callback should be of the form: function(event, device, module) event is this event device is the device object containing the COM module (typically a MOD4 or DINMOD4 device) module is the COM module object

<static> IO_CONFIGURATION_CHANGE :String

Event fired when a module's global configuration changes (one of the enabled, reportOnChange, reportInterval flags is updated). Your callback should be of the form: function(event, device, module) event is this event device is the device object containing the I/O module (typically a MOD4 or DINMOD4 device) module is the I/O module object

<static> IOPORT_CONFIGURATION_CHANGE :String

Event fired when a module's ports configuration changes. This event is fired after each individual IO port's CFLink.IOPort.CONFIGURATION_CHANGE event is fired, to allow your code to perform any necessary global update (i.e. GUI update) Your callback should be of the form: function(event, device, module) event is this event device is the device object containing the I/O module (typically a MOD4 or DINMOD4 device) module is the I/O module object
Methods
configureCOMPort ( index , mode , baud , dataBits , parity , stopBits , flowControl )
Parameters:
Name Description
index the COM port index, between 1 and the number of COM ports in the module
mode the mode to set (see CFLink.RS232Port.Valid.Modes or CFLink.RS232Port.Valid.Modes_COM)
baud the port speed to set (see CFLink.RS232Port.Valid.Bauds)
dataBits the number of data bits (7 or 8)
parity the parity ("N" for none, "E" for even, "O" for odd)
stopBits the number of stop bits (1 or 2)
flowControl whether to apply flow control (true or false and 1 or 0 accepted)
Configure one of the module's COM ports, if the module is a COM module
configureIOPort ( index , mode , minChange )
Parameters:
Name Type Description
index Number, Array the I/O port index (starts at 1, limited to the number of I/O ports in the module) or an array of I/O port indices
mode CFLink.IOPort.Mode the I/O port mode
minChange Number the minimum change value for I/O ports that are set to. Meaningful for CFLink.IOPort.Mode.RESISTANCE_READING, {@link CFLink.IOPort.Mode.
Configure an I/O port to set its operating mode, as well as minimum change value and power-on state (when applicable, depends on the chosen mode). Note that the command is being sent to the device, but the known values of the JavaScript representation of the port will stay the same until we receive the acknowledge from the device.

You can pass a single port number, or an array of port numbers to configure multiple ports at once with the same settings
configureRelay ( index , powerOnState )
Parameters:
Name Type Description
index Number, Array the relay index (starts at 1, limited to the number of relays in the module) or an array of relay indices
powerOnState pass 1 for the relay to be in closed state at power-on. Pass 0 for the relay to be in open state at power-on.
Set the power-on state of a relay (the state the relay should be in at power-on).

You can pass a single port number, or an array of port numbers to configure multiple relays at once
pulseRelayState ( index , duration )
Parameters:
Name Type Description
index Number, Array the relay index (starts at 1, limited to the number of relays in the module) or an array of relay indices
duration Number the duration. An integer that represent a number of 1/10s. For example, the value 10 represents 1 second.
Pulse a relay for the specified duration. A pulse will close the relay, then open it again after the specified duration. Duration is in 1/10s units.

You can pass a single port number, or an array of port numbers to pulse multiple relays at once
send ( commandType , command , payload )
Parameters:
Name Type Description
commandType String the command type (i.e. "Q", "T", "C", etc)
command String the command (i.e. "SET")
payload String the actual payload of the CFLink packet
Send a CFLink packet to the CFLink module this object represents
sendCOMData ( index , data )
Parameters:
Name Description
index the COM port index, between 1 and the number of COM ports in the module
data the data to send. Data is being sent verbatim. You can pass a string, or an array of character codes (if you pass an array, the software assumes these are character codes, and will turn each code into a byte)
Send data to a COM port
setIOPortValue ( index , value )
Parameters:
Name Type Description
index Number, Array the I/O port index (starts at 1, limited to the number of I/O ports in the module) or an array of I/O port indices
value Number the new value of the output port (0 or 1)
For IO ports configured as external relay control output or LED output, set the value (0 = open for relays, off for LEDs - 1 = closed for relays, on for LEDs)

You can pass a single port number, or an array of port numbers to set the value of multiple I/O ports at once.
setRelayState ( index , on )
Parameters:
Name Type Description
index Number, Array the relay index (starts at 1, limited to the number of relays in the module) or an array of relay indices
on Number, Boolean Pass 1 or true to close the relay, 0 or false to open it
Set the state of a relay. Note that if you are in the middle of a relay pulse for this relay, the pulse is cancelled and the relay state is updated immediately.

You can pass a single port number, or an array of port numbers to open or close multiple relays at once
toggleIOPortValue ( index )
Parameters:
Name Type Description
index Number, Array the I/O port index (starts at 1, limited to the number of I/O ports in the module) or an array of I/O port indices
For IO ports configured as external relay control output or LED output, toggle the value (0 = open for relays, off for LEDs - 1 = closed for relays, on for LEDs)

You can pass a single port number, or an array of port numbers to toggle the value of multiple I/O ports at once.
toggleRelayState ( index )
Parameters:
Name Type Description
index Number, Array the relay index (starts at 1, limited to the number of relays in the module) or an array of relay indices
Toggle the state of a relay (open if closed, close if opened). Note that if you are in the middle of a relay pulse for this relay, the pulse is cancelled and the relay state is updated immediately.

You can pass a single port number, or an array of port numbers to toggle multiple relays at once
unwatch ( watcherID )
Parameters:
Name Type Description
watcherID Number the watcher ID that was returned by CFLink.Module.watchIOPorts, CFLink.Module.watchRelays or CFLink.Module.watchCOMPorts
Stop watching the changes you asked to be notified for in CFLink.Module.watchIOPorts, CFLink.Module.watchRelays and CFLink.Module.watchCOMPorts. You could as well call CFLink.unwatch which does the same thing.
watchCOMPorts ( portNumbers , callback , me )
Parameters:
Name Type Description
portNumbers Array an array of the COM port numbers to watch (COM ports are numbered from 1 to 8 for the IO8 module). Pass `null' to watch all COM ports
callback Function your callback function, of the form myCallback(deviceObject, moduleObject, portNumber, data)
me Object the object to set as `this' when calling your callback function
Returns
a watcherID you can use to unwatch with CFLink.Module.unwatch or CFLink.unwatch
Type
Number
Setup a callback function that will be called whenever data is received on the specified ports (assuming the module is a COM module). Your callback can monitor one, several or all COM ports of the module. Having multiple callback monitoring the same COM ports is allowed. If you don't specify the port numbers (pass null or an empty array), by default you will be called for data received on all COM ports. Your callback function should be of the form: myCallback(deviceObject, moduleObject, portNumber, data) Where `deviceObject' is the CFLink.Device device object (typically, a CFLink.DINMOD4 object), `moduleObject' is the CFLink.Module object representing the module plugged in the device, `portNumber' is the COM port number that received data, and `data' is the received data (a String that may contain binary characters, as all received data is passed verbatim to you).
watchIOPorts ( portNumbers , callback , me )
Parameters:
Name Type Description
portNumbers Array an array of the I/O port numbers to watch (relays are numbered from 1 to 4). Pass `null' to watch all I/O ports
callback Function your callback function, of the form: myCallback(deviceObject, moduleObject, portNumber, previousValue, newValue)
me Object the object to set as `this' when calling your callback function
Returns
a watcherID you can use to unwatch with CFLink.Module.unwatch or CFLink.unwatch
Type
Number
Setup a callback function that is called when the state of the selected I/O port(s) change Your callback function should be of the form: myCallback(deviceObject, moduleObject, portNumber, previousValue, newValue) Where `deviceObject' is the CFLink.Device device object (typically, a CFLink.DINMOD4 object), `moduleObject' is the CFLink.Module object representing the module plugged in the device, `portNumber' is the I/O port number that changed value, `previousValue' is the previous value of this I/O port, and `newValue' is its new value. Note that when we get the initial value of the I/O port (at initialization time), the `previousValue' parameter will be -1.
watchRelays ( portNumbers , callback , me )
Parameters:
Name Type Description
portNumbers Array an array of the relay port numbers to watch (relays are numbered from 1 to 4). Pass `null' to watch all relays
callback Function your callback function, of the form: myCallback(deviceObject, moduleObject, portNumber, previousValue, newValue)
me Object the object to set as `this' when calling your callback function
Returns
a watcherID you can use to unwatch with CFLink.Module.unwatch or CFLink.unwatch
Type
Number
Setup a callback function that is called when the state of the selected Relay port(s) change This is a simple helper that watches the CFLink.IOPort.VALUE_CHANGE event and only calls you back when one of the Relay ports you want to watch changes state. Your callback function should be of the form: myCallback(deviceObject, moduleObject, portNumber, previousValue, newValue) Where `deviceObject' is the CFLink.Device device object (typically, a CFLink.DINMOD4 object), `moduleObject' is the CFLink.Module object representing the module plugged in the device, `portNumber' is the Relay port number that changed state, `previousValue' is the previous value of this Relay port (0 or 1), and `newValue' is its new value. Note that when we get the initial value of the relay (at initialization time), the `previousValue' parameter will be -1.