Time Delta starts at Pre-Event start rather than at Alarm

Forum for questions and support relating to the 1.25.x releases only.
Locked
bluejay
Posts: 2
Joined: Mon Nov 05, 2012 5:51 pm

Time Delta starts at Pre-Event start rather than at Alarm

Post by bluejay »

I have been using an older release (1.22.3) and just recently that box crashed. So, I installed the newer 1.25 version.

With the newer version, I noticed that the Frames, Time Deltas now start at the 1st Pre-Event frame rather than the 1st Frame of the Alarm Event, like the older version did (1.22.3).

Specifically, I am triggering the start of the "event" using zmtrigger.pl.

Any idea why this changed and/or if there's a configuration to get this to work properly (like in 1.22.3)?

See attachments for the two comparisons in the time delta reporting.

Thanks for any help and/or information regarding this,
J.J.
Attachments
ZM 1.25 Frames incorrectly showing the start of the first Pre-Event as 0.00 Time Delta, rather than the first frame of the actual Alarm as Time Delta 0.00.
ZM 1.25 Frames incorrectly showing the start of the first Pre-Event as 0.00 Time Delta, rather than the first frame of the actual Alarm as Time Delta 0.00.
ZM_1-25_FramesShowingFirstPreEventAsZeroDelta.png (23.86 KiB) Viewed 1029 times
ZM 1.22.3 Frames correctly showing the start of the alarm (within the total event) as 0.00 Time Delta.  Pre-Event frames are negative (as expected).
ZM 1.22.3 Frames correctly showing the start of the alarm (within the total event) as 0.00 Time Delta. Pre-Event frames are negative (as expected).
ZM_1-22-3_FramesShowingAlarmEventAsZeroDelta.png (21.5 KiB) Viewed 1029 times
bluejay
Posts: 2
Joined: Mon Nov 05, 2012 5:51 pm

Re: Time Delta starts at Pre-Event start rather than at Alar

Post by bluejay »

I guess a workaround solution to this is problem would be to post-process the Frames Table in the zm DB to recalculate the Delta after an Event completes.

Anyone have any idea how to fix this in the code and/or where it might be messing up?

Thanks for any help,
J.J.
tweedle_dumb
Posts: 1
Joined: Mon Nov 12, 2012 10:41 pm

Re: Time Delta starts at Pre-Event start rather than at Alar

Post by tweedle_dumb »

We had the exact same problem and couldn't figure out a way to fix it in the software itself so we wrote a trigger to basically do what you suggested. Here is the code if you'd like to use it in your environment:

Code: Select all

USE zm;

DELIMITER $$

CREATE
DEFINER = 'zmuser'@'%'
TRIGGER update_endTime
AFTER UPDATE
ON Events
FOR EACH ROW
BEGIN
  DECLARE inEventId   INT(10);
  DECLARE refDelta    DECIMAL(8, 2);
  DECLARE refFrameId  INT(10);
  DECLARE endTimeBool BOOLEAN;

  SET inEventId = NEW.Id;

  SELECT min(FrameId) FROM Frames WHERE Type = 'Alarm' AND EventId = inEventId INTO refFrameId;
  SELECT count(*) FROM  Events WHERE Id = inEventId AND EndTime IS NOT NULL INTO endTimeBool;
  IF endTimeBool > 0 THEN
    SELECT Delta FROM Frames WHERE EventId = inEventId AND FrameId = refFrameId INTO refDelta;
    IF refDelta <> 0 THEN
      UPDATE Frames SET Delta = Delta - refDelta WHERE EventId = inEventId;
    END IF;
  END IF;
END
$$

DELIMITER ;
Locked