Материал из for iRidium developers
Перейти к: навигация, поиск
Эта страница является переводом страницы Drivers API. Перевод выполнен на 99%.

Other languages:
English • ‎русский

API iRidium. Drivers

functions, methods and properties for work with equipment set up in the project: creation and control of drivers, sending commands, processing of the incoming data

Methods


IR object - it is a global object containing all iRidium API functions and constants. Methods of the IR object for drivers enable driver creation and reference to the driver in the iRidium project. Many methods are applied to the reference to the existing driver.

IR.CreateDevice

to create a driver based on "AV & Custom Systems" in iRidium project
Attention! The old syntax of this function supported by iRidium V3, but we do not recommend to use it

Syntax

IR.CreateDevice(type, name, {properties})

input value description
type IR.DEVICE_CUSTOM_TCP type: object
the driver type
name "AV Driver" type: string
the unique driver name
properties Host: "192.168.0.47", Port: 8080 type: string
list of properties separated by commas
output
Object [object DevicePrototype] type: Object
the reference to the driver


Sample

var driver = IR.CreateDevice(IR.DEVICE_CUSTOM_TCP, "AV Device (TCP)",	
			{Host: "192.168.0.47",
			Port: 80,
			SSL: false,
			SendMode: IR.ALWAYS_CONNECTED,
			ScriptMode: IR.DIRECT_AND_SCRIPT,
			SendCommandAttempts: 0,
			ConnectWaitTimeMax: 3000,
			ReceiveWaitTimeMax: 5000,
			Login: "admin",
			Password: "admin"
});
IR.Log(driver); // [object DevicePrototype]

the set of properties is different for different drivers
if you delete some parameter from the list of properties when create the driver, this parameter uses default value
if you want to create the driver later than application starts, you must call the method .Connect() to connect the driver to equipment. But when you create the driver at application start, the driver connects automatically. You can disconnect driver from equipment with .Disconnect() method


AV & Custom Systems parameters

AV & Custom Systems (TCP):

var driver = IR.CreateDevice(IR.DEVICE_CUSTOM_TCP, "AV Device (TCP)",	
			{Host: "192.168.0.47",
			Port: 80,
			SSL: false,
			SendMode: IR.ALWAYS_CONNECTED,
			ScriptMode: IR.DIRECT_AND_SCRIPT,
			SendCommandAttempts: 0,
			ConnectWaitTimeMax: 3000,
			ReceiveWaitTimeMax: 5000,
			Login: "",
			Password: "",
			DisableQueue: false
});

AV & Custom Systems (UDP):

var driver = IR.CreateDevice(IR.DEVICE_CUSTOM_UDP, "AV Device (UDP)",	
			{Host: "192.168.0.47",
			Port: 80,
			LocalPort: 80,  // port on iRidium side for data receiving
			Group: null,  // null - broadcast, "host" - multicast group
			Multicast: false,  // false - broadcast, true - multicast (if multicast group added)
			ScriptMode: IR.DIRECT_AND_SCRIPT
});

AV & Custom Systems (HTTP):

var driver = IR.CreateDevice(IR.DEVICE_CUSTOM_HTTP_TCP, "AV Device (HTTP)",	
			{Host: "192.168.0.47",
			Port: 8080,
			SSL: false,
			Login: "",
			Password: "",
			DisableQueue: false,
			SendCommandAttempts: 0,
			ConnectWaitTimeMax: 3000,
			ReceiveWaitTimeMax: 5000,
			UserAgent: ""
});

AV & Custom Systems (RS232):

var driver = IR.CreateDevice(IR.DEVICE_CUSTOM_RS232, "AV Device (HTTP)",	
			{PortName: "\\.\COM1",
			BaudRate: 9600,
			DataBits: 8,
			Parity: 0,
			StopBits: 0,
			Use485: false  // works with 485, not 232
});

AV & Custom Systems (TCP Server):

var driver = IR.CreateDevice(IR.DEVICE_CUSTOM_SERVER_TCP, "iRidium TCP Server",	
			{Port: 2323,
			MaxClients: 10  // maximum of clients connected at the same time
});

AV & Custom Systems (UDP Server):

var driver = IR.CreateDevice(IR.DEVICE_CUSTOM_SERVER_UDP, "iRidium UDP Server",	
			{Port: 2323,
			MaxClients: 10,  // maximum of clients connected at the same time
			ClientTimeOut: 100 // (ms) when the Client will be disconnected if it doesn't send data
});

Constants in Driver Settings


Send Mode

  • IR.ALWAYS_CONNECTED = 0; - the driver is always connected, it can send and receive data.
  • IR.CONNECT_WHEN_SENDING = 1; - the driver connects at the moment of data sending and disconnects after that, it can only send data.



Script Mode

  • IR.DIRECT_AND_SCRIPT = 0; // Commands can be sent via scripts and editor channels
  • IR.SCRIPT_ONLY = 1; // Commands can be sent via scripts only



Background Mode

  • IR.BACKGROUND_OFF = 0; // The driver works only in the foreground mode
  • IR.BACKGROUND_ON = 1; // The driver worksboth in the foreground and background modes


IR.GetDevice

to get access to any driver in the iRidium project. It works for all drivers not only for the ones created with the help of IR.CreateDevice.

