Пример #1
0
        public virtual ALARM setAlarmReport(string nodeID, string eq_id, string error_code, string errorDesc)
        {
            lock (lock_obj_alarm)
            {
                if (IsAlarmExist(eq_id, error_code))
                {
                    return(null);
                }
                //AlarmMap alarmMap = alarmMapDao.getAlarmMap(eq_id, error_code);
                AlarmMap alarmMap = alarmMapDao.getAlarmMap(nodeID, error_code);
                string   strNow   = BCFUtility.formatDateTime(DateTime.Now, SCAppConstants.TimestampFormat_19);
                ALARM    alarm    = new ALARM()
                {
                    EQPT_ID       = eq_id,
                    RPT_DATE_TIME = DateTime.Now,
                    ALAM_CODE     = error_code,
                    ALAM_LVL      = alarmMap == null ? E_ALARM_LVL.None : alarmMap.ALARM_LVL,
                    ALAM_STAT     = ProtocolFormat.OHTMessage.ErrorStatus.ErrSet,
                    ALAM_DESC     = alarmMap == null ? errorDesc : alarmMap.ALARM_DESC,
                };
                if (SCUtility.isEmpty(alarm.ALAM_DESC))
                {
                    alarm.ALAM_DESC = $"Unknow error:{error_code}";
                }
                using (DBConnection_EF con = DBConnection_EF.GetUContext())
                {
                    alarmDao.insertAlarm(con, alarm);
                    CheckSetAlarm();
                }

                return(alarm);
            }
        }
Пример #2
0
        private void MapAlarm()
        {
            bool IsAlarmMapPresent = false;

            if (SelectedAlarm != null && SelectedPanel != null)
            {
                var alarm = new AlarmMap()
                {
                    AlarmName = SelectedAlarm.Name,
                    SiteName  = SelectedAlarm.Site,
                    PanelName = SelectedPanel.Name,
                    PanelType = SelectedPanel.Type
                };
                foreach (var ala in _alarmMapping)
                {
                    if (ala.AlarmName.Equals(SelectedAlarm.Name) &&
                        ala.SiteName.Equals(SelectedAlarm.Site) &&
                        ala.PanelName.Equals(SelectedPanel.Name) &&
                        ala.PanelType.Equals(SelectedPanel.Type)
                        )
                    {
                        IsAlarmMapPresent = true;
                    }
                }
                if (!IsAlarmMapPresent)
                {
                    _alarmMapping.Add(alarm);
                }
            }
        }
