public void RaiseAlarm(object sender, int alarmID, string message = "")
        {
            FAAlarmEventArgs args = new FAAlarmEventArgs();

            if (sender is Sequence.FASequence)
                ((Sequence.FASequence)sender).SetAlarm();

            if (Items.Count == 0 ||
                Items.ContainsKey(alarmID) == false)
            {
                args.Alarm = new FAAlarm();
                args.Alarm.AlarmNo = alarmID;
                args.Alarm.AlarmName = "";
                args.Alarm.Description = "";
                args.Alarm.ImagePath = "";
                args.Alarm.Solution = "";
            }
            else
                args.Alarm = Items[alarmID];

            string debugInfo = "";

            try
            {
                StackTrace st = new StackTrace(true);
                int frameCount = st.FrameCount;
                if (frameCount > 7)
                    frameCount = 7;

                for(int i=0; i<frameCount; i++)
                {
                    string filename = st.GetFrame(i).GetFileName();
                    string lineNo = st.GetFrame(i).GetFileLineNumber().ToString();
                    string methodName = st.GetFrame(i).GetMethod().Name + "()";

                    string temp = filename + " - " +
                        methodName +
                        " Line(" + lineNo + ")";

                    debugInfo += temp + '\n';
                }
            }
            catch
            {
            }

            args.Message = message;
            args.DebugInfo = debugInfo;
            OnRaiseAlarm(sender, args);
        }
        private void ProcessAlarmOnAutoRunning(FAAlarmEventArgs e)
        {
            Equipment.MainEquipment mainEquip = Equipment.EquipmentManager.Instance.MainEquip;
            mainEquip.SubSequenceManager.Suspend();

            bool autoRunning = false;
            bool rankingData = IsRankingData(e.Alarm);
            if (mainEquip.Status == Equipment.EquipmentStatus.AUTO_RUNNING)
                autoRunning = true;

            _lastAlarmIsRankingAlarm = rankingData;

            if (IsAbleSendAlarm(e.Alarm, rankingData))
                SendAlarmToECServer(e.Alarm);

            mainEquip.LastAlarm = e.Alarm;

            if (Equipment.EquipmentManager.Instance.MainEquip.TestMode == false)
            {
                LogManager.Instance.WriteAlarmLog(e.Alarm.AlarmNo.ToString() + ", " +
                e.Alarm.AlarmName + ", " +
                e.Alarm.Status.ToString() + ", " +
                e.Alarm.Type.ToString() + ", " +
                rankingData.ToString() + ", " +
                autoRunning.ToString() + ", " +
                e.Message + ", " +
                e.DebugInfo);
            }

            Manager.LogManager.Instance.WriteTraceLog("ALARM : " + e.Alarm.AlarmNo.ToString() + ", " + e.Alarm.AlarmName);
        }
        private void EventHandlerOnAlarm(object sender, FAAlarmEventArgs e)
        {
            ShowEngineerCall(e.Alarm);

            Equipment.MainEquipment mainEquip = Equipment.EquipmentManager.Instance.MainEquip;

            if (mainEquip.RaisedAlarm)
                return;

            mainEquip.RaisedAlarm = true;

            if (mainEquip.Status == Equipment.EquipmentStatus.INITIALIZING)
            {
                ProcessAlarmOnInitializing();
            }
            else if (mainEquip.Status == Equipment.EquipmentStatus.AUTO_RUNNING ||
                mainEquip.Status == Equipment.EquipmentStatus.RUN_DOWN)
            {
                ProcessAlarmOnAutoRunning(e);
            }
            else
            {
                Equipment.EquipmentManager.Instance.MainEquip.SubSequenceManager.Suspend();
                Manager.LogManager.Instance.WriteTraceLog("ALARM : " + e.Alarm.AlarmNo.ToString() + ", " + e.Alarm.AlarmName);
            }

            if (e.Alarm.Status == ConfigClasses.GlobalConst.ALARM_STATUS_WARNING)
                Equipment.EquipmentManager.Instance.MainEquip.VirtualWarningStopSignal = true;
            else
                Equipment.EquipmentManager.Instance.MainEquip.VirtualAlarmStopSignal = true;

            _pageAlarm.SetAlarm(e.Alarm, e.Message);
            ShowAlarm(_pageAlarm);
        }
        private void EventHandlerOnAlarm(object sender, FAAlarmEventArgs e)
        {
            Equipment.MainEquipment mainEquip = Equipment.EquipmentManager.Instance.MainEquip;
            if (sender is FALibrary.Sequence.FASequence)
            {
                if (mainEquip.Status == Equipment.EquipmentStatus.INITIALIZING)
                {
                    mainEquip.SubSequenceManager.Suspend();

                    FALibrary.Sequence.FASequence sequence = (FALibrary.Sequence.FASequence)sender;
                    //if (sequence.SequenceManager == Equipment.EquipmentManager.Instance.MainEquip.SubSequenceManager)
                    //    sequence.SequenceManager.AllClearState();

                    mainEquip.InitialSequence.ClearState();
                    mainEquip.InitializeEquipment.ClearState();
                    mainEquip.VirtualAlarmStopSignal = true;
                }
                else
                {
                    mainEquip.SubSequenceManager.Suspend();

                    bool autoRunning = false;
                    bool rankingData = false;
                    if (mainEquip.Status == Equipment.EquipmentStatus.AUTO_RUNNING)
                        autoRunning = true;

                    if (mainEquip.LastAlarm != null)
                    {
                        if (mainEquip.LastAlarm.AlarmNo == e.Alarm.AlarmNo)
                        {
                            if ((DateTime.Now - mainEquip.StartedTime).TotalSeconds > Manager.ConfigManager.Instance.Config.JamDelay)
                            {
                                rankingData = true;
                            }
                        }
                        else
                            rankingData = true;
                    }
                    else
                    {
                        rankingData = true;
                    }

                    if (rankingData == true &&
                        e.Alarm.Status == ConfigClasses.GlobalConst.ALARM_STATUS_ALARM &&
                        Equipment.EquipmentManager.Instance.MainEquip.TestMode == false)
                    {
                        if (mainEquip.ECPart != null)
                        {
                            string lotID = Manager.ConfigManager.Instance.Config.DefaultLotID;
                            string partID = Manager.ConfigManager.Instance.Config.DefaultPartID;

                            if (mainEquip.ECPart.ECInfo.LotID != "")
                                lotID = mainEquip.ECPart.ECInfo.LotID;

                            if (mainEquip.ECPart.ECInfo.PartNo != "")
                                partID = mainEquip.ECPart.ECInfo.PartNo;

                            try
                            {
                                mainEquip.ECPart.SendAlarmRaiseInfo(Manager.ConfigManager.Instance.Config.EquipmentID,
                                    lotID,
                                    partID,
                                    e.Alarm.AlarmNo.ToString(),
                                    e.Alarm.AlarmName);

                                _lastAlarmLotID = lotID;
                                _lastAlarmPartID = partID;
                            }
                            catch
                            {
                            }
                        }

                        _lastAlarmIsRankingAlarm = rankingData;
                    }

                    mainEquip.LastAlarm = e.Alarm;

                    if (Equipment.EquipmentManager.Instance.MainEquip.TestMode == false)
                    {
                        LogManager.Instance.WriteAlarmLog(e.Alarm.AlarmNo.ToString() + ", " +
                        e.Alarm.AlarmName + ", " +
                        e.Alarm.Status.ToString() + ", " +
                        e.Alarm.Type.ToString() + ", " +
                        rankingData.ToString() + ", " +
                        autoRunning.ToString() + ", " +
                        e.Message);

                        Manager.LogManager.Instance.WriteTraceLog("ALARM : " + e.Alarm.AlarmNo.ToString() + ", " + e.Alarm.AlarmName);
                    }

                    Equipment.EquipmentManager.Instance.MainEquip.VirtualAlarmStopSignal = true;
                }
            }
            else
            {
                if (mainEquip.Status == Equipment.EquipmentStatus.INITIALIZING)
                {
                    mainEquip.SubSequenceManager.Suspend();
                    mainEquip.InitialSequence.ClearState();
                    mainEquip.InitializeEquipment.ClearState();
                    mainEquip.VirtualAlarmStopSignal = true;
                }
                else
                {
                    Equipment.EquipmentManager.Instance.MainEquip.SubSequenceManager.Suspend();
                    Equipment.EquipmentManager.Instance.MainEquip.VirtualAlarmStopSignal = true;
                    Manager.LogManager.Instance.WriteTraceLog("ALARM : " + e.Alarm.AlarmNo.ToString() + ", " + e.Alarm.AlarmName);
                }
            }

            _pageAlarm.SetAlarm(e.Alarm, e.Message);
            ShowAlarm(_pageAlarm);
        }