Syntax

IR.GetDevice(name)

input value description
name "Driver 1" type: string
the driver name in the iRidium project
output
Object [object DevicePrototype] type: Object
the reference to the driver


Sample

var myDriver = IR.GetDevice("AMX");
var myDriver1 = IR.GetDevice("HDL-BUS Pro Network (UDP)");
IR.Log(myDriver); // [object DevicePrototype]
IR.Log(myDriver1); // [object DevicePrototype]

HDL, Domintell: use the network name at reference - "HDL-BUS Pro Network (UDP)" / "Domintell Network (UDP)", not the name of a particular device in the network.

Below you can see the methods which can be applied to the reference to the driver received with the help of IR.GetDevice.


.Connect

to establish connection with equipment

Syntax

IR.GetDevice(name).Connect()

input value description
name "Driver 1" type: string
the driver name in the project iRidium
output
successful or not type: Boolean
successful


Sample

IR.GetDevice("AV & Custom Systems (TCP)").Connect();

after creation of the driver the connection is established automatically


.Disconnect

to disconnect from equipment

Syntax

IR.GetDevice(name).Disconnect()

input value description
name "Driver 1" type: string
the driver name in the iRidium project
output
successful or not type: Boolean
successful


Sample

IR.GetDevice("AV & Custom Systems (TCP)").Disconnect();





.Send

the method can be used only with AV & Custom Systems and Global Cache drivers. It enables sending of random data (string, number, array) to equipment

Syntax

IR.GetDevice(name).Send([data])
IR.GetDevice(name).Send(array)
IR.GetDevice(Global Cache).Send([data], transport)

input value description
name "Driver 1" type: string
the driver name in the iRidium project
data a, b, c type: string
the list of variables or strings: instructions for sending
array [a, b, c] type: array
the array of variables or strings: instructions for sending
transport 0 type: number
the identifier of transport. With the Global Cache used to select the transport via which you need to send data:
  • 0 - port 4998 (IR commands, relays, sensors, system)
  • 1 - port 4999 (СОМ 1)
  • 2 - port 5000 (СОМ 2)


Also used on iRidium Server and with Custom TCP Server driver. Allows to select the client - reseiver of message from Server. 0 - all the clients receive a message, 1..n (client ID ,received from IR.ACCEPT_CLIENT) - send to one client

output
successful or not type: Boolean
successful


Sample

// AV & Custom Systems (TCP, UDP, RS232)
IR.GetDevice("AV Device").Send(['instruction', '\r\n']);
// AV & Custom Systems (HTTP)
// <Type or request>,<URI>,<Data> devided by "," so u cannot use "," inside of <URI> and <Data>
IR.GetDevice("AV Device").Send(['GET,URI']); // GET 
IR.GetDevice("AV Device").Send(['POST,URI,Data']); // POST 
IR.GetDevice("AV Device").Send(['PUT,URI,Data']); // PUT
// Global Cache:
// IR.GetDevice("Global Cache").Send(<DATA>, <TRANSPORT ID>)
IR.GetDevice("Global Cache").Send(['setstate,1:1,1', '\r\n'], 0)
// iRidium Server:
// IR.GetServer().Send(<DATA>, <TRANSPORT ID>)
IR.GetServer().Send(['command', '\r\n'], 1)

HTTP: when sending HTTP command to the driver, first indicate the sending method: GET, POST, PUT, then after the comma indicate the command URI and Data for POST and PUT. Inside URI and Data do not use commas. If your protocol uses commas in HTTP commands, send them via AV & Custom Systems (TCP), forming entire requests.
Global Cache: make sure to indicate the ID of the transport where data must be sent


.SendEx

the method can be used only with AV & Custom Systems drivers. It enables sending of data arrays with indication of the parent object (execution context)

Syntax

IR.GetDevice(name).Send(array, object)

input value description
name "Driver 1" type: string
the driver name in the iRidium project
array [a, b, c] type: string
the data array for sending
object this type: object
the parent object
output
successful or not type: Boolean
successful


Sample

   IR.GetDevice("Server REST").SendEx({ 
      Type: "POST",        															
      Url:  "/html/login",
      Data: ["Password=2007&name=authform&Login=admin"],
      Headers: {"Content-Type": "application/x-www-form-urlencoded"},       
      cbReceiveText:       function(text, code, headers)    {IR.Log("cbReceiveText "+text+code+headers);},
      cbReceiveData:       function(text, code, headers)    {IR.Log("cbReceiveData "+text+code+headers);},
      cbReceiveCode:       function(code)                   {IR.Log("cbReceiveCode "+code);},
      cbReceiveKey:        function(key,value)              {IR.Log("cbReceiveKey "+key+value);},
      cbReceiveStartBody:  function(stream)                 {IR.Log("cbReceiveStartBody "+stream);},
      cbReceivePartBody:   function(stream)                 {IR.Log("cbReceivePartBody "+stream);},
      cbReceiveEndBody:    function(size)                   {IR.Log("cbReceiveEndBody "+size);}, 
      cbTimeOut:           function()                       {IR.Log("cbTimeOut");},
      cbReceiveStream:     function(stream, code, headers)  {IR.Log("cbReceiveStream "+stream+code+headers);}   
   });