Пример #3
0
        public ALARM setAlarmReport(string node_id, string eq_id, string error_code)
        {
            lock (lock_obj_alarm)
            {
                if (IsAlarmExist(eq_id, error_code))
                {
                    return(null);
                }
                string alarmUnitType = "OHCV";

                if (scApp.TransferService.isUnitType(eq_id, Service.UnitType.AGV))
                {
                    alarmUnitType = "AGV STATION";
                }

                if (scApp.TransferService.isUnitType(eq_id, Service.UnitType.CRANE))
                {
                    alarmUnitType = "CRANE";
                }

                AlarmMap alarmMap = alarmMapDao.getAlarmMap(alarmUnitType, error_code);

                if (alarmMap == null)
                {
                    scApp.TransferService.TransferServiceLogger.Info
                    (
                        DateTime.Now.ToString("HH:mm:ss.fff ") +
                        "OHT >> OHB|AlarmMap 不存在:"
                        + "    EQ_Name:" + eq_id
                        + "    Error_code:" + error_code
                    );
                }

                string strNow = BCFUtility.formatDateTime(DateTime.Now, SCAppConstants.TimestampFormat_19);
                ALARM  alarm  = new ALARM()
                {
                    EQPT_ID       = eq_id,
                    RPT_DATE_TIME = strNow,
                    ALAM_CODE     = error_code,
                    ALAM_LVL      = alarmMap == null ? E_ALARM_LVL.Warn : alarmMap.ALARM_LVL,
                    ALAM_STAT     = ProtocolFormat.OHTMessage.ErrorStatus.ErrSet,
                    ALAM_DESC     = alarmMap == null ? $"unknow alarm code:{error_code}" : $"{alarmMap.ALARM_DESC}(error code:{error_code})",
                    ERROR_ID      = error_code, //alarmMap?.ALARM_ID ?? "0",
                    UnitID        = eq_id,
                    UnitState     = "1",
                };
                using (DBConnection_EF con = DBConnection_EF.GetUContext())
                {
                    alarmDao.insertAlarm(con, alarm);

                    CheckSetAlarm();
                }

                return(alarm);
            }
        }
        public AlarmObjToShow(ALARM _alarm, AlarmBLL _alarmBLL)
        {
            alarm    = _alarm;
            alarmBLL = _alarmBLL;
            AlarmMap alarmMap = alarmBLL.cache.getSuggestion("VH_LINE", ALAM_CODE);

            if (alarmMap != null)
            {
                SUGGESTION      = alarmMap.SUGGESTION;
                POSSIBLE_CAUSES = alarmMap.POSSIBLE_CAUSES;
            }
        }
        //public ALARM setAlarmReport(string nodeID, string eq_id, string error_code, string errorDesc, string cmd_id_1, string cmd_id_2)
        public ALARM setAlarmReport(string nodeID, string eq_id, string error_code, string errorDesc, List <string> effectTranIDs)
        {
            lock (lock_obj_alarm)
            {
                if (IsAlarmExist(eq_id, error_code))
                {
                    return(null);
                }
                //AlarmMap alarmMap = alarmMapDao.getAlarmMap(eq_id, error_code);
                AlarmMap alarmMap = null;
                if (!SCUtility.isEmpty(nodeID))
                {
                    alarmMap = alarmMapDao.getAlarmMap(nodeID, error_code);
                }
                else
                {
                    alarmMap = alarmMapDao.getAlarmMap(eq_id, error_code);
                }

                var effect_tran_ids = tryGetTransferCommandIDs(effectTranIDs);

                string strNow = BCFUtility.formatDateTime(DateTime.Now, SCAppConstants.TimestampFormat_19);
                ALARM  alarm  = new ALARM()
                {
                    EQPT_ID       = eq_id,
                    RPT_DATE_TIME = DateTime.Now,
                    ALAM_CODE     = error_code,
                    ALAM_LVL      = alarmMap == null ? E_ALARM_LVL.None : alarmMap.ALARM_LVL,
                    ALAM_STAT     = ProtocolFormat.OHTMessage.ErrorStatus.ErrSet,
                    ALAM_DESC     = alarmMap == null ? errorDesc : alarmMap.ALARM_DESC,
                    CMD_ID_1      = effect_tran_ids.TranCmdId1,
                    CMD_ID_2      = effect_tran_ids.TranCmdId2,
                    CMD_ID_3      = effect_tran_ids.TranCmdId3,
                    CMD_ID_4      = effect_tran_ids.TranCmdId4
                };
                if (SCUtility.isEmpty(alarm.ALAM_DESC))
                {
                    alarm.ALAM_DESC = $"Unknow error:{error_code}";
                }
                using (DBConnection_EF con = DBConnection_EF.GetUContext())
                {
                    alarmDao.insertAlarm(con, alarm);
                    CheckSetAlarm();
                }
                return(alarm);
            }
        }
        public ALARM setAlarmReport(string node_id, string eq_id, string error_code, string currentAdrID)
        {
            lock (lock_obj_alarm)
            {
                if (IsAlarmExist(eq_id, error_code))
                {
                    return(null);
                }
                //AlarmMap alarmMap = alarmMapDao.getAlarmMap(scApp, eq_id, error_code);
                AlarmMap alarmMap = alarmMapDao.getAlarmMap(scApp, node_id, error_code);
                //string strNow = BCFUtility.formatDateTime(DateTime.Now, SCAppConstants.TimestampFormat_19);
                ALARM alarm = new ALARM()
                {
                    EQPT_ID       = eq_id,
                    RPT_DATE_TIME = DateTime.Now,
                    ALAM_CODE     = error_code,
                    ALAM_LVL      = alarmMap == null ? E_ALARM_LVL.None : alarmMap.ALARM_LVL,
                    ALAM_STAT     = ProtocolFormat.OHTMessage.ErrorStatus.ErrSet,
                    ALAM_DESC     = alarmMap == null ? $"unknow alarm code:{error_code}" : $"{alarmMap.ALARM_DESC}(error code:{error_code})",
                    ADDRESS_ID    = currentAdrID
                };
                //為了確保在存進去DB時,超出最大的ALAM_DESC字串範圍,因此將ALARM重新切一次長度
                if (alarm.ALAM_DESC.Length > 80)
                {
                    alarm.ALAM_DESC = alarm.ALAM_DESC.Substring(0, 80);
                }
                using (DBConnection_EF con = DBConnection_EF.GetUContext())
                {
                    alarmDao.insertAlarm(con, alarm);

                    CheckSetAlarm();
                }

                return(alarm);
            }
        }
