Jump to content
vvtech

Programing conditionals not working as expected

Recommended Posts

I'm trying to turn on a light when the door bell is press and conditionals don't seem to work.  I will like the light to come on from 7pm till 11pm.  Delay for 5min and then turn off.

Control4-Issue.PNG

Share this post


Link to post
Share on other sites

You have to "nest" the commands under the conditional. Drag the one you want on top of the conditional so it applies. If the command indents under the conditional, it will work fine. Everything under the time conditional. You don't really need "stop" as there are not any additional commands after your condition.

Sent from my iPhone using Tapatalk

Share this post


Link to post
Share on other sites

Don't use delays in the span of minutes please - it can cause major overall system delays.

Instead, create a 5 minute timer, and start the timer instead - then on the timer expiring, turn the light back off.

 

Other than that, yes, anything dependent on the if statement needs to be 'indented'.

Share this post


Link to post
Share on other sites
6 hours ago, ramesh.khiani said:

Cyknight is right; create a 5 minute timer instead of delay and command indents under the condition.

sol.png

but use a timer as Cy said vs a delay.  Delay introduces system lag.  Timers are the correct way to do what you want.

Share this post


Link to post
Share on other sites
Don't use delays in the span of minutes please - it can cause major overall system delays.

Dang, missed that. I may be a little rusty.

Sent from my iPhone using Tapatalk

Share this post


Link to post
Share on other sites

Also, and this is a personal preference. I'd change the time to "when time is night time". This way it works with the sunset. Here in NYC, it gets dark at 4:30 pm in the winter. You want that light to work when it's dark out. Delete 1 second delay and stop command. 

Share this post


Link to post
Share on other sites

LONG delays aren't good - because they are DELAYS.

See delay as a 'stop what you're doing and wait there five minutes until I say go' command.

Where a timers is 'stop what you're doing and come back in 5 minutes' command

Using 5 minute delay will hold up the system for 5 minutes, whereas a timer does not.

Frankly personally for anything more than a second - I use a timer, but especially if you're looking at minutes.

Share this post


Link to post
Share on other sites

Composer Programming Delays are not implemented poorly.

They do not cause Director to stop doing what it's doing for X seconds, and shouldn't cause any system latency.

From what I've seen, they are implemented internally very similar to timers.

The main reason you might want to use timers instead of delays is that they're more flexible.  When you use a delay in a script, it will delay running the rest of the script, and if that script gets triggered multiple times, delays can cause things to work differently than you might expect, where if you'd used a timer, it's more straightforward (i.e. the 'rest of the story' would only get executed once, when the timer expires).

RyanE

 

Share this post


Link to post
Share on other sites

Now, if you were writing a DriverWorks driver, and you inserted delays (busy waiting by looping, etc.) in a *driver*, that's a completely different story, which *would definitely* cause system latency.  Drivers must be event driven, and return control to Director fairly quickly.

RyanE

 

Share this post


Link to post
Share on other sites
17 minutes ago, RyanE said:

Composer Programming Delays are not implemented poorly..

The main reason you might want to use timers instead of delays is that they're more flexible.  When you use a delay in a script, it will delay running the rest of the script, and if that script gets triggered multiple times, delays can cause things to work differently than you might expect, where if you'd used a timer, it's more straightforward (i.e. the 'rest of the story' would only get executed once, when the timer expires).

RyanE

 

First off - I wasn't suggesting they were implemented poorly.

Second - my example was heavily simplified.

Third - yeah, the idea of what I intended to say is indeed that it 'holds' the individual script 'hostage' - not the system as a whole.

Fourth - while delays do not cause a true 'lag' on a system overall, it's not that hard to create conflicts where delays build creating a perceived delay or other weird behavior (where in actuality it's just following script). Triggering (and re-triggering) a timer won't cause this.

 

Example:

WHEN door bell is pressed

turn light on

delay 1 second

play announcement

delay 5 minutes

turn light off

 

Now have someone push that doorbell 15 times in a row. (Durn kids)

Now add a schedule to have the light on at an hour before dusk

Add some motion events to that same lights.

Now imagine that doorbell being pressed a few minutes before the scheduled time, and the kids playing in the front yard.

 

I think you can see where you'll get a lot of odd behavior of the light turning on and off.

Share this post


Link to post
Share on other sites
On 7/15/2016 at 12:17 AM, Cyknight said:

Don't use delays in the span of minutes please - it can cause major overall system delays.

Instead, create a 5 minute timer, and start the timer instead - then on the timer expiring, turn the light back off.

 

Other than that, yes, anything dependent on the if statement needs to be 'indented'.

Are you able to provide an example screenshot of how I can create a timer.  thank you!

Share this post


Link to post
Share on other sites
6 hours ago, vvtech said:

Can someone provide an example screenshot of how to create a timer.  Thanks.

The timer is an Agent.  "Timer Agent".  Create one there and set the duration.   It can be used for all sorts of reasons.  Typically you start the timer when an event happens.  When the timer expires, program the desired action.  There's other events that can be programmed off of.

What's the application?

Share this post


Link to post
Share on other sites

Thanks dcovach.  I figured it out.  I just didn't have the timer agent added in my project.  Once I added then I was able to figure it out.  Thanks again.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...