IR.GetDevice("Server REST").SendEx({ 
      Type: "GET",        															
      Url:  "/json/ok/server/channel",
      Headers: {"Cookie":"ir-session-id=o8lKdEvw2ZlU"},
      cbReceiveText:   function(text, code, headers)    {IR.Log("cbReceiveText "+text);}
   });





.Set

to execute the native driver command preset in the command tree of the editor. When executing the command you send the value to it the same way it is done when you press on the button in the interface. It works for native drivers only. You can activate the command by its index (the sequence number in the tree, beginning with zero) or name. If the command is not preset in the project tree, it cannot be executed.

Syntax

IR.GetDevice(driver).Set(command, value)

input value description
driver "Driver 1" type: string
the driver name in the iRidium project
command "Channel 1" type: string, number
the command index or name
value 100 type: string, number
the number or string to be transferred to the command for sending to equipment
output
successful or not type: Boolean
successful


Sample

//KNX. 0 - first Commands in project Tree; 100 - value to send, "Dimming" - command name
IR.GetDevice("KNX Router (KNXnet/IP)").Set(0, 100);
IR.GetDevice("KNX Router (KNXnet/IP)").Set("Dimming", 100);
//Global Cahe. "Command 1" - name of command on GC output, "" - empty data
IR.GetDevice("Global Cache").Set("Command 1", "")
//HDL. "HDL-BUS Pro Network (UDP)" - name of network
//"Dimmer" - name of Device in Network, "Channel 1" - name of Channel, 100 - value to send
IR.GetDevice("HDL-BUS Pro Network (UDP)").Set("Dimmer:Channel 1", 100);
//Domintell. "Domintell Network (UDP)" - name of network
//"DDIM01" - name of Device in Network, "Channel 1" - name of Channel, 100 - value to send
IR.GetDevice("Domintell Network (UDP)").Set("DDIM01:Channel 1", 100);

HDL, Domintell: use the network name "HDL-BUS Pro Network (UDP)" / "Domintell Network (UDP)" at reference, not the name of a particular network device.


.SetFeedback

to write the value in the driver feedback channel. The channel must be created in Project Device Panel in advance. It is used for displaying data received from equipment during work of scripts.

Syntax

IR.GetDevice(driver).SetFeedback(name, value)

input value description
driver "Driver 1" type: string
the driver name in the iRidium project
name "Channel 1" type: string
the feedback channel name (Feedbacks)
value "data" type: string, number
the string or number to be written in the channel
output
successful or not type: Boolean
successful


Sample

IR.GetDevice("MyDevice").SetFeedback("Value 1", 100);





.GetFeedback

to get the value from the driver feedback channel. The channel must be created in Project Device Panel in advance. It is used for getting access to the data written in the channel.

Syntax

IR.GetDevice(driver).GetFeedback(name)

input value description
driver "Driver 1" type: string
the driver name in the iRidium project
name "Channel 1" type: string
the feedback channel name (Feedbacks)
output
value "data" type: string, number
the string or number received from the feedback channel


Sample

IR.GetDevice("MyDevice").GetFeedback("Value 1"); // 100





.SetParameters

to change driver properties of connection to the controlled equipment. A typical example: switch between the local and Internet connections. It is possible to change only some properties.
The new connection do not change the initial driver properties and are not saved at the application relaunch.
Any TCP, UDP, HTTP driver always has a standard set of parameters: Host, Port, Login, Password (even if the driver does not use the login and password). There are also sets of unique parameters depending on the driver type.

Syntax

IR.GetDevice(driver).SetParameters(Host: host, Port: port, <other>);

input value description
driver "Driver 1" type: string
the driver name in the iRidium project
host "192.168.0.100" type: string
the IP-address or domain name for connection to equipment
port 8080 type: number
the connection port
other type: -
other parameters typical for the driver. If the parameter is not indicated, the previous value of the default value will be saved
output
successful or not type: Boolean
successful


Sample

IR.GetDevice("KNX").SetParameters({Host: "215.110.10.22", Port: 8080});

The List of current settings of driver are available as driver Properties


.GetCookies

to get the Cookies array via the AV & Custom Systems (HTTP) driver

Syntax

IR.GetDevice(driver).GetCookies()

input value description
driver "Driver 1" type: string
the name of the HTTP driver in the iRidium project
output
array type: array
the Cookies array


Sample

var num = IR.GetDevice("MyDevice").GetCookies()





.SetCookie

to send Cookie together with the other header-information via the AV & Custom Systems (HTTP) driver

Syntax

IR.GetDevice(driver).SetCookie(key, value)

input value description
driver "Driver 1" type: string
the name of the HTTP driver in the iRidium project
key type: string
the key
value type: string
the value
output
successful or not type: Boolean
successful


Sample

IR.GetDevice("MyDevice").SetCookie("TestCookie", "value")





.GetLogin

to get the login of connection with any driver

Syntax

IR.GetDevice(driver).GetLogin()

input value description
driver "Driver 1" type: string
the driver name
output
login 'admin' type: string
the driver login


Sample

var login = IR.GetDevice("MyDevice").GetLogin()
IR.Log(login) // admin





.GetPassword

to get the password of connection with any driver

