Great. That did the trick. Do you always have to put the wait in for the off command?
No - unless you really want it to wait - like in the case - the last command was not being passed to the plugin/com port - so the wait just allowed the script time to send the command - one minute was an excessive amount of time to wait - I just picked a number.....
... the Wait() modifer in a script is a way to have your script pause for a specified timeframe. Just Off() a channel that is not in use or really should be off at the time you call it...
Sorry for the delay. I changed the wait to 1 sec and it worked perfectly.
NOW, I want to Ramp the lights up and have them stay up and then Ramp them down when it's over.
I tried it, but the ramp runs every time the script cycles.
Can you give me some more guidance?
I am guessing - Move the Ramp() calls outside of the while loop...
Post the new version and we can look...
I will as soon as the show quits running. I'm afraid to mess with it now.
Here's the new version. I have // out the Ramp.
void Start() {
Off(All);
DateTime now = DateTime.Now; //get the current time
ChannelCollection normalLights;
normalLights = Channels(TreeGroup1, TreeGroup2, Tree1, Tree2, Tree3, Tree4, Tree5, Tree6, Bushes1, Bushes2, Bushes3, Bushes4, PorchPost1, PorchPost2, PorchPost3, PorchPost4, PorchPost5, PorchPost6, Icecycle1, Icecycle2, Icecyles3, Icecyles4, Channel_64, Door_Trees);
//The DateTime constructor goes (YYYY, MM, DD, HH, MM, SS)
DateTime start = new DateTime(now.Year, now.Month, now.Day, 17, 30, 00);
DateTime end = new DateTime(now.Year, now.Month, now.Day, 23, 00, 00);
//We only want the channels to turn on while the current time is
//between 5:30 and 11 pm
while (now.CompareTo(start) >= 0 && now.CompareTo(end) <= 0)
{
//Ramp (normalLights, 0, 100, Over (5).Seconds,Wait);
On(normalLights, At(100));
now = DateTime.Now; //update the current time
}
Off(All,For(1).Second,Wait);
}
Ah, I see the problem. You want the ramp at 5:30 to run only once...
Ok, try this:
void Start() {
Off(All);
DateTime now = DateTime.Now; //get the current time
ChannelCollection normalLights;
normalLights = Channels(TreeGroup1, TreeGroup2, Tree1, Tree2, Tree3, Tree4, Tree5, Tree6, Bushes1, Bushes2, Bushes3, Bushes4, PorchPost1, PorchPost2, PorchPost3, PorchPost4, PorchPost5, PorchPost6, Icecycle1, Icecycle2, Icecyles3, Icecyles4, Channel_64, Door_Trees);
//The DateTime constructor goes (YYYY, MM, DD, HH, MM, SS)
DateTime start = new DateTime(now.Year, now.Month, now.Day, 17, 30, 00);
DateTime end = new DateTime(now.Year, now.Month, now.Day, 23, 00, 00);
//We only want the channels to turn on while the current time is
//between 5:30 and 11 pm
int X = 1;
while (now.CompareTo(start) >= 0 && now.CompareTo(end) <= 0)
{
if (X == 1) {
Ramp (normalLights, 0, 100, Over (5).Seconds,Wait);
X = 0;
}
On(normalLights, At(100));
now = DateTime.Now; //update the current time
}
Off(All,For(1).Second,Wait);
}
Thanks. That works great. But, now I have another problem?????
I cannot get the script to run.
If I set the times to 9:30 on and 9:35 off, it doesn't come on. If I start it manually it does fine. Don't know what I have done to cause that.
I have it set as the background sequence and the box is checked to allow background sequencing with a 10 sec delay.
Any thoughts??
By the way, thanks so much for your help. You have been a lifesaver for me.
Ahhh, yes, If you start Vixen before the first while loop, it just skips it (because it is not time to run it) and then the script exits. And Vixen doesn't restart it - it ran it already. So you have to put another loop in the script that never exits, so the script will run whenever Vixen is running.
So, that would look like this:
void Start() {
Off(All);
while(true)
{
DateTime now = DateTime.Now; //get the current time
ChannelCollection normalLights;
normalLights = Channels(TreeGroup1, TreeGroup2, Tree1, Tree2, Tree3, Tree4, Tree5, Tree6, Bushes1, Bushes2, Bushes3, Bushes4, PorchPost1, PorchPost2, PorchPost3, PorchPost4, PorchPost5, PorchPost6, Icecycle1, Icecycle2, Icecyles3, Icecyles4, Channel_64, Door_Trees);
//The DateTime constructor goes (YYYY, MM, DD, HH, MM, SS)
DateTime start = new DateTime(now.Year, now.Month, now.Day, 17, 30, 00);
DateTime end = new DateTime(now.Year, now.Month, now.Day, 23, 00, 00);
//We only want the channels to turn on while the current time is
//between 5:30 and 11 pm
int X = 1;
while (now.CompareTo(start) >= 0 && now.CompareTo(end) <= 0)
{
if (X == 1) {
Ramp (normalLights, 0, 100, Over (5).Seconds,Wait);
X = 0;
}
On(normalLights, At(100),For(30).Seconds,Wait);
now = DateTime.Now; //update the current time
}
Off(All,For(1).Second,Wait);
}
Off(All,For(30).Seconds,Wait);
}
The final Off() waits for 30 seconds, so the inner loop may not start exactly at 5:30, it may be as late as 30 seconds "late", but if you don't wait there, the script will use CPU asking constantly, as WireWrap so eloquently summarized, "Are we there yet?" You can shorten that wait time, but if you make it too short.....
I also made the same change in the inner loop to the On() - for the same reason....
(that was driving me crazy - I had to indent the source ... :))
I think I have another problem. I cannot get the script to start. I went back to a simple, on/off, script. It will not start at the appointed time unless I execute it manually.
It seems that I have everything set right. I have rebooted and restarted Vixen.
I'll keep looking.

