Help with Logic

Discussion in 'C-Touch/HomeGate/SchedulePlus/PICED Software' started by Josh, Jan 6, 2006.

  1. Josh

    Josh

    Joined:
    Aug 25, 2004
    Messages:
    240
    Likes Received:
    0
    Location:
    Pretoria, South Africa
    I have the logic below in which I am trying to switch all inside lights on when there is an alarm (Comfort) and it is at night, and for the outside lights to flush, while the alarm is still on.

    When there is an alarm (at night), all inside lights turn on, but the outside lights do not flash at all. Can anyone tell me what am I doing wrong? :confused:

    ---------------- Start of logic -------------------------------------
    once (GetCBusState("Network 1", "Security", "Alarm State") = ON) then
    begin
    if (darkOutside =true) then
    begin
    SetScene("All Inside Lighting Scene");
    while (GetCBusState("Network 1", "Security", "Alarm State")=ON) do
    begin
    SetLightingLevel("Perimeter Lights", 100%, "0s");
    Delay("00:00:04");
    SetLightingLevel("Perimeter Lights", 0%, "0s");
    Delay("00:00:01");
    end;
    SetLightingLevel("Perimeter Lights", 90%, "0s");
    end;

    end;

    ----------------------------- end of logic ------------------------------

    Regards
    J
     
    Last edited by a moderator: Jan 6, 2006
    Josh, Jan 6, 2006
    #1
  2. Josh

    Phil.H

    Joined:
    Jul 29, 2004
    Messages:
    466
    Likes Received:
    0
    Location:
    Sydney
    Logic and once

    I think you will find it is because you have nested your 'while' operation inside the once statement.

    Once is a very handy 'non standard' process for automation. 'once the condition is true it has to transition not true then true again (once) before the following actions will be executed.

    You might have to write additional code to set an alarm flag (boolean variable) then send commands (if) whilst the flag is true. Don't forget your delays and good code to reset the alarm flag after a period of time or when the alarm resets.

    PS . Do I get this right - do you have three Tags inside the once condition. Does this actually compile ?
     
    Last edited by a moderator: Jan 6, 2006
    Phil.H, Jan 6, 2006
    #2
  3. Josh

    Darren Senior Member

    Joined:
    Jul 29, 2004
    Messages:
    2,361
    Likes Received:
    0
    Location:
    Adelaide, South Australia
    Do the outside lights go on ?

    Try a delay of 2 or 3 seconds and see if it makes a difference. It may be that the lights are flashing off for such a short time that it isn't noticeable.
     
    Darren, Jan 9, 2006
    #3
  4. Josh

    NickD Moderator

    Joined:
    Nov 1, 2004
    Messages:
    1,420
    Likes Received:
    62
    Location:
    Adelaide
    I may be misunderstanding the operation of the logic engine, but isn't this :

    Code:
    while (GetCBusState("Network 1", "Security", "Alarm State")=ON) do
    begin
    SetLightingLevel("Perimeter Lights", 100%, "0s");
    Delay("00:00:04");
    SetLightingLevel("Perimeter Lights", 0%, "0s");
    Delay("00:00:01");
    end;
    going to loop until the alarm stops? ie no other logic code will be executed while the alarm is going?

    Nick
     
    NickD, Jan 9, 2006
    #4
  5. Josh

    Richo

    Joined:
    Jul 26, 2004
    Messages:
    1,257
    Likes Received:
    0
    Location:
    Adelaide
    yes, I think so. With a scan based engine like the PAC you would be much better programming it using PLC mentality and using a timer you check on each scan to do timed actions based on events.
     
    Richo, Jan 9, 2006
    #5
  6. Josh

    Darren Senior Member

    Joined:
    Jul 29, 2004
    Messages:
    2,361
    Likes Received:
    0
    Location:
    Adelaide, South Australia
    yes
    Logic code in other modules will continue to run.
     
    Last edited by a moderator: Jan 9, 2006
    Darren, Jan 9, 2006
    #6
  7. Josh

    Josh

    Joined:
    Aug 25, 2004
    Messages:
    240
    Likes Received:
    0
    Location:
    Pretoria, South Africa
    The outside lights remain on the whole night. When there is an alarm, I would like them to start flushing and once the alarm is off again, the outside lights should remain on.

    The inside lights do turn on

    I tried the same logic without the do loop and alarm if condition and it works.
     
    Josh, Jan 9, 2006
    #7
  8. Josh

    Josh

    Joined:
    Aug 25, 2004
    Messages:
    240
    Likes Received:
    0
    Location:
    Pretoria, South Africa
    That is what I wanted to do in this case, that is keep the lights flashing until the alarm stops. Then turn the lights back on (in the logic).
     
    Josh, Jan 9, 2006
    #8
  9. Josh

    Josh

    Joined:
    Aug 25, 2004
    Messages:
    240
    Likes Received:
    0
    Location:
    Pretoria, South Africa
    Yes it compiles.
     
    Josh, Jan 9, 2006
    #9
  10. Josh

    Darren Senior Member

    Joined:
    Jul 29, 2004
    Messages:
    2,361
    Likes Received:
    0
    Location:
    Adelaide, South Australia
    It may be best to send your project archive into Tech Support so that they can duplicate the problem and find the cause.
     
    Darren, Jan 9, 2006
    #10
  11. Josh

    Josh

    Joined:
    Aug 25, 2004
    Messages:
    240
    Likes Received:
    0
    Location:
    Pretoria, South Africa
    Did as you suggested, alarm went off last night, still no flashing .....
     
    Josh, Feb 2, 2006
    #11
  12. Josh

    richy

    Joined:
    Aug 8, 2004
    Messages:
    88
    Likes Received:
    0
    Location:
    VIC
    For what its worth,

    Write the Test before you Write the code.

    When my logic is not working, I always write code to show where the logic is falling over. This is usually in the form of Screen indicators, and monitors on all the variables involved.

    Hope that helps.
     
    richy, Feb 2, 2006
    #12
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.