0
Answered

Send the same Value to a lot of Commands

Paolo Scarpetta 8 years ago in Server Solutions / Windows Server updated by Ekaterina (head of support) 8 years ago 1

I need to set the same value to a lot of commands, Is it possible to set the same value to a group of commands by defining the desired one in a virtual channel for example?

Answered

If it is a constant values from the some button, you can just drag and drop all the needed commands to the single Item (make a "macro command").




But if you have some conditions or math that should be done before sending, you can use the script:

// this function send the value to the list of commands with specified interval (100ms) 
// to be sure that the automation system will bot be overloaded by the commands
function send_macro (driver, channel, value) {
   function send () {
      if (channel[0]) IR.GetDevice(driver).Set(channel.shift(), value);
      else IR.ClearInterval(interval)
   }
   var interval = IR.SetInterval(100, send)
}

// here we send a call the macro function with needed parameters when press on Item
IR.AddListener(IR.EVENT_ITEM_PRESS, IR.GetPage("Page 1").GetItem("Item 1"), function() 
{
   send_macro  ('Modbus',      // driver
               ['Channel 1', 'Channel 2', 'Channel 3', 'Channel 4'],   // list of channels
               1);        // value to send
});

/* 
   var value = 100;  //you can define the value as a variable from external logic
   
   send_macro  ('Modbus',
               ['Channel 1', 'Channel 2', 'Channel 3', 'Channel 4'],
               value); 
*/

Macro send.irpz