0
Answered

Different values in in_Value and in_Name

Bram Swinkels 6 months ago updated by Vladimir Ovchinnikov 6 months ago 6

I need 2 different values in the 'vari' variable. How can I do this?

var vari = "Server.Tags." + in_Name;

var value = in_Value;

var dag = IR.GetVariable("System.Date.DayOfWeek");

if(dag == 1 && vari == "Server.Tags.ma1" && value == "1")

{

     if(vari == "Server.Tags.uur1")

     {

           IR.Log("test");

     }

}

Under review

Hello.

if((dag == 1) && ((vari == "Server.Tags.ma1") || (vari == "Server.Tags.uur1")) && (value == "1"))
{
IR.Log("test");
}

Thank you!

Is it also possible to check the system time? When 'vari == "Server.Tags.uur1' is equal to the system hour then it should say 'test'.

var hour = IR.GetVariable("System.Time.Hour");
var min = IR.GetVariable("System.Time.Minutes");

if((dag == 1) && ((vari == "Server.Tags.ma1") || (vari == "Server.Tags.uur1")) && (value == "1"))
{
IR.Log("test");
}

IR.SetGlobalListener(IR.EVENT_GLOBAL_TAG_CHANGE, function(name, value)
{
if ((name == "System.Time.Hour") && (value == 1))
{
if((dag == 1) && ((vari == "Server.Tags.ma1") || (vari == "Server.Tags.uur1")) && (value == "1"))
{
IR.Log("test");
}
}
});

IR.SubscribeTagChange("System.Time.Hour");

Is there a way to check the system time every second?

Hello.

var count = 0;
var period = 3;
IR.SetGlobalListener(IR.EVENT_GLOBAL_TAG_CHANGE, function(name, value)
{
IR.Log(name + " = " + value);
if (count < period)
{
count += 1;
}
else
{
IR.Log("action");
count = 0;
}
});
IR.SubscribeTagChange("System.Time.Seconds");