View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0002276 | JEDI VCL | 00 JVCL Components | public | 2004-10-30 16:53 | 2006-06-27 03:34 |
Reporter | Nanotonne | Assigned To | obones | ||
Priority | normal | Severity | trivial | Reproducibility | always |
Status | resolved | Resolution | fixed | ||
Product Version | 3.00 BETA 2 | ||||
Target Version | Fixed in Version | 3.30 | |||
Summary | 0002276: JVAlarm don't work correctly for OnAlarm event | ||||
Description | i don't know why, but the event OnAlarm for JvAlarm is called each second for 1 minute if i have set tkEachMinute, each second for 1 hour if i set tkEachHour, etc.. and if i set Time to void, when i run the application, onevent is automatically called at creation if active=true log example for tkEachMinute and time=31/10/2004 02:16:50 : (started at 01:28:34) Memo1 31/10/2004 01:28:34 31/10/2004 01:28:35 31/10/2004 01:28:36 31/10/2004 01:28:37 31/10/2004 01:28:38 31/10/2004 01:28:39 31/10/2004 01:28:40 31/10/2004 01:28:41 31/10/2004 01:28:42 31/10/2004 01:28:43 31/10/2004 01:28:44 31/10/2004 01:28:45 31/10/2004 01:28:46 31/10/2004 01:28:47 31/10/2004 01:28:48 31/10/2004 01:28:49 31/10/2004 01:28:50 31/10/2004 01:28:51 31/10/2004 01:28:52 31/10/2004 01:28:53 31/10/2004 01:28:54 31/10/2004 01:28:55 31/10/2004 01:28:56 31/10/2004 01:28:57 31/10/2004 01:28:58 31/10/2004 01:28:59 31/10/2004 01:29:00 31/10/2004 01:29:01 31/10/2004 01:29:02 31/10/2004 01:29:03 31/10/2004 01:29:04 31/10/2004 01:29:05 31/10/2004 01:29:06 31/10/2004 01:29:07 31/10/2004 01:29:08 31/10/2004 01:29:09 31/10/2004 01:29:10 31/10/2004 01:29:50 31/10/2004 01:30:50 see attached file project for test delphi6pro/win2000pro the probleme is present since a long time ! | ||||
Additional Information | the problem don't appareat systematically if i change kind propertie jvalarmitem, (random bug), but often. bug possible for each hour, eachmonth, .... After max 1 minute (for tkEachMinute ), is stable and no bug! i think is same for 1 hour( first hour is bug and after is good), etc... warning, if time propertie is void (not set), a event is automatically called when running exe too !! bug or no bug !? for me is bug! | ||||
Tags | No tags attached. | ||||
2004-10-30 16:53
|
bugJValarm.zip (251,709 bytes) |
|
The problem seems to be that Alarm.Time is triggered every second until it is > Now and Alarm.Time is only incremented one minute at each interval without taking Now into consideration. If Alarm.Time is set to sometime yesterday, you will get an update every second until Alarm.Time catches up with Now, which could take a long time. One solution would be to set Alarm.Time = Now (unless it is > Now) when Active is set to true. To do that, I suggest adding a protected method, ResetAlarms, to SetActive, i.e: procedure TJvAlarms.SetActive(const Value: Boolean); begin FActive := Value; FRunning := FActive and (Alarms.Count > 0); FLast := DateTimeToTimeStamp(Now); if FRunning then ResetAlarms; FTimer.Enabled := Running; end; procedure TJvAlarms.ResetAlarms; var Current: TDateTime; i: integer; function MaxDate(Val1, Val2: TDateTime): TDateTime; begin Result := Val1; if Val2 > Val1 then Result := Val2; end; begin Current := Now; for i := 0 to Alarms.Count - 1 do Alarms[i].Time := MaxDate(Current, Alarms[i].Time); end; One could also argue that if Alarm.Time < Now at startup, it should not be triggered at all, but supporting that would mean a significant rewrite of the component's logic AFAICS. |
|
I've committed this fix to CVS. If there are issues with it, please report back ASAP, otherwise I will close this report. |
|
sorry, i am in holidays actually, but i'm going to test your fix ans submit you my suggest when i return my home, i need to post you a suggestion (good structure and code write on paper at my home), do not close this report actually please, wait my next post ! thank! |
|
Please provide feedback in the next 7 days, or this will be considered as fixed. |
|
Okay, i provide a shematic teorical of feature jvalarm (a other solution) , how need work jvalarm, see TJValarmshema.png file attachement. (ouups, error! replace TimePref by TimePrev, thank!) "cycle" is variable, is a kind for jvalarm (tkEachSecond = 1 , tkEachMinute = 60, tkEachHour = 3600, tkEachDay = 3600*24, ...), can be too tkOneShot (=0) "TimeRef" is "time" (JvAlarms1.Alarms[n].Time) variable, example : 14/02/1970 21:45:12, if kind is tkoneshot then cycle = none and a event OnAlarm is called if . "TimeNow" is time when the test is raised ( = now, = each second or millisecond ??) "TimeDiff" is difference between TimeNow And TimeRef "TimeCount is necessary to calculate TimePos, it's numbers of count of complete cycle (TimeDiff is too equal n*cycle TimePos is barrier of comparison for OnAlarm triggered event for tkEachXXX and tkOneShot(for tkOneShot TimePos := TimeRef) TimeMod is modulo beetween TimeDiff and cycle (or too Difference beetween TimeNow and TimePos), variable not used actually but probably for futur improvement. How i see the pseudo theorical pascal code for JvAlarm.pas? see follow (not complete), i'm not good in Object Langage, if you can integrate/convert this in components and units : Const tkEachOneShot = 0; tkEachMilliSecond = 1; tkEachHundredth = 10; tkEachTenth = 100; tkEachSecond = 1000; tkEachMinute = 60000; tkEachHour = 3600000 tkEachHalfDay = tkEachHour*12 ; tkEachDay = tkEachHour*24; tkEachWeek = tkEachDay*7; tkEachMonth = tkEachDay*30 + tkEachHalfDay; tkEachMonthAverage = 2629743767 // 1 month average = 30.43684915 days exactly; tkEachMonth30 = tkEachDay*30; tkEachMonth31 = tkEachDay*31; tkEachQuarter = tkEachMonth31 + tkEachMonth30 + tkEachMonth31; tkEachYear = 31556925199; tkEachDecenie = 315569251987; tkEachCentury = 3155692519872; tkEachMillenium = 31556925198720; type valarm = record Active : boolean; Name : string; TimeRef, TimeDiff, TimePrev, { should be initialized at 1st creating, TimePrev := now} TimePos, TimeNow, TimeMod : TDatetTime; Cycle : Int64; {I prefer in millissecond, but can be in second} end; TItemsAlarm = array of valarm; TJvAlarm = record Timer : TTimer; { initialization of property : timer.interval := 10, 100 or 1000 i don't know, 100 is good for me timer.enabled := true timer.OnEvent := TimerEvent} ItemsAlarm : TItemsAlarm; Active : boolean; end; . . . . procedure timer.OnEvent var i:integer; begin with jvalarm do begin if active then for i := 0 to pred(length(ItemsAlarm)) do begin with ItemsAlarm[i] do if Active then begin TimePrev := TimeNow; TimeNow := Now; if cycle = 0 then // type tkOneShot TimePos:=TimeRef else begin TimeDiff = trunc((TimeNow – TimeRef)*24*3600); // in ms TimeCount = TimeDiff div cycle; // count of cycle TimeMod = TimeDiff mod cycle; TimePos = IncMillisecond(TimeRef,TimeCount * cycle); end; // possibility to replace/re-calculate TimePos with other value if cycle is tkEachMonth (depend of month we are, 31 or 30 day of month....it's flexible and sure with this method !) { testing if triggering event Alarm} if (TimePrev < TimePos) AND //before (TimeNow > = TimePos) AND // and after ? then .... (TimeNow >= TimeRef) then // event triggered OnAlarm begin OnAlarm; // Warning !!! if event OnAlarm too long, the others valarm of ItemsAlarm array CAN'T be tested!, need to execute OnAlarm WITHOUT BLOCKING, via thread for example or other technical method. if cycle = 0 then active := false; // OneShot => disable this alarm end; end; end; end; end; normally it work, i have theorically annalyzed and tested, it'sq good solution, but i can't translate this in component for replacement of tjvAlarm component, if you can translate in object oriented my code, thank ! |
2005-02-12 14:14
|
|
|
Is this still hapenning with the latest sources? |
|
Well, without any response, I'm assuming this is fixed in the latest development version. Should it not be the case, please provide a sample application and/or a diff file against the latest SVN content: http://homepages.borland.com/jedi/wiki/index.php?title=Repository |
Date Modified | Username | Field | Change |
---|---|---|---|
2004-10-30 16:53 | Nanotonne | New Issue | |
2004-10-30 16:53 | Nanotonne | File Added: bugJValarm.zip | |
2004-10-31 04:04 |
|
Note Added: 0005533 | |
2004-10-31 04:04 |
|
Status | new => feedback |
2004-11-13 14:30 |
|
Note Added: 0005623 | |
2004-11-28 14:08 | Nanotonne | Note Added: 0005748 | |
2005-02-04 05:16 | obones | Note Added: 0006406 | |
2005-02-12 14:13 | Nanotonne | Note Added: 0006474 | |
2005-02-12 14:14 | Nanotonne | File Added: TJvAlarmShema.png | |
2005-02-12 14:32 | Nanotonne | Note Edited: 0006474 | |
2005-02-12 15:52 | Nanotonne | Note Edited: 0006474 | |
2005-02-12 17:46 | Nanotonne | Note Edited: 0006474 | |
2005-02-12 17:48 | Nanotonne | Note Edited: 0006474 | |
2006-03-30 02:57 | obones | Note Added: 0008739 | |
2006-06-27 03:33 | obones | Status | feedback => resolved |
2006-06-27 03:33 | obones | Fixed in Version | => Daily / SVN |
2006-06-27 03:33 | obones | Resolution | open => fixed |
2006-06-27 03:33 | obones | Assigned To | => obones |
2006-06-27 03:33 | obones | Note Added: 0009654 |