aLf Posted March 16, 2008 Posted March 16, 2008 I've tried several different ways of using Parenthesis. Each way seems to do the same end result in ISY. Can anyone explain the basic, and maybe more than basic use of these. Also I can understand in therory the difference in "IF" or "AND" Parenthesis, but what do you do when you have an IF and an AND in the same call. Thanks, aLf
IndyMike Posted March 16, 2008 Posted March 16, 2008 Alf, What were talking about here is really the "distributive property" of multiplication. i.e. A x (b + c) = (A x + (A x C) In the above the "X" is an "and" statement and the "+" is an "or" statement. The equivalent logic in terms of the ISY conditions : A X (B + C) If Condition1 and ( Condition 2 or Condition 3) would be the same as: (A X + (A X C) If (Condition 1 and condition 2) or (Condition 1 and condition 3) Does that make sense, or have I just made things more confusing? IM
aLf Posted March 16, 2008 Author Posted March 16, 2008 Indy, thanks, but I'm still confused, in you example you use examples of and (and) or in the same example without () around either or the other. Here is what I need. It works many ways, I just want to be sure to do it right... IF 'KPL ABC E' is ON OR 'KPL XYZ E' is ON OR 'APL AWAY' is ON AND FROM 12:00:00 0n 1/1/08 to 11:59:59 oN 12/31/08 AND FROM SUNRISE -30 MINUTES TO SUNSET +30 MINUTES AND STATUS 'LAKE OUTLETLINC' IS OFF THEN 'LAKE OUTLETLINC' ON Let me know what to do (properly). Also, how the heck do you copy a screen or program within ISY to this forum so one doesn't have to type the code as I did above. Thanks, aLf
DEGoodrich Posted March 16, 2008 Posted March 16, 2008 What were talking about here is really the "distributive property" of multiplication. i.e. A x (b + c) = (A x + (A x C) In the above the "X" is an "and" statement and the "+" is an "or" statement. The equivalent logic in terms of the ISY conditions : A X (B + C) If Condition1 and ( Condition 2 or Condition 3) would be the same as: (A X + (A X C) If (Condition 1 and condition 2) or (Condition 1 and condition 3) IM OMG That just blew me away, so early in the morning.... I just thought i might see if anyone else has noticed the strange thing I have discovered? : I have noticed that the order of several grouped "and" conditions and also several "or" conditions grouped together makes a difference on the outcome of the program becomeing "true" or "false"! Is this by design? If so I would love to know exactly how the programs are "scanned". Maybe it is just a timing thing and my brain is going faster than the CPU in that "Black Box" thing. Does it scan the programs in a specific order, does it finish one before starting another? It seems to me that it is processing the programs as if they were all one.
upstatemike Posted March 16, 2008 Posted March 16, 2008 Alf, What were talking about here is really the "distributive property" of multiplication. i.e. A x (b + c) = (A x + (A x C) In the above the "X" is an "and" statement and the "+" is an "or" statement. The equivalent logic in terms of the ISY conditions : A X (B + C) If Condition1 and ( Condition 2 or Condition 3) would be the same as: (A X + (A X C) If (Condition 1 and condition 2) or (Condition 1 and condition 3) Does that make sense, or have I just made things more confusing? IM I am planning to use this with "Control" triggers where I expect the trigger to be a switch being turned On but also want to allow for an accidental double tapping of the switch Fast On.
IndyMike Posted March 16, 2008 Posted March 16, 2008 Indy, thanks, but I'm still confused, in you example you use examples of and (and) or in the same example without () around either or the other. Here is what I need. It works many ways, I just want to be sure to do it right... IF 'KPL ABC E' is ON OR 'KPL XYZ E' is ON OR 'APL AWAY' is ON AND FROM 12:00:00 0n 1/1/08 to 11:59:59 oN 12/31/08 AND FROM SUNRISE -30 MINUTES TO SUNSET +30 MINUTES AND STATUS 'LAKE OUTLETLINC' IS OFF THEN 'LAKE OUTLETLINC' ON Let me know what to do (properly). Also, how the heck do you copy a screen or program within ISY to this forum so one doesn't have to type the code as I did above. Thanks, aLf Alf, I think I understand what you are trying to accomplish with the above. However, if your above code works for you then I don't understand the ISY "order of operations" (we'll need to consult Chris and Michel). I normally evaluate these by writing a boolean equation. Definitions: True=1 False=0 X (multiplication) = and statement + (addition) = or statement A + B = 0 + 0 = 0 (false) A + B = 1 + 0 = 1 (true) A + B = 0 + 1 = 1 (true) A + B = 1 + 1 = 1 (true) A X B = 0 X 0 = 0 (false) A X B = 1 X 0 = 0 (False) A X B = 0 X 1 = 0 (False) A X B = 1 X 1 = 1 (true) Now for your code - Changing the "Or statments" to "+" and the "and statements" to "X": ('KPL ABC E' is ON) + ('KPL XYZ E' is ON) + ('APL AWAY' is ON) X (FROM 12:00:00 0n 1/1/08 to 11:59:59 oN 12/31/08) X (FROM SUNRISE -30 MINUTES TO SUNSET +30 MINUTES) X (STATUS 'LAKE OUTLETLINC' IS OFF) Substituting variables: A + B + C X T1 X T2 X D = result Looking at the above, if either A or B are true, condition will evaluate to a true 1 + B + C X T1 X T2 X D = 1 (true) A + 1 + C X T1 X T2 X D = 1 (true) If A and B are false, and any of the multiplied terms are false, you will get a false out of that section of the code. Said differently terms C, T1, T2 and D all need to be true to get a true. A + B + 0 X T1 X T2 X D = 0 (false) I'm not entirely sure why you have the T1 constraint below. As written, your schedule will stop functioning on 1/1/09. AND FROM 12:00:00 0n 1/1/08 to 11:59:59 oN 12/31/08 AND FROM SUNRISE -30 MINUTES TO SUNSET +30 MINUTES So, if I haven't bored you to tears yet, here's what I believe you were trying to accomplish - (A + B + C) X T1 X T2 X D = result For your actual code: IF ( 'KPL ABC E' is ON OR 'KPL XYZ E' is ON OR 'APL AWAY' is ON ) AND FROM 12:00:00 0n 1/1/08 to 11:59:59 oN 12/31/08 And FROM SUNRISE -30 MINUTES TO SUNSET +30 MINUTES AND STATUS 'LAKE OUTLETLINC' IS OFF THEN 'LAKE OUTLETLINC' ON If ( Status 'Bar Cans' is On And Status 'Bar Lamp' is On And Status 'Dinette' is On ) And From 12:00:00AM on 2008/01/01 To 11:59:00PM on 2008/12/31 And From Sunrise - 30 minutes To Sunset + 30 minutes (same day) And Status 'Kitchen Cans' is On Then - No Actions - (To add one, press 'Action') Else - No Actions - (To add one, press 'Action') Also - copy a program by "right clicking" on the program tree. Select copy to clipboard and past into the forum post. Happy programming, IM
aLf Posted March 17, 2008 Author Posted March 17, 2008 Indy Mike: Thank you! I will take your post home tonight as homework! Very detailed explanation, I WILL get it straight. I fly airplanes for a living, I don't write code. I'm guessing if I gave you an explanation of basic international flying you'd be almost as lost as I am with your explanation. You've given me enough information however to figure it out. Thanks again. aLf
IndyMike Posted March 17, 2008 Posted March 17, 2008 Indy Mike: Thank you! I will take your post home tonight as homework! Very detailed explanation, I WILL get it straight. I fly airplanes for a living, I don't write code. I'm guessing if I gave you an explanation of basic international flying you'd be almost as lost as I am with your explanation. You've given me enough information however to figure it out. Thanks again. aLf Sorry! I didn't realize I was assigning homework (I always hated that). In regard to the rest of your post - 1) It's amazing the number of Pilots I've met doing HA. Is it because you guys are always "on the road"? 2) If you're asking me to strap into the cockpit of a wide-body, yep that scares the heck out of me. However, if you're flying a Boeing, Airbus, or MD airframe, you've got many of my components on board. 3) I write code, but I am certainly not a programmer. Actually I'm just a design engineer that had to pick up some programming experience to "get by" (makes me the worst kind of hack). I'm still curious about the schedule: AND FROM 12:00:00 0n 1/1/08 to 11:59:59 oN 12/31/08 Do you want your program to stop on 1/1/09? IM
aLf Posted March 17, 2008 Author Posted March 17, 2008 Indy: I fly a Cessna Citation X. Midsize corp. jet, fast, Mach .92, 100 mph faster than most airliners, 3,000 mile range. Thanks again for the code. In regards to the date question, actually I abreviated the date. In reality, I use the same outlet for different things, some when I'm home, some not. For instance, one oulet will do one thing during the Holidays for Christmas lights, but will do lawn type things, sprinklers, etc from mid April to October. When ISY can do same date runs for "ALL" years, I will be able to program forever. For now, I change the dates every year. I will eventually do folders for the (HOME) or (AWAY) items. I understand your code as to how it works, I will read and re-read your method tonight. Thanks again, aLf
Recommended Posts