PDA

View Full Version : Set scene using logic


theok
21 Dec 09, 12:32 AM
Hi All

I'm experiencing some problems whilst using logic to set a scene once another is set and is night. Here is the code:

once (Sceneisset("Goodbye") or Sceneisset("Goodbye Garage")) and
((TIME > SUNSET ) or (TIME < SUNRISE )) then

begin

SetScene("Exit Night");
end;

Background
Both Goodbye and Goodbye Garage belong to the same Trigger Group. Both scenes have the same lighting group with the same levels. Both scenes are also stored in the CTouch. The only difference is that "Goodbye" is triggered from the Ctouch and "Goodbye Garage" from a 6 gang in the garage.

On exit the customer wanted to set the goodbye scene from the Ctouch or 6 Gang from the garage. The scene sets most of the lighting groups in the house to 0 (OFF). If it is a night exit an "Exit Night" scene was to be triggered which switched on the garage and a couple of other groups for 2 mins lighting an exit path.

The problem
Once "Goodbye" is set from the CTouch all the loads switch off and the "Exit Night" scene is trigger. After 2 mins the garage lights switch off, however, immediately switch back on. The customer claims the garage lights remain on ndefinately. The Application log indicates that the CTouch unit is re-triggering the "Exit Night" scene. I haven't had a chance to wait around and see whether the cycle repeats.

Manually switching a load on immediately after the "Goodbye" scene is set (from Ctouch) and the "Exit Night" scene was set (using the logic code) breaks the cycle and the logic works as expected.

I suspect my logic code must be looping, because the "Goodbye" scene remains set thus it sets "Exit Night" with each loop. When the goodbye is broken "Exit Night" runs a final time.

Questions


Are my assumptions correct?
How do I fix this?
Is there a better/more efficient way to acheive what we're trying to do?


Your assistance would be much appreciated.

Cheers

Theo

Mark
21 Dec 09, 12:15 PM
Hi Theok,

Its really hard to debug logic problems like this without looking at the entire project. If you cant work it out, i would suggest contacting Tech Support for assistance.

That said, here's a guess:
If your "Exit Night" scene has the same group/level settings as either "Goodbye" or "Goodbye Garage", then its possible that when Exit Night is set, one of the other two is repaired (all its groups are at the levels specified by the scene, so C-Touch considers it set again), causing the once statement to execute again. If this is what's happening, toggling the "Use indicator kill for showing scene status" option in the PICED Project Details Wizard may fix it.

Otherwise, i'd suggest doing some debugging in PICED to see if the same problem occurs when you simulate the logic. A few indicators on screen to show you if scenes are set should help you see what is going on.

Good luck!
Mark.

Darren
27 Dec 09, 07:48 AM
I'm experiencing some problems whilst using logic to set a scene once another is set and is night.
Firstly, thanks for taking the trouble to structure your question nicely. It makes life much easier for us (and ultimately for you too).

Both Goodbye and Goodbye Garage belong to the same Trigger Group. Both scenes have the same lighting group with the same levels. Both scenes are also stored in the CTouch. The only difference is that "Goodbye" is triggered from the Ctouch and "Goodbye Garage" from a 6 gang in the garage.
This seems like an odd thing to do. Why have two identical Scenes?


Once "Goodbye" is set from the CTouch all the loads switch off and the "Exit Night" scene is trigger. After 2 mins the garage lights switch off, however, immediately switch back on.
If any groups in the Exit Night scene are also in the Goodbye scene, then this will cause the problem you are seeing.

When you set the Goodbye Scene, the groups are switched off, then immediately after, the Exit Night scene is set. If this contains a group in the Goodbye scene, then the Goodbye scene is no longer considered to be "set". At the end of the 2 minute delay (pulse), this group (or groups) get set back to level 0. The Goodbye scene is now "set" again and the "once" statement is now true again, so it sets the Exit Night scene again.

Manually switching a load on immediately after the "Goodbye" scene is set (from Ctouch) and the "Exit Night" scene was set (using the logic code) breaks the cycle and the logic works as expected.
This would confirm what I wrote above, because it "breaks" the Goodbye scene and stops it from becoming set again and causing the once to be true again.

I suspect my logic code must be looping, because the "Goodbye" scene remains set thus it sets "Exit Night" with each loop. When the goodbye is broken "Exit Night" runs a final time.
Yes


Are my assumptions correct?
How do I fix this?
Is there a better/more efficient way to acheive what we're trying to do?


Try the "Use indicator kill for showing scene status" option in the PICED Project Details Wizard as Mark suggested.

Alternatively, remove any groups that are in Exit Night from the Goodbye scene. Put them into a new Scene called Exit Path Off. Then change the logic to:

once Sceneisset("Goodbye") or Sceneisset("Goodbye Garage") then
begin
if (TIME > SUNSET ) or (TIME < SUNRISE ) then
SetScene("Exit Night")
else
SetScene("Exit Path Off");
end;

ashleigh
27 Dec 09, 12:56 PM
This post explains some essentials about scenes, what they are and how they work:

http://www.cbusforums.com/forums/showthread.php?t=439

theok
28 Dec 09, 12:04 AM
Thanks all for all the useful feedback.

The identical scenes have been removed after getting a better understanding of scenes (thanks ashleigh).

I've taken up your suggestions Darren with the addition of the else line and a new scene. I try this and Mark's suggestion when I'm back on site.

Cheers