Simple Or Statement

Discussion in 'C-Touch/HomeGate/SchedulePlus/PICED Software' started by Memphix, Aug 11, 2011.

  1. Memphix

    Memphix

    Joined:
    Aug 31, 2006
    Messages:
    248
    Likes Received:
    1
    Location:
    Australia
    I have a simple statement that is not working as I'd expect:

    Code:
    once ((GetEnableState("Lights Enable Schedule") = ON) and
          (GetLightingState("PE Cell") = ON)) then
    begin
      SetLightingLevel("Outside Light", 100%, "0s");
    end;
    
    once (GetLightingState("PE Cell") = OFF) or
         (GetEnableState("Lights Enable Schedule") = OFF) then
    begin
      SetLightingLevel("Outside Light", 0%, "0s");
    end;
    The "or" does not seem to be working. In simulation it works fine. On site, the light only turns off when "PE Cell" is OFF, not when the "Lights Enable Schedule" turns OFF. Caption of logs below.

    ------------------
    9/08/2011 10:59:37 PM Screen Draw: 310ms to 311ms
    9/08/2011 11:00:01 PM Info : Schedule "Lights Disable Time"
    9/08/2011 11:00:01 PM C-Bus Tx : Set Enable Control, Lights Enable Off (Schedule "Lights Disable Time")
    9/08/2011 11:00:38 PM Free Memory: 26.7 MB
    ------------------
    10/08/2011 7:28:48 AM C-Bus Rx : Set Warehouse Lights On (unit 196)
    10/08/2011 7:28:53 AM C-Bus Rx : Set PE Cell Off (unit 205)
    10/08/2011 7:28:54 AM C-Bus Tx : Set Outside Light Off (Logic Line 43)
    10/08/2011 7:28:59 AM Free Memory: 36.0 MB
    ------------------

    Can someone tell me where I'm wrong or ?
    I'm sure if I made two seperate statements it would work fine but I'd like to know why the or statement is not working. Does it require additional brackets? But why is it working in the simulation then? Is it something to do with the Enable Control Application?
     
    Last edited by a moderator: Aug 11, 2011
    Memphix, Aug 11, 2011
    #1
  2. Memphix

    Darren Senior Member

    Joined:
    Jul 29, 2004
    Messages:
    2,361
    Likes Received:
    0
    Location:
    Adelaide, South Australia
    In your code, you are using an enable group called "Lights Enable Schedule", but in the log, the enable group is called "Lights Enable".

    Also, in your code, you are controlling a lighting group called "Outside Light", but in the log, there is a group called "Light".

    What is going on?
     
    Darren, Aug 11, 2011
    #2
  3. Memphix

    Memphix

    Joined:
    Aug 31, 2006
    Messages:
    248
    Likes Received:
    1
    Location:
    Australia
    I was simplifying my group address names & schedules, didn't quite make them match. The log shows the schedule name which can be different to event or the group address it turns on/off. I've only modified the names, the logic statement is exactly the same otherwise.

    The schedule is from sunset to 11pm.
     
    Last edited by a moderator: Aug 11, 2011
    Memphix, Aug 11, 2011
    #3
  4. Memphix

    Darren Senior Member

    Joined:
    Jul 29, 2004
    Messages:
    2,361
    Likes Received:
    0
    Location:
    Adelaide, South Australia
    OK, but it makes things very confusing when people provide project information and logs which don't match (it happens quite a lot).

    Your logic code looks OK.

    In the log at 11PM, the controlled group should only go off if the PE Cell was off. If the PE Cell was on, then the once condition would not be changing and nothing would happen. It is not possible to tell this from the log extract provided.

    Also, it depends on whether the once condition was true at the time the touch screen started and stayed that way until 11PM. It is not possible to tell this from the log extract provided either.

    We really need to see logged events showing both of the once conditions going from false to true.

    An easy test is to make sure that at 11PM, the PE Cell is OFF and the Lights Enable is ON. When the Schedule switches the Lights Enable OFF, you should see the controlled group go off.
     
    Darren, Aug 12, 2011
    #4
  5. Memphix

    Memphix

    Joined:
    Aug 31, 2006
    Messages:
    248
    Likes Received:
    1
    Location:
    Australia
    I've always had in the back of my mind the simulation mode is not gospel...

    In simulation mode, if either the PE Cell or Lights Enable turns off, the Light turns off. Is this not true for this statement? That is the result I want. Should it be reversed:

    Code:
    once (GetEnableState("Lights Enable Schedule") = OFF)  or 
            (GetLightingState("PE Cell") = OFF) then
    begin
      SetLightingLevel("Outside Light", 0%, "0s");
    end;
    Thanks.
     
    Memphix, Aug 12, 2011
    #5
  6. Memphix

    Darren Senior Member

    Joined:
    Jul 29, 2004
    Messages:
    2,361
    Likes Received:
    0
    Location:
    Adelaide, South Australia
    Simulation mode in PICED is identical to Colour C-Touch. It is the exact same code running, except that PICED uses C-Gate to communicate with C-Bus and Colour C-Touch uses the C-Bus Module DLL.

    That will only happen if they are both on to start with. I suspect that when you simulate this you have slightly different conditions from when you are testing it on the actual site.

    Reversing the order will make no difference.

    Can you describe what you are trying to achieve and we can check that the logic is correct. It may be that the code is just slightly wrong, but it is hard to be sure without knowing what the aim is.
     
    Darren, Aug 12, 2011
    #6
  7. Memphix

    Memphix

    Joined:
    Aug 31, 2006
    Messages:
    248
    Likes Received:
    1
    Location:
    Australia
    Thanks Darren.

    The Light should only be ON if both conditional groups are ON. Therefore, if either group is OFF, then the Light should be OFF.

    One conditional group is turned on by the PE Cell. The other conditional group is turned on by a schedule.

    ---
    My current setup has the scheduled conditional group in the Enable Control application.
    ---
    To fix this problem I would put the PE Cell conditional group in the relay as a logic group set to AND and have the schedule turn on the Light address directly.
    However, as I mentioned, I'd like to know why the current setup has not worked.

    I re-visited the logs to confirm whats happened on site... however my logs cant be relied on. I do not have a complete consecutive two days to see. Some of the logs are blank? The details from the logs I provided have a gap between midnight and 715am... this should not be a problem however as the schedule should be operating from sunset to 11pm.
     
    Memphix, Aug 13, 2011
    #7
  8. Memphix

    Ingo

    Joined:
    Dec 2, 2006
    Messages:
    290
    Likes Received:
    1
    Location:
    South Africa
    I simulated this quickly in PICED and it works. I used Lighting Group 0, Enable Control Group 1 and a Lighting Group 2 as output. If any of these go Off then the Output goes Off.

    Code:
    once (GetLightingState(0) = OFF) or
         (GetEnableState(1) = OFF) then
    begin
      SetLightingLevel(2, 0%, "0s");
    end;
    Ingo
     
    Ingo, Aug 13, 2011
    #8
  9. Memphix

    Darren Senior Member

    Joined:
    Jul 29, 2004
    Messages:
    2,361
    Likes Received:
    0
    Location:
    Adelaide, South Australia
    OK. That is what I expected. Your logic code is correct.

    That would work too.

    I would do a search through the log to find everywhere the three group addresses occur. I expect that you will find that at some time prior to 11PM, one of the group addresses switched off so at 11PM, the once condition does not actually change.
     
    Darren, Aug 14, 2011
    #9
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.