Содержание
- 1 General description
- 1.1 Module
- 1.1.1 module.GetSubDevice
- 1.1.2 module.AddSubDevice
- 1.1.3 module.DeleteSubDevice
- 1.1.4 module.CreateDevice
- 1.1.5 module.GetDevice
- 1.1.6 module.GetSubDevices
- 1.1.7 module.GetPopup
- 1.1.8 module.ShowPopup
- 1.1.9 module.HidePopup
- 1.1.10 module.ClonePopup
- 1.1.11 module.GetVariable
- 1.1.12 module.SetVariable
- 1.1.13 module.AddRelation
- 1.1.14 module.RemoveRelation
- 1.1.15 module.GetProperty
- 1.1.16 module.SetProperty
- 1.1.17 module.GetProperties
- 1.1.18 module.AddListener
- 1.1.19 module.RemoveListener
- 1.1.20 module.SetInterval
- 1.1.21 module.ClearInterval
- 1.1.22 module.SetTimeout
- 1.1.23 module.CreateEffect
- 1.1.24 module.CreateItem
- 1.1.25 module.Import
- 1.1.26 module.GetDeviceSetup
- 1.1.27 module.GetDeviceSetups
- 1.1.28 module.SaveCache
- 1.1.29 module.LoadCache
- 1.1.30 module.CreateImage
- 1.1.31 module.GetText
- 1.1.32 Module property
- 1.2 Subdevices
- 1.2.1 SubDevice.Connect
- 1.2.2 SubDevice.Disconnect
- 1.2.3 SubDevice.Send
- 1.2.4 SubDevice.SendEx
- 1.2.5 SubDevice.GetCookies
- 1.2.6 SubDevice.SetCookie
- 1.2.7 SubDevice.Set
- 1.2.8 SubDevice.SetParameters
- 1.2.9 SubDevice.InvokeAction
- 1.2.10 SubDevice.Subscribe
- 1.2.11 SubDevice.Unsubscribe
- 1.2.12 SubDevice.GetFeedback
- 1.2.13 SubDevice.GetLogin
- 1.2.14 SubDevice.GetPassword
- 1.2.15 SubDevice.AddChannel
- 1.2.16 SubDevice.DeleteChannel
- 1.2.17 SubDevice.AddTag
- 1.2.18 SubDevice.DeleteTag
- 1.2.19 SubDevice.AddWidget
- 1.2.20 SubDevice.GetWidget
- 1.2.21 SubDevice.DeleteWidget
- 1.2.22 SubDevice.AddVirtualTag
- 1.2.23 SubDevice.DeleteVirtualTag
- 1.2.24 SubDevice.GetVirtualTag
- 1.2.25 SubDevice.GetVirtualTags
- 1.2.26 SubDevice.AddDataRequestHandler
- 1.2.27 SubDevice.GetDataRequests
- 1.2.28 SubDevice.AddAction (working via a function)
- 1.2.29 SubDevice.AddAction (without a function)
- 1.2.30 SubDevice.DeleteAction
- 1.2.31 SubDevice.GetAction
- 1.2.32 SubDevice.AddEvent (working without a function)
- 1.2.33 SubDevice.AddEvent (working via a function)
- 1.2.34 SubDevice.DeleteEvent
- 1.2.35 SubDevice.GetEvent
- 1.2.36 SubDevice.AddCondition (working via a function)
- 1.2.37 SubDevice.AddCondition (working without a function)
- 1.2.38 SubDevice.DeleteCondition
- 1.2.39 SubDevice.GetCondition
- 1.2.40 SubDevice.AddSettingsFunction
- 1.2.41 SubDevice.RunAction
- 1.2.42 SubDevice.SetProperty
- 1.2.43 SubDevice.GetProperty
- 1.2.44 SubDevice.GetProperties
- 1.2.45 SubDevice.DiscoverServices
- 1.2.46 SubDevice.GetServices
- 1.2.47 SubDevice.ReadCharacteristic
- 1.2.48 SubDevice.WriteCharacteristic
- 1.2.49 SubDevice.SetCharacteristicNotification
- 1.2.50 Subdevice properties
- 1.2.51 Types of complicated actions, events, conditions
- 1.3 Widget
- 1.4 List
- 1.4.1 List.AddItem
- 1.4.2 List.Clear
- 1.4.3 List.GetState
- 1.4.4 List.MoveItem
- 1.4.5 List.GetItemByName
- 1.4.6 List.GetItemByCustomID
- 1.4.7 List.GetItemByIndex
- 1.4.8 List.GetItemPositionByName
- 1.4.9 List.GetItemPositionByCustomID
- 1.4.10 List.GetSelected
- 1.4.11 List.DeleteItemByName
- 1.4.12 List.DeleteItemByCustomID
- 1.4.13 List.DeleteItemByIndex
- 1.4.14 List.DeleteItemsByName
- 1.4.15 List.DeleteItemsByCustomID
- 1.4.16 List.GetItemsByName
- 1.4.17 List.GetItemsByCustomID
- 1.4.18 List.ClearSelected
- 1.4.19 List.SelectByIndex
- 1.4.20 List.StartReleaseActionByIndex
- 1.4.21 List.ScrollByName
- 1.4.22 List.ScrollByCustomID
- 1.4.23 List.ScrollByIndex
- 1.4.24 List.ScrollToStart
- 1.4.25 List.ScrollToEnd
- 1.4.26 List.SetSelectFunction
- 1.4.27 List.SetDataFilter
- 1.4.28 List.ApplyDataFilter
- 1.4.29 List.ClearDataFilter
- 1.4.30 List.DeleteDataFilter
- 1.4.31 List properties
- 1.5 List item
- 1.6 Events
- 1.7 Setup object
- 1.8 Properties of a virtual tag
- 1.9 Types of keyboards
- 1.10 Module example
- 1.1 Module
General description
Principles of working with modules are identical to the principles of working with projects in i3 pro excluding methods and and properties described below. When a module is developed new notions appear "Module", "Subdevice", "Module properties ". Parameters described in the methods in brackets are not obligatory.
Module
This section describes methods and properties for working with modules. By default a developer can get access to module methods and properties by refering to the module variable.
module.GetSubDevice
get a subdevice by the name or ID
Syntax
module.GetSubDevice(Name)
input | sample | description |
Name | "SubDevice 1" | type: string Subdevice name |
output |
Object | type: Object Subdevice object |
Example:
var SubDevice = module.GetSubDevice("SubDevice 1");
Access to a subdevice can be received via ID. To do it, indicate the required ID of a subdevice as the input parameter.
module.AddSubDevice
Creating a subdevice with the help of script
Syntax
module.AddSubDevice(SystemName, [Device], [System], [Type], [Tags], [Name], [Callback])
input | sample | description |
SystemName | "SubDevice 1" | type: string Subdevice system name |
Device | type: Object a driver to which a subdevice will be assigned |
System | false | type: boolean old parameter, "false" is to be used |
Type | 1 | type: number type of smart device. Parameter is under development |
Tags | type: Array Array of virtual tag objects |
Name | "SubDevice 1" | type: string subdevice name that is displayed to the user |
Callback | function(){do somethings} | type: function a function that is on till the IR.EVENT_ADD_SUBDEVICE event happens. |
output |
Object | type: Object Subdevice object |
Example:
var SubDevice = module.GetSubDevice("SubDevice 1");
module.DeleteSubDevice
Delete subdevice
Syntax
module.DeleteSubDevice(ID)
input | sample | description |
ID | 1 | type: number Subdevice ID |
output |
Boolean | type: Boolean Result (true, false) |
Example:
var l_oSubDevice = module.GetSubDevice("SubDevice 1"); module.DeleteSubDevice(l_oSubDevice.ID); //deleting a subdevice
module.CreateDevice
Create driver from script. You can create only AV&Custom Systems and BLE driver form script. Other drivers you should add from database
Syntax
module.CreateDevice(Type, Name, Options)
input | sample | description |
Type | IR.DEVICE_CUSTOM_TCP | type: Number driver type |
Name | "AV Driver 1" | type: String unique driver name |
Options | Host: '192.168.0.47', Port: 80 | type: Object driver parameters |
output |
Object | [object DevicePrototype] | type: Object link to the driver as to an object |
Example:
var Device = module.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(Device); // [object DevicePrototype]
the set of parameters is different for different drivers
if the parameter is not given in the list, its value is set by default (i.e. when a driver is created only Host and Port can be given)
if you create a driver not at the app launch but later, call Connect() method for this driver for it to connect to equipment. Drivers created at the app launch connect automatically. If required, they can be disconnected using the following method .Disconnect()
module.GetDevice
Get device
Syntax
module.GetDevice(Name)
input | sample | description |
Name | "Device 1" | type: string Device name |
output |
Object | type: Object Subdevice object |
Example:
var Device = module.GetDevice("Device 1");
module.GetSubDevices
Get subdevices list
Syntax
module.GetSubDevices()
input | sample | description |
- | - | type: - - |
output |
Array | type: Array Array of subdevices |
Example:
var SubDevices = module.GetSubDevices();
module.GetPopup
Get a popup from module
Syntax
module.GetPopup(Name)
input | sample | description |
Name | "Popup 1" | type: string Popup name |
output |
Object | type: Object Popup object |
Example:
var Popup = module.GetPopup("Popup 1");
module.ShowPopup
Get a popup from module
Syntax
module.ShowPopup(Name, [GroupEffectNumber])
input | sample | description |
Name | "Popup 1" | type: string Popup name |
GroupEffectNumber | 1000 | type: number Number of effect group (optional) |
output |
Boolean | type: Boolean Result (true, false) |
Example:
module.ShowPopup("Popup 1");
module.HidePopup
Hide a popup from module
Syntax
module.HidePopup(Name, [GroupEffectNumber])
input | sample | description |
Name | "Popup 1" | type: string Popup name |
GroupEffectNumber | 1000 | type: number Number of effect group (optional) |
output |
Boolean | type: Boolean Result (true, false) |
Example:
module.HidePopup("Popup 1");
module.ClonePopup
Clone a popup
Syntax
module.ClonePopup(Popup, ClonePopupName)
input | sample | description |
Popup | Popup | type: Object Object of original popup |
ClonePopupName | "ClonePopup" | type: string The name of cloned popup |
output |
Object | type: Object Object of the cloned popup on the basis of the original one |
Example:
var Popup = module.GetPopup("Popup 1") var ClonePopup = module.ClonePopup(Popup, "ClonePopup");
The name of the cloned popup must be different from the name of the original popup
module.GetVariable
Get a global variable
Syntax
module.GetVariable(Path.Name)
input | sample | description |
Path | Tokens | type: string shows the path to the variable and its type:
|
Name | Update | type: string Variable name |
output |
Value | true | type: string, number Variable value |
Example:
// System Tokens var tag1 = module.GetVariable("System.Update"); // Project Tokens var tag2 = module.GetVariable("Global.My Var 1"); // Driver Tokens var tag3 = module.GetVariable("Drivers.AV & Custom Systems (TCP).Online"); var tag4 = module.GetVariable("Drivers.AV & Custom Systems (TCP).Channel 1"); // GUI Tags var tag5 = module.GetVariable("UI.Page 1.Text"); var tag6 = module.GetVariable("UI.Page 1.Item 1.Value");
module.SetVariable
Set the global varibale
Syntax
module.SetVariable(Path.Name, Value)
input | sample | description |
Path | Tokens | type: string shows the way to the variable and its type
|
Name | "Name" | type: string Variable name |
Value | 1 | type: string, number Set value |
output |
-
Example:
module.SetVariable("Global.Name", "Name")
module.AddRelation
Create a connection between properties. Properties that can be parts of connections are: properties of graphic items, token values, values of driver feedback channels
Syntax
module.AddRelation(LHSName, RHSName)
input | sample | description |
LHSName | "Drivers.HDL-BUS Pro Network (UDP).HDL-MC48IPDMX.231:channel" | type: string Full path to first property |
RHSName | "UI.Dimmer.Level.Value" | type: string Full path to second property |
output |
Boolean | true | type: Boolean The result of creating a connection |
Example:
module.AddRelation("Drivers.HDL-BUS Pro Network (UDP).HDL-MC48IPDMX.231:channel", "UI.Dimmer.Level.Value"); // creates relation between the feedback and the value of dimmer
Learn the full path to the property with the help of Relations in the studio.
module.RemoveRelation
Delete connection between properties. Properties that can be parts of connection are: graphic item properties, token values, values of driver feedback chanels.
Syntax
module.RemoveRelation(LHSName, RHSName)
input | sample | description |
LHSName | "Drivers.HDL-BUS Pro Network (UDP).HDL-MC48IPDMX.231:channel" | type: string Full path to first property |
RHSName | "UI.Dimmer.Level.Value" | type: string Full path to second property |
output |
Boolean | true | type: Boolean Result of deleting a connection |
Example:
module.RemoveRelation("Drivers.HDL-BUS Pro Network (UDP).HDL-MC48IPDMX.231:channel", "UI.Dimmer.Level.Value");
Learn the full path to the property with the help of Relations in the studio.
module.GetProperty
Get a module property
Syntax
module.GetProperty(Name)
input | sample | description |
Name | "Property 1" | type: string Property name |
output |
Value | type: string Property value |
Example:
var Property = module.GetProperty("Property 1");
module.SetProperty
Add or refresh module property
Syntax
module.SetProperty(Name, Value)
input | sample | description |
Name | "Property 1" | type: string Property name |
Value | "Value" | type: string Value |
output |
-
Example:
module.SetProperty("Property 1", "Value");
This property is displayed in i3 lite in Module preferences
module.GetProperties
Get an object with properties
Syntax
module.GetProperties()
input | sample | description |
-
output |
Object | {Name: Value} | type: Object Object with properties
|
Example:
var Properties = module.GetProperties();
module.AddListener
Add an event handler
Syntax
module.AddListener(EventType, EventParent, Listener, [Pointer])
input | sample | description |
EventType | IR.EVENT_MODULE_START | type: number Event ID that a listener listens |
EventParent | module.GetPopup("Popup 1").GetItem("Item 1") | type: Object The input parameter that is required to create a listener. If there is no parameter, use 0 |
Listener | function(){...} | type: Function An unnamed fucntion or a link to a named function in which actions are done |
Pointer | type: Object Pointer to an object that services a fucntion (optional) |
output |
Boolean | true | type: Boolean The result of adding a handler |
Example:
module.AddListener(IR.EVENT_ITEM_PRESS,module.GetPopup("Popup 1").GetItem("Item 1"),function() { IR.Log("Item 1 pressed"); });
Events for a listener can be seen here ссылка
module.RemoveListener
Deleting an event handler
Syntax
module.RemoveListener(EventType, EventParent, Listener)
input | sample | description |
EventType | IR.EVENT_MODULE_START | type: number Event ID that a listener listens |
EventParent | module.GetPopup("Popup 1").GetItem("Item 1") | type: Object The input parameter that is required to create a listener. If there is no parameter, use 0. |
Listener | function(){...} | type: Function An unnamed fucntion or a link to a named function in which actions are done |
output |
Boolean | true | type: Boolean The result of deleting a handler |
Example:
module.RemoveListener(IR.EVENT_ITEM_PRESS,module.GetPopup("Popup 1").GetItem("Item 1"),function() { IR.Log("Item 1 pressed"); });
Events for a listener can be seen here ссылка
module.SetInterval
Creating a cyclic function
Syntax
module.SetInterval(Delay, Function, [This])
input | sample | description |
Delay | 1000 | type: number Delay(in milliseconds) |
Function | function(){...} | type: Function An unnamed fucntion or a link to a named function in which actions are done |
This | type: Object Pointer to an object that services a fucntion (optional) |
output |
Number | 1 | type: Number interval id |
Example:
var Interval = module.SetInterval(1000, function(){ IR.Log("Hello, world!"); });
module.ClearInterval
Deleting a cyclic function
Syntax
module.ClearInterval(ID)
input | sample | description |
ID | 1 | type: number interval id |
output |
Boolean | true | type: Boolean The result of deleting a cyclic function |
Example:
var Interval = module.SetInterval(1000, function(){ IR.Log("Hello, world!"); }); module.ClearInterval(Interval);
module.SetTimeout
Functions call with delay
Syntax
module.SetTimeout(Delay, Function, [This])
input | sample | description |
Delay | 1000 | type: number Delay(in milliseconds) |
Function | function(){...} | type: Function An unnamed fucntion or a link to a named function in which actions are done |
This | type: Object Pointer to an object that services a fucntion (optional) |
output |
Number | 1 | type: Number interval id |
Example:
var Timeout = module.SetTimeout(1000, function(){ IR.Log("Hello, world!"); });
module.CreateEffect
Create an animation effect during the app work and use it when showing and hiding a popup.
Syntax
var name = module.CreateEffect(Type)
input | sample | description |
name | name | type: string Variable name to save a group of effects is requiered to assign a number and other parameters to the group |
Type | IR.EFFECT_FADE | type: Object Effect type |
output |
Object | [Object EffectPrototype] | type: Object Link to a group of animation effects |
Example:
var Fade = module.CreateEffect(IR.EFFECT_FADE); // create group and save it in variable Fade.Group = 1000; // asign a number to a group Fade.Delay = 0; // delay before doing an effect Fade.Duration = 400; // effect duration Fade.Tween = 0; // a formula to calculate an effer (tweener) module.ShowPopup("Popup 1", 1000) // show a popup with effects of group 1000
Effects:
- IR.EFFECT_FADE - smoth appearing / disappearing
- IR.EFFECT_ROTATE - rotation, the center of rotation is the middled of the popup
- IR.EFFECT_SCALE - zooming in / zooming out
- IR.EFFECT_SLIDE - moving from side to side
- IR.EFFECT_TVSCAN - horizontal squeezing
Effects properties:
- Group (число) - The number of effer group where the effect is located. It it recommended to use numbers of effect groups starting with 1000. It will prevent them from mixing up with effect groups created by the studio. If you want to add dynamically created effects to effect groups creted in the studio, use it deliberatelly.
- Delay (число, мс) - Delay before doing an effect
- Duration (число, мс) - effect duration;
- Tween (число) - Calculation formula
module.CreateItem
Creating a dialogue item
Syntax
module.CreateItem(Type, Name, X, Y, Width, Height)
input | sample | description |
Type | IR.ITEM_BUTTON | type: Number Type of graphic item |
Name | "Button 1" | type: string Item name, unique for a popup |
X | 30 | type: Number Axis X coordinate |
Y | 40 | type: Number Axis Y coordinate |
Width | 800 | type: Number Element width |
Height | 150 | type: Number Element height |
output |
Object | [Object DialogItemPrototype] | type: Object Example of a graphic object |
Example:
var src = module.CreateItem(IR.ITEM_BUTTON,"Button 1",30,40,800,150); IR.Log(src) // [Object DialogItemPrototype]
Types of graphic items created via module.CreateItem:
- IR.ITEM_POPUP - popup (Popup)
To create a dialogue item on a concrete popup, use CreateItem to the popup link
var src = module.GetPopup("Popup 1").CreateItem(IR.ITEM_BUTTON,"Button 1",30,40,800,150); IR.Log(src) // [Object DialogItemPrototype]
Types of graphic items created via Popup.CreateItem:
- IR.ITEM_BUTTON - button (Button)
- IR.ITEM_TRIGGER_BUTTON - trigger button (Trigger Button)
- IR.ITEM_MUTI_STATE_BUTTON - animated button (Multistate Button)
- IR.ITEM_UPDOWN_BUTTON - up/down button (Up/Down Button)
- IR.ITEM_LEVEL - level (Level)
- IR.ITEM_MUTI_STATE_LEVEL - animated level (Multistate Level)
- IR.ITEM_EDIT_BOX - edit box (EditBox)
- IR.ITEM_VIRTUAL_KEY_BUTTON - virtual key (Virtual Key)
- IR.ITEM_JOYSTICK - joystick (Joystick)
- IR.ITEM_PICKER - drum
Creating IR.ITEM_PICKER has the following construction:
Syntax
Popup.CreateItem(Type, Name, Parameters)
input | sample | description |
Type | IR.ITEM_PICKER | type: Number graphic element type |
Name | "Picker 1" | type: string element name, unique for popup |
Parameters | - | type: Object There are two variants of parameters. The first is {X: Number, Y: Number, Min: Number, Max: Number, VisibleCount: Number, Template: Popup}, Второй: {X: Number, Y: Number, Items: Array, VisibleCount: Number, Template: Popup |
output |
Object | [Object DialogItemPrototype] | type: Object Example of a graphic object |
Example:
var Template = module.GetPopup("Template"); var Popup = module.GetPopup("Popup 1"); //Создание IR.ITEM_PICKER с Parameters v1 var Picker_1 = Popup.CreateItem(IR.ITEM_PICKER, "Picker_1", { X: 30, //Axis X coordinate Y: 40, //Axis Y coordinate Min: 1, //The initial value of an item picker Max: 31, //The final value of an item picker VisibleCount: 3, //The number of displayed values Template: Template //Template for an item picker }); var Value = Picker_1.Value; //getting item picker value Picker_1.Position = 10; //setting th position for an item picker //Создание IR.ITEM_PICKER с Parameters v2 var DayOfWeek = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]; var Picker_2 = Popup.CreateItem(IR.ITEM_PICKER, "Picker_2", { X: 30, Y: 40, Items: DayOfWeek, //array of value VisibleCount: 3, Template: Template }); var Value = Picker_2.Value; //get drum value Picker_2.Position = 3; //set drum position
VisibleCount field must contain only odd numbers!
module.Import
Import of an object with classes from a module file
Syntax
module.Import(FileName)
input | sample | description |
FileName | "GUI.js" | type: string File name with js resolution |
output |
Object | type: Object Object with classes |
Example:
//Name_1.js - first js file this.Text = "Hello, world!"; //Pointer to a text variable //Name_2.js - second js file var Text = module.Import("Name_1.js").Text; //Impor an object with a pointer to a text variable from the first js file IR.Log(Text); //"Hello, world!" //log the text variable
module.GetDeviceSetup
Get data, set in the driver
Syntax
module.GetDeviceSetup(DeviceName)
input | sample | description |
DeviceName | "Device 1" | type: string Device name |
output |
Object | type: Object Object with data set in the driver |
Example:
var SetupData = module.GetDeviceSetup("Device 1");
module.GetDeviceSetups
Get all data set in all drivers
Syntax
module.GetDeviceSetups()
input | sample | description |
-
output |
Array | type: Array Array of data objects set in drivers |
Example:
var SetupsData = module.GetDeviceSetups();
module.SaveCache
Save the module cache
Syntax
module.SaveCache(Value)
input | sample | description |
SaveCache | "1" | type: string Value |
output |
-
Example:
module.SaveCache("1");
module.LoadCache
Download module cache
Syntax
module.LoadCache()
input | sample | description |
-
output |
String | type: String Value, saved in the cache |
Example:
var CacheData = module.LoadCache();
module.CreateImage
Create a dynamic image with a given set of parameters. If not all parameters of an image are indicated, the missed parameters are taken by default or keep the previous value. The image is created without a connection to a graphic item, it can be used on different popups when called by the name. The name of a created image unlike other properties, can not be changed.
Syntax
module.CreateImage(Name, Param);
input | sample | description |
Name | "Camera 1" | type: String name of a dynamic image (cameras) |
Param | type: Object set of properties of a dynamic image
|
output |
Object | [object ImagePrototype] | type: Object example of a graphic object (image) |
Example:
// Create image module.CreateImage("Camera 1", {URI: "http://login:pass@host:port/file", Refresh: 0, Demuxer: '', ProbeSize: 0, Param: '', Audio: false, ScaleWidth: 640, ScaleHeight: 480 }); // Get image var l_oImage = module.GetImage("Camera 1"); IR.Log(l_oImage) // [object ImagePrototype] // Get image properties IR.Log(l_oImage.URI) // http://login:pass@host:port/file // Setup image (set image properties) l_oImage.URI = "http://login:pass@host:port/file"; l_oImage.Refresh = 0; l_oImage.Demuxer = ''; l_oImage.ProbeSize = 0; l_oImage.Param = ''; l_oImage.Audio = false; l_oImage.ScaleWidth = 1024; l_oImage.ScaleHeight = 768; // Link image to Item module.GetPopup("Popup 1").GetItem("Item 1").GetState(0).Image = module.GetImage("Camera 1"); module.GetPopup("Popup 2").GetItem("Item 2").GetState(0).Image = l_oImage;
module.GetText
Get the localization of your text, used in the module.
Syntax
module.GetText(Text)
input | sample | description |
Text | "Time" | type: string Текст, used on a graphic item |
output |
string | type: string Returns localized text |
Example:
var l_oText = module.GetText("Time"); module.GetPopup("Popup 1").GetItem("Item 1").Text = l_oText;
Module property
module.property
Name | "HDL Relay" | type: String module name |
ID | 1 | type: Number module ID |
Icon | type: String module icon |
Used | true | type: Boolean a flag that a module is used |
Hidden | false | type: Boolean flag of a hidden module |
Smart | false | type: Boolean feature of an intellectual module |
StoreID | 102 | type: Number module ID in the store |
SubDeviceCount | 3 | type: Number Number of subdevices |
Version | 1.0.4 | type: String Module version |
SetupCount | 2 | type: Number Number of objects with settings date for drivers |
SubDeviceGroupCount | 2 | type: Number Number of objects of subdevice groups |
SettingsPopupName | "SettingsPopup 1" | type: String Name of a setting popup for a module. A setting popup is created by a module developer to provide its work, if required. |
AuthorizationPopupName | "AuthorizationPopup 1" | type: String authorization popup. It provide the work of modules requiring authorization. It is created by a module developer. |
AuthorizationStatus | true | type: Boolean authorization flag. When developing a module requiring authorization, indicate authorization status.
|
WorkMode | type: Number Mode of module work (panel, server) Constants:
|
ServerSupport | false | type: Boolean work with a server support of a module |
Subdevices
This section describes methods and properties to work with subdevices. A subdevice object in this section is looked upon as SubDevice variable.
SubDevice.Connect
Connection to a device in a subdevice
Syntax
SubDevice.Connect()
input | sample | description |
-
output |
-
Example:
var l_oDevice = module.GetDevice("Device 1"); //Getting a device var l_oSubDevice = module.AddSubDevice("SubDevice 1", l_oDevice); //creating a subdevice l_oSubDevice.Connect(); //Connecting to a device
SubDevice.Disconnect
Connection breach to a device in a subdevice
Syntax
SubDevice.Disconnect()
input | sample | description |
-
output |
-
Example:
var l_oDevice = module.GetDevice("Device 1"); //Getting a device var l_oSubDevice = module.AddSubDevice("SubDevice 1", l_oDevice); //creating a subdevice l_oSubDevice.Disconnect(); //Disconnecting from a device
SubDevice.Send
The method can be used only with AV & Custom Systems and Global Cache drivers. It allows to send a random set of data (string, number, array) to equipment
Syntax
SubDevice.Send(DataString)
SubDevice.Send(DataArray)
SubDevice.Send(DataString, Transport)
input | sample | description |
DataString | a, b, c | type: string list of variables or stings: instructions to send |
DataArray | [a, b, c] | type: array array of variables or stings: instructions to send |
Transport | 0 | type: number Global Cache trabsport ID via which data are sent:
|
output |
-
Example:
// AV & Custom Systems (TCP, UDP, RS232) var l_oDevice = module.GetDevice("AV Device"); //Getting a device var l_oSubDevice = module.AddSubDevice("SubDevice 1", l_oDevice); //creating a subdevice l_oSubDevice.Send(['instruction', '\r\n']);
// AV & Custom Systems (HTTP) // <Type or request>,<URI>,<Data> devided by "," so u cannot use "," inside of <URI> and <Data> var l_oDevice = module.GetDevice("AV Device"); //Getting a device var l_oSubDevice = module.AddSubDevice("SubDevice 1", l_oDevice); //creating a subdevice l_oSubDevice.Send(['GET,URI']); // GET l_oSubDevice.Send(['POST,URI,Data']); // POST l_oSubDevice.Send(['PUT,URI,Data']); // PUT
// Global Cache: // IR.GetDevice("Global Cache").Send(<DATA>, <TRANSPORT ID>) var l_oDevice = module.GetDevice("Global Cache"); //Getting a device var l_oSubDevice = module.AddSubDevice("SubDevice 1", l_oDevice); //creating a subdevice l_oSubDevice.Send(['setstate,1:1,1', '\r\n'], 0)
HTTP: When a command is sent to HTTP driver, indicate at the beginning the sending method: GET, POST, PUT, indicate URI commands and Data separated by commas for POST and PUT. No commas inside URI and Data are possible. If your protocol uses commas in HTTP commands, send them via AV & Custom Systems (TCP), forming whole requests.
Global Cache: indicate the tranport ID where data must be sent
SubDevice.SendEx
The method can be used only with AV & Custom Systems (HTTP) drivers. It allows to send to equipment a data array with a pointer to a parent object (execution context). A number or events can be added inside SendEx that send data about their work to functions. Events allow to track getting data from HTTP server and process different stages of work with a server.
Syntax
SubDevice.SendEx(Data, Object)
input | sample | description |
Data | [a, b, c] | type: array data array to send |
Object | this | type: Object parent object |
output |
-
Example:
var l_oDevice = module.GetDevice("Server REST"); //Getting a device var l_oSubDevice = module.AddSubDevice("SubDevice 1", l_oDevice); //creating a subdevice l_oSubDevice.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);} }); l_oSubDevice.SendEx({ Type: "GET", Url: "/json/ok/server/channel", Headers: {"Cookie":"ir-session-id=o8lKdEvw2ZlU"}, cbReceiveText: function(text, code, headers) {IR.Log("cbReceiveText "+text);} });
SubDevice.GetCookies
Get Cookies array via AV & Custom Systems (HTTP) driver
Syntax
SubDevice.GetCookies()
input | sample | description |
-
output |
Array | type: Array Массив Cookies |
Example:
var l_oDevice = module.GetDevice("Device 1"); //Getting a device var l_oSubDevice = module.AddSubDevice("SubDevice 1", l_oDevice); //creating a subdevice var l_aCookies = l_oSubDevice.GetCookies();
SubDevice.SetCookie
It sends Coockies with other header information via AV & Custom Systems (HTTP) driver
Syntax
SubDevice.SetCookie(Key, Value)
input | sample | description |
Key | type: String Key |
Value | type: String Value |
output |
Boolean | type: Boolean Sending success |
Example:
var l_oDevice = module.GetDevice("Device 1"); //Getting a device var l_oSubDevice = module.AddSubDevice("SubDevice 1", l_oDevice); //creating a subdevice var l_aCookies = l_oSubDevice.SetCookie("TestCookie", "value");
SubDevice.Set
Setting a value to a device channel
Syntax
SubDevice.Set(ChannelID, Value)
input | sample | description |
ChannelID | "Channel 1" | type: String, Number Index or command name |
Value | 100 | type: String, Number Number or string to send to a command to send to equipment |
output |
Boolean | type: Boolean Success |
Example:
//KNX. 0 - first Commands in project Tree; 100 - value to send, "Dimming" - command name var l_oDevice = module.GetDevice("KNX Router (KNXnet/IP)"); //Getting a device var l_oSubDevice = module.AddSubDevice("SubDevice 1", l_oDevice); //creating a subdevice l_oSubDevice.Set(0, 100); l_oSubDevice.Set("Dimming", 100);
//Global Cahe. "Command 1" - name of command on GC output, "" - empty data var l_oDevice = module.GetDevice("Global Cache"); //Getting a device var l_oSubDevice = module.AddSubDevice("SubDevice 1", l_oDevice); //creating a subdevice l_oSubDevice.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 var l_oDevice = module.GetDevice("HDL-BUS Pro Network (UDP)"); //Getting a device var l_oSubDevice = module.AddSubDevice("SubDevice 1", l_oDevice); //creating a subdevice l_oSubDevice.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 var l_oDevice = module.GetDevice("Domintell Network (UDP)"); //Getting a device var l_oSubDevice = module.AddSubDevice("SubDevice 1", l_oDevice); //creating a subdevice l_oSubDevice.Set("DDIM01:Channel 1", 100);
HDL, Domintell: When addressing, use "HDL-BUS Pro Network (UDP)" / "Domintell Network (UDP)" network name, but not the name of a concrete device in the net.
SubDevice.SetParameters
Setting device parameters
Syntax
SubDevice.SetParameters({Host: host, Port: port, other})
input | sample | description |
host | "192.168.0.100" | type: string IP address of the domain name to connect to equipment |
port | 8080 | type: number connection port |
other | type: - other parameters, characteristic of a driver. If the parameter is not indicates, the previous value or default value is saved |
output |
Boolean | type: Boolean Success |
Example:
var l_oDevice = module.GetDevice("KNX"); //Getting a device var l_oSubDevice = module.AddSubDevice("SubDevice 1", l_oDevice); //creating a subdevice l_oSubDevice.SetParameters({Host: "215.110.10.22", Port: 8080});
Driver properties can be seen here Свойства драйверов
SubDevice.InvokeAction
Sending a command to UPNP device
Syntax
SubDevice.InvokeAction(ActionName, ServiceType, [Arguments, Callback])
input | sample | description |
ActionName | "Play" | type: string command name |
ServiceType | "service:AVTransport:1" | type: string used service |
Arguments | {InstanceID: 0, Speed: 1} | type: string list of command agruments |
Callback | type: function call back function |
output |
Boolean | type: Boolean Success |
Example:
var l_oDevice = module.GetDevice("Sonos"); //Getting a device var l_oSubDevice = module.AddSubDevice("SubDevice 1", l_oDevice); //creating a subdevice l_oSubDevice.InvokeAction("Play", "service:AVTransport:1", {InstanceID: 0, Speed: 1});
SubDevice.Subscribe
Subscription to UPNP events
Syntax
SubDevice.Subscribe(ServiceType)
input | sample | description |
ServiceType | "urn:schemas-upnp-org:service:AVTransport:1" | type: string used service |
output |
Boolean | type: Boolean Success |
Example:
var l_oDevice = module.GetDevice("Sonos"); //Getting a device var l_oSubDevice = module.AddSubDevice("SubDevice 1", l_oDevice); //creating a subdevice l_oSubDevice.Subscribe("urn:schemas-upnp-org:service:AVTransport:1");
SubDevice.Unsubscribe
Unsubscribe from UPNP events
Syntax
SubDevice.Unsubscribe(ServiceType)
input | sample | description |
ServiceType | "urn:schemas-upnp-org:service:AVTransport:1" | type: string used service |
output |
Boolean | type: Boolean Success |
Example:
var l_oDevice = module.GetDevice("Sonos"); //Getting a device var l_oSubDevice = module.AddSubDevice("SubDevice 1", l_oDevice); //creating a subdevice l_oSubDevice.Unsubscribe("urn:schemas-upnp-org:service:AVTransport:1");
SubDevice.GetFeedback
Get value from driver feedback channel
Syntax
SubDevice.GetFeedback(Name)
input | sample | description |
Name | "Feedback 1" | type: string name of driver feedback channel (Feedbacks) |
output |
Value | "data" | type: string, number string or number, received from a feedback channel |
Example:
var l_oDevice = module.GetDevice("MyDevice"); //Getting a device var l_oSubDevice = module.AddSubDevice("SubDevice 1", l_oDevice); //creating a subdevice l_oSubDevice.GetFeedback("Value 1"); // 100
SubDevice.GetLogin
Get the login to connect to any driver
Syntax
SubDevice.GetLogin()
input | sample | description |
-
output |
Login | 'admin' | type: string driver login |
Example:
var l_oDevice = module.GetDevice("MyDevice"); //Getting a device var l_oSubDevice = module.AddSubDevice("SubDevice 1", l_oDevice); //creating a subdevice var l_Login = l_oSubDevice.GetLogin(); IR.Log(l_Login) // admin
SubDevice.GetPassword
Get the password to connect to any driver
Syntax
SubDevice.GetPassword()
input | sample | description |
-
output |
Password | 'admin' | type: string driver password |
Example:
var l_oDevice = module.GetDevice("MyDevice"); //Getting a device var l_oSubDevice = module.AddSubDevice("SubDevice 1", l_oDevice); //creating a subdevice var l_oPass = l_oSubDevice.GetPassword(); IR.Log(l_oPass) // 'admin'
SubDevice.AddChannel
Adding a driver channel
Syntax
SubDevice.AddChannel(Name, DataArray)
input | sample | description |
Name | "Channel 1" | type: string channel name |
DataArray | type: array data array (specific for every driver) |
output |
Boolean | type: Boolean Success |
Example:
var l_oDevice = module.GetDevice("MyDevice"); //Getting a device var l_oSubDevice = module.AddSubDevice("SubDevice 1", l_oDevice); //creating a subdevice l_oSubDevice.AddChannel("Channel 1", [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]);
SubDevice.DeleteChannel
Delete a driver channel
Syntax
SubDevice.DeleteChannel(Name)
input | sample | description |
Name | "Channel 1" | type: string channel name |
output |
Boolean | type: Boolean Success |
Example:
var l_oDevice = module.GetDevice("MyDevice"); //Getting a device var l_oSubDevice = module.AddSubDevice("SubDevice 1", l_oDevice); //creating a subdevice l_oSubDevice.AddChannel("Channel 1", [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]); l_oSubDevice.DeleteChannel("Channel 1"); //Deleting a channel
SubDevice.AddTag
Adding a driver feedback channel
Syntax
SubDevice.AddTag(Name, DataArray)
input | sample | description |
Name | "Feedback 1" | type: string name of feedback channel |
DataArray | type: array data array (specific for every driver) |
output |
Boolean | type: Boolean Success |
Example:
var l_oDevice = module.GetDevice("MyDevice"); //Getting a device var l_oSubDevice = module.AddSubDevice("SubDevice 1", l_oDevice); //creating a subdevice l_oSubDevice.AddTag("Feedback 1", [0x00, 0x00, 0x00, 0x00]);
SubDevice.DeleteTag
Deleting a driver feedback channel
Syntax
SubDevice.DeleteTag(Name)
input | sample | description |
Name | "Feedback 1" | type: string name of feedback channel |
output |
Boolean | type: Boolean Success |
Example:
var l_oDevice = module.GetDevice("MyDevice"); //Getting a device var l_oSubDevice = module.AddSubDevice("SubDevice 1", l_oDevice); //creating a subdevice l_oSubDevice.AddTag("Feedback 1", [0x00, 0x00, 0x00, 0x00]); l_oSubDevice.DeleteTag("Feedback 1"); //Deleting a tag
SubDevice.AddWidget
Add a widget to a subdevice
Syntax
SubDevice.AddWidget(Name)
input | sample | description |
Name | "Popup 1" | type: string Popup name |
output |
Object | type: Object Widget object |
Example:
var l_oSubDevice = module.AddSubDevice("SubDevice 1"); //creating a subdevice var l_oWidget = module.GetPopup("Popup 1"); l_oSubDevice.AddWidget(l_oWidget.Name);
SubDevice.GetWidget
Det a subdevice widget
Syntax
SubDevice.GetWidget(Name)
input | sample | description |
Name | "Popup 1" | type: string widget name |
output |
Object | type: Object Widget object |
Example:
var l_oSubDevice = module.AddSubDevice("SubDevice 1"); //creating a subdevice var l_oWidget = l_oSubDevice.GetWidget("Popup 1");
SubDevice.DeleteWidget
Delete a widget
Syntax
SubDevice.DeleteWidget(ID)
input | sample | description |
ID | 1 | type: number Widget ID |
output |
Boolean | type: Boolean Success |
Example:
var l_oSubDevice = module.AddSubDevice("SubDevice 1"); //creating a subdevice var l_oWidget = l_oSubDevice.GetWidget("Popup 1"); l_oSubDevice.DeleteWidget(l_oWidget.ID); //Deleting a widget
SubDevice.AddVirtualTag
Add a virtual tag
Syntax
SubDevice.AddVirtualTag(Name, Value, [Edit], [smartID], [Hidden])
input | sample | description |
Name | "Tag" | type: String name of a subdevice virtual tag |
Value | "Name" | type: String Tag value |
Edit | true | type: Boolean Permission to edit a tag |
smartID | type: Number Parameter is under development! Set "false" |
Hidden | true | type: Boolean Feature of a hidden tag |
output |
Object | type: Object Object of a virtual tag |
Example:
var l_oSubDevice = module.AddSubDevice("SubDevice 1"); //creating a subdevice var l_oTag = l_oSubDevice.AddVirtualTag("Name", "HDL-BUS", true);
SubDevice.DeleteVirtualTag
Delete a virtual tag
Syntax
SubDevice.DeleteVirtualTag(Name)
SubDevice.DeleteVirtualTag(VirtualTag)
input | sample | description |
Name | "Tag" | type: String name of a device vritual tag |
VirtualTag | type: Object Virtual tag object |
output |
Boolean | type: Boolean Success |
Example:
var l_oSubDevice = module.AddSubDevice("SubDevice 1"); //creating a subdevice var l_oTag = l_oSubDevice.AddVirtualTag("Name", "HDL-BUS", true); l_oSubDevice.DeleteVirtualTag(l_oTag);
SubDevice.GetVirtualTag
Get the device virtual tag
Syntax
SubDevice.GetVirtualTag(Name)
input | sample | description |
Name | "Tag" | type: String name of subdevice virtual tag |
output |
Object | type: Object Virtual tag object |
Example:
var l_oSubDevice = module.AddSubDevice("SubDevice 1"); //creating a subdevice var l_oTag = l_oSubDevice.GetVirtualTag("Tag"); //Getting a virtual tag
SubDevice.GetVirtualTags
Get a subdevice virtual tag
Syntax
SubDevice.GetVirtualTags()
input | sample | description |
-
output |
Array | type: Array Object array of subdevice virtual tags |
Example:
var l_oSubDevice = module.AddSubDevice("SubDevice 1"); //creating a subdevice var l_oTags = l_oSubDevice.GetVirtualTags(); //Getting all virtual tags
SubDevice.AddDataRequestHandler
Add a request to a subdevice
Syntax
SubDevice.AddDataRequestHandler(Name, Type, Callback)
input | sample | description |
Name | "Image" | type: String request name |
Type | type: Number type of request:
|
Callback | type: Function An executed function |
output |
Boolean | type: Boolean Success |
Example:
var l_oDevice = module.GetDevice("MyDevice"); //Getting a device var l_oSubDevice = module.AddSubDevice("SubDevice 1", l_oDevice); //creating a subdevice l_oSubDevice.AddDataRequestHandler("Image", IR.SUB_DEVICE_REQUEST_DINAMIC_IMAGE, function(){ IR.Log("Hello, world!"); });
SubDevice.GetDataRequests
Get all requests of a subdevice
Syntax
SubDevice.GetDataRequests()
input | sample | description |
-
output |
Array | type: Array Object array of subdevice requests |
Example:
var l_oDevice = module.GetDevice("MyDevice"); //Getting a device var l_oSubDevice = module.AddSubDevice("SubDevice 1", l_oDevice); //creating a subdevice var l_aRequests = l_oSubDevice.GetDataRequests();
SubDevice.AddAction (working via a function)
Add an action (used in macros ans rules) Paramaters in brackets are not compulsory.
Syntax
SubDevice.AddAction(Name, ScriptCall, Method, Space, [Default], [SmartID], [AdvancedField], [Hidden])
input | sample | description |
Name | "Power on" | type: String name of action |
ScriptCall | false | type: Boolean feature, that an action works via a function. Use true. |
Method | function(in_data){...} | type: Function An executed function. The incoming parameter can be:
|
Space | this | type: Object Pointer to an object that services a function. If a pointer is not required, leave an empty object or undefined |
Default | "1" | type: String Value that is the incoming parameter in Method |
SmartID | type: Number This parameter is not available at the momnet, that's why set null |
AdvancedField | {Name, Type, ...} | type: Object, Array It is used to work with complicated actions. When AdvancedField is used, put null in Default parameter. One data object or an object arrat can be sent in AdvancedField.
|
Hidden | true | type: Boolean Feature of a hidden action |
output |
Object | type: Object Action object |
Example:
var l_oDevice = module.GetDevice("MyDevice"); //Getting a device var l_oSubDevice = module.AddSubDevice("SubDevice 1", l_oDevice); //creating a subdevice //Creating an action with Default l_oSubDevice.AddAction("Power on", true, function(in_data){ IR.Log(in_data); //"on" }, undefined, "on", null, null, false); //Creating with IR.ADVANCED_NUMBER l_oSubDevice.AddAction("Set temperature", true, function(in_data){ IR.Log(in_data); //"35" - if a user chooses 35 }, undefined, null, null, { Type: IR.ADVANCED_NUMBER, Name "Temperature", Min: 1, Max: 100 }, false); //Creating an action with IR.ADVANCED_SLIDER and IR.ADVANCED_STRING l_oSubDevice.AddAction("Set temperature", true, function(in_data){ var l_oData = JSON.Parse(in_data); //parsing an object IR.Log(l_oData.Temperature); //"35" - if a user chooses 35 IR.Log(l_oData.Message); //"Hello, world!" - if a user enters this text }, undefined, null, null, [{ Type: IR.ADVANCED_SLIDER, Name "Temperature", Min: 1, Max: 100 }, { Type: IR.ADVANCED_STRING, Name "Message", Default: "Hello", Keyboard: IR.KEYBOARD_DECIMALPAD }], false); //Creating an action with IR.ADVANCED_SELECT l_oSubDevice.AddAction("Power", true, function(in_data){ var l_nValue = parseInt(in_data, 10); //converting to a numeric format, if required IR.Log(l_nValue); //1 - if a user chooses "Power on" }, undefined, null, null, { Type: IR.ADVANCED_SELECT, Name "Temperature", Parameters: [ { Caption: "Power on", //Name that a user sees Value: "1", //It is written in the function }, { Caption: "Power off", Value: "0", } ] }, false); //Creating an action with IR.ADVANCED_SELECT l_oSubDevice.AddAction("Set color", true, function(in_data){ var l_oColor = JSON.Parse(in_data); //parsing an object IR.Log(l_oColor["Color (R)"]); //239 IR.Log(l_oColor["Color (G)"]); //251 IR.Log(l_oColor["Color (B)"]); //112 }, undefined, null, null, { Type: IR.ADVANCED_COLOR, Name: "Color", }, false);
SubDevice.AddAction (without a function)
Add an action (used in macros ans rules) Paramaters in brackets are not compulsory.
Syntax
SubDevice.AddAction(Name, ScriptCall, Channel, [Default], [SmartID], [AdvancedField], [Hidden])
input | sample | description |
Name | "Power on" | type: String name of action |
ScriptCall | false | type: Boolean feature, that an action works via a function. Use true in this case. |
Channel | "Channel 1" | type: String channel name |
Default | "1" | type: String Value that is set in thr channel |
SmartID | type: Number This parameter is not available at the momnet, that's why set null |
AdvancedField | {Name, Type, ...} | type: Object, Array It is used to work with complicated actions. When AdvancedField is used, put null in Default parameter. One data object or an object arrat can be sent in AdvancedField.
|
Hidden | true | type: Boolean Feature of a hidden action |
output |
Object | type: Object Action object |
Example:
var l_oDevice = module.GetDevice("MyDevice"); //Getting a device var l_oSubDevice = module.AddSubDevice("SubDevice 1", l_oDevice); //creating a subdevice //Creating an action with Default l_oSubDevice.AddAction("Power on", false, "Channel 1", "on", null, null, false); //Creating with IR.ADVANCED_NUMBER l_oSubDevice.AddAction("Set temperature", false, "Channel 1", null, null, { Type: IR.ADVANCED_NUMBER, Name "Temperature", Min: 1, Max: 100 }, false);
SubDevice.DeleteAction
Delete an action
Syntax
SubDevice.DeleteAction(Action)
SubDevice.DeleteAction(ID)
input | sample | description |
Action | type: Object Action object |
ID | 1 | type: Number Action ID |
output |
Boolean | true | type: Boolean Result of deletion |
Example:
var l_oDevice = module.GetDevice("MyDevice"); //Getting a device var l_oSubDevice = module.AddSubDevice("SubDevice 1", l_oDevice); //creating a subdevice //Creating an action with Default var l_oAction = l_oSubDevice.AddAction("Power on", false, "Channel 1", "on", null, null, false); //Deleting with an action object l_oSubDevice.DeleteAction(l_oAction); //Deleting with ID l_oSubDevice.DeleteAction(l_oAction.ID);
SubDevice.GetAction
Get an action
Syntax
SubDevice.GetAction(ID)
input | sample | description |
ID | 1 | type: Number Action ID |
output |
Object | type: Object Action object |
Example:
var l_oDevice = module.GetDevice("MyDevice"); //Getting a device var l_oSubDevice = module.AddSubDevice("SubDevice 1", l_oDevice); //creating a subdevice //Creating an action with Default var l_oAction = l_oSubDevice.AddAction("Power on", false, "Channel 1", "on", null, null, false); var l_nActionID = l_oAction.ID; //Gettting an action l_oSubDevice.GetAction(l_nActionID);
SubDevice.AddEvent (working without a function)
Add an event. An event if an obligatory part of creating rules. This event works without a function.
Syntax
SubDevice.AddEvent(Name, Path, ScriptCall, Compare, [Default], [AdvancedField])
input | sample | description |
Name | "Temperature drops below..." | type: String name of event |
Path | "Drivers.Nest.CurrentTemperature" | type: String Full path to a channel, a driver feedback channel or a token. Subscription to tracking changes. |
ScriptCall | false | type: Boolean Feature of work via a function. Set false in this realization. |
Compare | type: String Comparison operator as a string. |
Default | "23" | type: String Default value |
AdvancedField | type: Object, Array It is used to work with complicated actions. When AdvancedField is used, put null in Default parameter. One data object or an object arrat can be sent in AdvancedField.
|
output |
Object | type: Object Event object |
Example:
var l_oDevice = module.GetDevice("MyDevice"); //Getting a device var l_oSubDevice = module.AddSubDevice("SubDevice 1", l_oDevice); //creating a subdevice //Creating an action with Default var l_oEvent = l_oSubDevice.AddEvent("Temperature drops below...", "Drivers.Nest.CurrentTemperature", false, "<", "23"); //Creating an action with IR.ADVANCED_NUMBER var l_oEvent = l_oSubDevice.AddEvent("Temperature drops below...", "Drivers.Nest.CurrentTemperature", false, "<", null, { Type: IR.ADVANCED_NUMBER, Name: "Temperature", Min: 0, Max: 100 });
You can use following operators ==, !=, >, <, >=, <=
SubDevice.AddEvent (working via a function)
Add an event. An event if an obligatory part of creating rules. This event works via a function.
Syntax
SubDevice.AddEvent(Name, Path, ScriptCall, Method, Space, [Default], [AdvancedField])
input | sample | description |
Name | "Temperature drops below..." | type: String name of event |
Path | "Drivers.Nest.CurrentTemperature" | type: String Full path to a channel, a driver feedback channel or a token. Subscription to tracking changes. |
ScriptCall | true | type: Boolean Feature of work via a function. Set true in this realization. |
Method | function(in_data){...} | type: Function An executed function. The incoming parameter can be:
Function must return boolean value (true, false) signaling that event happened (true - event happened) |
Space | this | type: Object Pointer to an object that services a function. If a pointer is not required, leave an empty object or undefined |
Default | "23" | type: String Default value |
AdvancedField | type: Object, Array It is used to work with complicated actions. When AdvancedField is used, put null in Default parameter. One data object or an object arrat can be sent in AdvancedField.
|
output |
Object | type: Object Event object |
Example:
var l_oDevice = module.GetDevice("MyDevice"); //Getting a device var l_oSubDevice = module.AddSubDevice("SubDevice 1", l_oDevice); //creating a subdevice //Creating an event with Default var l_oEvent = l_oSubDevice.AddEvent("Temperature drops below...", "Drivers.Nest.CurrentTemperature", true, function(in_data){ var l_nValue = parseInt(in_data, 10); //getting in_data in a numeric form var l_nFeedback = parseInt(l_oSubDevice.GetFeedback("CurrentTemperature"), 10); //getting feedback in a numeric form // making a comparison if (l_nFeedback < l_nValue) return true; }, this, "23"); //Creating an event with IR.ADVANCED_NUMBER var l_oEvent = l_oSubDevice.AddEvent("Temperature drops below...", "Drivers.Nest.CurrentTemperature", true, function(in_data){ var l_nValue = parseInt(in_data, 10); //getting in_data in a numeric form var l_nFeedback = parseInt(l_oSubDevice.GetFeedback("CurrentTemperature"), 10); //getting feedback in a numeric form // making a comparison if (l_nFeedback < l_nValue) return true; }, this, { Type: IR.ADVANCED_NUMBER, Name: "Temperature", Min: 0, Max: 100 });
You can use following operators ==, !=, >, <, >=, <=
SubDevice.DeleteEvent
Delete an event
Syntax
SubDevice.DeleteEvent(Event)
SubDevice.DeleteEvent(ID)
input | sample | description |
Event | type: Object Event object |
ID | 1 | type: Number Event ID |
output |
Boolean | true | type: Boolean Result of deletion |
Example:
var l_oDevice = module.GetDevice("MyDevice"); //Getting a device var l_oSubDevice = module.AddSubDevice("SubDevice 1", l_oDevice); //creating a subdevice //Creating an event with Default var l_oEvent = l_oSubDevice.AddEvent("Temperature drops below...", "Drivers.Nest.CurrentTemperature", false, "<", "23"); //Deleting with an event object l_oSubDevice.DeleteEvent(l_oEvent); //Deleting with ID l_oSubDevice.DeleteEvent(l_oEvent.ID);
SubDevice.GetEvent
Get an event
Syntax
SubDevice.GetEvent(ID)
input | sample | description |
ID | 1 | type: Number Event ID |
output |
Object | type: Object Event object |
Example:
var l_oDevice = module.GetDevice("MyDevice"); //Getting a device var l_oSubDevice = module.AddSubDevice("SubDevice 1", l_oDevice); //creating a subdevice //Creating an event with Default var l_oEvent = l_oSubDevice.AddEvent("Temperature drops below...", "Drivers.Nest.CurrentTemperature", false, "<", "23"); var l_nEventID = l_oEvent.ID; //Getting an event l_oSubDevice.GetEvent(l_nEventID);
SubDevice.AddCondition (working via a function)
Add a condition. A condition is not an obligatory part or a rule, but it can be used when more comparisons are required before an action is done, This condition works via a function.
Syntax
SubDevice.AddCondition(Name, Token, ScriptCall, Method, Space, [Default], [AdvancedField])
input | sample | description |
Name | "Temperature is below..." | type: String Name of condition |
Path | "Drivers.Nest.CurrentTemperature" | type: String Full path to a channel, a driver feedback channel or a token. Subscription to tracking changes. |
ScriptCall | true | type: Boolean Feature of work via a function. Set true in this realization. |
Method | function(in_data){...} | type: Function Executed function. The incoming parameter to the function can be:
The function must return the boolean value (true, false), signaling that a condition is executed (true - a condition is executed) |
Space | this | type: Object Pointer to an object that services a function. If a pointer is not required, leave an empty object or undefined |
Default | "23" | type: String Default value |
AdvancedField | type: Object, Array It is used to work with complicated actions. When AdvancedField is used, put null in Default parameter. One data object or an object arrat can be sent in AdvancedField.
|
output |
Object | type: Object Condition object |
Example:
var l_oDevice = module.GetDevice("MyDevice"); //Getting a device var l_oSubDevice = module.AddSubDevice("SubDevice 1", l_oDevice); //creating a subdevice //Creating a condition with Default var l_oCondition = l_oSubDevice.AddCondition("Temperature is below...", "Drivers.Nest.CurrentTemperature", true, function(in_data){ var l_nValue = parseInt(in_data, 10); //getting in_data in a numeric form var l_nFeedback = parseInt(l_oSubDevice.GetFeedback("CurrentTemperature"), 10); //getting feedback in a numeric form // making a comparison if (l_nFeedback < l_nValue) return true; }, this, "23"); //Creating a condition with IR.ADVANCED_NUMBER var l_oCondition = l_oSubDevice.AddCondition("Temperature is below...", "Drivers.Nest.CurrentTemperature", true, function(in_data){ var l_nValue = parseInt(in_data, 10); //getting in_data in a numeric form var l_nFeedback = parseInt(l_oSubDevice.GetFeedback("CurrentTemperature"), 10); //getting feedback in a numeric form // making a comparison if (l_nFeedback < l_nValue) return true; }, this, { Type: IR.ADVANCED_NUMBER, Name: "Temperature", Min: 0, Max: 100 });
Learn the full path to a channel, a driver feedback channel or a token with the help of Relations in the studio.
SubDevice.AddCondition (working without a function)
Add a condition. A condition is not an obligatory part or a rule, but it can be used when more comparisons are required before an action is done, This condition works without a function.
Syntax
SubDevice.AddCondition(Name, Token, ScriptCall, Compare, [Default], [AdvancedField])
input | sample | description |
Name | "Temperature drops below..." | type: String Name of condition |
Path | "Drivers.Nest.CurrentTemperature" | type: String Full path to a channel, a driver feedback channel or a token. Subscription to tracking changes. |
ScriptCall | false | type: Boolean Feature of work via a function. Set false in this realization. |
Compare | type: String Comparison operator as a string. |
Default | "23" | type: String Default value |
AdvancedField | type: Object, Array It is used to work with complicated conditions. When AdvancedField is used, set null in the Dafault parameter. One object or an object array with data can be sent in AdvancedField. See types of complicated conditions here ссылка |
output |
Object | type: Object Condition object |
Example:
var l_oDevice = module.GetDevice("MyDevice"); //Getting a device var l_oSubDevice = module.AddSubDevice("SubDevice 1", l_oDevice); //creating a subdevice //Creating a condition with Default var l_oCondition = l_oSubDevice.AddCondition("Temperature is below...", "Drivers.Nest.CurrentTemperature", false, "<", "23"); //Creating a condition with IR.ADVANCED_NUMBER var l_oCondition = l_oSubDevice.AddCondition("Temperature is below...", "Drivers.Nest.CurrentTemperature", false, "<", null, { Type: IR.ADVANCED_NUMBER, Name: "Temperature", Min: 0, Max: 100 });
Learn the full path to a channel, a driver feedback channel or a token with the help of Relations in the studio.
SubDevice.DeleteCondition
Delete a condition
Syntax
SubDevice.DeleteCondition(Condition)
SubDevice.DeleteCondition(ID)
input | sample | description |
Condition | type: Object Condition object |
ID | 1 | type: Number Condition ID |
output |
Boolean | true | type: Boolean Result of deletion |
Example:
var l_oDevice = module.GetDevice("MyDevice"); //Getting a device var l_oSubDevice = module.AddSubDevice("SubDevice 1", l_oDevice); //creating a subdevice //Creating a condition with Default var l_oCondition = l_oSubDevice.AddCondition("Temperature is below...", "Drivers.Nest.CurrentTemperature", false, "<", "23"); //Deleting with condition object l_oSubDevice.DeleteCondition(l_oCondition); //Deleting with ID l_oSubDevice.DeleteCondition(l_oCondition.ID);
SubDevice.GetCondition
Get a condition
Syntax
SubDevice.GetCondition(ID)
input | sample | description |
ID | 1 | type: Number Condition ID |
output |
Object | type: Object Condition object |
Example:
var l_oDevice = module.GetDevice("MyDevice"); //Getting a device var l_oSubDevice = module.AddSubDevice("SubDevice 1", l_oDevice); //creating a subdevice //Creating a condition with Default var l_oCondition = l_oSubDevice.AddCondition("Temperature is below...", "Drivers.Nest.CurrentTemperature", false, "<", "23"); var l_nConditionID = l_oCondition.ID; //Getting a condition l_oSubDevice.GetCondition(l_nConditionID);
SubDevice.AddSettingsFunction
Installing a a subdevice setting function. It is used for additional settings of a device. It is called by pressing the "wheel" icon in the app
i3 lite -> "Config" -> "Devices" -> Select a required device-> The setting button is in the top right corner (the "wheel" icon).
Syntax
SubDevice.AddSettingsFunction(callback, space);
input | sample | description |
callback | function(){...} | type: function Call back function |
space | this | type: object Pointer to an object that services a function |
output |
Example:
var l_oDevice = module.GetDevice("MyDevice"); //Getting a device var l_oSubDevice = module.AddSubDevice("SubDevice 1", l_oDevice); //creating a subdevice l_oSubDevice.AddSettingsFunction(function(){ IR.Log("Hello, world!"); }, this);
SubDevice.RunAction
Executing a subdevice action
Syntax
SubDevice.RunAction(ActionID, Param)
input | sample | description |
ActionID | 1 | type: Number Action ID |
Param | type: Object, String, Number Value, that is sent to a function, if an action is created to work via a function or is sent to a channel, if an action is created without a function. |
output |
Example:
var l_oDevice = module.GetDevice("MyDevice"); //Getting a device var l_oSubDevice = module.AddSubDevice("SubDevice 1", l_oDevice); //creating a subdevice //Creating an action with IR.ADVANCED_SLIDER and IR.ADVANCED_STRING var l_oAction = l_oSubDevice.AddAction("Set temperature", true, function(in_data){ var l_oData = JSON.Parse(in_data); //parsing an object IR.Log(l_oData.Temperature); //"35" - if a user chooses 35 IR.Log(l_oData.Message); //"Hello, world!" - if a user enters this text }, undefined, null, null, [{ Type: IR.ADVANCED_SLIDER, Name "Temperature", Min: 1, Max: 100 }, { Type: IR.ADVANCED_STRING, Name "Message", Default: "Hello", Keyboard: IR.KEYBOARD_DECIMALPAD }], false); l_oSubDevice.RunAction(l_oAction.ID, {Temperature: 35, Message: "Hello, world!"}); //doing an action
SubDevice.SetProperty
Add or update a subdevice property
Syntax
SubDevice.SetProperty(Name, Value)
input | sample | description |
Name | "Property 1" | type: string Property name |
Value | "Value" | type: string Value |
output |
-
Example:
var l_oDevice = module.GetDevice("MyDevice"); //Getting a device var l_oSubDevice = module.AddSubDevice("SubDevice 1", l_oDevice); //creating a subdevice l_oSubDevice.SetProperty("Property 1", "Value");
SubDevice.GetProperty
Get a property
Syntax
SubDevice.GetProperty(Name)
input | sample | description |
Name | "Property 1" | type: string Property name |
output |
Value | "Value" | type: string Value |
Example:
var l_oSubDevice = module.GetSubDevice("SubDevice 1"); //getting a subdevice var l_oProperty = l_oSubDevice.GetProperty("Property 1"); //getting a property value
SubDevice.GetProperties
Get all properties
Syntax
SubDevice.GetProperties()
input | sample | description |
output |
Object | {Name: Value} | type: Object Object with properties |
Example:
var l_oSubDevice = module.GetSubDevice("SubDevice 1"); //getting a subdevice var l_oProperties = l_oSubDevice.GetProperties(); //getting all properties
SubDevice.DiscoverServices
Search all services of a BLE device
Syntax
SubDevice.DiscoverServices()
input | sample | description |
output |
Example:
var l_oDevice = module.CreateDevice(IR.DEVICE_BLE_DEVICE, "Kettle", UUID); //Creating a BLE device var l_oSubDevice = module.AddSubDevice("SubDevice 1", l_oDevice); //creating a subdevice l_oSubDevice.DiscoverServices(); //searching services module.AddListener(IR.EVENT_SERVICES_DISCOVERED, l_oSubDevice, function(){ IR.Log("Hello, world!"); });
Call the IR.EVENT_SERVICES_DISCOVERED event
SubDevice.GetServices
Get services of a BLE device
Syntax
SubDevice.GetServices()
input | sample | description |
output |
Array | type: Array Array of service objects |
Example:
var l_oDevice = module.CreateDevice(IR.DEVICE_BLE_DEVICE, "Kettle", UUID); //Creating a BLE device var l_oSubDevice = module.AddSubDevice("SubDevice 1", l_oDevice); //creating a subdevice l_oSubDevice.DiscoverServices(); //searching services module.AddListener(IR.EVENT_SERVICES_DISCOVERED, l_oSubDevice, function(){ var l_aServices = l_oSubDevice.GetServices(); //Getting services for (var i = 0; i < l_aServices.length; i++) { ... } });
Fields of a service onject (OPTIONAL marker means that this field is not compulsory, TO_DLETE means they can be deleted later on, as their realization is practically useless):
- Uuid: (String) - service ID
- Value: (Array) - OPTIONAL, TO_DELETE service value is practically always empty
SubDevice.ReadCharacteristic
Read a characteristic of a BLE device
Syntax
SubDevice.ReadCharacteristic(Characteristic)
input | sample | description |
Characteristic | type: Object Characteristic object |
output |
-
Example:
var l_oDevice = module.CreateDevice(IR.DEVICE_BLE_DEVICE, "Kettle", UUID); //Creating a BLE device var l_oSubDevice = module.AddSubDevice("SubDevice 1", l_oDevice); //creating a subdevice l_oSubDevice.DiscoverServices(); //searching services module.AddListener(IR.EVENT_SERVICES_DISCOVERED, l_oSubDevice, function(){ var l_aServices = l_oSubDevice.GetServices(); //Getting services for (var i = 0; i < l_aServices.length; i++) { var l_aCharacteristics = l_aServices[i].GetCharacteristics(); for (var j = 0; j < l_aCharacteristics.length; j++) { l_oSubDevice.ReadCharacteristic(l_aCharacteristics[j]); //Reading a characteristic } } }); module.AddListener(IR.EVENT_CHARACTERISTIC_READ, l_oSubDevice, function(in_serviceUuid, in_characteristicUuid, in_array, in_status){ IR.Log(in_serviceUuid); IR.Log(in_characteristicUuid); IR.Log(in_array); IR.Log(in_status); })
Calls the IR.EVENT_CHARACTERISTIC_READ event - the characteristic is read.
Characteristic properties:
- UUID - uuid of a characteristic
- Permissions - level of permission
- Properties - properties
- Value - value
SubDevice.WriteCharacteristic
Rewrite a characteristic of a BLE device
Syntax
SubDevice.WriteCharacteristic(Characteristic)
input | sample | description |
Characteristic | type: Object Characteristic object |
output |
-
Example:
var l_oDevice = module.CreateDevice(IR.DEVICE_BLE_DEVICE, "Kettle", UUID); //Creating a BLE device var l_oSubDevice = module.AddSubDevice("SubDevice 1", l_oDevice); //creating a subdevice l_oSubDevice.DiscoverServices(); //searching services module.AddListener(IR.EVENT_SERVICES_DISCOVERED, l_oSubDevice, function(){ var l_aServices = l_oSubDevice.GetServices(); //Getting services for (var i = 0; i < l_aServices.length; i++) { var l_aCharacteristics = l_aServices[i].GetCharacteristics(); for (var j = 0; j < l_aCharacteristics.length; j++) { l_aCharacteristics[j].Value = [...]; //writing a new value l_oSubDevice.WriteCharacteristic(l_aCharacteristics[j]); //Rewriting a characteristic } } }); module.AddListener(IR.EVENT_CHARACTERISTIC_WRITE, l_oSubDevice, function(in_serviceUuid, in_characteristicUuid, in_status){ IR.Log(in_serviceUuid); IR.Log(in_characteristicUuid); IR.Log(in_status); })
Calls IR.EVENT_CHARACTERISTIC_WRITE event- a characteristic is written
Note:
- Property Value of a characteristic is used as a container to send a new value to a device ;
- The format of a byte array to write can be different from the format that is received when reading ;
- The characterictic must have the following CharacteristicPropertyWritor similar properties.
Characteristic properties:
- UUID - uuid of a characteristic
- Permissions - level of permission
- Properties - properties
- Value - value
SubDevice.SetCharacteristicNotification
Subscribe to characteristic changes of a BLE device or unsubscribe from it.
Syntax
SubDevice.SetCharacteristicNotification(Characteristic, subscription)
input | sample | description |
Characteristic | type: Object Characteristic object |
subscription | true | type: Boolean Subscription flag |
output |
-
Example:
var l_oDevice = module.CreateDevice(IR.DEVICE_BLE_DEVICE, "Kettle", UUID); //Creating a BLE device var l_oSubDevice = module.AddSubDevice("SubDevice 1", l_oDevice); //creating a subdevice l_oSubDevice.DiscoverServices(); //searching services module.AddListener(IR.EVENT_SERVICES_DISCOVERED, l_oSubDevice, function(){ var l_aServices = l_oSubDevice.GetServices(); //Getting services for (var i = 0; i < l_aServices.length; i++) { var l_aCharacteristics = l_aServices[i].GetCharacteristics(); for (var j = 0; j < l_aCharacteristics.length; j++) { l_oSubDevice.SetCharacteristicNotification(l_aCharacteristics[j], true); //Subscribing to characteristic change } } }); module.AddListener(IR.EVENT_CHARACTERISTIC_CHANGED, l_oSubDevice, function(in_serviceUuid, in_characteristicUuid, in_status){ IR.Log(in_serviceUuid); IR.Log(in_characteristicUuid); IR.Log(in_status); })
It calls IR.EVENT_CHARACTERISTIC_CHANGED event - a characteristic is changed.
Subdevice properties
SubDevice.property
Name | "Relay" | type: String Subdevice name |
ID | 1 | type: Number Subdevice ID |
Icon | type: String Subdevice icon |
Module | type: ModuleObject parent module |
ModuleName | type: String name of a parent module |
Device | type: DeviceObject device |
SystemName | 3 | type: String Subdevice system name |
ExistSettingsFunction | type: Boolean subdevice setting fucntion exists |
Types of complicated actions, events, conditions
This section describes types and structures of objects of comlicated actions, events, conditions There are several types of object depending on the type of a complicated action:
- IR.ADVANCED_NUMBER - when this type is used, a popup with an item is used IR.ITEM_PICKER to select values:
- Name: String, //Name with the help of which value inside a function can be received
- Type: IR.ADVANCED_NUMBER, //Type
- Min: Number //minimal value of IR.ITEM_PICKER item
- Max: Number //maximal value of IR.ITEM_PICKER item
- IR.ADVANCED_SLIDER - when this type is used, a popup with a dimmer to select value is used :
- Name: String, //Name with the help of which value inside a function can be received
- Type: IR.ADVANCED_SLIDER, //Тип
- Min: Number // minimal value of Level item
- Max: Number //maximum value of Level item
- IR.ADVANCED_SELECT - when this type is used, a popup with a list if values is used:
- Name: String, //Name with the help of which value inside a function can be received
- Type: IR.ADVANCED_SELECT, //Type
- Parameters: Array //Object array, see below
- IR.ADVANCED_STRING - when this type is used, a popup with a text field is used:
- Name: String, //Name with the help of which value inside a function can be received
- Type: IR.ADVANCED_STRING, //type
- Default: String //Default value
- Keyboard: Number //Type of keyboard: ссылка
- IR.ADVANCED_COLOR - when this type is used, a popup with ColorPicker is used:
- Name: String, //Name with the help of which value inside a function can be received
- Type: IR.ADVANCED_COLOR //Type
There are two types of object array structures in Parameters field in IR.ADVANCED_SELECT:
- With fields Caption and Value:
[{ Caption: String, //Value that a user will see Value: String //Value that will be written in the function }]
- С полем Value:
[{ Value: String //Value that a user will see and that will be written in the function }]
Widget
This section describes methods and properties to work with widgets. A widget object in this section is looked upon as Widget variable.
Widget.AddVirtualTag
Add a virtual tag to a widget
Syntax
Widget.AddVirtualTag(Name, Value, [Edit], [Hidden])
input | sample | description |
Name | "Tag" | type: String name of virtual tag widget |
Value | "Name" | type: String Tag value |
Edit | true | type: Boolean Permission to edit a tag |
Hidden | true | type: Boolean Feature of a hidden tag |
output |
Object | type: Object Object of a virtual tag |
Example:
var l_oSubDevice = module.GetSubDevice("SubDevice 1"); //getting a subdevice var l_oWidget = l_oSubDevice.GetWidget("Popup 1"); //getting a widget var l_oTag = l_oWidget.AddVirtualTag("Tag", "HDL-BUS", true); //creating a virtual tag
Widget.GetVirtualTag
Get a virtual tag of a widget
Syntax
Widget.GetVirtualTag(Name)
input | sample | description |
Name | "Tag" | type: String name of virtual tag widget |
output |
Object | type: Object Object of a virtual tag |
Example:
var l_oSubDevice = module.GetSubDevice("SubDevice 1"); //getting a subdevice var l_oWidget = l_oSubDevice.GetWidget("Popup 1"); //getting a widget var l_oTag = l_oWidget.GetVirtualTag("Tag"); //getting a virtual tag
Widget.GetVirtualTags
Get all virtual tags of a widget
Syntax
Widget.GetVirtualTags()
input | sample | description |
-
output |
Array | type: Array Array of virtual tag objects |
Example:
var l_oSubDevice = module.GetSubDevice("SubDevice 1"); //getting a subdevice var l_oWidget = l_oSubDevice.GetWidget("Popup 1"); //getting a widget var l_oTag = l_oWidget.GetVirtualTags(); //getting virtual tags
Widget.GetVirtualTags
Get all virtual tags of a widget
Syntax
Widget.DeleteVirtualTag(Name)
Widget.DeleteVirtualTag(VirtualTag)
input | sample | description |
Name | type: String name of widget virtual tag |
VirtualTag | type: PropertyObject widget virtual tag |
output |
Boolean | type: Boolean Result of deletion (true, false) |
Example:
var l_oSubDevice = module.GetSubDevice("SubDevice 1"); //getting a subdevice var l_oWidget = l_oSubDevice.GetWidget("Popup 1"); //getting a widget var l_oTag = l_oWidget.GetVirtualTag("Tag"); //getting a virtual tag //Deletion by name l_oWidget.DeleteVirtualTag(l_oTag.Name); //deleting a virtual tag //Deletion by tag l_oWidget.DeleteVirtualTag(l_oTag); //deleting a virtual tag
Wodget properties
Widget.property
Name | "Relay" | type: String widget name |
FullName | type: String full name of a widget |
ID | 1 | type: Number widget ID |
SubDevice | type: SubDeviceObject subdevice |
Popup | type: DialogItemObject popup |
List
This section descibes methods and properties to work with lists. List object is looked upon as List variable in this section.
List.AddItem
Adding an item to a list
Syntax
List.AddItem([Template], [Options], [customID], [position], [Name])
input | sample | description |
Template | type: String Popup name |
Options | type: Object Object with settings of graphic items of a popup |
customID | type: String List item ID |
position | type: Number List item position |
Name | type: String name of list item |
output |
Object | type: Object Object of list item |
Example:
var l_oList = module.GetPopup("Popup 1").GetItem("list"); //getting a list object l_oList.AddItem("Popup 2", { Name: { //name of a graphic item Text: "Hello, world!" //text on Name item }, Switcher: { Value: 1 //trigger value of Switcher button } }, "ID", 0, "First");
List.Clear
Clearing a list
Syntax
List.Clear()
input | sample | description |
-
output |
-
Example:
var l_oList = module.GetPopup("Popup 1").GetItem("list"); //getting a list object l_oList.Clear(); //clearing a list
List.GetState
Get an item state
Syntax
List.GetState(Index)
input | sample | description |
Index | 1 | type: Number item index |
output |
Object | type: Object object of item state |
Example:
var l_oList = module.GetPopup("Popup 1").GetItem("list"); //getting a list object l_oList.GetState(1); //getting a state
List.MoveItem
Moving an item
Syntax
List.MoveItem(CurrentPostition, NewPosition)
input | sample | description |
CurrentPostition | 1 | type: Number the current position of an item |
NewPosition | 1 | type: Number new position of an item |
output |
-
Example:
var l_oList = module.GetPopup("Popup 1").GetItem("list"); //getting a list object l_oList.MoveItem(1, 4); //moving a list item
List.GetItemByName
Getting a list item by name
Syntax
List.GetItemByName(Name)
input | sample | description |
Name | type: String item name |
output |
Object | type: Object Object of list item |
Example:
var l_oList = module.GetPopup("Popup 1").GetItem("list"); //getting a list object var l_oItem = l_oList.GetItemByName("First");
List.GetItemByCustomID
Getting a list object by user ID
Syntax
List.GetItemByCustomID(ID)
input | sample | description |
ID | 1 | type: String item ID |
output |
Object | type: Object Object of list item |
Example:
var l_oList = module.GetPopup("Popup 1").GetItem("list"); //getting a list object var l_oItem = l_oList.GetItemByCustomID("ID");
List.GetItemByIndex
Getting a list item by the ordinal number
Syntax
List.GetItemByIndex(Index)
input | sample | description |
Index | 1 | type: Number item position |
output |
Object | type: Object Object of list item |
Example:
var l_oList = module.GetPopup("Popup 1").GetItem("list"); //getting a list object var l_oItem = l_oList.GetItemByIndex(1);
List.GetItemPositionByName
Get the position of a list item by name
Syntax
List.GetItemPositionByName(Name)
input | sample | description |
Name | type: String item name |
output |
Number | 1 | type: Number List item position |
Example:
var l_oList = module.GetPopup("Popup 1").GetItem("list"); //getting a list object var l_nPosition = l_oList.GetItemPositionByName("First");
List.GetItemPositionByCustomID
Getting a list item by user ID
Syntax
List.GetItemPositionByCustomID(CustomID)
input | sample | description |
CustomID | type: String item ID |
output |
Number | 1 | type: Number list item position |
Example:
var l_oList = module.GetPopup("Popup 1").GetItem("list"); //getting a list object var l_nPosition = l_oList.GetItemPositionByCustomID("ID");
List.GetSelected
Get a list of selected list items
Syntax
List.GetSelected()
input | sample | description |
-
output |
Array | type: Array array of selected list items |
Example:
var l_oList = module.GetPopup("Popup 1").GetItem("list"); //getting a list object var l_oItem = l_oList.GetItemByCustomID("ID"); l_oItem.Selected = true; var l_oSelectedItems = l_oList.GetSelected(); //[l_oItem]
List.DeleteItemByName
Delete an item by name
Syntax
List.DeleteItemByName(Name)
input | sample | description |
Name | type: String item name |
output |
-
Example:
var l_oList = module.GetPopup("Popup 1").GetItem("list"); //getting a list object l_oList.DeleteItemByName("First");
List.DeleteItemByCustomID
Delete an item by user ID
Syntax
List.DeleteItemByCustomID(CustomID)
input | sample | description |
CustomID | type: String item ID |
output |
-
Example:
var l_oList = module.GetPopup("Popup 1").GetItem("list"); //getting a list object l_oList.DeleteItemByCustomID("ID");
List.DeleteItemByIndex
Delete an item by index
Syntax
List.DeleteItemByIndex(Index)
input | sample | description |
Index | 1 | type: Number item position |
output |
-
Example:
var l_oList = module.GetPopup("Popup 1").GetItem("list"); //getting a list object l_oList.DeleteItemByIndex(1);
List.DeleteItemsByName
Delete items by name
Syntax
List.DeleteItemsByName(Name)
input | sample | description |
Name | type: String item name |
output |
-
Example:
var l_oList = module.GetPopup("Popup 1").GetItem("list"); //getting a list object l_oList.DeleteItemsByName("First");
List.DeleteItemsByCustomID
Delete items by user ID
Syntax
List.DeleteItemsByCustomID(CustromID)
input | sample | description |
CustomID | type: String item ID |
output |
-
Example:
var l_oList = module.GetPopup("Popup 1").GetItem("list"); //getting a list object l_oList.DeleteItemsByCustomID("ID");
List.GetItemsByName
Get an item array by name
Syntax
List.GetItemsByName(Name)
input | sample | description |
Name | type: String item name |
output |
Array | type: Array array of list items |
Example:
var l_oList = module.GetPopup("Popup 1").GetItem("list"); //getting a list object var l_oItems = l_oList.GetItemsByName("First");
List.GetItemsByCustomID
Get an item array by user ID
Syntax
List.GetItemsByCustomID(CustomID)
input | sample | description |
CustomID | type: String item ID |
output |
Array | type: Array array of list items |
Example:
var l_oList = module.GetPopup("Popup 1").GetItem("list"); //getting a list object var l_oItems = l_oList.GetItemsByCustomID("ID");
List.ClearSelected
Cancel all selected items
Syntax
List.ClearSelected()
input | sample | description |
-
output |
-
Example:
var l_oList = module.GetPopup("Popup 1").GetItem("list"); //getting a list object l_oList.SelectByIndex(1, true); l_oList.ClearSelected();
List.SelectByIndex
Select an item by index
Syntax
List.SelectByIndex(Index, Selected)
input | sample | description |
Index | 1 | type: Number item position |
Selected | true | type: Boolean True value - selected, false - not selected |
output |
-
Example:
var l_oList = module.GetPopup("Popup 1").GetItem("list"); //getting a list object l_oList.SelectByIndex(1, true);
List.StartReleaseActionByIndex
Do an action from an item by index
Syntax
List.StartReleaseActionByIndex(Index)
input | sample | description |
Index | 1 | type: Number item position |
output |
-
Example:
var l_oList = module.GetPopup("Popup 1").GetItem("list"); //getting a list object var l_oItem = l_oList.GetItemByIndex(1); l_oItem.SetReleaseAction(function (){ //Setting an action for an item IR.Log("Hello, world!"); }) l_oList.StartReleaseActionByIndex(1); //Launching an action
List.ScrollByName
Rewind the list to an item with the indicated name
Syntax
List.ScrollByName(Name)
input | sample | description |
Name | type: String item name |
output |
-
Example:
var l_oList = module.GetPopup("Popup 1").GetItem("list"); //getting a list object l_oList.ScrollByName("Last");
List.ScrollByCustomID
Rewind the list to an item with the indicated ID
Syntax
List.ScrollByCustomID(CustomID)
input | sample | description |
CustomID | type: String item ID |
output |
-
Example:
var l_oList = module.GetPopup("Popup 1").GetItem("list"); //getting a list object l_oList.ScrollByCustomID("ID");
List.ScrollByIndex
Rewind the list to an item with the indicated index
Syntax
List.ScrollByIndex(Index)
input | sample | description |
Index | 1 | type: Number item position |
output |
-
Example:
var l_oList = module.GetPopup("Popup 1").GetItem("list"); //getting a list object l_oList.ScrollByIndex(4);
List.ScrollToStart
Rewind the list to the beginning
Syntax
List.ScrollToStart()
input | sample | description |
output |
-
Example:
var l_oList = module.GetPopup("Popup 1").GetItem("list"); //getting a list object l_oList.ScrollToStart();
List.ScrollToEnd
Go to the list end
Syntax
List.ScrollToEnd()
input | sample | description |
output |
-
Example:
var l_oList = module.GetPopup("Popup 1").GetItem("list"); //getting a list object l_oList.ScrollToEnd();
List.SetSelectFunction
Install a funtion to process selection of list items
Syntax
List.SetSelectFunction(Function)
input | sample | description |
Function | function(in_listItem, in_object){...} | type: Function function that tracks that a list item is selected
|
output |
-
Example:
var l_oList = module.GetPopup("Popup 1").GetItem("list"); //getting a list object l_oList.SetSelectFunction(function(in_listItem, in_object){ if (in_listItem.Selected){ ... } else { ... } });
List.SetDataFilter
Add a filter by data
Syntax
List.SetDataFilter(key, value)
input | sample | description |
key | type: String name of any object filed, installed on a list item via ListItem.SetData ссылка |
value | type: Mixed value from this field |
output |
-
Example:
var l_oList = module.GetPopup("Popup 1").GetItem("list"); //getting a list object var l_oItem_1 = l_oList.GetItemByIndex(1); // getting list items var l_oItem_2 = l_oList.GetItemByIndex(2); var l_oItem_3 = l_oList.GetItemByIndex(3); //Installing data to each list item l_oItem_1.SetData( { type: "coffee", name: "test" }) l_oItem_2.SetData( { type: "fruit", name: "test2" } l_oItem_3.SetData( { type: "coffee", name: "test2" } // clearing a filter by data l_oList.ClearDataFilter(); // adding a filter by data l_oList.SetDataFilter("type", "coffee"); //installing a filter by type with coffee value l_oList.SetDataFilter("name", "test2"); //and one more filter by name with test2 value // using a filter by data l_oList.ApplyDataFilter();
List.ApplyDataFilter
Use a filter by data
Syntax
List.ApplyDataFilter()
input | sample | description |
-
output |
-
Example:
var l_oList = module.GetPopup("Popup 1").GetItem("list"); //getting a list object var l_oItem_1 = l_oList.GetItemByIndex(1); // getting list items var l_oItem_2 = l_oList.GetItemByIndex(2); var l_oItem_3 = l_oList.GetItemByIndex(3); //Installing data to each list item l_oItem_1.SetData( { type: "coffee", name: "test" }) l_oItem_2.SetData( { type: "fruit", name: "test2" } l_oItem_3.SetData( { type: "coffee", name: "test2" } // clearing a filter by data l_oList.ClearDataFilter(); // adding a filter by data l_oList.SetDataFilter("type", "coffee"); l_oList.SetDataFilter("name", "test2"); // using a filter by data l_oList.ApplyDataFilter();
List.ClearDataFilter
Clear a filter by data
Syntax
List.ClearDataFilter()
input | sample | description |
-
output |
-
Example:
var l_oList = module.GetPopup("Popup 1").GetItem("list"); //getting a list object var l_oItem_1 = l_oList.GetItemByIndex(1); // getting list items var l_oItem_2 = l_oList.GetItemByIndex(2); var l_oItem_3 = l_oList.GetItemByIndex(3); //Installing data to each list item l_oItem_1.SetData( { type: "coffee", name: "test" }) l_oItem_2.SetData( { type: "fruit", name: "test2" } l_oItem_3.SetData( { type: "coffee", name: "test2" } // clearing a filter by data l_oList.ClearDataFilter(); // adding a filter by data l_oList.SetDataFilter("type", "coffee"); l_oList.SetDataFilter("name", "test2"); // using a filter by data l_oList.ApplyDataFilter();
List.DeleteDataFilter
Delete a filter by data
Syntax
List.DeleteDataFilter(key)
input | sample | description |
key | type: String name of any object field installed on a list item via ListItem.SetData |
output |
-
Example:
var l_oList = module.GetPopup("Popup 1").GetItem("list"); //getting a list object var l_oItem_1 = l_oList.GetItemByIndex(1); // getting list items var l_oItem_2 = l_oList.GetItemByIndex(2); var l_oItem_3 = l_oList.GetItemByIndex(3); //Installing data to each list item l_oItem_1.SetData( { type: "coffee", name: "test" }) l_oItem_2.SetData( { type: "fruit", name: "test2" } l_oItem_3.SetData( { type: "coffee", name: "test2" } // clearing a filter by data l_oList.ClearDataFilter(); // adding a filter by data l_oList.SetDataFilter("type", "coffee"); l_oList.SetDataFilter("name", "test2"); // using a filter by data l_oList.ApplyDataFilter(); // deleting a filter by data l_oList.DeleteDataFilter("name");
List properties
List.property
Template | "Popup 1" | type: String template |
Direction | 0 | type: Number direction
|
ItemsCount | 3 | type: Number number of items |
Filter | type: String filter by popup name |
ScrollEnabled | false | type: Boolean scrolling on/off |
DragDropEnable | false | type: Boolean drag'n'drop on/off |
Resistance | 5 | type: Number speed of scrolling |
ScrollBar | true | type: Boolean display of scrolling |
List item
This section describes methods and properties to work with list item object. List item object is looked upon as ListItem variable.
ListItem.SetData
Install data of list item
Syntax
List.SetData(Data)
input | sample | description |
Data | type: Object Object with data for list item |
output |
-
Example:
var l_oList = module.GetPopup("Popup 1").GetItem("list"); //getting a list object var l_oItem_1 = l_oList.GetItemByIndex(1); // getting list items //Installing data l_oItem_1.SetData( { type: "coffee", name: "test" })
ListItem.SetReleaseAction
Add an action to a list item
Syntax
List.SetReleaseAction(Action, [Space])
input | sample | description |
Action | function(in_listItem, in_object){...} | type: Function function that is executed when a list item is pressed
|
Space | type: Object Pointer to an object that services a function |
output |
-
Example:
var l_oList = module.GetPopup("Popup 1").GetItem("list"); //getting a list object var l_oItem_1 = l_oList.GetItemByIndex(1); // getting a list item l_oItem_1.SetReleaseAction(function(in_listItem, in_object){ IR.Log("Hello, world!"); });
ListItem.SetOptions
Installing the graphic image of an interface item via JSON
Syntax
List.SetOptions(Data)
input | sample | description |
Data | {
itemName: { PropertyName: Value, ... States: [ PropertyName: Value, ... ] }, .. } |
type: JSONObject
|
output |
-
Example:
var l_oList = module.GetPopup("Popup 1").GetItem("list"); //getting a list object var l_oItem_1 = l_oList.GetItemByIndex(1); // getting a list item l_oItem_1.SetOptions({ Name: { Text: "Test", States: [{ Border: 8 }] }, Switcher: { Value: 1 } });
Properties of list items
ListItem.property
Popup | type: DialogItemObject Popup object |
Parent | type: DialogItemObject List object |
Data | type: Object Object with data written via .SetData |
RadioGroup | type: Number Radio group |
Selected | type: Boolean Flag of a selected item |
CustomID | type: String User ID |
Index | type: Number Index of a list item |
Context | type: Object pointer to an object that services a function in .SetReleaseAction method |
Deleted | type: Boolean Flag of a deleted list item |
var l_oList = module.GetPopup("Popup 1").GetItem("list"); //getting a list object var l_oItem_1 = l_oList.GetItemByIndex(1); // getting a list item //Popup l_oItem_1.Popup.GetItem("Name").Text = "Test"; //Parent var l_oList_1 = l_oItem_1.Parent; //Data var l_oData = l_oItem_1.Data; //RadioGroup var l_nRadioGroup = l_oItem_1.RadioGroup; //Selected l_oItem_1.Selected = false; //CustomID l_oList.ScrollByCustomID(l_oItem_1.CustomID); //Index l_oList.ScrollByIndex(l_oItem_1.Index); //Context l_oItem_1.SetReleaseAction(function (in_listItem, in_object){ IR.Log(this.type); // coffee }, {type: "coffee"}) l_oItem_1.Context = {type: "fruit"}; //IR.Log(this.type) - "fruit" //Deleted IR.Log(l_oItem_1.Deleted) //false
Properties and methods of IR objects
This section describes properties and methods to work with IR object.
IR properties
IR.property
ProjectLanguage | type: String Language of a project |
HWID | type: String Gettig HWID of a device |
Language | type: String Getting the laguage of a device |
ProjectScaleWidth | type: Number Getting the scaling in width |
ProjectScaleHeight | type: Number Getting the scaling in height |
DisplayType | type: Number Getting the type of resolution. Types od resolutions:
|
ProjectWorkMode | type: Number Work mode of a project:
|
//ProjectLanguage var l_sProjectLanguage = IR.ProjectLanguage; //HWID var l_sHWID = IR.HWID; //Language var l_sLanguage = IR.Language; //ProjectScaleWidth var l_nProjectScaleWidth = IR.ProjectScaleWidth; //Setting the position on Axis X coordinate depending on the width scaling function resizeX(in_nValue) { return in_nValue / l_nProjectScaleWidth; } //Setting the width of a graphical item depending on the width scaling function resizeWidth(in_nValue) { var l_nValue = in_nValue / l_nProjectScaleWidth; return l_nValue < 1 ? 1 : l_nValue; } module.GetPopup("Popup 1").GetItem("Name").Width = resizeWidth(240) //Setting the new width of a graphical item depending on the width scaling //ProjectScaleHeight var l_nProjectScaleHeight = IR.ProjectScaleHeight; //Setting the height of a graphical item depending on the height scaling function resizeHeight(in_nValue) { var l_nValue = in_nValue / l_nProjectScaleHeight; return l_nValue < 1 ? 1 : l_nValue; } //Setting the position on Axis Y coordinate depending on the height scaling function resizeY(in_nValue) { return in_nValue / l_nProjectScaleHeight; } module.GetPopup("Popup 1").GetItem("Name").Height = resizeHeight(240) //Setting the new height of a graphical item depending on the height scaling //DisplayType //Checking the type of resolution if (IR.DisplayType == IR.DISPLAY_TYPE_TABLET){ ... } else { ... } //ProjectWorkMode var l_nProjectMode = IR.ProjectWorkMode;
IR.ModuleSetupFinish
Completion of module installation. It is required for scanner development. When a scanner is developed, use this method to set the module to installation with all required data.
Syntax
IR.ModuleSetupFinish(StoreID, ModuleData, [Callback])
input | sample | description |
StoreID | 82 | type: Number Module ID in the store |
ModuleData | type: Object Data for module required for its work. See below the format to write data for module work |
Callback | function(in_error){...} | type: Function Function that is executed after a module is installed.
|
output |
-
Example:
//Example of installing HDL Dimmer with a scanner var l_nStoreID = 82; var l_oModuleData = { Module: { //Data required for module work Type: "Dimmer", SubnetID: 3, DeviceID: 6 Name: "HDL Dimmer" } Drivers: { //Data for a driver "HDL-BUS Pro Network (UDP)": { Host: "255.255.255.255", //installing a host for a driver Port: "6000" //installing a port for a driver }, } } IR.ModuleSetupFinish(l_nStoreID, l_oModuleData, function(in_error){ if (!in_error){ ... } else { ... } }); //Data are received in a module via module.GetProperty //Data received ina module after its installation var l_sType = module.GetProperty("Type"); //calling the popup name that was written in ModuleData in Module object ...
Format for writing data for a module
var l_oModuleData = { Module: { Field: Value, .. }, Drivers: { Name: { Field: Value, .. }, .. } }
- Module - module object, where data about its work are sent
- Field - property name, that can be received in a module via module.GetProperty
- Value - value of this property
- Drivers - object of used drivers
- Name - driver name, for which data have to be installed
- Field - name of driver property
- Value - value for this property
- Name - driver name, for which data have to be installed
IR.ModuleSetupCancel
Cancelling module installation. It is used in scanner development.
Syntax
IR.ModuleSetupCancel(StoreID)
input | sample | description |
StoreID | type: Number Module ID in the store |
output |
-
Example:
var l_nStoreID = 82; IR.ModuleSetupCancel(l_nStoreID); //Cancelling module installation
Events
When a module is developed all events described in i3 pro can be used: [[1]]. Besides these events, events described below can be used in i3 lite.
IR.EVENT_MODULE_START
Start of module work.IR.EVENT_START event is not supported.
Syntax
module.AddListener(IR.EVENT_MODULE_START, 0, function, [pointer]);
input | sample | description |
function | type: function an unnamed function or calling a fucntion |
pointer | type: object Pointer to an object that services a function (optional) |
output |
-
Example:
module.AddListener(IR.EVENT_MODULE_START, 0, function () { IR.Log("action"); // action });
IR.EVENT_ADD_WIDGET
Adding a widget
Syntax
module.AddListener(IR.EVENT_ADD_WIDGET, 0, function, [pointer]);
input | sample | description |
function | function(in_widget) | type: function an unnamed function or calling a function
|
pointer | type: object Pointer to an object that services a function (optional) |
output |
-
Example:
module.AddListener(IR.EVENT_ADD_WIDGET, 0, function (in_widget) { IR.Log(in_widget.Name); });
IR.EVENT_REMOVED_WIDGET
Deleting a widget
Syntax
module.AddListener(IR.EVENT_REMOVED_WIDGET, 0, function, [pointer]);
input | sample | description |
function | function(in_widgetID) | type: function an unnamed function or calling a function
|
pointer | type: object Pointer to an object that services a function (optional) |
output |
-
Example:
module.AddListener(IR.EVENT_REMOVED_WIDGET, 0, function (in_widgetID) { IR.Log(in_widgetID); });
IR.EVENT_ADD_SUBDEVICE
Adding a subdevice
Syntax
module.AddListener(IR.EVENT_ADD_SUBDEVICE, 0, function, [pointer]);
input | sample | description |
function | function(in_subDevice) | type: function an unnamed function or calling a function
|
pointer | type: object Pointer to an object that services a function (optional) |
output |
-
Example:
module.AddListener(IR.EVENT_ADD_SUBDEVICE, 0, function (in_subDevice) { IR.Log(in_subDevice.Name); });
IR.EVENT_REMOVED_SUBDEVICE
Deleting a subdevice
Syntax
module.AddListener(IR.EVENT_REMOVED_SUBDEVICE, 0, function, [pointer]);
input | sample | description |
function | function(in_subDeviceID, in_module) | type: function an unnamed function or calling a function
|
pointer | type: object Pointer to an object that services a function (optional) |
output |
-
Example:
module.AddListener(IR.EVENT_REMOVED_SUBDEVICE, 0, function (in_subDeviceID, in_module) { IR.Log(in_subDeviceID); IR.Log(in_module.Name); });
IR.EVENT_OPEN_SCANNER
When developing a scanner use this event to signal that start of scanner work IR.EVENT_MODULE_START
Syntax
module.AddListener(IR.EVENT_OPEN_SCANNER, 0, function, [pointer]);
input | sample | description |
function | function() | type: function an unnamed function or calling a fucntion |
pointer | type: object Pointer to an object that services a function (optional) |
output |
-
Example:
module.AddListener(IR.EVENT_OPEN_SCANNER, 0, function () { IR.Log("action"); // action });
Setup object
When a module is added from the store, sometimes a user must enter information required for module work. Setup object has to be used for this purpose. Data can be sent to module and driver with the help of this object.
To realize it, create a new script file in iRidium studio and indicate it type - Type: Setup. The script itself if JSONObject.
The following writing format is required:
// format of coming Setup data (creted in the studio) { // Data to connect derivers created in Project Device Panel Drivers: [ { Name: "HDL-BUS Pro Network (UDP)", // driver name Properties: // driver property [ { Type: "textfield", //It signals that a test field to enter data must be shown Name: "SubnetID", //Property name where data are sent Validation: function (in_value) { //Function that checks values entered by a user //in_value - the coming parameter, containing a value, entered by a user if (in_value != "") return 0; //If there are no erros, 0 is returned. else return "Please input SubnetID"; //If there are errors, error text is returned. } }, .. ], }, .. ], // General data for a module (and drivers created via script) Module: [ { Type: "textfield", //It signals that a test field to enter data must be shown Name: "Relay Count", //property name, that can be received in a module via module.GetProperty Validation: function (in_value) { //Function that checks values entered by a user //in_value - the coming parameter, containing a value, entered by a user if (in_value != "") return 0; //If there are no erros, 0 is returned. else return "Please input Count"; //If there are errors, error text is returned. } } .. ] };
Properties of a virtual tag
Name | "Tag" | type: String name of virtual tag |
ID | 1 | type: Number virtual tag ID |
Edit | true | type: Boolean Editing flag |
Value | "Test" | type: String Value |
Types of keyboards
IR.KEYBOARD_REGULAR | type: Number Regular keyboard |
IR.KEYBOARD_URL | type: Number Keyboard optomized to enter URL |
IR.KEYBOARD_NUMBERPAD | type: Number 0-9 keyboard, suitable to enter PIN |
IR.KEYBOARD_PHONEPAD | type: Number Phone keybord with letters belows numbers and #, * symbols |
IR.KEYBOARD_NAMEPHONEPAD | type: Number Keyboad optimized to enter named or numbers |
IR.KEYBOARD_EMAIL_ADDRESS | type: Number Keyboard with quick access to @ |
IR.KEYBOARD_DECIMALPAD | type: Number Numeric keyboard with a decimal point |
IR.KEYBOARD_NONE | type: Number Hide keyboard |
Module example
To understand better how modules are made, you can download Demo module for Netatmo and see the code example. It is fully functional, you can test its work of you have Netatmo equipment and an account Netatmo, Client_secret and Client_id. Enter Client_secret and Client_id JS editor (iRidium studio) in Driver.js. You can download this module at this link: Netatmo Demo