Syntax

IR.GetDevice(driver).GetPassword()

input value description
driver "Driver 1" type: string
the driver name
output
login 'admin' type: string
the driver password


Sample

var pass = IR.GetDevice("MyDevice").GetPassword()
IR.Log(pass) // password





.AddChannel

*the function is under development* to add a channel for the driver

Syntax

IR.GetDevice(driver).AddChannel(name, data)

input value description
driver "Driver 1" type: string
the driver name
name "Channel 1" type: string
the command name
data type: array
the data array specific for each driver
output

-


Sample

/* under development */





.AddTag

*the function is under development* to add a feedback channel for the driver

Syntax

IR.GetDevice(driver).AddTag(name, data)

input value description
driver "Driver 1" type: string
the driver name
name "Channel 1" type: string
the feedback channel name
data type: array
the data array specific for each driver
output

-


Sample

/* under development */





.GetCommandsCount

to get the number of commands set up in the AV & Custom System driver (HTTP, TCP, UDP, RS232)

Syntax

IR.GetDevice(driver).GetCommandsCount()

input value description
driver "Driver 1" type: string
the driver name in the iRidium project
output
CommandsCount 52 type: number
the number of device commands


Sample

var num = IR.GetDevice("MyDevice").GetCommandsCount(); 
IR.Log(num); // number of commands





.GetCommandAtName

to get data from the Data field of the command of the AV & Custom System driver (HTTP, TCP, UDP, RS232). The command is referred by its name or identifier.

Syntax

IR.GetDevice(driver).GetCommandAtName(name/ID)

input value description
driver "Driver 1" type: string
the driver name in the iRidium project
name/ID "Command 1" type: string/number
the command name/ identifier
output
object [object Object] type: object
the reference to the driver command
object.id 1 type: number
the object property: the command identifier (beginning with 1)
object.name Command 1 type: string
the object property: the command name
object.data 74,65,73,74 type: array
the object property: the data from the Data field of the command presented as a byte array


Sample

   var Command = IR.GetDevice("AV").GetCommandAtName("Command 1");
   IR.Log("id: " + Command.id + ", name: " + Command.name + ", data: " + Command.data);   
   // id: 1, name: Command 1, data: 74,65,73,74





.GetCommandAtPos

to get data from the Data field of the command of the AV & Custom System driver (HTTP, TCP, UDP, RS232). The command is referred by its sequence number, beginning with 0.

Syntax

IR.GetDevice(driver).GetCommandAtPos(position)

input value description
driver "Driver 1" type: string
the driver name in the iRidium project
position 0 type: number
the command sequence number (beginning with 0)
output
object [object Object] type: object
the reference to the driver command
object.id 1 type: number
the object property: the command identifier (beginning with 1)
object.name Command 1 type: string
the object property: the command name
object.data 74,65,73,74 type: array
the object property: the data from the Data field of the command presented as a byte array


Sample

   var Command = IR.GetDevice("AV").GetCommandAtPos(0);
   IR.Log("id: " + Command.id + ", name: " + Command.name + ", data: " + Command.data);   
   // id: 1, name: Command 1, data: 74,65,73,74





.GetFeedbacksCount

to get the number of feedback channels set up in the AV & Custom System driver (HTTP, TCP, UDP, RS232)

Syntax

IR.GetDevice(driver).GetFeedbacksCount()

input value description
driver "Driver 1" type: string
the driver name in the iRidium project
output
FeedbacksCount 52 type: number
the number of device channels


Sample

var num = IR.GetDevice("MyDevice").GetFeedbacksCount(); 
IR.Log(num); // number of feedbacks





.GetFeedbackAtName

to get data from the Data field of the feedback channel of the AV & Custom System driver (HTTP, TCP, UDP, RS232). The feedback channel is referred by its name or identifier.

Syntax

IR.GetDevice(driver).GetFeedbackAtName(name/ID)

input value description
driver "Driver 1" type: string
the driver name in the iRidium project
name/ID "Feedback 1" type: string/number
the channel name/identifier
output
object [object Object] type: object
the reference to the object: the feedback channel
object.id 1 type: number
the object property: the channel identifier (beginning with 1)
object.name Command 1 type: string
the object property: the channel name
object.data 74,65,73,74 type: array
the object property: the data from the Data field of the channel presented as a byte array


Sample

   var Feedback = IR.GetDevice("AV & Custom System (TCP)").GetCommandAtName("Feedback 1");
   IR.Log("id: " + Feedback.id + ", name: " + Feedback.name + ", data: " + Feedback.data);   
   // id: 1, name: Feedback 1, data: 74,65,73,74





.GetFeedbackAtPos

to get data from the Data field of the feedback channel of the AV & Custom System driver AV & Custom System (HTTP, TCP, UDP, RS232). The channel is referred by its sequence number, beginning with 0.

Syntax

IR.GetDevice(driver).GetFeedbackAtPos(position)

input value description
driver "Driver 1" type: string
the driver name in the iRidium project
position 0 type: number
the channel sequence number (beginning with 0)
output
object [object Object] type: object
the reference to the feedback channel
object.id 1 type: number
the object property: the channel identifier (beginning with 1)
object.name Command 1 type: string
the object property: the channel name
object.data 74,65,73,74 type: array
the object property: the data from the Data field of the channel presented as a byte array


