Set scene using logic

Discussion in 'C-Touch/HomeGate/SchedulePlus/PICED Software' started by theok, Dec 20, 2009.

  1. theok

    theok

    Joined:
    Apr 28, 2008
    Messages:
    7
    Likes Received:
    0
    Hi All

    I'm experiencing some problems whilst using logic to set a scene once another is set and is night. Here is the code:

    Code:
    once (Sceneisset("Goodbye") or Sceneisset("Goodbye Garage")) and
        ((TIME > SUNSET ) or (TIME < SUNRISE )) then
       
    begin
        
         SetScene("Exit Night");
    end;
    Background
    Both Goodbye and Goodbye Garage belong to the same Trigger Group. Both scenes have the same lighting group with the same levels. Both scenes are also stored in the CTouch. The only difference is that "Goodbye" is triggered from the Ctouch and "Goodbye Garage" from a 6 gang in the garage.

    On exit the customer wanted to set the goodbye scene from the Ctouch or 6 Gang from the garage. The scene sets most of the lighting groups in the house to 0 (OFF). If it is a night exit an "Exit Night" scene was to be triggered which switched on the garage and a couple of other groups for 2 mins lighting an exit path.

    The problem
    Once "Goodbye" is set from the CTouch all the loads switch off and the "Exit Night" scene is trigger. After 2 mins the garage lights switch off, however, immediately switch back on. The customer claims the garage lights remain on ndefinately. The Application log indicates that the CTouch unit is re-triggering the "Exit Night" scene. I haven't had a chance to wait around and see whether the cycle repeats.

    Manually switching a load on immediately after the "Goodbye" scene is set (from Ctouch) and the "Exit Night" scene was set (using the logic code) breaks the cycle and the logic works as expected.

    I suspect my logic code must be looping, because the "Goodbye" scene remains set thus it sets "Exit Night" with each loop. When the goodbye is broken "Exit Night" runs a final time.

    Questions

    1. Are my assumptions correct?
    2. How do I fix this?
    3. Is there a better/more efficient way to acheive what we're trying to do?

    Your assistance would be much appreciated.

    Cheers

    Theo
     
    theok, Dec 20, 2009
    #1
  2. theok

    Mark

    Joined:
    Oct 28, 2004
    Messages:
    196
    Likes Received:
    1
    Location:
    Grenoble, France
    Hi Theok,

    Its really hard to debug logic problems like this without looking at the entire project. If you cant work it out, i would suggest contacting Tech Support for assistance.

    That said, here's a guess:
    If your "Exit Night" scene has the same group/level settings as either "Goodbye" or "Goodbye Garage", then its possible that when Exit Night is set, one of the other two is repaired (all its groups are at the levels specified by the scene, so C-Touch considers it set again), causing the once statement to execute again. If this is what's happening, toggling the "Use indicator kill for showing scene status" option in the PICED Project Details Wizard may fix it.

    Otherwise, i'd suggest doing some debugging in PICED to see if the same problem occurs when you simulate the logic. A few indicators on screen to show you if scenes are set should help you see what is going on.

    Good luck!
    Mark.
     
    Mark, Dec 21, 2009
    #2
  3. theok

    Darren Senior Member

    Joined:
    Jul 29, 2004
    Messages:
    2,361
    Likes Received:
    0
    Location:
    Adelaide, South Australia
    Firstly, thanks for taking the trouble to structure your question nicely. It makes life much easier for us (and ultimately for you too).

    This seems like an odd thing to do. Why have two identical Scenes?


    If any groups in the Exit Night scene are also in the Goodbye scene, then this will cause the problem you are seeing.

    When you set the Goodbye Scene, the groups are switched off, then immediately after, the Exit Night scene is set. If this contains a group in the Goodbye scene, then the Goodbye scene is no longer considered to be "set". At the end of the 2 minute delay (pulse), this group (or groups) get set back to level 0. The Goodbye scene is now "set" again and the "once" statement is now true again, so it sets the Exit Night scene again.

    This would confirm what I wrote above, because it "breaks" the Goodbye scene and stops it from becoming set again and causing the once to be true again.

    Yes

    Try the "Use indicator kill for showing scene status" option in the PICED Project Details Wizard as Mark suggested.

    Alternatively, remove any groups that are in Exit Night from the Goodbye scene. Put them into a new Scene called Exit Path Off. Then change the logic to:

    Code:
    once Sceneisset("Goodbye") or Sceneisset("Goodbye Garage") then
    begin
      if (TIME > SUNSET ) or (TIME < SUNRISE ) then
        SetScene("Exit Night")
      else
        SetScene("Exit Path Off");
    end;
     
    Darren, Dec 26, 2009
    #3
  4. theok

    ashleigh Moderator

    Joined:
    Aug 4, 2004
    Messages:
    2,391
    Likes Received:
    24
    Location:
    Adelaide, South Australia
    ashleigh, Dec 27, 2009
    #4
  5. theok

    theok

    Joined:
    Apr 28, 2008
    Messages:
    7
    Likes Received:
    0
    Thanks all for all the useful feedback.

    The identical scenes have been removed after getting a better understanding of scenes (thanks ashleigh).

    I've taken up your suggestions Darren with the addition of the else line and a new scene. I try this and Mark's suggestion when I'm back on site.

    Cheers
     
    theok, Dec 27, 2009
    #5
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.