Материал из Module developer
SubDevice.Send
Method can be used only with drivers AV & Custom Systems и Global Cache. It allows to send a number of data (string, number, array) to equipment
Синтаксис
SubDevice.Send(DataString)
SubDevice.Send(DataArray)
SubDevice.Send(DataString, Transport)
| Название | Пример | Описание |
| DataString | a, b, c | type: string list of variables or strings: instructions to send |
| DataArray | [a, b, c] | type: array array of variables or strings : instructions to send |
| Transport | 0 | type: number Global Cache transport ID via which data are sent:
|
| На выходе |
-
Пример
// 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"); //Gettins a device var l_oSubDevice = module.AddSubDevice("SubDevice 1", l_oDevice); //creating a device 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 subdevice var l_oSubDevice = module.AddSubDevice("SubDevice 1", l_oDevice); //creating a subdevice l_oSubDevice.Send(['setstate,1:1,1', '\r\n'], 0)
HTTP: When you send a command to HTTP driver, first indicate a method: GET, POST, PUT then indicate URI commands and Data for POST and PUT separated with commas. No commas are allowed inside URI and Data. If your protocol uses commas in HTTP commands, send them via AV & Custom Systems (TCP), as whole requests.
Global Cache: indicate transport ID where data have to be sent
