Using OR in PC Access

ano

Senior Member
Has anyone been using that "OR" statement in their PC Access code?  I've stayed away from it because i never seemed to need it, and because I wasn't exactly sure how it worked, but now I see a possible use.  If someone uses it, could they explain it?  I've done some fast tests and it doesn't seem to work like I expected, but i need to test more.
 
So if I do:
 
AND IF ....
AND IF ......
OR
AND IF ....
AND IF ....
OR
AND IF ...
 
Does the OR only relate to the nearest AND IF's or do all the AND IF's have to be true between the OR's? 
 
It steps through the groups of AND IFs.
The first one that is satisfied executes the code block, it doesn't look at the subsequent groups during that pass.

Each group of AND IFs are a separate package, the OR separates the packages.


Block A
OR
Block B
OR
Block C


If you want 3 mandatory condition and one optional condition then each block would have 4 AND IF statements, the first 3 would be repeated in each block.


AND IF A
AND IF B
AND IF C
AND IF D1
OR
AND IF A
AND IF B
AND IF C
AND IF D2
 
Desert_AIP said:
It steps through the groups of AND IFs.
The first one that is satisfied executes the code block, it doesn't look at the subsequent groups during that pass.

Each group of AND IFs are a separate package, the OR separates the packages.


Block A
OR
Block B
OR
Block C


If you want 3 mandatory condition and one optional condition then each block would have 4 AND IF statements, the first 3 would be repeated in each block.


AND IF A
AND IF B
AND IF C
AND IF D1
OR
AND IF A
AND IF B
AND IF C
AND IF D2
THANKS!!!  I got it. And it does work?  ^_^
 
I'm making a few passes through my code to optimize it.  I've consolidated much of it using unnamed buttons/macros and its much cleaner. I think this OR will help in a few places too.
 
Now if I could only trigger when a zone has trouble? OK I'll quite when I'm ahead.  :o 
 
I'll try out the OR tonight.
 
Thanks again.
 
I have a few places where I stack ~5 conditions plus some options. 
Instead of repeating them in each OR block, I have a block that sets a flag if they are all true, and then use the flag status as one of the conditionals in each OR block in the actual block to execute an action. 
In those situations that saves me several programming lines. 
I only use this method if it will save me a line or more because the trigger and flag setting actions take up two.
 
I usually use the flag on for 1 second when the conditions are true action so that if they ever become not true the flag turns off without having a separate block evaluate the conditions and turn it off. 
The 1 second on ensures the flag is on for at least the current pass through the code (and actually lasts for several passes -  which depending on the conditions could have consequences so be aware).
 
Sidebar: I do something similar to toggle the status of a button so I can use one button for two actions.
 
 
Does a Trouble set a NOT READY condition, I can't recall?
 
So you would trigger on:

WHEN ZONE NOT READY
AND IF ZONE HAS TROUBLE
THEN...
 
Thanks again. I didn't know there was an "AND IF ZONE HAS TROUBLE" 
That seems a bit like testing if the AC is running. You trigger on it directly, but you can test for it after the fact.  Better than nothing. I do wish you could trigger on it directly so I didn't have to use an "EVERY 1 MINUTE." 
 
Low Battery for wireless sensors cause TROUBLE and it would be nice to test for them too. But is good to know. I currently have a Betabrite LED sign that displays when a zone is "Not Ready" I can just put a trouble test for it after, so the sign will say something like: 'MASTER BACK DR' then 'LOW BATTERY.'   I speak it also if its a door or window.
 
I also wish I could measure the loop time it takes to run through the program.  I'm not so much trying to have less lines as much as trying to keep the panel fast by minimizing the number of initial triggers, or at least test for each only once.  They are what could slow it down, not the AND IF's since they only run if a line is triggered.
 
One of the reasons I don't like using "WHEN EVERY" triggers, I think it slows things down or has the potential to.
I would guess the ceiling is the 300ms zone response window. 
Never want to go over that in a single pass or you'd miss a change.
So I assume the panel loop time is faster than that.
 
I've had the low battery from wireless driveway sensor issue, which is why I changed them from supervised to unsupervised since they're only for automation not security.
 
I'm still running some 5.7e's here. 
They will track all three states and allow you to send an action on a change in state.
That might be used to end around the triggers available in PCAccess.
 
Desert_AIP said:
I've had the low battery from wireless driveway sensor issue, which is why I changed them from supervised to unsupervised since they're only for automation not security.
Its funny you mention that because I'm in the process of installing two of these, for me Resolution Products RE104. They actually work pretty good. I had one in my previous house and it didn't detect all three car driveways, but for my new house, I got two and its only two cars wide, and quite long, so garbage trucks shouldn't be detected. Its 25 ft. from the road, one on each side. I have supervision on, not sure why you don't want it.  I am putting them in cement in the hole, so removed the sensor, and sure enough, maybe 4 hours later the trouble activated for both.
 
They are just automation, of course, but thinking how I'll use them. I was thinking, when a car in the driveway is detected, if the garage door is open, and if no motion recently occurred in my house, then close garage door and set alarm to away. I wonder if that would work?  :o
 
The 300ms zone time for max. loop time? Possibly, but the zone hardware can probably lock the status if the software is a bit slow so maybe the loop time could be greater than 300ms. Also realize that the Omni must have a completely independent loop for security and that has a higher priority than automation. If an alarm is in progress, automation goes REALLY slow, if at all. The dialer and security definitely get 99.9% of its attention. 
 
Likely the alarm zones get evaluated independently from the automation programming, determined by the type setting you set up. Aux zones probably have the lowest priority.

I changed the zones to unsupervised because I was getting calls at 2 AM from the monitoring company telling me zone XX had trouble.
 
Desert_AIP said:
I changed the zones to unsupervised because I was getting calls at 2 AM from the monitoring company telling me zone XX had trouble.
Wow, you must have a very aggressive alarm company.  I didn't even realize the panel sends out a signal for aux. zones. If I have Trouble on an alarm zone NextAlarm will send me an email, but they would never call. Don't even get an email for Aux. zones.  I thought it bad enough that the panel would beep for Trouble, but I turned that off long ago. Even still, when you have Trouble, the consoles light up bright, and since I have one in the bedroom, that's usually enough to wake me up. 
 
Sounds like your driveway sensors might have range issues, or low battery. Low battery always occur in the middle of the night, because its the coolest and battery voltage is the lowest.
 
I think it was the latter (cold temps).  I've since repositioned them.
 
I am using Alarm Relay/Watchlight. 
I've been happy for 5 years.
I'd prefer them to be overly aggressive until I tell them what not to call me about.
 
Back
Top