Материал из Module developer
module.CreateDevice
Create a driver with the help of script. You can only create drivers like AV & Custom Systems and BLE. Other drivers are worked with after they are added to a project from the database.
Синтаксис
module.CreateDevice(Type, Name, Options)
| Название | Пример | Описание |
| 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 set of driver parameters separated by commas |
| На выходе |
| Object | [object DevicePrototype] | type: Object a link to a driver as an object |
Пример
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]
a set of parameters for different drivers is different
if a parameter is not in the list, its value is set by default (i.e. only Host and Port can be indicated when a driver is created)
if you create a driver that does not start at the app launch, but later, Connect() method has to be called for the driver to connect to equipment. Drivers that start working together with the app launch are connected automatically. If necessary they can be turned off with the help of .Disconnect() method.