Sample

   var Feedback = IR.GetDevice("AV & Custom System (TCP)").GetFeedbackAtPos(0);
   IR.Log("id: " + Feedback.id + ", name: " + Feedback.name + ", data: " + Feedback.data);   
   // id: 1, name: Feedback 1, data: 74,65,73,74





Conversion of Data from the Data Field

The methods described above return data from the Data field in the HEX format. To convert the data into ASCII strings, use the following instructions:

// process an array of HEX bytes from Data field of Command or Feedback
function HexArrayToAsciiString(in_aArray) 
{
   // init string
   var l_sStr = '';
 
   // aray bypass
   for(var i = 0; i < in_aArray.length; i++)
      l_sStr += String.fromCharCode(parseInt(in_aArray[i], 16));
 
   // return string in ASCII format
   return l_sStr;
}
IR.AddListener(IR.EVENT_START, 0, function()  
{ 
    var l_pCommand =  IR.GetDevice("Driver").GetCommandAtName(1);
    IR.Log("data:" + HexArrayToAsciiString(l_pCommand.data)); // ASCII data
});


Events


An event - a process forwarded to scripts with an identifier for monitoring.

A listener - it is a function which is executed if the event set for it is activated

Add a listener using the method IR.AddListener

IR.AddListener(event, input, action);
  • event - the identifier of the event monitored by the listener
  • input - the input parameter required for creating the listener. If there is not such parameter indicate 0
  • action - the unnamed function or the link to the named function in which the actions are performed



Sample:

// function inside of listener
IR.AddListener(IR.EVENT_TAG_CHANGE, IR.GetDevice("Driver"), function (name, value)
{
    IR.Log("changes: "+name+" > "+value); // changes: Feedback 1 > 100
});

IR.EVENT_ONLINE

the identifier of the event activated at connection with equipment

Syntax

IR.AddListener(IR.EVENT_ONLINE, driver, function, [pointer]);

input value description
driver IR.GetDevice("MyDriver") type: object
the reference to the driver
function function() {} type: function
the unnamed function or reference to the function
pointer - type: object
the pointer to the object which serves the function (optional)
output

-


Sample

IR.AddListener(IR.EVENT_ONLINE, IR.GetDevice("Global Cache"), function() 
{  
    IR.Log("Device online");
});





IR.EVENT_OFFLINE

the identifier of the event activated at disconnection from equipment

Syntax

IR.AddListener(IR.EVENT_OFFLINE, driver, function, [pointer]);

input value description
driver IR.GetDevice("MyDriver") type: object
the reference to the driver
function function() {} type: function
the unnamed function or reference to the function
pointer - type: object
the pointer to the object which serves the function (optional)
output

-


Sample

IR.AddListener(IR.EVENT_OFFLINE, IR.GetDevice("Global Cache"), function() 
{  
    IR.Log("Device offline");
});





IR.EVENT_TAG_CHANGE

the identifier of the event activated at changing the status of the native driver feedback channel. The event does not work with the AV & Custom Systems driver.

Syntax

IR.AddListener(IR.EVENT_TAG_CHANGE, driver, function, [pointer]);

input value description
driver IR.GetDevice("MyDriver") type: object
the reference to the driver
function function(name, value) {} type: function
the unnamed function or reference to the function
pointer - type: object
the pointer to the object which serves the function (optional)
output
name "Feedback 1" type: string
the name of the changed channel
value 100 type: number
the new value


Sample

// Subscribe to driver
IR.AddListener(IR.EVENT_TAG_CHANGE, IR.GetDevice("KNX Router (KNXnet/IP)"), function(name, value) 
{  
    IR.Log(name+": "+value); // Feedback 1: 100
});
// subscribe to iRidium Server variables (in Server project)
IR.AddListener(IR.EVENT_TAG_CHANGE, IR.GetServer(), function(name, value) 
{  
    IR.Log(name+": "+value);
});

listeners do not work with the AV & Custom Systems driver! Use IR.EVENT_RECEIVE_DATA or IR.EVENT_RECEIVE_TEXT to parse data of this driver
HDL: instead of the driver name indicate the name of the HDL network, "HDL-BUS Pro Network (UDP)" by default. The changed channel value is returned as "device:channel"; device - the name of the executing HDL device, channel - the channel in the settings of this device.
Domintell: nstead of the driver name indicate the name of the Domintell network, "Domintell Network (UDP)" by default. The changed channel value is returned as "device:channel"; device - the name of the executing Domintell device, channel - the channel in the settings of this device.


IR.EVENT_RECEIVE_DATA

the identifier of the event activated when receiving data by the AV & Custom Systems driver. The data are output as an array. It works only for AV & Custom Systems.

Syntax

IR.AddListener(IR.EVENT_RECEIVE_DATA, driver, function, [pointer]);

input value description
driver IR.GetDevice("MyDriver") type: object
the reference to the driver
function function(data) {} type: function
the unnamed function or reference to the function
pointer - type: object
the pointer to the object which serves the function (optional)
output
data type: array
array of data


Sample

IR.AddListener(IR.EVENT_RECEIVE_DATA, IR.GetDevice("AV & Custom Systems (TCP)"), function(data) 
{  
    IR.Log(data);
});

