C-Bus Forums  

Go Back   C-Bus Forums > Logic Code Library > Community Logic Code Examples

The C-Bus Community Forums is place where C-Bus users can share information and help others with C-Bus. From time to time you will see Clipsal staff on the forums, but this is not an official support channel. If you really need help contact the official support services of Clipsal. More information about the purpose of this forum is available here.

Reply
 
Thread Tools Display Modes
  #1  
Old 12 Sep 05, 12:17 PM
Darren Darren is offline
Senior Member
 
Join Date: Jul 2004
Location: Adelaide, South Australia
Posts: 1,830
Default Load accumulated duration

Sometimes it is necessary to know the total duration for which a load has been switched on. A timer can be used to determine how long it has been since the load was last switched on, but to cope with the load going on and off, a little more code is required.

In the code below, the accumulated time for which the "Kitchen 1" light has been on is displayed on the screen. Timer number 1 records how long it has been since the load was last switched on. The AccumulatedTime variable stores how long the load was on previously. The sum of these two is the total on time. Note that when the Timer is not running, its value will be -1 which will make the total one second lower than it should be. If you can't live with this, you need to check whether the timer is running or not, as shown in the code below.

Code:
{ var section }
AccumulatedTime : integer;

{ initialisation section }
AccumulatedTime := 0;

{ module }
once GetLightingState("Kitchen 1") = ON then
  TimerStart(1);

once GetLightingState("Kitchen 1") = OFF then
begin
  AccumulatedTime := AccumulatedTime + TimerTime(1);
  TimerStop(1);
end;

{ display accumulated time on screen }
ClearScreen;
TextPos(300, 100);
if TimerRunning(1) then
  DrawText(AccumulatedTime + TimerTime(1))
else
  DrawText(AccumulatedTime);
Note that if you are using a PAC, the timers only go up to 9 hours, so the code may been to be written differently.
__________________
Regards,

Darren
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Schedule Plus Load Manager sjfp C-Touch/HomeGate/SchedulePlus/PICED 1 27 Oct 08 10:03 AM
Minimum load for dimmers? curiouser Other C-Bus Hardware 2 04 May 08 10:55 AM
Load Balancing across Relays & Dimmers Guff Other C-Bus Hardware 1 08 Feb 08 09:28 PM
Toolkit : how find out the TRUE status of a load ? JohnC C-Bus Toolkit/C-Gate 6 20 Feb 06 05:48 PM
Load monitor JasonCox C-Touch/HomeGate/SchedulePlus/PICED 2 18 Oct 05 06:29 PM


All times are GMT +10.5. The time now is 11:18 PM.


Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.