- Source:
- xcf/driver/DriverBase.js
Members
-
<inner> lineBreak :string
-
Type:
- string
- Default Value:
-
- \r
- Source:
- xcf/driver/DriverBase.js
-
<inner> options :object
-
The information about the device in this structure:
Type:
- object
- Source:
- xcf/driver/DriverBase.js
Example
{ driver:"Marantz/MyMarantz.js", host:"102.123.23.23" port:23, protocol:"tcp" scope:"system_drivers" } -
<inner> responseSettings :object
-
responseSettings contains the constants for receiving data from a device
its being set at initialization time and has this structure:Type:
- object
- Source:
- xcf/driver/DriverBase.js
Example
{ start:false, startString:'' cTypeByte:false, //construction type 'Per Byte' cTypePacket:false, //construction type 'Per Packet' cTypeDelimiter:true, //construction type 'Per Delimiter' cTypeCount:false, //construction type 'Per Count' delimiter:'', //the delimiter count:10 //packet count } -
<inner> sendSettings :object
-
sendSettings contains the constants for receiving and sending data to a device
its being set at initialization time and has this structure:Type:
- object
- Source:
- xcf/driver/DriverBase.js
Example
{ constants:{ end:'\r', start:'', }, send:{ interval:500, mode:true|false, //true=onReply | false=Interval onReply:'\n', timeout:500 } }
Methods
-
<inner> getLineBreak()
-
Deal with Javascript special characters, indexOf("\n") fails otherwise
- Source:
- xcf/driver/DriverBase.js
Returns:
- Type
- string
-
<inner> getLineBreakSend()
-
Deal with Javascript special characters, indexOf("\n") fails otherwise
- Source:
- xcf/driver/DriverBase.js
Returns:
- Type
- string
-
<inner> getVariable(title)
-
Return a variable's value
Parameters:
Name Type Description titlestring the name of the variable
- Source:
- xcf/driver/DriverBase.js
Returns:
the value of the variable
- Type
- string
-
<inner> log(level, type, message, data)
-
Method to add a logging message.
Parameters:
Name Type Description levelstring This can be error, warning, info, trace or custom
typestring An additional string, by default this is set to "Device"
messagestring The message it self
dataobject An optional object/data you want to include
- Source:
- xcf/driver/DriverBase.js
Example
// for instance you want to log any incoming message in a custom way, you need to overwrite 'sendMessage' in // your base class like this: onMessage: function (data) { this.log('info', 'my marantz', 'Marantz Driver Message: ' + data.message, { some: 'extra', message: data }); this.inherited(arguments); //important, call BaseDriver::onMessage! } -
<inner> onMessage(data)
-
Standard callback when we have a message from the device we're bound to (specified in profile).
- put the message in the incoming queue, tag it as 'unread'
- in case we have messages to send and we are in 'onReply' mode, trigger outgoing queue
Parameters:
Name Type Description dataObject : Message Struct build by the device manager
Properties
Name Type Description deviceObject : Device info
Properties
Name Type Description hostString : The host
portString : The host's port
protocolString : The host's protocol
messageString : RAW message, untreated
- Source:
- xcf/driver/DriverBase.js
Example
// for instance you might update the "Volume" Variable within onMessage: onMessage:function(data){ var value = data.message; var volume = 0; if (value.indexOf('MV') != -1 && value.indexOf('MVMAX') == -1) { var _volume = value.substring(2, value.length); _volume = parseInt(_volume.substring(0, 2)); if (!isNaN(_volume)) { this.setVariable('Volume', _volume); volume = _volume; } } // do something else with volume: this.log('info',null,'Did update volume to ' + volume); //important, call BaseDriver::onMessage! this.inherited(arguments); } -
<inner> prepareMessage(msg)
-
Surround command with 'start' and 'end' constant, specified in the command settings
of the driver.Parameters:
Name Type Description msg- Source:
- xcf/driver/DriverBase.js
Returns:
- Type
- * | string | String
-
<inner> sendMessage(msg, now, src, id)
-
Send message send a string to the device. Basing on the send settings this message will be queued or send
on reply.Parameters:
Name Type Description msgstring the string to send
nowstring force sending now!
srcstring the id of the source block
idstring the id of the send job
- Source:
- xcf/driver/DriverBase.js
-
<inner> setVariable(title, value)
-
Set a variable's value
Parameters:
Name Type Description titlestring the name of the variable
valuestring the new value
- Source:
- xcf/driver/DriverBase.js
-
<inner> split(str)
-
Splits a message string from the device server into an array of messages. Its using 'responseSettings'
Parameters:
Name Type Description str- Source:
- xcf/driver/DriverBase.js
Returns:
- Type
- Array.<string>
-
<inner> start()
-
Main entry when this instance is started
- Source:
- xcf/driver/DriverBase.js
Returns:
- Type
- boolean