How to write if function of 2 node value

8 years 11 months ago - 8 years 11 months ago #1554 by lesjaw
Hai..

In VB usually i write like this..

If M=1 and N=2 then
c = 3
end if

how do i write like that in automation?

example is like this..
public void Setup()   
{  
  EventHelper.ModuleChangedHandler((o, m, p) =>  
{   
if (m.Domain == Domains.VIRTUAL && m.Address == "N3S0" && p.Property == "Sensor.Motion" == (p.Value == "1"))
    {  
 // filter when switch on event  
if (m.Domain == Domains.VIRTUAL && m.Address == "N14S0" && p.Property == "Sensor.DigitalValue" == (p.Value == "1"))
{

DriverHelper.ProcessCommad(Domains.VIRTUAL, "N14S0", "ControlOn", ""); 
     
 
      {  
       }  
    }  
}
 
    return true;   

 
 });   

 
  }

what i want to achieve is, i want to check N14S0 value first before "DriverHelper.ProcessCommad" if N14S0 value is 1 and the "N3S0 is also 1 then it executed..

thanks

Please Log in or Create an account to join the conversation.

8 years 11 months ago #1557 by lesjaw
ah founded..i'm using this approach



/*  

 
 This code is running one time when program is enabled  

 
*/  

 
public void Setup()  

 
{  

 
  EventHelper.ModuleChangedHandler((o, m, p) =>  

 
  {   

 
    // filter digital switch - change module address  

 
    if (m.Domain == Domains.VIRTUAL && m.Address == "N3S0" && p.Property == "Sensor.Motion"){  

 
      // filter when switch on event
      ModuleParameter n = ModuleHelper.GetProperty(Domains.VIRTUAL, "N14S0", "Sensor.DigitalValue");

 
      if (p.Value == "1")  
        if (n.Value == "0")

 
      {  
        
 
        //here are commands to execute in sequence - change commands to suit your configuration    

 
        DriverHelper.ProcessCommad(Domains.VIRTUAL, "N14S0", "ControlOn", "");  

 
              

 
      }  

 
    }  

 
    return true;   

 
  });   

 
}  

 
  

 
/*  

 
  This code is running periodicaly when program is enabled.    

 
  Cron job detirmine running period.   

 
*/  

 
public void Run()  

 
{  

 
}  

so it check of Sensor.DigitalValue first (if Lamp is on) then this :
DriverHelper.ProcessCommad(Domains.VIRTUAL, "N14S0", "ControlOn", "");
not executed

Please Log in or Create an account to join the conversation.

8 years 11 months ago #1580 by EasyIoT
Your solution is good. You combine event and GetProperty. But you need two checks, first if event occur for node 1 and GetProperty for node 2 and in second case check event for node 2 and GetProperty for node 1.

Please Log in or Create an account to join the conversation.

Time to create page: 0.235 seconds

Forum latest

  • No posts to display.