First I want to tell everyone that this may be machine spacific in nature. But I don't think so. If you find yourself absolutly needing a background sequence I spent several days tweeking what little info and examples I could find on the wiki and what it boils down to is this.
1. Use Vixen 2.1.1.0 do not let auto update run! (Vixen 2.1.1.4 and up did not work for this)
2. I wanted a BGS to run all the time. Would execute different functions at different times.
Example: from 6 am to 5 pm flash one light on every 3 seconds (Light System Heartbeat) This shows me that all is well with my system.
Then from 5pm to 11pm run another loop for show background.
Then from 11pm to 6am another loop to turn the lights on and off to discourage anyone from messing with it.
3. I attempted these loops with if statements and other C# code for loops but ended up using While and a While(True) statements.
4. I found that this code:
Example: DateTime start = new DateTime(now.Year, now.Month, now.Day, 23, 00, 00);
DateTime end = new DateTime(now.Year, now.Month, now.Day, 06, 00, 00);
would not funtion after 11pm to 6am. So I had to put an extra loop in for the time after 11pm to midnight.
Example: DateTime start = new DateTime(now.Year, now.Month, now.Day, 23, 00, 00);
DateTime end = new DateTime(now.Year, now.Month, now.Day, 23, 59, 00);
and another for 12am to 6am :
DateTime start3 = new DateTime(now.Year, now.Month, now.Day, 00, 00, 00);
DateTime end3 = new DateTime(now.Year, now.Month, now.Day, 06, 00, 00);
notice that Start and End are now Start3 and End3 new holders for each loop. Keeps each loop independant of the others.
5. Most important part of the code is the: now = DateTime.Now; used in each loop to grap the upgraded time in each loop. If the time has changed outside the loops start and end time it proceeds to the next loop that the time does qualify to start.
All these loops run under a While(true) loop. This is basicly a never ending loop. But in this case it does exactly what it is asked to do. it returns the program back to the start to compare times.
I am posting my code here:
void Start() {
ChannelCollection AllClear1;
ChannelCollection AllRed;
ChannelCollection AllGreen;
ChannelCollection JesusIsLord;
ChannelCollection Heartbeat;
JesusIsLord = Channels(Jesus_is_lord);
AllClear1 = Channels(Tree_W,Tree_W_2,Tree_W_3,Tree_W_4,Tree_W_5,Spiral_Star,Tree_Star,Shed_Star,Shed_W,Pole_1_W,Pole_2_W,Pole_3_W,Pole_4_W,Pole_5_W,Pole_6_W,Pole_7_W,Merry_Christmas,Spitral_Tree_GP,Tm_W_1,Tm_W_2,Tm_W_3,Tm_W_4,Tm_W_5,Tm_W_6,Tm_W_7,Tm_W_8,White_Roof,Spiral_W_1,Spiral_W_2,Spiral_W_3,Spiral_W_4,Spiral_W_5,Spiral_W_6,Spiral_W_7,Spiral_W_8);
AllRed = Channels(Tree_R,Tree_R_2,Tree_R_3,Tree_R_4,Tree_R_5,Red_Star_left,Red_Star_right,Shed_R,Pole_1_R,Pole_2_R,Pole_3_R,Pole_4_R,Pole_5_R,Pole_6_R,Pole_7_R,Tm_R_1,Tm_R_2,Tm_R_3,Tm_R_4,Tm_R_5,Tm_R_6,Tm_R_7,Tm_R_8,Red_Roof,Candy_Cane_1,Candy_Cane_2,Candy_Cane_3);
AllGreen= Channels(Tree_G,Tree_G_2,Tree_G_3,Tree_G_4,Tree_G_5,Shed_G,Tm_G_1,Tm_G_2,Tm_G_3,Tm_G_4,Tm_G_5,Tm_G_6,Tm_G_7,Tm_G_8,Spiral_G_1,Spiral_G_2,Spiral_G_3,Spiral_G_4,Spiral_G_5,Spiral_G_6,Spiral_G_7,Spiral_G_8,Green_Star_left,Green_Star_right);
Heartbeat= Channels(Shed_Star);
while(true){
//We only want the background script to turn on while the current time is
//between 11:00pm and 6:00am the next day
DateTime now = DateTime.Now; //get the current time
//The DateTime constructor goes (YYYY, MM, DD, HH, MM, SS)
DateTime start = new DateTime(now.Year, now.Month, now.Day, 23, 00, 00);
DateTime end = new DateTime(now.Year, now.Month, now.Day, 23, 59, 00);
Off(All);
while(now.CompareTo(start) >= 0 && now.CompareTo(end) <= 0)
{
On(JesusIsLord,At(100));
Ramp(All,0,100,Over(3).Seconds,Wait);
Ramp(AllClear1,100,0,Over(2).Seconds);
//Ramp(AllRed,0,100,Over(3).Seconds,Wait);
Ramp(AllRed,100,0,Over(2).Seconds);
//Ramp(AllGreen,0,100,Over(3).Seconds,Wait);
Ramp(AllGreen,100,0,Over(2).Seconds,Wait);
now = DateTime.Now;
}
//We only want the background script to turn on while the current time is
//between 12:00pm and 6:00am the next day
now = DateTime.Now; //get the current time
//The DateTime constructor goes (YYYY, MM, DD, HH, MM, SS)
DateTime start3 = new DateTime(now.Year, now.Month, now.Day, 00, 00, 00);
DateTime end3 = new DateTime(now.Year, now.Month, now.Day, 06, 00, 00);
Off(All);
while(now.CompareTo(start3) >= 0 && now.CompareTo(end3) <= 0)
{
On(JesusIsLord,At(100));
Ramp(All,0,100,Over(3).Seconds,Wait);
Ramp(AllClear1,100,0,Over(2).Seconds,Wait);
//Ramp(AllRed,0,100,Over(3).Seconds,Wait);
Ramp(AllRed,100,0,Over(2).Seconds,Wait);
//Ramp(AllGreen,0,100,Over(3).Seconds,Wait);
Ramp(AllGreen,100,0,Over(2).Seconds,Wait);
now = DateTime.Now;
}
{
DateTime start1 = new DateTime(now.Year, now.Month, now.Day, 17, 00, 00);
DateTime end1 = new DateTime(now.Year, now.Month, now.Day, 23, 00, 00);
while(now.CompareTo(start1) >= 0 && now.CompareTo(end1) <= 0)
{
Off(All);
On(JesusIsLord,At(100));
Ramp(AllClear1,0,100,Over(3).Seconds,Wait);
Ramp(AllClear1,100,0,Over(2).Seconds);
Ramp(AllRed,0,100,Over(3).Seconds,Wait);
Ramp(AllRed,100,0,Over(2).Seconds);
Ramp(AllGreen,0,100,Over(3).Seconds,Wait);
Ramp(AllGreen,100,0,Over(2).Seconds);
now = DateTime.Now;
}
DateTime start2 = new DateTime(now.Year, now.Month, now.Day, 06, 00, 00);
DateTime end2 = new DateTime(now.Year, now.Month, now.Day, 17, 00, 00);
while(now.CompareTo(start2) >= 0 && now.CompareTo(end2) <= 0)
{
Off(All);
On(Heartbeat, For(2).Seconds,Wait);
Off (Heartbeat,For(3).Seconds,Wait);
now = DateTime.Now;
}
}
}
}
Heartbeat is an important part as well, I suggest you declare a group or item (Lights) in this and avoid tweaking.
I have had this running for 3 days now with no issues at all. everthing works fine with schedular and does not give you the router error. That shows up in all vixen 2.1.1.4 and up.
The whole point with this is, schedular kills it with no problems and then when it starts back up it drops back into the same loop or new depending on time and does what it is supposed to do and instead of sceduling a blank sequence to run it checks the time for itself and can move along in it's loops.
This may make more questions than answers but these are my observations.
2012 will say goodbye to us and then 2013 would be a nice year. What I learned from 2012 is no pain no gain. I think every one can make his dream come true if he tries his best. www.linkdelight.com offers me a lot of Christmas gifts.
