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

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

iRidium Server API

The unique functions, methods and properties that can be used in iRidium Server project (*.sirpz)

Methods

IR is a global object that includes all the functions and constants of iRidium API. All the methods that can be used an IR object includes.

IR.GetServer

This method works only in Server project (*.sirpz). It can be used to work with internal variables of iRidium server available for control panels. You can call the variable using the full name. The method returns the object that you can use to call the methods from this list: IR.GetDevice.

Syntax

IR.GetServer()

input value description

-

output
Object [object DevicePrototype] type: Object
link to the driver object


Sample

var server = IR.GetServer();  // [object DevicePrototype]
 
server.Set("Virtual 1", 1);    // set 1 to Virtual Channel
server.Set("KNX.Address 1", 1);    // set 1 to the Address of KNX driver
 
IR.AddListener(IR.EVENT_TAG_CHANGE , IR.GetServer(), function(name,value)
{
   if (name == "KNX.Address 1")	IR.Log("KNX Address Changed");
   if (name == "Virtual 1")	IR.Log("Virtual Tag Changed");
});

works only in server project (*.sirpz)
The method returns the object that you can use to call the methods from this list: IR.GetDevice.


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



Example:

// functions 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_ACCEPT

the identifier of event that fires when trying to connect to iRidium Server. It will the network settings of control panel that tried to connect to the Server. Then the control panel starts authorizing on Server. If the authorization is OK, the IR.EVENT_AUTHORIZE fires. This event means that the panel successfully authorized. The data received from ACCEPT and AUTHORIZE events gives the compleat information about panel. This events can be related via ID property - the identifier of connection.

Syntax

IR.AddListener(IR.EVENT_ACCEPT, IR.GetServer(), function (ID, LocalIP, LocalPort, HostIP, HostPort) {});

input value description
driver IR.GetServer() type: object
link to iRidium Server driver
output
ID 1 type: string
the serial number of control panel in the list of connections (from 1)
LocalIP 192.168.0.100 type: string
local host of control panel
LocalPort 30464 type: string
port on control panel opened to receive the data from server
HostIP 192.168.0.100 type: string
IP-address of remote system from where the panel connected to server
HostPort 30464 type: string
the external port of remote system opened to receive the data from server


Sample

IR.AddListener(IR.EVENT_ACCEPT, IR.GetServer(), function (ID, LocalIP, LocalPort, HostIP, HostPort)
{
    var time = IR.GetVariable("System.Time.24");
    IR.Log("Accept Client: "+time+", "+ID+", "+LocalIP+", "+LocalPort+", "+HostIP+", "+HostPort);
});





IR.EVENT_AUTHORIZE

*Function is under development. Server allows connection for any panel regardless of the password*
the identifier of event that fires when the control panel successfully authorized on iRidium Server. This event fires after IR.EVENT_ACCEPT and returns information about panel: connection ID, HWID of control panel, user's login, the identifier of Object and the name of visualization project started on panel. The combination of data received from ACCEPT and AUTHORIZE events gives the full information about control panel. To associate these two events, use the ID - identifier of the connection.

Syntax

IR.AddListener(IR.EVENT_AUTHORIZE, IR.GetServer(), function (ID, ObjectId, Login, ProjectName, HWID) {});

input value description
driver IR.GetServer() type: object
link to iRidium Server driver
output
ID 1 type: string
the serial number of control panel in the list of connections
ObjectId 7071 type: number
the ID of the automation object in the iRidium Cloud, from which the control panel loaded the project
Login user@my.mail type: string
the login of the user logged on the control panel
ProjectName Project Home type: string
the name of the visualization project runs on the control panel
HWID 69538...a7acf type: string
the unique identifier of the control panel (sometimes it may change, do not use the HWID as a permanent identifier of the panel!)


Sample

IR.AddListener(IR.EVENT_AUTHORIZE, IR.GetServer(), function (ID, ObjectId, Login, ProjectName, HWID)
{
    var time = IR.GetVariable("System.Time.24");
    IR.Log("Client Authorized: "+time+", "+ID+" "+ObjectId+" "+Login+" "+ProjectName+" "+HWID)
});





IR.EVENT_RELEASE

the identifier of event that fires when the i3 pro disconnecting from Server and receive the information about this panel

Syntax

IR.AddListener(IR.EVENT_RELEASE, IR.GetServer(), function (ID, LocalIP, LocalPort, HostIP, HostPort) {});

input value description
driver IR.GetServer() type: object
link to iRidium Server driver
output
ID 1 type: string
the serial number of control panel in the list of connections (from 1)
LocalIP 192.168.0.100 type: string
local host of control panel
LocalPort 30464 type: string
port on control panel opened to receive the data from server
HostIP 192.168.0.100 type: string
IP-address of remote system from where the panel connected to server
HostPort 30464 type: string
the external port of remote system opened to receive the data from server


Sample

IR.AddListener(IR.EVENT_RELEASE, IR.GetServer(), function (ID, LocalIP, LocalPort, HostIP, HostPort)
{
    var time = IR.GetVariable("System.Time.24");
    IR.Log("Release Client: "+time+", "+ID+", "+LocalIP+", "+LocalPort+", "+HostIP+", "+HostPort);
});