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

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

the ducumentation is updated 10.3.2017


Description

iRidium can send ASCII, DEC, HEX commands via TCP, UDP, HTTP(s), RS232 and get feedback from equipment with the help of JavaScript. You can set up commands to equipment without scripts but feedback is set up with scripts.

Set up commands to any equipment for which there is no support in iRidium at the moment. For example: Home Theater, Multi-room, TV, DVD/BluRay players, iTunes, XBMC, commutators, matrix, preamplifiers. You can control equipment directly via Wi-Fi, Ethernet or via IP-to-RS232, IP-to-IR converters (such as Global Cache).


Licensing of iRidium for AV & Custom Systems (more):

  • Deivice License Pro (AV & Custom Systems) - a license for one control panel. It enables sending of commands and processing of data from equipment to which you connect using AV & Custom Systems drivers.


If you need to connect several control panels to equipment but the equipment has limitations for the number of concurrent connections, use iRidium Server


Connection

Equipment configuration and settings required for iRidium to control equipment via IP.


Ways of Connection

Depending on the way of control supported by your equipment, you can select a AV & Custom Systems driver and set it up for work with a particular device.


AV & Custom Systems (Client)

The list of AV & Custom Systems drivers includes the drivers for Client part are able to connect to automation system or server to send commands and receive data

HowItWorksTCP.png


Add the driver in PROJECT DEVICE PANEL from DEVICE BASE

GC-AddDriver.png
select a driver depending on the way of control:
  • TCP > "AV & Custom Systems (TCP)"
  • UDP > "AV & Custom Systems (UDP)"
  • HTTP / HTTPs > "AV & Custom Systems (HTTP)"
  • RS232 > "AV & Custom Systems (RS232)"

Connection properties for AV & Custom Systems (TCP):

  • Host - the IP-address of domain name
  • Port - the TCP connection port
  • Mode - the mode of connection to equipment
    • Always Connected - connected constantly
    • Connect when Sending - connected only at the moment of command sending. Feedback does not work but commands can be sent from different devices not occupying the connection
  • Script Mode - defines where to send commands
    • Direct and Script - to send commands directly to equipment and duplicate them to scripts
    • Script Only - to send commands to scripts only (commands will not be sent when clicking on the button)
  • Disable Queue - to disable the queue of command sending in iRidium for commands no to be accumulated when having problems with sending. 0 - false, 1 - true
  • Send Command Attempts - the number of attempts to send a command if there was no delivery confirmation, 0 - not to repeat the sending
  • Wait for Connection - (ms) the time for waiting for connection (then reconnect)
  • Wait for Data - (ms) the time for waiting for response from equipment (then repeat the request and check the connection). Set 0 if you need the driver always connected to equipment even there is no data received from

Connection properties for AV & Custom Systems (UDP):

  • Host - the IP-address of domain name
  • Port - the UDP connection port
  • Mode - the mode of connection to equipment
    • Always Connected - connected constantly
    • Connect when Sending - connected only at the moment of command sending. Feedback does not work but commands can be sent from different devices not occupying the connection
  • SSL - to enable/disable SSL
  • Script Mode - defines where to send commands
    • Direct and Script - to send commands directly to equipment and duplicate them to scripts
    • Script Only - to send commands to scripts only (commands will not be sent when clicking on the button)
  • Local Port - the UDP port opened on the control panel side (data from controlled equipment will come here). It can be different from the external port (opened on the equipment side)
  • Multicast - to use the mode of multicast
    • Group - the multicast group


Connection properties for AV & Custom Systems (HTTP):

  • Host - the IP-address of domain name
  • Port - the TCP connection port (usually 80)
  • Login / Password - the login and password for SSL
  • SSL - to enable/disable SSL
  • User Agent - the user name used by iRidium
  • Script Mode - defines where to send commands
    • Direct and Script - to send commands directly to equipment and duplicate them to scripts
    • Script Only - to send commands to scripts only (commands will not be sent when clicking on the button)
  • Disable Queue - to disable the queue of command sending in iRidium for commands no to be accumulated when having problems with sending. 0 - false, 1 - true
  • Send Command Attempts - the number of attempts to send a command if there was no delivery confirmation, 0 - not to repeat the sending
  • Wait for Connection - (ms) the time for waiting for connection with equipment (then reconnect)
  • Wait for Data - (ms) the time for waiting for response from equipment (then repeat the request and check the connection). Set 0 if you need the driver always connected to equipment even there is no data received from