Пример #7
0
        public AlarmMap GetAlarmMap(string objID, string errorCode)
        {
            AlarmMap alarmMap = alarmMapDao.getAlarmMap(objID, errorCode);

            return(alarmMap);
        }
Пример #8
0
        public void ProcessAlarmReport(string nodeID, string eqID, string eqRealID, string currentAddressID, string errCode, ErrorStatus errorStatus)
        {
            string      node_id        = nodeID;
            string      eq_id          = eqID;
            string      eq_real_id     = eqRealID;
            string      current_adr_id = currentAddressID;
            string      err_code       = errCode;
            ErrorStatus status         = errorStatus;

            List <ALARM> alarms   = null;
            AlarmMap     alarmMap = scApp.AlarmBLL.GetAlarmMap(eq_id, err_code);
            //在設備上報Alarm時,如果是第一次上報(之前都沒有Alarm發生時,則要上報S6F11 CEID=51 Alarm Set)
            bool processBeferHasErrorExist = scApp.AlarmBLL.hasAlarmErrorExist();

            if (alarmMap != null &&
                alarmMap.ALARM_LVL == E_ALARM_LVL.Error &&
                status == ErrorStatus.ErrSet &&
                //!scApp.AlarmBLL.hasAlarmErrorExist())
                !processBeferHasErrorExist)
            {
                scApp.ReportBLL.newReportAlarmSet();
            }
            scApp.getRedisCacheManager().BeginTransaction();
            using (TransactionScope tx = SCUtility.getTransactionScope())
            {
                using (DBConnection_EF con = DBConnection_EF.GetUContext())
                {
                    LogHelper.Log(logger: logger, LogLevel: LogLevel.Debug, Class: nameof(VehicleService), Device: "OHxC",
                                  Data: $"Process vehicle alarm report.alarm code:{err_code},alarm status{status}",
                                  VehicleID: eq_id);
                    ALARM alarm = null;
                    switch (status)
                    {
                    case ErrorStatus.ErrSet:
                        //將設備上報的Alarm填入資料庫。
                        alarm = scApp.AlarmBLL.setAlarmReport(node_id, eq_id, err_code, null);
                        //將其更新至Redis,保存目前所發生的Alarm
                        scApp.AlarmBLL.setAlarmReport2Redis(alarm);
                        alarms = new List <ALARM>()
                        {
                            alarm
                        };
                        break;

                    case ErrorStatus.ErrReset:
                        if (SCUtility.isMatche(err_code, "0"))
                        {
                            alarms = scApp.AlarmBLL.resetAllAlarmReport(eq_id);
                            scApp.AlarmBLL.resetAllAlarmReport2Redis(eq_id);
                        }
                        else
                        {
                            //將設備上報的Alarm從資料庫刪除。
                            alarm = scApp.AlarmBLL.resetAlarmReport(eq_id, err_code);
                            //將其更新至Redis,保存目前所發生的Alarm
                            scApp.AlarmBLL.resetAlarmReport2Redis(alarm);
                            alarms = new List <ALARM>()
                            {
                                alarm
                            };
                        }
                        break;
                    }
                    tx.Complete();
                }
            }
            scApp.getRedisCacheManager().ExecuteTransaction();
            //通知有Alarm的資訊改變。
            scApp.getNatsManager().PublishAsync(SCAppConstants.NATS_SUBJECT_CURRENT_ALARM, new byte[0]);


            foreach (ALARM report_alarm in alarms)
            {
                if (report_alarm == null)
                {
                    continue;
                }
                if (report_alarm.ALAM_LVL == E_ALARM_LVL.Warn ||
                    report_alarm.ALAM_LVL == E_ALARM_LVL.None)
                {
                    continue;
                }
                //需判斷Alarm是否存在如果有的話則需再判斷MCS是否有Disable該Alarm的上報
                int ialarm_code = 0;
                int.TryParse(report_alarm.ALAM_CODE, out ialarm_code);
                string alarm_code = (ialarm_code < 0 ? ialarm_code * -1 : ialarm_code).ToString();
                if (scApp.AlarmBLL.IsReportToHost(alarm_code))
                {
                    //scApp.ReportBLL.ReportAlarmHappend(eqpt.VEHICLE_ID, alarm.ALAM_STAT, alarm.ALAM_CODE, alarm.ALAM_DESC, out reportqueues);
                    List <AMCSREPORTQUEUE> reportqueues = new List <AMCSREPORTQUEUE>();
                    if (report_alarm.ALAM_STAT == ErrorStatus.ErrSet)
                    {
                        scApp.ReportBLL.ReportAlarmHappend(report_alarm.ALAM_STAT, alarm_code, report_alarm.ALAM_DESC);
                        scApp.ReportBLL.newReportUnitAlarmSet(eq_real_id, alarm_code, report_alarm.ALAM_DESC, current_adr_id, reportqueues);
                    }
                    else
                    {
                        scApp.ReportBLL.ReportAlarmHappend(report_alarm.ALAM_STAT, alarm_code, report_alarm.ALAM_DESC);
                        scApp.ReportBLL.newReportUnitAlarmClear(eq_real_id, alarm_code, report_alarm.ALAM_DESC, current_adr_id, reportqueues);
                    }
                    scApp.ReportBLL.newSendMCSMessage(reportqueues);

                    LogHelper.Log(logger: logger, LogLevel: LogLevel.Debug, Class: nameof(VehicleService), Device: "OHxC",
                                  Data: $"do report alarm to mcs,alarm code:{err_code},alarm status{status}",
                                  VehicleID: eq_id);
                }
            }
            //在設備上報取消Alarm,如果已經沒有Alarm(Alarm都已經消除,則要上報S6F11 CEID=52 Alarm Clear)
            bool processAfterHasErrorExist = scApp.AlarmBLL.hasAlarmErrorExist();

            if (status == ErrorStatus.ErrReset &&
                //!scApp.AlarmBLL.hasAlarmErrorExist())
                processBeferHasErrorExist &&
                !processAfterHasErrorExist)
            {
                scApp.ReportBLL.newReportAlarmClear();
            }
        }
