Page 1 of 1

CheckTrigger in Events module

PostPosted: Sat Sep 18, 2010 3:00 pm
by hhg
Hi

I had some troubles getting my Oregon sensor to control the bathroom fan when I noticed this in the debug log:
2010/09/18 11:27:06 [Events] Check trigger 67 > 63 = False
2010/09/18 11:27:06 [Events] Check trigger 67 < 63 = False

Well, turns out to be line 343 that failed:

Code: Select all
IF IsDigit(sValue) AND IF IsDigit(sCond) = FALSE THEN

So I replaced that block with the one from CheckCondition:

Code: Select all
CASE ">"
         sValue = "" & sValue ' be sure it are strings
         sCond = "" & sCond
         IF IsDigit(sValue) AND IsDigit(sCond) THEN
           IF Val(sValue) > Val(sCond) THEN bReturn = TRUE
         ENDIF

Do the same for > an it works - And then I realised that CheckTrigger and CheckCondition does the same, and are identical except for the log messages, so in the end, I just replaced the call in line line 218 in CheckDeviceChangeEvent with a call of CheckCondition:

Code: Select all
IF NOT CheckCondition(sValue, rResult["triggers.param3"], rResult["triggers.param4"]) THEN CONTINUE

And then deleting the CheckTrigger procedure

/hhg

Re: CheckTrigger in Events module

PostPosted: Sat Sep 18, 2010 3:51 pm
by RDNZL
Thanks, I have added your changes and deleted the CheckTrigger() code.

Re: CheckTrigger in Events module

PostPosted: Thu Sep 23, 2010 4:37 pm
by RDNZL
I have added numerous fixes to events code and editors again in revision 420.

I now finally know why older code failed to work, DoEvent() and RunActions() got a result set as argument, that set included all records of the same type of trigger but without additional checks for value and field, so they also run all triggers and actions that where not meeting the conditions. 8)

And although it looked very clean it was not efficient, since some sql queries where done over and over again in different routines.
Now I just pass the needed value(s) directly so extra queries are not needed anymore.