Connection properties for AV & Custom Systems (RS232):

  • Port - the СОМ-port number
  • Baud Rate - the speed of data exchange
  • Data Bits - the number of information bits in a frame
  • Parity - the parity control
  • Stop Bits - the stop bit in a frame
  • Script Mode - defines where to send commands
    • Direct and Script - to send commands directly to equipment and duplicate them to scripts
    • Script Only - to send commands to scripts only (commands will not be sent when clicking on the button)


AV & Custom Systems (Server)

You can use the AV & Custom Systems drivers outside of the main list for creation of free configured TCP or UDP Server. It is possible to create such Serever only with JavaScript methods.

See the info about driver creation with help of JavaScript in iRidium.

Example of AV & Custom Systems (TCP Server) driver creation.


Change of Connection Settings

You need the possibility to change connection properties when you disconnect from the Wi-Fi network of the automation object and start using 3G or another Wi-Fi network. To maintain control of the object you need to switch from the local to public IP-address of the Internet router.

The switch is not automatic. You have to select the connection mode. For remote acces you have to make ports for controlling the automation system public. In order to do that you have o set up the Port Forwarding service on your Internet router. VPN can provide protected connection.


1 Download the template (*.js) (right-click button: "Save object as ..."), add the template in the script editor with the buttonIcon Scripts.png (+) Add Script from file


2 Set up script properties as it is shown in the example:

function Internal_1() {
IR.GetDevice("AV & Custom Systems (TCP)").SetParameters({Host: "192.168.0.100", Port: 8080, SendMode: IR.ALWAYS_CONNECTED, ScriptMode: IR.DIRECT_AND_SCRIPT, DisableQueue: false, SendCommandAttempts: 0, ConnectWaitTimeMax: 0, ReceiveWaitTimeMax: 0});
}
function External_1() {
IR.GetDevice("AV & Custom Systems (TCP)").SetParameters({Host: "215.110.10.10", Port: 8081});
}

Copy the driver name from Projeсt Device Panel - the list of properties has to be copied from the example.


3 Select the button which will be responsible for the switch of Internal and External properties. Open Macros Editor for the Press event (Object Properties > Programming), select the Script Call command and add it by double-clicking on it. Select the name of the function which will be activated by the button:

Script call internal-external.png

Now each pressing on the button will apply the corresponding connection properties.

Examples:

//AV & Custom Systems (TCP)
IR.GetDevice("AV & Custom Systems (TCP)").SetParameters({Host: "192.168.0.100", Port: 8080, SendMode: IR.ALWAYS_CONNECTED, ScriptMode: IR.DIRECT_AND_SCRIPT, DisableQueue: false, SendCommandAttempts: 0, ConnectWaitTimeMax: 0, ReceiveWaitTimeMax: 0, LogLevel: 0, BackgroundMode: 0});
 
//AV & Custom Systems (UDP)
IR.GetDevice("AV & Custom Systems (UDP)").SetParameters({Host: "192.168.0.100", Port: 6001, ScriptMode: IR.DIRECT_AND_SCRIPT, LocalPort: 8080, Group: "224.0.0.1", Multicast: 1});
 
//AV & Custom Systems (HTTP)
IR.GetDevice("AV & Custom Systems (HTTP)").SetParameters({Host: "192.168.0.100", Port: 80, Login: "admin", Password: "pass", UseSSL: true, UserAgent: "iRidium", ScriptMode: IR.DIRECT_AND_SCRIPT, DisableQueue: false, SendCommandAttempts: 0, ConnectWaitTimeMax: 0, ReceiveWaitTimeMax: 0});
 
