This page is a
translated version of the page
Server API and the translation is 100% complete.
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()
-
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) {});
driver
|
IR.GetServer()
|
type: object link to iRidium Server driver
|
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
*The function is outdated and does not fulfill what is stated in it, left for compatibility. At the moment, the server starts any panel, regardless of the presence of a 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) {});
driver
|
IR.GetServer()
|
type: object link to iRidium Server driver
|
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!)
|
Name
|
DESKTOP-1
|
type: string name of a device where a panel was connected to a server
|
Model
|
Windows 6.2 build 9200 sp 0.0
|
type: string model of a device where a panel was connected to a server
|
Producer
|
Microsoft Windows 8 x64
|
type: string operation system of a device where a panel was connected to a server.
|
Version
|
0.0.3
|
type: string OS version of a device where a panel was connected to a server
|
Group
|
2
|
type: number group of client that connects to the server
|
Channel
|
1
|
type: number variables that can be controlled
|
Tags
|
1
|
type: number variables from which feedback can be received.
|
Sample
IR.AddListener(IR.EVENT_AUTHORIZE, IR.GetServer(), function (ID, ObjectId, Login, ProjectName, HWID, in_oFullInfo)
{
var time = IR.GetVariable("System.Time.24");
IR.Log("Client Authorized: " + time + ", " + ID + " " + ObjectId + " " + Login + " " + ProjectName + " " + HWID)
IR.Log(JSON.Stringify(in_oFullInfo))
});
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) {});
driver
|
IR.GetServer()
|
type: object link to iRidium Server driver
|
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);
});
IR.EVENT_SCHEDULE_EVENT_CHANGE
start or end event of any event in the schedule. The event is available only on the server.
Syntax
IR.AddListener(IR.EVENT_SCHEDULE_EVENT_CHANGE, 0, function(scheduleName, eventName, status){}, [pointer]);
function(){}
|
function(){}
|
type: function an unnamed function or a function call
|
pointer
|
-
|
type: object a pointer to an object that services a function (optional)
|
scheduleName
|
'Schedule 1'
|
type: string schedule name
|
eventName
|
'Event N'
|
type: string event name
|
status
|
1
|
type: number states of an event: 1 - IR.SCHEDULE_EVENT_STATE_START - it has started, 2 - IR.SCHEDULE_EVENT_STATE_RUN - it is working, 3 - IR.SCHEDULE_EVENT_STATE_FINISH - it has finished.
|
Sample
IR.AddListener(IR.EVENT_SCHEDULE_EVENT_CHANGE, 0, function(scheduleName, eventName, status)
{
if (eventName == "Light" && status == IR.SCHEDULE_EVENT_STATE_START)
{
IR.Log("Light on");
}
if (eventName == "Light" && status == IR.SCHEDULE_EVENT_STATE_FINISH)
{
IR.Log("Light off");
}
if (eventName == "Heating" && status == IR.SCHEDULE_EVENT_STATE_START)
{
IR.Log("Heater on");
}
if (eventName == "Heating" && status == IR.SCHEDULE_EVENT_STATE_FINISH)
{
IR.Log("Heater off");
}
});