Beispiel #1
0
        public virtual bool PostAlarmEvent(IMonitorAlarm alarm)
        {
            if (alarm != null && CheckAlarmInterval(alarm.AlarmTime))
            {
                if (DoAlarmPrepProcess(alarm))
                {
                    mAlarmID   = alarm.ID;
                    mAlarmTime = alarm.AlarmTime;

                    alarm.OnTransactAlarm += new TransactAlarm(DoTransactAlarm);

                    if (mAlarmManager != null)
                    {
                        mAlarmManager.AppendAlarm(alarm);
                    }

                    mDoMonitorAlarm.BeginInvoke(alarm, null, null);

                    if (mConfig != null && mConfig.AutoSaveAlarmImage)
                    {
                        alarm.SaveAlarmImage();
                    }

                    return(true);
                }
            }
            return(false);
        }
Beispiel #2
0
        public void AppendAlarm(IMonitorAlarm alarm)
        {
            if (alarm == null)
            {
                return;
            }

            mSyncPostAlarm.BeginInvoke(alarm, null, null);

            if (AlarmQueueLength > 0)
            {
                ChangeType    type;
                IMonitorAlarm firstAlarm = null;

                lock (mLockObj)
                {
                    //if (mMonitor != null && mCurAlarms.Count >= mAlarmQueueLength)
                    //{
                    //    firstAlarm = (IMonitorAlarm)mCurAlarms[0];
                    //    mWaitAlarms.Add(firstAlarm);
                    //    mCurAlarms.RemoveAt(0);

                    //    mCurAlarms.Add(alarm);
                    //    type = ChangeType.Both;
                    //}
                    //else
                    //{
                    //    mCurAlarms.Add(alarm);
                    //    type = ChangeType.Add;
                    //}

                    if (mCurAlarms.Count >= mAlarmQueueLength)
                    {
                        firstAlarm = (IMonitorAlarm)mCurAlarms[0];
                        mWaitAlarms.Add(firstAlarm);
                        mCurAlarms.RemoveAt(0);

                        mCurAlarms.Add(alarm);
                        type = ChangeType.Both;
                    }
                    else
                    {
                        mCurAlarms.Add(alarm);
                        type = ChangeType.Add;
                    }

                    TotalNumber++;
                }

                //alarm.OnRecordStateChanged += new RecordStateChanged(DoRecordStateChanged);

                //if (firstAlarm != null && firstAlarm.IsPlay)
                //    firstAlarm.stopPlayAlarmRecord();

                mDoAlarmListChanged.BeginInvoke(type, null, null);
            }
            else
            {
                lock (mLockObj)
                {
                    TotalNumber++;
                }
                //alarm.OnRecordStateChanged += new RecordStateChanged(DoRecordStateChanged);
                mSyncTransactAlarm.BeginInvoke(alarm, null, null);
            }
        }