//AV & Custom Systems (RS232)
IR.GetDevice("AV & Custom Systems (RS232)").SetParameters({Port: 1, BaudRate: 19200, Bits: 8, Parity: "e", StopBit: 1, ScriptMode: 1});


Setting up commands

AV & Custom Systems (TCP, UDP, RS232)

Commands of AV & Custom Systems (TCP, UDP, RS232) have similar settings. They can send data strings in the HEX, DEC, ASCII formats to equipment.

AV-TCP-CommandFeedback.png
  • Name - the command name. Using it, you can call commands from the script
  • Data - the data the command sends to the equipment. They can be writen in the HEX, DEC, ASCII formats. Rules for data forming change depending on the format
  • Disable Header - the professional setting for headers. It matters only when you create a device in the your database and indicate a preamble (the command part which will be added to any data input in the Data field) in its settings (see the database editor)


Setting up feedback:

  • Name - the feedback channel name. Using the name, JavaScript can send data received from equipment into your graphic interface. All work with feedback is performed in scripts.


Commands in the Data field have to be formmatted in accordance with the iRidium, syntax for the program to determine correctly how your data has to be sent (as strings, HEX codes or numbers):


ASCII (string)

Formatting ASCII strings in the Data field:

  • include strings in 'single quotes'
  • in the string end add
    ,$0D - carriage return <CR>
    ,$0A - string end <LF>


Formatting commands:

In documentation: PWR01 <CR> VOLUME 50 <CR> <LF>
Format: ASCII ASCII
In iRidium (the Data field): 'PWR01',0x0D 'VOLUME 50',0x0D,0x0A


Formatting the carriage return <CR> and sting end <LF>:

In documentation: <CR> <CR> <CR> <LF> <LF> <LF>
Format: HEX HEX DEC HEX HEX DEC
In iRidium (the Data field): ,0x0D ,$0D ,13 ,0x0A ,$0A ,10


HEX (hexadecimal)

Formatting HEX symbols in the Data field:

  • Before each HEX symbol write 0x or $
  • Remove unnecessary indications before НЕХ codes, for example: 0Ah >> $0A
  • Separate НЕХ symbols with commas, delete all blank spaces
  • in the string end add
    ,$0D - carriage return <CR>
    ,$0A - string end<LF>


In documentation: 16 8A FF 81 <CR> 19h EEh A1h 00h <CR> <LF>
Format: HEX HEX
In iRidium (the Data field): 0x16,0x8A,0xFF,0x81,0x0D $19,$EE,$A1,$00,0x0D,0x0A


Formatting the carriage return <CR> and sting end <LF>:

In documentation: <CR> <CR> <CR> <LF> <LF> <LF>
Format: HEX HEX DEC HEX HEX DEC
In iRidium (the Data field): ,0x0D ,$0D ,13 ,0x0A ,$0A ,10


DEC (decimal)

Formatting decimal numbers in the Data field:

  • separate numbers with commas, delete all blank spaces
  • in the string end add
    ,$0D - carriage return <CR>
    ,$0A - string end <LF>


In documentation: 01 255 255 15 <CR> 01 10 25 255 <CR> <LF>
Format: DEC DEC
In iRidium (the Data field): 01,255,255,15,13 01,10,25,255,13,10


Formatting the carriage return <CR> and sting end <LF>:

In documentation: <CR> <CR> <CR> <LF> <LF> <LF>
Format: HEX HEX DEC HEX HEX DEC
In iRidium (the Data field): ,0x0D ,$0D ,13 ,0x0A ,$0A ,10


Adding commands in Device Base

In the general "DEVICE BASE" you can create the list of devices and commands for fast adding in any new iRidium project. You can create AV & Custom Systems devices only in your custom database as the standard one is not available for editing.

Create a user database:

AV Database New.png

Add a TCP, UDP, RS232 or HTTP device in it:

RS232 1.png

In the Commands & Feedbacks tab create a list of commands:

RS232 4.png

Open Command Properties with double-clicking and add a command in the Command field:

RS232 5.png

Add a ready set of commands to your project: select your database in the DEVICE BASE list and drag the device in your project (PROJECT DEVICE PANEL).


AV & Custom Systems (HTTP)