it works only with AV & Custom Systems


IR.EVENT_RECEIVE_TEXT

the identifier of the event activated when receiving data by the AV & Custom Systems driver. The data are output in the string format. It works only for AV & Custom Systems.

Syntax

IR.AddListener(IR.EVENT_RECEIVE_TEXT, driver, function, [pointer]);

input value description
driver IR.GetDevice("MyDriver") type: object
the reference to the driver
function function(text) {} type: function
the unnamed function or reference to the function
pointer - type: object
the pointer to the object which serves the function (optional)
output
text type: string
the received data in the string format


Sample

IR.AddListener(IR.EVENT_RECEIVE_TEXT, IR.GetDevice("AV & Custom Systems (TCP)"), function(text) 
{  
    IR.Log(text);
});

it works only with AV & Custom Systems


IR.EVENT_ERROR

the identifier of the event activated when on send of HTTP command the resource is not available or resource is available but not responded within the set time. The event shows the result of the request as Error Code.

Синтаксис

IR.AddListener(IR.EVENT_ERROR, driver, function, [pointer]);

на входе значение описание
driver IR.GetDevice("AV & Custom Systems (HTTP)") type: object
link to the driver object
function function(transport_id, local_ip, local_port, host_ip, host_port, errorCode) {} type: function
the unnamed function or reference to the function
pointer - type: object
the pointer to the object which serves the function (optional)
на выходе
transport_id 0 type: number
the identifier of transport. 0 for any AV driver except Global Cache: 0 - IR, system, 1 - COM1, 2 - СОМ2
local_ipt 192.168.0.100 type: string
the local address of command sender
local_port 80 type: number
the local port of command sender
host_ip 200.200.10.10 type: string
the address of command receiver
host_port 80 type: number
the port of command receiver
errorCode 1 type: number
the error code:
  • 1 - the request wasn't sent (the resource is not available)
  • 2 - the resource is available, but the answer wasn't received in a time


Пример

var driver = IR.CreateDevice(IR.DEVICE_CUSTOM_HTTP_TCP, "AV Device (HTTP)", {
   Host: "ResourceUnavailable.net", Port: 80
});
 
driver.SendEx({ 
   Type: "GET",  Url:  "/request", Headers: {},
   cbReceiveText:   function(text, code, headers)    {IR.Log("cbReceiveText (code) = "+code);}
});
 
IR.AddListener(IR.EVENT_ERROR, driver, function(transport_id, local_ip, local_port, host_ip, host_port, errorCode) {
   IR.Log("IR.EVENT_ERROR (code) = "+errorCode);
});

работает только с AV & Custom Systems (HTTP)
не сработает, если от ресурса пришел ответ, даже с ошибкой. Для обработки ошибок используйте SendEx


IR.EVENT_CHANNEL_SET

the identifier of the event activated at activation of the driver command

Syntax

IR.AddListener(IR.EVENT_CHANNEL_SET, driver, function, [pointer]);

input value description
driver IR.GetDevice("AV") type: object
the reference to the driver
function function(name, value) {} type: function
the unnamed function or reference to the function
pointer - type: object
the pointer to the object which serves the function (optional)
output
name "Command 1" type: string
the name of the command which was activated
value 100 type: number
the value written in the command


Sample

IR.AddListener(IR.EVENT_CHANNEL_SET, IR.GetDevice("AV & Custom Systems (TCP)"), function(name, value) {  
   switch(name) {
      case "Volume": 
         IR.Log("Volume set: "+value)
         break;
      case "Play":
         IR.Log("Play")
         break;
   }
});

this event works only with AV & Custom Systems and Global Cache drivers


UPnP

.InvokeAction

отослать инструкцию на устройство с поддержкой UPnP

Синтаксис

IR.GetDevice(driver).InvokeAction(action_name, service_type, [arguments, callback])

на входе значение описание
driver "Driver 1" type: string
имя драйвера в проекте iRidium
action_name "Play" type: string
имя команды
service_type "service:AVTransport:1" type: string
используемый сервис
arguments {InstanceID: 0, Speed: 1} type: string
список аргументов команды
callback type: object
функция обратного вызова
на выходе
успешность type: Boolean
успешность


Пример

IR.GetDevice("Sonos").InvokeAction("Play", "service:AVTransport:1", {InstanceID: 0, Speed: 1});





.Subscribe

to subscribe to the event of the device with UPnP support

Syntax

IR.GetDevice(driver).Subscribe(service_type)

input value description
driver "Driver 1" type: string
the driver name in the iRidium project
service_type "urn:schemas-upnp-org:service:AVTransport:1" type: string
the used service
output
true true type: Boolean
successful


Sample

IR.GetDevice("Sonos").Subscribe("urn:schemas-upnp-org:service:AVTransport:1");





.Unsubscribe

to unsubscribe from the event of the device with UPnP support

Syntax

IR.GetDevice(driver).Unsubscribe(service_type)

input value description
driver "Driver 1" type: string
the driver name in the iRidium project
service_type "urn:schemas-upnp-org:service:AVTransport:1" type: string
the used service
output
true true type: Boolean
successful


Sample

