bit of a logic issue

Discussion in 'C-Touch/HomeGate/SchedulePlus/PICED Software' started by GettingInTouch, Oct 16, 2012.

  1. GettingInTouch

    GettingInTouch

    Joined:
    Oct 16, 2012
    Messages:
    2
    Likes Received:
    0
    Location:
    perth
    Hey im a bit new on the c-bus scene but i cant figure out how to make this bit of coding work on a PAC

    I have separated the code into 2 separate sections

    Summer_Var is a global integer

    if (month >="11") or (month <= "04") then
    begin
    Summer_Var := 1;
    end
    else
    begin
    Summer_Var := 2 ;
    end

    This is one peice of code just to separate between the 2 different times i want the system to come on during the year depending on the month.

    The second peice of code

    if (Summer_Var =1) and (Time >= "3:30:00 AM") and (Time <="7:00:00 AM") then
    begin
    SetLightingState("Hot water system", on)
    end
    else
    begin
    SetLightingState("Hot water system", off)
    end;

    After that i created a button on the simulation page for the HWS, and ran the program.

    I changed the time on the computer to be within the "on" range and nothing happens, and i get an error saying something along the lines of too many messages being sent on the c-bus

    I did try changing this code and using "once" statements, however this did not work either.

    This is obviously not what the full code will be when i add the second time of year etc but i tried to get just this section working with no luck.

    Any help is appreciated.
     
    GettingInTouch, Oct 16, 2012
    #1
  2. GettingInTouch

    Roosta

    Joined:
    Nov 22, 2011
    Messages:
    560
    Likes Received:
    1
    Location:
    Australia
    Hey,

    Why not just use the scheduling function in the PAC?

    Setup 4 schedules:

    Summer HWS ON
    Summer HWS OFF
    Winter HWS ON
    Winter HWS OFF

    No logic required.. :-D

    Cheers..
     
    Roosta, Oct 16, 2012
    #2
  3. GettingInTouch

    GettingInTouch

    Joined:
    Oct 16, 2012
    Messages:
    2
    Likes Received:
    0
    Location:
    perth
    Hah so easy! Thank you.

    I'm still due to do my courses so I'm just playing on a system I'm putting into my own home and clearly missed one if the basics!

    Can anyone explain the error in my logic anyway as I can't see why it wouldn't work.
     
    GettingInTouch, Oct 17, 2012
    #3
  4. GettingInTouch

    TimB C-Bus Systems Engineer

    Joined:
    Dec 23, 2004
    Messages:
    21
    Likes Received:
    0
    Location:
    Adelaide, South Australia
    As has been pointed out the correct way to do this is using schedules, but I'll explain what's wrong with your code anyway.

    This code will execute either one or the other branch of the IF statement on every cycle of the logic engine. Since both branches set a lighting group, this will cause a C-Bus message to be sent every 200ms. The logic engine detects this and gives the error you saw to prevent your C-Bus network from being overloaded by this incorrect code.

    The correct version of this, using once statements, is

    Code:
    once (Summer_Var =1) and (Time = "3:30:00 AM") then
      SetLightingState("Hot water system", on);
    
    once (Summer_Var =1) and (Time ="7:00:00 AM") then
      SetLightingState("Hot water system", off);
    
     
    TimB, Oct 17, 2012
    #4
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.