Commands of the AV & Custom Systems (HTTP) driver can be sent using one of the following methods:

  • GET - to get. To send the resource identifier: URI
  • POST - to add, change, delete. To send a data unit
  • PUT - to add, substitute. To send a data unit


You can send the HTTP command from the items of your GUI project (see below).

To send the HTTP command with JavaScript you can use the specialized method called .SendEx, or the methods .Set and .Send.


GET Method

Input the GET request in the URI window:

  • remove the part of the request with the resource IP-address and port for referring to the resource
  • add the request body in the URI window, including slash / in the beginning:
    • from the request httр://<host>:<port>/<url> leave only /<url> in the URI field of command settings


In documentation: httр://192.168.0.100:81/cgi-bin/do?cmd=ir_code=B748BF00
In iRidium (the URI field): /cgi-bin/do?cmd=ir_code=B748BF00
GETrequestinGUI.png


POST and PUT Methods

Mark the valuable request parts and enter them in the URI and Data fields:

  • add the resource identifier in URI
  • add the request body in Data - it can be a big data unit. Include it in 'single quotes'


Example 1:

In documentation (POST): POST /YamahaRemoteControl/ctrl HTTP/1.1

Accept: */*
Accept-Language: ru
Referer: http://192.168.10.102/
Content-Type: text/xml; charset=UTF-8
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET
CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; BRI/2)
Host: 192.168.10.100
Content-Length: 105
Connection: Keep-Alive
Cache-Control: no-cache
Cookie: mstnc=1

<YAMAHA_AV cmd="PUT"><System><Power_Control><Power>Standby</Power></Power_Control></System></YAMAHA_AV>

In iRidium (the URI field): /YamahaRemoteControl/ctrl
In iRidium (the Data field): '<YAMAHA_AV cmd="PUT"><System><Power_Control><Power>Standby</Power></Power_Control></System></YAMAHA_AV>'


Example 2:

In documentation (POST): POST /WAN/dvdr/dvdr_ctrl.cgi? HTTP/1.1

User-Agent: MEI-LAN-REMOTE-CALL
Host: 192.168.1.105
Content-Length: 39

cCMD_RC_POWER.x=100&cCMD_RC_POWER.y=100

In iRidium (the URI field): /WAN/dvdr/dvdr_ctrl.cgi?
In iRidium (the Data field): 'cCMD_RC_POWER.x=100&cCMD_RC_POWER.y=100'
POSTrequestinGUI.png

Custom TCP, UDP, HTTP Network

Custom TCP Network, Custom UDP Network, Custom HTTP Network - is a way to organize your "AV & Custom Systems" drivers that have a same connection settings (Host and Port). This way allows you to create a single connection to equipment and add there many devices with the same commands and feedback. It is also give you a convenient access to devices and commands via the Java Script API. The AV devices inside of Network cannot have the same names, but the commands could be the same.

To the Network you must add the device with the same type of transport that the Network has.

CustomNetwork.png

"Custom Network" driver will be available by name as the other drivers. The commands inside of Networ will be available as <device name>:<command name>

For example: add the Custom TCP Network. Add the AV & Custom Systems (TCP) driver inside of Network and call it Device 1. Add the command Power On to this driver. Driver and commands will be available with Java Script as:

// Set: IR.GetDevice(driver).Set(command, value)
IR.GetDevice("Custom TCP Network").Set("Device 1:Power On", "")
 
// Send: IR.GetDevice(name).Send([data])
IR.GetDevice("Custom TCP Network").Send(['instruction', '\r\n']);


Sending commands

You can send commands with the help of buttons or via the script.


1 To send a command once, assign it to the Press or Release event:

AV 1 Press.png

2 To create a macro command, assign several command to Press or Release :

AV 2 Macro.png

You can add a delay between the commands - Delay() to regulate the speed of command sending


3 To send a command in a cycle when holding the button, select Press and Hold :

AV 3 Hold.png

Hold settings are located in Object Properties > General:

  • Hold Time (ms) - the time after which Hold is activated when holding the item
  • Repeat Time (ms) - the interval for repeating commands from the Hold event.


4 commands can be sent via JavaScript. In order to do that use the .Set and .Send methods from Drivers API:

var device = IR.GetDevice("AV & Custom Systems (TCP)");
var HTTP_device = IR.GetDevice("AV & Custom Systems (HTTP)");
var CommandString = 'comand data /1';
var CommandName = "COMMAND";
 
IR.AddListener(IR.EVENT_ONLINE , device, function() 
{
    device.Set(CommandName, "");            // .Set command by name
    device.Send([CommandString,0x0D]);        // .Send command as string
    HTTP_device.SendEx({ 
      Type: "GET",        															
      Url:  "/command",
      Headers: {},
      cbReceiveText:   function(text, code, headers)    {IR.Log("cbReceiveText "+text);}
   });
});

Formatting of IR commands for the Send method is described in detail in iTach API.

Feedback

Feedback from equipment controlled with the help of AV & Custom Systems, can be received only with the help of JavaScript. it is conditioned by the fact that the program does not know to which equipment it will connect in advance. So it cannot determine the format and type of data which can be received.


Functions used at procesing of incoming data are described in Drivers API. They work only with licenses which support feedback from script drivers ("Pro" licenses). In practice, a license activates work of listeners


All the rest JavaScript methods and events work with any licenses.


Example of processing incoming data with the help of JavaScript:

var driver = IR.GetDevice("AV (TCP)");
// IR.EVENT_RECEIVE_TEXT makes you able to parse incomming data from equipment 
IR.AddListener(IR.EVENT_RECEIVE_TEXT, driver, function(text) 
{
   // divide the received data by '\r\n' to get the separated strings
   var strings = text.split('\r\n');
   var string;
   while(string = strings.shift())
   {
		// divide the string into parts with separator comma (it would be space or something else)
		var parts = string.split(",");
		switch(parts[0])
		{
		  // if the first part of devides string = "#OK"
		  case "#OK":    
			 // for equipment it means that we are ready to work
			 IR.Log("Ready to control!");
		  break;
 
		  // if the first part of devides string = "#RID"
		  case "#RID":
		  // the second part should be "ALL", third part shouldn't be empty
		  if (parts[1] == 'ALL' && parts[2]) 
		  {
			 //devide the third part into 12 parts to know the status on 12 variables we got in this feedback
			 var slots = parts[2];
			 for(var i = 0; i < 12; i++)
			 {
				var slot = parseInt(slots.substring(i, i+1));
				a_dOutputs[i] = slot;
				var fName = "OUT "+(i+1);   
				// in AV driver we have a preconfigured Feedback channels with name OUT 1 ... OUT 12
				//so we can write the received data in this feedbacks and display on items  
				driver.SetFeedback(fName, slot);
			 }
		  }
		break;
		}	
	}
});


Emulator: project testing

Emulator - an application launched in iRidium Studio to test the project work.

An Emulator works only when you authorized with login and password from iRidium Mobile web site

Emulator work modes see in iRidium Studio > Tools > Options > Emulator:

  • Client Fullscreen - start the Emulator in Full Screen mode (press Alt+F4 to Exit)
  • Client Sound On - switch sound in app
  • Show log at Emuator Start - open the log window automatically at Emulator start (you can also use F4)


Path to the license.png

Hot keys:

  • F4 - open the debug log
  • F5 - launch Emulator
  • F7 - open the app Menu to manage account and download projects from iRidium Cloud
  • F8 - open the settings (password: 2007)


Synchronization with Control Panels

Upload and launch of the iRdidium project on the control panel is performed with the help of the iRidium Transfer application, installed on your PC. You can also upload the project on the panel from the editor via Transfer.


Use i3 pro for iOS, Android, Windows, Mac in Test Mode by downloading projects via iRidium Transfer (the possibility is available for integrators):


iRidium Transfer settings


Commercial use of iRidium is possible only at download of visualization projects with the help of the iRidium Cloud service on the iRidium Mobile web site (see the instructions).

iRidium Cloud can be set up only by a registered integrator. After the setting up he can invite end-users to control the automation object.