IR.GetDevice("BAOS").Unsubscribe("urn:schemas-upnp-org:service:AVTransport:1");





IR.EVENT_DEVICE_FOUND

the identifier of the event activated at the event on the UPnP device

Syntax

IR.AddListener(IR.EVENT_DEVICE_FOUND, 0, function, [pointer]);

input value description
function function(name) {} type: function
the unnamed function or reference to the function
pointer - type: object
the pointer to the object which serves the function (optional)
output
name "Device" type: string
the name of the found UPnP device


Sample

IR.AddListener(IR.EVENT_DEVICE_FOUND, 0, function(name) 
{  
    IR.Log(name);
});





IR.EVENT_RECEIVE_EVENT

the identifier of the event activated at receiving the event from the UPnP device

Syntax

IR.AddListener(IR.EVENT_RECEIVE_EVENT, driver, function, [pointer]);

input value description
driver IR.GetDevice("MyDriver") type: object
the reference to the UPnP driver
function function(type, text) {} type: function
the unnamed function or reference to the function
pointer - type: object
the pointer to the object which serves the function (optional)
output
type type: string
the event type
text type: string
the message from the device


Sample

IR.AddListener(IR.EVENT_RECEIVE_EVENT, IR.GetDevice("MyDriver"), function(type, text) 
{  
    IR.Log(text);
});





Properties

Driver Properties

Параметры подключения драйвера доступны для чтения как свойства объекта Драйвер. Чтобы изменить параметры подключения, нужно использовать метод .SetParameters.

Основные свойства драйвера в проекте iRidium - это имя и тип. Их можно запросить у любого драйвера. :

driver.property

property:

Name Crestron 1 type: string
the driver name
Type Crestron (TCP) type: string
the driver type. You can see the exact type name in the Driver Type property in the window of connection settings
var driver = IR.GetDevice("Crestron 1");
IR.AddListener(IR.EVENT_START,0,function()
{
     var properties  = driver.Name + " (" + driver.Type + ") created";
     IR.Log(properties); 
});


Остальные параметры драйверов уникальны, и зависят от типа драйвера. Имена параметров драйвера можно посмотреть в системном меню i3 pro или взять из списка:

driver.property


AMX

Host 192.168.0.100 type: string
the IP-address or domain name
Port 1319 type: number
the connection port
DeviceID 10001 type: number
the unique identifier of the AMX panel
Login admin type: string
the login of the secure session
Password admin type: string
the password of the secure session


AV & Custom Systems (UDP)

Host 192.168.0.100 type: string
the IP-address or domain name
Port 8080 type: number
the connection port
LocalPort 80 type: number
the local port for data receipt (on the side of iRidium)
Group null type: string
null - broadcast, "host" - the multicast group
Multicast false type: string
false - broadcast, true - multicast (if the group is indicated)
ScriptMode 0 type: number
to send data directly to the driver and scripts (0) or to scripts only (1)


AV & Custom Systems (HTTP)

Host 192.168.0.100 type: string
the IP-address or domain name
Port 8080 type: number
the connection port
SSL false type: number
secure connection
Login admin type: string
the login of the secure session
Password admin type: string
the password of the secure session
DisableQueue 0 type: number
do not add commands to the queue if they couldn't be sent
SendCommandAttempts 0 type: string
the number of times to repeat the command if its sending failed (0 - do not repeat, single sending)
ConnectWaitTimeMax 3000 type: number
(ms) the time to wait for connection
ReceiveWaitTimeMax 5000 type: number
(ms) the time to wait for response
UserAgent iRidium type: string
how iRidium identifies itself to the HTTP server


AV & Custom Systems (RS232)

PortName \\.\COM1 type: string
the name of the COM port
BaudRate 19200 type: number
the speed of data exchange
DataBits 8 type: number
the number of information bits in a frame
Parity e type: string
parity check
StopBits 1 type: number
the stop bit in a frame
Use485 0 type: number
to use the RS485 transport


AV & Custom Systems (TCP Server)

Port 8080 type: number
the connection port
MaxClients 10 type: number
the maximum number of connected clients


AV & Custom Systems (UDP Server)

Port 8080 type: number
the connection port
MaxClients 10 type: number
the maximum number of connected clients
ClientTimeOut 100 type: number
(ms) the client will be disconnected after the indicated time if it does not send data to the server


Clipsal

Host 192.168.0.100 type: string
the IP-address or domain name
Port 20023 type: number
the connection port
Project PROJ type: string
the name of the Toolkit project


Crestron

Host 192.168.0.100 type: string
the IP-address or domain name
Port 41794 type: number
the connection port
NetID 3 type: number
the IP ID (IP Net Address) of the panel from the project in SIMPL Windows
TelnetPort 41795 type: number
the Telnet connection port (system)
TelnetSSL 1 type: number
use of SSL connection
TelnetLogin admin type: string
the login for SSL
TelnetPassword admin type: string
the password for SSL


DVR

Host 192.168.0.100 type: string
the IP-address or domain name
Port 8080 type: number
the connection port
Login admin type: string
the login of the secure session
Password admin type: string
the password of the secure session


Domintell

Host 192.168.0.100 type: string
the IP-address or domain name
Port 17481 type: number
the connection port
Password admin type: string
the connection password
PingTime 1000 type: number
(ms) the frequency of data update


