Ejemplo n.º 1
0
        private void DoTransactAlarm(IMonitorAlarm alarm, bool isExist)
        {
            alarm.OnTransactAlarm -= new TransactAlarm(DoTransactAlarm);

            CMonitorAlarm monitorAlarm = alarm as CMonitorAlarm;

            if (monitorAlarm != null)
            {
                CAlarmOut alarmOut = monitorAlarm.Property.GetValue("_AlarmOutObj") as CAlarmOut;
                if (alarmOut != null)
                {
                    alarmOut.StopAlarmOut();
                }
            }
        }
Ejemplo n.º 2
0
        protected override bool ExecuteAction(object source, IActionParam param)
        {
            try
            {
                CMonitorAlarm alarm = source as CMonitorAlarm;
                if (alarm != null)
                {
                    //CLocalSystem.WriteDebugLog(string.Format("{0} CHKAlarmOutAction({1}).ExecuteAction: Sender={2}, AlarmID={3}, ActionParam={4}", Config.Desc, Name, alarm.Sender, alarm.ID, param.Name));

                    AlarmClient alarmClient = GetAlarmClient();
                    if (alarmClient == null)
                    {
                        IVisionMonitorConfig vmc = alarm.Monitor.Config as IVisionMonitorConfig;
                        if (vmc != null)
                        {
                            IVideoSourceConfig vsConfig = vmc.SystemContext.VideoSourceConfigManager.GetConfig(vmc.VisionParamConfig.VSName);
                            alarmClient = GetAlarmClient(vsConfig);
                        }
                    }

                    if (alarmClient != null)
                    {
                        int outputPort = -1;
                        if (param.IsExist("OutputPort"))
                        {
                            outputPort = param.IntValue("OutputPort");
                        }
                        else
                        {
                            outputPort = AlarmOutConfig.OutputPort;
                        }

                        string key = CAlarmOut.GetKey(alarmClient, outputPort);

                        CAlarmOut alarmOut = mAlarmOutTable[key] as CAlarmOut;
                        if (alarmOut == null)
                        {
                            lock (mAlarmOutTable.SyncRoot)
                            {
                                alarmOut = mAlarmOutTable[key] as CAlarmOut;
                                if (alarmOut == null)
                                {
                                    alarmOut = new CAlarmOut(alarmClient, outputPort);
                                    mAlarmOutTable.Add(alarmOut.Key, alarmOut);
                                }
                            }
                        }

                        alarm.Property.SetValue("_AlarmOutObj", alarmOut);
                        alarm.OnTransactAlarm += new TransactAlarm(DoTransactAlarm);

                        alarmOut.StartAlarmOut();
                    }
                    else
                    {
                        CLocalSystem.WriteErrorLog(string.Format("CHKAlarmOutAction({0}).ExecuteAction: Sender={1} 无法获取报警输出对象!", Name, alarm.Sender));
                    }
                }
            }
            catch (Exception e)
            {
                CLocalSystem.WriteErrorLog(string.Format("CHKAlarmOutAction({0}).ExecuteAction Excepton: {1}", Name, e));
            }
            return(false);
        }