Пример #9
0
        //public AlarmMap getAlarmMap(string eqpt_real_id, string alarm_id)
        //{
        //    DBConnection conn = null;
        //    AlarmMap alarmMap = null;
        //    try
        //    {
        //        conn = scApp.getDBConnection();
        //        conn.BeginTransaction();

        //        alarmMap = alarmMapDao.getAlarmMap(conn, eqpt_real_id, alarm_id);
        //    }
        //    catch (Exception ex)
        //    {
        //        logger.Warn("getAlarmMap Exception!", ex);
        //    }
        //    return alarmMap;
        //}
        public AlarmMap GetAlarmMap(string eq_id, string error_code)
        {
            AlarmMap alarmMap = alarmMapDao.getAlarmMap(eq_id, error_code);

            return(alarmMap);
        }
        //public AlarmMap getAlarmMap(string eqpt_real_id, string alarm_id)
        //{
        //    DBConnection conn = null;
        //    AlarmMap alarmMap = null;
        //    try
        //    {
        //        conn = scApp.getDBConnection();
        //        conn.BeginTransaction();

        //        alarmMap = alarmMapDao.getAlarmMap(conn, eqpt_real_id, alarm_id);
        //    }
        //    catch (Exception ex)
        //    {
        //        logger.Warn("getAlarmMap Exception!", ex);
        //    }
        //    return alarmMap;
        //}
        public AlarmMap GetAlarmMap(string nodeID, string error_code)
        {
            AlarmMap alarmMap = alarmMapDao.getAlarmMap(scApp, nodeID, error_code);

            return(alarmMap);
        }
