mattyb
05 Dec 07, 03:51 PM
G'day
I'm looking for a bit of a sanity check on the code below and hope someone will be kind enough to offer their thoughts.
This is meant to be a very simple "lived in look" but the client reports that whenever they, or their cleaners, arrive home after being away that "Holiday Scene 1" is always set. Apparently the code that sets the following scenes to turn all the lights OFF never gets called.
I have tested the code just on PICED with shorter random times and have found that sometimes the code gets to "Holiday Scene 2" and has never got to "Holiday Scene 3".
Any thoughts on why it's not working properly or ways to improve it would be appreciated.
Thanks
Matt
{Initialise Random Times Each Day}
if (Time = "2:00:00 AM") then
begin
RandomTime2 := random("03:00:00");
RandomTime3 := random("01:05:00");
end;
once (time > (sunset)) then
begin
if (GetEnableState("HOLIDAY MODE") = ON) then
begin
SetScene("Holiday Scene 1");
{Evening}
TimerStart(1);
end;
end;
once (TimerTime(1) > RandomTime2) then
begin
SetScene("Holiday Scene 2");
{Bedtime}
TimerStop(1);
TimerStart(2);
end;
once (TimerTime(2) > RandomTime3) then
begin
SetScene("Holiday Scene 3");
{Goodnight}
TimerStop(2);
end;
I'm looking for a bit of a sanity check on the code below and hope someone will be kind enough to offer their thoughts.
This is meant to be a very simple "lived in look" but the client reports that whenever they, or their cleaners, arrive home after being away that "Holiday Scene 1" is always set. Apparently the code that sets the following scenes to turn all the lights OFF never gets called.
I have tested the code just on PICED with shorter random times and have found that sometimes the code gets to "Holiday Scene 2" and has never got to "Holiday Scene 3".
Any thoughts on why it's not working properly or ways to improve it would be appreciated.
Thanks
Matt
{Initialise Random Times Each Day}
if (Time = "2:00:00 AM") then
begin
RandomTime2 := random("03:00:00");
RandomTime3 := random("01:05:00");
end;
once (time > (sunset)) then
begin
if (GetEnableState("HOLIDAY MODE") = ON) then
begin
SetScene("Holiday Scene 1");
{Evening}
TimerStart(1);
end;
end;
once (TimerTime(1) > RandomTime2) then
begin
SetScene("Holiday Scene 2");
{Bedtime}
TimerStop(1);
TimerStart(2);
end;
once (TimerTime(2) > RandomTime3) then
begin
SetScene("Holiday Scene 3");
{Goodnight}
TimerStop(2);
end;