wallcontrol10
v1.0.0
Published
Send WallControl 10 commands to wall controller and decode responses to JS values
Downloads
2
Maintainers
Readme
Introduction
wallcontrol10
is module for working with WallControll 10 command line interface over LAN-TCP. Decode responses from Wall Control 10 into JS values.
Main features
- connect over LAN-TCP
- execute native WallControl 10 commands
- decode responses into JS values
- command queue and time management
- events driven
- different schemas for connect-disconnect cycle
Usage
const WC10 = require('wallcontrol10');
//send-receive data using TCP socket
const dev = new WC10({host: '192.168.4.111'});
dev.emitter.on('responseFromDevice', data => console.log(data));
dev.process('wcmd -layouts'); //ask for layouts for default wall
dev.process('wcmd -layout="layout 1"'); //apply 'layout 1' for default wall
WC10cli Object
The primary exported object is WC10cli
. It uses RAW
object from raw-device
as its prototype.
Constructor new WC10cli(AddressObject, OptionsObject)
AddressObject <Object>
- required.name <string>
- default 'WC10'id <string>
- default 'blueprint'host <string>
- required. Use valid IP addressport <number>
- default 23
OptionsObject <Object>
- optional, default is{encoding: 'ASCII', duration: 1400, disconnect: true, splitter: {timeout: 1200}}
encoding <string>
- default 'ASCII'duration <number>
- default 1400 ms. Inter-command period [ms]. A time for device to process command and to prepare and send a response.disconnect <boolean|number>
- default true. Connecion cycle scheme. Use true, false or timeout[ms]. True means close connection when command queue is empty, false means do not close connection, number means close connection after some ms. of connection inactivity.splitter <Object>
Used to select one among three supported transform streams which merge incoming data chunks and split it into valid messages. Only single property from delimiter, regex, timeout can be used. Default is{timeout: 1200}
delimiter <string>
- use@serialport/parser-delimiter
with string delimiterregex <Regex>
- use@serialport/parser-regex
with regextimeout <number>
- use@serialport/parser-inter-byte-timeout
with timeout. Response is completed if inter-byte time is longer then timeout. Please consider that timeout must be shorter than duration (inter-command period) and disconnect time (if disconnect use timeout scheme)
Method process(...commands)
Encode and send commands to controler. Commands will be queued and executed FIFO. You can use multiple commands in single call. Commands must be native WallControl 10 CLI commands as described in WallControl 10 Help/Tools/Command Line Interface or WallControl 10 User Guide. The most commonly used commands are:
wcmd [-wall=wall_name] -layouts
- Get layout names for given wallwcmd [-wall=wall_name] -layout=layout_name
- Apply layout for wallwcmd [-wall=wall_name] -layout
- Get current layout name for given wallwcmd -inputs
- Get list of sourceswcmd [-wall=wall_name] -openwindows
- Get list of opened windows with their propertieswcmd -wallstate
- Get list of defined walls with their properties
Internal commands
There are some internal commands which start with #
. They are not sent to controller, but are processed by WC10cli object itself.
#pause duration
- Append additional pause between neighboring commands as number of miliseconds.
Event: responseFromDevice
Emited when response from controller is properly decoded.
response <Object>
dev <string>
- controler nameid <string>
- wall nameraw <string>
- not decoded responsestatus <string>
- response status. If command is executed OK, returned status is 'Success'value <string|[string]|Object>
- decoded response value. Returned type depends on request id (req).req <string>
- request id, used to identify response value. Currently following request are implemented:req:'layouts'
(available layouts), response forwcmd -layouts
commandreq:'layout'
(current layout), response for wcmd -layoutreq:'inputs'
(available inputs), response forwcmd -inputs
req:'providers'
(installed source providers), response forwcmd -providers
req:'windows'
(opened windows), response forwcmd -openwindows
req:'walls'
(available walls), response forwcmd -wallstate
req:'favourities'
(available favourities), response forwcmd -favourities
Event: commandForDevice
Emited when command is properly encoded and sent to controler. Of course only encoded
property is sent to controler itself.
command <Object>
name <string>
- device namecommand <string>
- a command itself, not parsed or encodedencodedstr <string>
- command encoded as stringencoded <Buffer>
- command encoded as Bufferduration <number>
- time [ms] for device to process the command.
Event: connectionData
A data which comes directly from controler port "as is". Not decoded, merged or chopped by splitter
data <Buffer>
Event: connectionStatus
Emited when device connection status changes.
statusObj <Object>
dev <string>
- device nameaddress <string>
- device address as stringstatus <string>
- connection statusmore <string|Object>
- additional status information