Пример #11
0
        public ALARM setAlarmReport(string node_id, string eq_id, string error_code, ACMD_MCS mcsCmdData)
        {
            lock (lock_obj_alarm)
            {
                string alarmEq = eq_id;
                //if (scApp.TransferService.isUnitType(eq_id, Service.UnitType.AGVZONE))
                //{
                //    alarmEq = eq_id.Remove(0, 12);
                //}

                if (IsAlarmExist(alarmEq, error_code))
                {
                    return(null);
                }
                string alarmUnitType = "LINE";

                if (scApp.TransferService.isUnitType(eq_id, Service.UnitType.AGV))
                {
                    alarmUnitType = "AGV";
                }
                else if (scApp.TransferService.isUnitType(eq_id, Service.UnitType.CRANE))
                {
                    alarmUnitType = "CRANE";
                }
                else if (scApp.TransferService.isUnitType(eq_id, Service.UnitType.NTB))
                {
                    alarmUnitType = "NTB";
                }
                else if (scApp.TransferService.isUnitType(eq_id, Service.UnitType.OHCV) ||
                         scApp.TransferService.isUnitType(eq_id, Service.UnitType.STK)
                         )
                {
                    int stage = scApp.TransferService.portINIData[eq_id].Stage;

                    if (stage == 7)
                    {
                        alarmUnitType = "OHCV_7";
                    }
                    else
                    {
                        alarmUnitType = "OHCV_5";
                    }
                }
                else if (scApp.TransferService.isUnitType(eq_id, Service.UnitType.AGVZONE))
                {
                    //B7_OHBLINE1_ST01
                    alarmUnitType = "LINE";
                    //eq_id = eq_id.Remove(0, 12);
                }

                AlarmMap alarmMap = alarmMapDao.getAlarmMap(alarmUnitType, error_code);

                if (alarmMap == null)
                {
                    scApp.TransferService.TransferServiceLogger.Info
                    (
                        DateTime.Now.ToString("HH:mm:ss.fff ") +
                        "OHT >> OHB|AlarmMap 不存在:"
                        + "    EQ_Name:" + eq_id
                        + "    Error_code:" + error_code
                    );
                }

                string strNow = BCFUtility.formatDateTime(DateTime.Now, SCAppConstants.TimestampFormat_19);

                ALARM alarm = new ALARM()
                {
                    EQPT_ID        = eq_id,
                    RPT_DATE_TIME  = strNow,
                    ALAM_CODE      = error_code,
                    ALAM_LVL       = alarmMap == null ? E_ALARM_LVL.Warn : alarmMap.ALARM_LVL,
                    ALAM_STAT      = ProtocolFormat.OHTMessage.ErrorStatus.ErrSet,
                    ALAM_DESC      = alarmMap == null ? $"unknow alarm code:{error_code}" : $"{eq_id} {alarmMap.ALARM_DESC}(error code:{error_code})",
                    ERROR_ID       = error_code, //alarmMap?.ALARM_ID ?? "0",
                    UnitID         = eq_id,
                    UnitState      = "3",
                    RecoveryOption = "",
                    CMD_ID         = "",
                };

                if (mcsCmdData != null)
                {
                    alarm.CMD_ID = mcsCmdData.CMD_ID.Trim();
                }

                if (scApp.TransferService.isUnitType(eq_id, UnitType.CRANE))
                {
                    if (error_code == SCAppConstants.SystemAlarmCode.OHT_Issue.DoubleStorage)
                    {
                        alarm.UnitState      = "1";
                        alarm.RecoveryOption = "ABORT";
                    }

                    if (error_code == SCAppConstants.SystemAlarmCode.OHT_Issue.EmptyRetrieval)
                    {
                        alarm.UnitState      = "2";
                        alarm.RecoveryOption = "ABORT";
                    }
                }

                using (DBConnection_EF con = DBConnection_EF.GetUContext())
                {
                    if (alarmDao.insertAlarm(con, alarm) == false)
                    {
                        alarm = null;
                    }

                    CheckSetAlarm();
                }

                //if (scApp.TransferService.isUnitType(eq_id, UnitType.CRANE) == false)
                //{
                //    alarm.EQPT_ID = "";
                //    alarm.UnitID = "";
                //}

                return(alarm);
            }
        }