EPSNET

Host 192.168.0.100 type: string
the IP-address or domain name
Port 61682 type: number
the connection port
UpdateTime 1000 type: number
(ms) the frequency of data update
DeviceAddress type: string
it is not used by default


Global Cache

Host 192.168.0.100 type: string
the IP-address or domain name
Port 4998 type: number
the port for sending system commands - 4998
IrConfirm 0 type: number
to confirm delivery of IR commands
SerialPort1 4999 type: number
СОМ port 1 (serial 1), if there is one
SerialPort2 5000 type: number
СОМ port 2 (serial 2), if there is one
SerialPort3 0 type: number
reserved
PingTime 0 type: number
(ms) to check at regular intervals if there is connection with GC. 0 - no ping
DisableQueue 0 type: number
do not add commands to the queue if they couldn't be sent
SendCommandAttempts 0 type: string
the number of times to repeat the command if its sending failed (0 - do not repeat, single sending)
ConnectWaitTimeMax 3000 type: number
(ms) the time to wait for connection
ReceiveWaitTimeMax 5000 type: number
(ms) the time to wait for response


HDL-Buspro

Host 255.255.255.255 type: string
the IP-address or domain name. In the local network - broadcast address 255.255.255.255
Port 6000 type: number
the connection port
SendTimeOut 20 type: number
(ms) the forced interval between commands
ConnectMode 0 type: number
0 - Local, 2 - Internet, 3 - Remote Server
Login User type: string
the login (for Internet and Remote Server)
Password User type: string
the password (for Internet and Remote Server)
Project ir_proj type: string
the project name (for Internet and Remote Server)
ExtendedPort 6000 type: string
the server port (for Remote Server)
Group ir_group type: string
the group (for Remote Server)
// Local (ConnectMode=0)
IR.GetDevice("HDL Buspro UDP").SetParameters({Host: "255.255.255.255", Port: 6000, 
SendNeedConfirm: 0, SendTimeout: 20, ConnectMode: 0});
 
// Internet (ConnectMode=1)
IR.GetDevice("HDL Buspro UDP").SetParameters({Host: "215.110.10.10", Port: 6000, 
Login: "User", Password: "User", SendNeedConfirm: 0, SendTimeout: 20, ConnectMode: 2, 
Project: "ir_proj"});
 
// HDL Remote Server (ConnectMode=2)
IR.GetDevice("HDL Buspro UDP").SetParameters({Host: "215.110.10.10", Port: 9999, 
Login: "User", Password: "User", SendNeedConfirm: 0, SendTimeout: 20, ConnectMode: 3, 
ExtendedPort: 6000, Project: "ir_proj", Group: "ir_group"});


Helvar

Host 192.168.0.100 type: string
the IP-address or domain name (none for Net Internal UDP)
Port 50001 type: number
the connection port


KNX

Host 192.168.0.100 type: string
the IP-address or domain name
Port 3671 type: number
the connection port
ConnectionWaitTime 120000 type: number
(ms) the waiting time at emergency disconnection: 60000 or 120000 ms (depends on the KNX interface)
SendWaitTime 0 type: number
(ms) the pause between command sending in the bus, it is used to decrease the load on the bus
PingTime 60000 type: number
(ms) the frequency of sending the Ping command to check connection with the router
Nat 0 type: number
the NAT mode (it has to be activated when you work via the Internet or with several network interfaces)


KNX IP BAOS

Host 192.168.0.100 type: string
the IP-address or domain name
Port 12004 type: number
the connection port
UpdateTime 0 type: number
(ms) the frequency of sending the Ping command to check connection with the router


Modbus

Host 192.168.0.100 type: string
the IP-address or domain name
Port 502 type: number
the connection port
UpdateTime 1000 type: number
(ms) the frequency of data update


Modbus Serial

Port 1 type: number
the number of the СОМ port
PortName \\.\COM1 type: string
the name of the COM port
BaudRate 19200 type: number
the speed of data exchange
DataBits 8 type: number
the number of information bits in a frame
Parity e type: string
parity check
StopBits 1 type: number
the stop bit in a frame
Use485 0 type: number
to use the RS485 transport


SIP

Host 192.168.0.100 type: string
the IP-address or domain name of the SIP server
Port 502 type: number
the port of connection to the SIP server
CallerID Ben type: string
the subscriber's alias
ID Ben type: number, string
the subscriber's number
Password Pwd type: number, string
the subscriber's
FirstRTPPort 40000 type: number
the first port of the RTP range
LastRTPPort 41000 type: number
the last range of the RTP range
ToneDTMF 1 type: number
to send DTMF tones
ToneSIP 0 type: number
to send SIP tones
ExternalIP type: string
the external subscriber's address
PCMU 1 type: number
to turn on/off the codec
PCMA 1 type: number
to turn on/off the codec
GSM 1 type: number
to turn on/off the codec
H263 1 type: number
to turn on/off the codec
H263_1998 1 type: number
to turn on/off the codec


iRidium Server

Host 192.168.0.100 type: string
the IP-address or domain name
Port 30464 type: number
the connection port
Login admin type: string
the login of the secure session
Password admin type: string
the password of the secure session