Scripting Newbie
 
Notifications
Clear all

Scripting Newbie

45 Posts
4 Users
0 Reactions
18 K Views
rokkett
Posts: 441
(@rokkett)
Reputable Member
Joined: 17 years ago
bobkeyes wrote:If I set my script as the background sequence, I have to manually start it and then stop it. After that it comes on and runs as it should.

Anyone have any advice??

And you have the Tools->Preferences->Background Items->Enable Background Sequence option checked?


Reply
rokkett
Posts: 441
(@rokkett)
Reputable Member
Joined: 17 years ago
bobkeyes wrote:When you set a background sequence, how long is it before Vixen polls to start that sequence?

I set a sequence and never see the "progression window" in the lower left. I have seen it run, but not lately.

This is controlled with Tools->Preferences->Background Items->Background Sequence delay. The default is 10 seconds.


Reply
Posts: 448
Topic starter
(@bobkeyes)
Honorable Member
Joined: 17 years ago

Yes, background sequence is enabled.

Tonight, I started the background sequence manually. When show time came there was a message that an error was caused by a plugin and the execution has stopped. The show did not start.

I clicked OK on the message and the show started. I'm waiting for it to finish to see if the script runs after the show is over. I don't have much confidence in it.

Dirk, I'll work with resetting the timers. Maybe that will work, but everything worked last night without doing that???? Wouldn't shutting down Vixen and restarting it reset the timers?

I'm thinking about reloading Vixen. What do you all think??


Reply
Posts: 448
Topic starter
(@bobkeyes)
Honorable Member
Joined: 17 years ago

OK!! The show is over and the script started running on its own. Wish I knew what was going on.


Reply
rokkett
Posts: 441
(@rokkett)
Reputable Member
Joined: 17 years ago

Oh! - the background script will exit automatically before a scheduled event....

...and the start back up when there is no more activity. If you haven't added the outer loop to your code yet, the script will exit when the loop exits. And then you will have to wait until after the next days start time to run it. Get that while(true) outer loop coded, and I think you will have what you want....


Reply
rokkett
Posts: 441
(@rokkett)
Reputable Member
Joined: 17 years ago
bobkeyes wrote:...

Tonight, I started the background sequence manually. When show time came there was a message that an error was caused by a plugin and the execution has stopped. The show did not start.

I clicked OK on the message and the show started. I'm waiting for it to finish to see if the script runs after the show is over. I don't have much confidence in it.

...

I'm thinking about reloading Vixen. What do you all think??

Ok, the background script is supposed to exit before scheduled item begins. This does not always happen, and when it doesn't, you will get the port access error. To work around this, give the background script more time to exit. Create a short (10 seconds is enough), empty sequence that uses no plugins and add that to the beginning of your program. Make sure your program is configured to use the sequence's plugins, not the program plugin option.


Reply
Posts: 448
Topic starter
(@bobkeyes)
Honorable Member
Joined: 17 years ago

Is this how to put in that while(true) loop?

I hate to be so ignorant, but I just don't have any experience with C#.

void Start() {
Off(All);

DateTime now = DateTime.Now; //get the current time

while(true)
{

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)

{
On (normalLights, At(100));

now = DateTime.Now; //update the current time
}}

Off(All,For(3).Seconds,Wait);
}

Once I get this running again, I'll go back to the ramp thing.


Reply
rokkett
Posts: 441
(@rokkett)
Reputable Member
Joined: 17 years ago

I would add an Off() with Wait to the outer loop, but yeah, this looks good, parsing this in my head, so there may be a syntax error in there...

Like this:


void Start() {
Off(All);

DateTime now = DateTime.Now; //get the current time

while(true)
{

    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)
    {
        On (normalLights, At(100));

        now = DateTime.Now; //update the current time
    }
    Off(All,For(3).Seconds,Wait);
}

Off(All,For(3).Seconds,Wait);
}

Sorry, but I just can't seem to read code that is not indented... 🙂


Reply
Posts: 448
Topic starter
(@bobkeyes)
Honorable Member
Joined: 17 years ago

It compiled fine. No errors. I have it running. But, when I first start Vixen I would expect it to look for the background script. It apparently doesn't. I have to start the script manually and then stop it manually. After about 10 seconds it will then start the script running.


Reply
Posts: 448
Topic starter
(@bobkeyes)
Honorable Member
Joined: 17 years ago

Ah Ha! This time it started running on it's own.

Thanks again for your help. I will try the ramping thing again.


Reply
Page 4 / 5
Share: