Page 1 of 1

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

Posted: Mon Nov 05, 2012 6:11 pm
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.

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

Posted: Mon Nov 12, 2012 5:26 pm
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.

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

Posted: Mon Nov 12, 2012 10:47 pm
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 ;