Initialising every 10 minutes

Discussion in 'C-Bus Wiser 2 Controller' started by MichaelD, Nov 4, 2016.

  1. MichaelD

    MichaelD

    Joined:
    Apr 3, 2016
    Messages:
    46
    Likes Received:
    0
    Location:
    UK
    I've been having a series of scheduling problems with my Wiser2, and now seem to have identified the problem.

    After a day or so of running, it starts to run the initialisation module every 10 minutes. It seems to be a deliberate thing, the repeats are exactly 10 minutes apart, to within a second. It does this day and night, regardless of any user inputs.

    Is it meant to do this? Do they all do it? Is there some way to stop it? Its completely screwing up my logic modules
     
    MichaelD, Nov 4, 2016
    #1
  2. MichaelD

    DarylMc

    Joined:
    Mar 24, 2006
    Messages:
    1,308
    Likes Received:
    49
    Location:
    Cleveland, QLD, Australia
    It could be a logic error forcing an initialization.
    In logic options do you have "Auto restart on error" turned on?
     
    DarylMc, Nov 4, 2016
    #2
  3. MichaelD

    MichaelD

    Joined:
    Apr 3, 2016
    Messages:
    46
    Likes Received:
    0
    Location:
    UK
    That is a really useful question. Its an area I hadn't looked at.

    "Auto restart on error" isn't turned on, but "Treat all errors as critical errors" is checked, which according to the help means that all errors will cause a restart of the Logic Engine.

    It looks like that could be the problem. The log is showing Logic Engine Stopped then Logic Engine Started every 10 minutes.

    Every time the logic engine starts, each C_Bus Tx is followed by "Info : Network 254 (Local Network) is off-line, command has been queued".
    This seems to continue for some time, then this happens:


    04/11/2016 23:48:48 Info : Network 254 (Local Network) is off-line, command has been queued
    04/11/2016 23:48:49 Info : Clock adjusted from 23:48:37 04/11/2016 to 23:48:49 04/11/2016
    04/11/2016 23:48:49 Info : - all schedules in this interval will be executed
    04/11/2016 23:57:57 Warning : Average CPU Usage : 48.1 %
    04/11/2016 23:58:01 Warning : Average CPU Usage : 54.7 %
    04/11/2016 23:58:02 Warning : Average CPU Usage : 62.6 %
    04/11/2016 23:58:13 Warning : Average CPU Usage : 70.1 %
    04/11/2016 23:58:24 Warning : Average CPU Usage : 81.7 %
    04/11/2016 23:58:29 Warning : Average CPU Usage : 90.2 %
    05/11/2016 C-Bus Tx : Set Virtual Sleep On (Logic Line 529)
    05/11/2016 Info : Network 254 (Local Network) is off-line, command has been queued
    05/11/2016 00:18:02 Info : Logic Engine Stopped

    Any thoughts on why this could be happening?
     
    MichaelD, Nov 5, 2016
    #3
  4. MichaelD

    DarylMc

    Joined:
    Mar 24, 2006
    Messages:
    1,308
    Likes Received:
    49
    Location:
    Cleveland, QLD, Australia
    Hi Michael
    Someone else with more experience is needed.
     
    DarylMc, Nov 5, 2016
    #4
  5. MichaelD

    Ashley

    Joined:
    Dec 1, 2005
    Messages:
    1,524
    Likes Received:
    173
    Location:
    Adelaide, Australia
    Make sure you have "Wait until C-Bus is on-line to start logic" ticked under logic engine Options/Other. (I'm not really sure why this isn't the default).

    If the logic tries to output a lot of commands at startup and Cbus isn't yet running the commands will be queued and may be responsible for the restarts.

    If this solves the problem then you probably still have an issue with your logic since it shouldn't really be sending out so many commands that quickly.

    If you want to post the logic we could have a look at it for you.
     
    Ashley, Nov 5, 2016
    #5
  6. MichaelD

    MichaelD

    Joined:
    Apr 3, 2016
    Messages:
    46
    Likes Received:
    0
    Location:
    UK
    Thanks guys, this is really helpful.

    For the Wiser2, "Wait until C-Bus is on-line to start logic" is the default, according to PICED, but it doesn't seem to be working that way, so I'll check the box on that too.

    In the initialise, I'm setting two groups, one scene (with 12 groups) and enabling 5 modules, so that everything is in a 'safe' and known state. Does this seem excessive?

    I'll crawl through the logic modules to make sure I'm not doing anything stupid, and see if that does it. If not, then I'd like to take you up on the offer of looking at the logic. I have been developing software for many years, but this processing of modules is very different from my usual stuff, so my instincts might be tripping me up.
     
    MichaelD, Nov 5, 2016
    #6
  7. MichaelD

    MichaelD

    Joined:
    Apr 3, 2016
    Messages:
    46
    Likes Received:
    0
    Location:
    UK
    After a few days of changing things around in logic, the Wiser2 is still re-initialising every 10 minutes. I've added in a new group 'xxxx Wiser Reboot xxx' to help find the reboots in the log, but its actually pretty easy to find them, they happen every 10 minutes. As I write, I know there will be another one in 91 seconds.

    The re-initialises don't happen when I run the logic inside PICED, only on the Wiser. And it happens right through the night, even when there is nothing much going on within the network.

    And I don't have anything in my logic that is triggered every 10 minutes, so I'm thinking it must be something inherent in the Wiser.

    Would it help if I posted the logic? If so, how do I do that?
     

    Attached Files:

    MichaelD, Nov 8, 2016
    #7
  8. MichaelD

    rhamer

    Joined:
    Aug 3, 2004
    Messages:
    673
    Likes Received:
    3
    Location:
    Melbourne, Australia
    Can you comment out modules one at a time to see if you can find the culprit module at least.

    The other thing I would do is download and run the diagnostics utility and watch the traffic there, to see if there is any event correlation.
    This utility talks directly to a PCI/CNI and shows the raw data a bit better than the log.

    Cheers

    Rohan
     
    rhamer, Nov 8, 2016
    #8
  9. MichaelD

    Ashley

    Joined:
    Dec 1, 2005
    Messages:
    1,524
    Likes Received:
    173
    Location:
    Adelaide, Australia
    To post your logic, open the logic then just select FILE/LOGIC REPORT. Either copy and paste it or print it to PDF.
     
    Ashley, Nov 8, 2016
    #9
  10. MichaelD

    MichaelD

    Joined:
    Apr 3, 2016
    Messages:
    46
    Likes Received:
    0
    Location:
    UK
    Finding the bad module took a while, with 19 modules to check. Used a binary search, which I haven't used for years, and that helped a lot.

    But, this is the logic that is causing the problem. If I disable this module, everything works fine, if I enable it, then the Wiser2 re-initialises after exactly 10 minutes.

    Can anyone see the problem? at this stage, I can't, it works fine in PICED, but not on the Wiser2

    =============================================================

    once (Time = "07:30:00") and (DayOfWeek in ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday"]) then
    begin
    SetLightingState("Virtual Sleep", OFF);
    end;

    once (Time = "09:00:00") and (DayOfWeek in ["Sunday", "Saturday"]) then
    begin
    SetLightingState("Virtual Sleep", OFF);
    end;


    once (GetLightingState("Virtual Sleep") = OFF) then
    begin

    SetLightingLevel("Night Dimming Level", 100%, "0s");
    SetScene("Daytime Switch Brightness");
    Delay("0:05:00");
    SetLightingState("Utility Rm PIR Enable", ON);
    end;
     
    MichaelD, Nov 9, 2016
    #10
  11. MichaelD

    Ashley

    Joined:
    Dec 1, 2005
    Messages:
    1,524
    Likes Received:
    173
    Location:
    Adelaide, Australia
    I don't have a Wiser 2 so I can't test this myself, but Sets were only ever supported in the Color Touchscreen. The help doesn't mention them being introduced into Wiser 2 and I would have thought you would have got a compile error. Do you use sets in any other module?
     
    Ashley, Nov 9, 2016
    #11
  12. MichaelD

    MichaelD

    Joined:
    Apr 3, 2016
    Messages:
    46
    Likes Received:
    0
    Location:
    UK
    Doing some more research on this.

    The faulty module has three ONCE statements. If I comment out the first two, then it doesn't trigger the initialise, so the problem is in the first two ONCEs.

    Just ran with the second ONCE commented out, and the Wiser2 initialised every 20 minutes, at 22:18:09, 22:38:08, 22:58:07.

    This looks like something is filling up, or something is running out, but why is it on those 10-minute boundaries?

    Will now try commenting out just the first ONCE to see what that does
     
    MichaelD, Nov 9, 2016
    #12
  13. MichaelD

    MichaelD

    Joined:
    Apr 3, 2016
    Messages:
    46
    Likes Received:
    0
    Location:
    UK
    I generated the code using the statement wizard in PICED, and don't use it anywhere else, just these two times in this module.

    We seem to have identifed the few lines of code that are causing the problem, so I could just code them another way, but am curious to know why this is happening
     
    MichaelD, Nov 9, 2016
    #13
  14. MichaelD

    NickD Moderator

    Joined:
    Nov 1, 2004
    Messages:
    1,420
    Likes Received:
    62
    Location:
    Adelaide
    It wouldn't surprise me if there was something strange relating to how the logic engine handles the validity of the time after startup.

    It's not a great solution but a workaround (and arguably a better approach) would be to get rid of those 2 once statements and use a schedule to set the Virtual Sleep group off instead of logic... another benefit of this is that it would be much easier for the user to change the times and days.

    Nick
     
    NickD, Nov 9, 2016
    #14
  15. MichaelD

    MichaelD

    Joined:
    Apr 3, 2016
    Messages:
    46
    Likes Received:
    0
    Location:
    UK
    That's a good thought.

    However, I'd abandoned schedules on the Wiser2 because they never seemed to work, the Daylight saving one didn't adjust the clock when it was supposed to, and I had a midnight schedule to set the Virtual Sleep group, but that never worked, so this was part of my recoding to get round the schedules problem.

    But maybe the scheduling wasn't working because the dumb thing kept reinitialising itself, and I didn't realise it.

    Will try the recode, then see if schedules have started working.
     
    MichaelD, Nov 10, 2016
    #15
  16. MichaelD

    Ashley

    Joined:
    Dec 1, 2005
    Messages:
    1,524
    Likes Received:
    173
    Location:
    Adelaide, Australia
    Not sure what you mean by this. The Wiser is supposedly a High Precision Clock Master so should continuously maintain the correct time internally. The logic engine would just access this time. Why do you think there may be an issue?

    Anyway, it still all points to a bug in the logic engine that should be investigated.
     
    Ashley, Nov 10, 2016
    #16
  17. MichaelD

    MichaelD

    Joined:
    Apr 3, 2016
    Messages:
    46
    Likes Received:
    0
    Location:
    UK
    Well, after a recode, the initialise problem seems to have gone away, its run for 1:15 without reinitialising, so will leave it till the morning to see if its actually fixed it, or just increased the time to fail :rolleyes:

    The new code is:

    ===================================================================================

    once (Time = "07:30:00") then
    if (DayOfWeek = "Monday") or
    (DayOfWeek = "Tuesday") or
    (DayOfWeek = "Wednesday") or
    (DayOfWeek = "Thursday") or
    (DayOfWeek = "Friday") then
    begin
    SetLightingState("Virtual Sleep", OFF);
    end;


    once (Time = "09:00:00") then
    if (DayOfWeek = "Saturday") or
    (DayOfWeek = "Sunday") then
    begin
    SetLightingState("Virtual Sleep", OFF);
    end;


    once (GetLightingState("Virtual Sleep") = OFF) then
    begin
    SetLightingLevel("Night Dimming Level", 100%, "0s");
    SetScene("Daytime Switch Brightness");
    Delay("0:05:00");
    SetLightingState("Utility Rm PIR Enable", ON);
    end;
     
    MichaelD, Nov 10, 2016
    #17
  18. MichaelD

    Ashley

    Joined:
    Dec 1, 2005
    Messages:
    1,524
    Likes Received:
    173
    Location:
    Adelaide, Australia
    So it does look like a problem with Sets in the Wiser2.

    You could simplify your code a bit.

    create variable weekday: boolean;

    Code:
    weekday := (dayOfWeek >= "Monday") and (dayOfWeek <= "Friday");
    once ((Time = "07:30:00") and weekday) or
       ((Time = "09:00:00") and not weekday)  then
    begin
      SetLightingState("Virtual Sleep", OFF);
      SetLightingLevel("Night Dimming Level", 100%, "0s");
      SetScene("Daytime Switch Brightness");
      Delay("0:05:00");
      SetLightingState("Utility Rm PIR Enable", ON); 
    end;
    
     
    Ashley, Nov 10, 2016
    #18
  19. MichaelD

    NickD Moderator

    Joined:
    Nov 1, 2004
    Messages:
    1,420
    Likes Received:
    62
    Location:
    Adelaide
    It is, however around system startup, when NTP sync is not complete, there are many edge cases with logic and schedules that have to be handled.

    It took a long time to get all that right so it wouldn't surprise me if there were some edge case that had been missed.

    The fact that the problem seems to have gone away by restructuring the code to use the same conditions in a different way suggests this isn't that case anyway, and maybe there is something wrong with the evaluation of the condition.

    Nick
     
    NickD, Nov 10, 2016
    #19
  20. MichaelD

    NickD Moderator

    Joined:
    Nov 1, 2004
    Messages:
    1,420
    Likes Received:
    62
    Location:
    Adelaide
    I looked into this and you're right.

    Looking at the source code there is no code to handle sets in the C codebase that is used for CTouch/Wiser2 etc.

    Looking at the Logic Help under "Sets" it says they are applicable for Colour C-Touch only.

    I would have thought that PICED should have given an error if you tried to use this in a Wiser2 project.

    I will raise a defect to this effect.

    Nick
     
    NickD, Nov 10, 2016
    #20
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.