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); } }
/// <summary> /// Adds the alarm his. /// </summary> /// <param name="alarm">The alarm.</param> public virtual void addAlarmHis(ALARM alarm) { lock (alarmLock) { alarmList.Add(alarm); OnPropertyChanged(BCFUtility.getPropertyName(() => this.AlarmList)); } }
public void InsertAlarm(ALARM alarm) { string sql = String.Format("INSERT INTO ALARM VALUES('{0}','{1}', CONVERT(datetime, '{2}', 103), CONVERT(datetime, '{3}', 103), '{4}', '{5}', '{6}', '{7}', CONVERT(datetime, '{8}', 103))", alarm.DLU, alarm.ERL, alarm.startDate, alarm.endDate, alarm.isSuccess, alarm.LevelAlarm, alarm.Status, alarm.HOST, alarm.dateEvent); sqlQueryExecutor = new SqlServerSqlQueryExecutor(Properties.Settings.Default.Server, 1433, Properties.Settings.Default.Database, Properties.Settings.Default.User, Properties.Settings.Default.Pass); sqlQueryExecutor.ExecuteUpdate(sql); }
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 DataTable GetAlarmBeginCCSM(ALARM alarm) { string sql = String.Format("SELECT * FROM PSTNAlarmTapTrung WHERE NAlarm like '{0}%' AND TrangThaiEnd = 0 ORDER BY MaSend desc", alarm.HOST + "_" + alarm.DLU + "_" + alarm.ERL + "_"); sqlQueryExecutor = new SqlServerSqlQueryExecutor(Properties.Settings.Default.Server, 1433, Properties.Settings.Default.Database, Properties.Settings.Default.User, Properties.Settings.Default.Pass); DataTable lsAlarm = new DataTable(); lsAlarm = sqlQueryExecutor.Execute(sql); return(lsAlarm); }
public DataTable GetAlarmBegin(ALARM alarm) { string sql = String.Format("SELECT * FROM ALARM WHERE DLU = '{0}' AND ERL = '{1}' AND HOST = '{2}' AND IsSuccess = 0 ORDER BY ID desc", alarm.DLU, alarm.ERL, alarm.HOST); sqlQueryExecutor = new SqlServerSqlQueryExecutor(Properties.Settings.Default.Server, 1433, Properties.Settings.Default.Database, Properties.Settings.Default.User, Properties.Settings.Default.Pass); DataTable lsAlarm = new DataTable(); lsAlarm = sqlQueryExecutor.Execute(sql); return(lsAlarm); }
public virtual void resetAlarmReport2Redis(ALARM alarm) { if (alarm == null) { return; } string hash_field = $"{alarm.EQPT_ID.Trim()}_{alarm.ALAM_CODE.Trim()}"; //scApp.getRedisCacheManager().AddTransactionCondition(StackExchange.Redis.Condition.HashExists(SCAppConstants.REDIS_KEY_CURRENT_ALARM, hash_field)); scApp.getRedisCacheManager().HashDeleteAsync(SCAppConstants.REDIS_KEY_CURRENT_ALARM, hash_field); }
public virtual void setAlarmReport2Redis(ALARM alarm) { if (alarm == null) { return; } string hash_field = $"{alarm.EQPT_ID}_{alarm.ALAM_CODE}"; scApp.getRedisCacheManager().AddTransactionCondition(StackExchange.Redis.Condition.HashNotExists(SCAppConstants.REDIS_KEY_CURRENT_ALARM, hash_field)); scApp.getRedisCacheManager().HashSetAsync(SCAppConstants.REDIS_KEY_CURRENT_ALARM, hash_field, JsonConvert.SerializeObject(alarm)); }
public List <ALARM> getCurrentAlarmsFromRedis() { List <ALARM> alarms = new List <ALARM>(); var redis_values_alarms = scApp.getRedisCacheManager().HashValuesAsync(SCAppConstants.REDIS_KEY_CURRENT_ALARM).Result; foreach (string redis_value_alarm in redis_values_alarms) { ALARM alarm_obj = (ALARM)JsonConvert.DeserializeObject(redis_value_alarm, typeof(ALARM)); alarms.Add(alarm_obj); } return(alarms); }
public void XuatPhieuAlarm(ALARM alarm) { var dmAlarm = GetDMAlarm(alarm.ERL, alarm.HOST, "VETINH"); var dmVeTinh = GetDMVeTinh(alarm.DLU, alarm.HOST); string url = "http://10.10.20.49/dhscInternalApi/api/v1/Service/CanhBaoSuCoMangNew"; string result = ""; if (dmAlarm.Rows.Count > 0 && dmVeTinh.Rows.Count > 0 && alarm.ERL != "5") { if (alarm.isBegin == true) { string input = String.Format("\"MaSuCo\": \"{0}\",\"MaVeTinh\": \"{1}\",\"LoaiMang\":\"{2}\",\"LoaiCanhBao\":\"{3}\",\"CapDoId\": \"{4}\",\"TgSuCo\": \"{5}\",\"TgClr\":\"{6}\",\"MaTinhThanh\":\"{7}\",\"TrangThai\": \"{8}\",\"HeThongId\": \"{9}\",\"NoiDungCanhBao\":\"{10}\"", //alarm.HOST + "_" + dmVeTinh.Rows[0]["MaVT"] + "_" + alarm.DLU + "_" + alarm.ERL+ "_" + alarm.startDate.Value.ToString("ddMMyyyyHHmmss"), alarm.HOST + "_" + dmVeTinh.Rows[0]["MaVT"] + "_" + alarm.ERL, dmVeTinh.Rows[0]["MaVT"], 40112, dmAlarm.Rows[0]["LoaiCanhBao"], dmAlarm.Rows[0]["CapDo"], alarm.dateEvent.ToString("dd/MM/yyyy HH:mm:ss"), "", "HNI", 1, 1, dmVeTinh.Rows[0]["MaVT"] + ":" + alarm.DLU + ":" + dmAlarm.Rows[0]["Name"] ); result = POST(url, "{" + input + "}"); LogXuatPhieu(result, input); } else { var lsAlarm = GetAlarmBegin(alarm); if (lsAlarm.Rows.Count > 0) { string input = String.Format("\"MaSuCo\": \"{0}\",\"MaVeTinh\": \"{1}\",\"LoaiMang\":\"{2}\",\"LoaiCanhBao\":\"{3}\",\"CapDoId\": \"{4}\",\"TgSuCo\": \"{5}\",\"TgClr\":\"{6}\",\"MaTinhThanh\":\"{7}\",\"TrangThai\": \"{8}\",\"HeThongId\": \"{9}\",\"NoiDungCanhBao\":\"{10}\"", //alarm.HOST + "_" + dmVeTinh.Rows[0]["MaVT"] + "_" + alarm.DLU + "_" + alarm.ERL + "_" + Convert.ToDateTime(lsAlarm.Rows[0]["StartDate"].ToString()).ToString("ddMMyyyyHHmmss"), alarm.HOST + "_" + dmVeTinh.Rows[0]["MaVT"] + "_" + alarm.ERL, dmVeTinh.Rows[0]["MaVT"], 40112, dmAlarm.Rows[0]["LoaiCanhBao"], dmAlarm.Rows[0]["CapDo"], Convert.ToDateTime(lsAlarm.Rows[0]["StartDate"].ToString()).ToString("dd/MM/yyyy HH:mm:ss"), alarm.dateEvent.ToString("dd/MM/yyyy HH:mm:ss"), "HNI", 3, 1, dmVeTinh.Rows[0]["MaVT"] + ":" + alarm.DLU + ":" + dmAlarm.Rows[0]["Name"] ); result = POST(url, "{" + input + "}"); LogXuatPhieu(result, input); } } } }
public void UpdateAlarmEndCCSM(ALARM alarm) { var lsAlarm = GetAlarmBeginCCSM(alarm); if (lsAlarm.Rows.Count > 0) { string sql = String.Format("UPDATE PSTNAlarmTapTrung SET TimeEnd = '{0}', TrangThaiEnd = 1, TrangThaiXL = 0 WHERE MaSend = {1}", alarm.endDate.Value.ToString("dd/MM/yyyy HH:mm:ss"), lsAlarm.Rows[0]["MaSend"]); sqlQueryExecutor = new SqlServerSqlQueryExecutor(Properties.Settings.Default.Server, 1433, Properties.Settings.Default.Database, Properties.Settings.Default.User, Properties.Settings.Default.Pass); sqlQueryExecutor.ExecuteUpdate(sql); } }
/// <summary> /// Updates the alarm. /// </summary> /// <param name="conn">The connection.</param> /// <param name="alarm">The alarm.</param> public void updateAlarm(DBConnection_EF conn, ALARM alarm) { try { conn.SaveChanges(); } catch (Exception ex) { logger.Warn(ex); throw; } }
public void UpdateAlarmEnd(ALARM alarm) { var lsAlarm = GetAlarmBegin(alarm); if (lsAlarm.Rows.Count > 0) { string sql = String.Format("UPDATE ALARM SET EndDate = CONVERT(datetime, '{0}', 103), IsSuccess = 1, DateEvent = CONVERT(datetime, '{1}', 103) WHERE ID = {2}", alarm.endDate, alarm.dateEvent, lsAlarm.Rows[0]["ID"]); sqlQueryExecutor = new SqlServerSqlQueryExecutor(Properties.Settings.Default.Server, 1433, Properties.Settings.Default.Database, Properties.Settings.Default.User, Properties.Settings.Default.Pass); sqlQueryExecutor.ExecuteUpdate(sql); } }
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; } }
/// <summary> /// Inserts the alarm. /// </summary> /// <param name="conn">The connection.</param> /// <param name="alarm">The alarm.</param> public void insertAlarm(DBConnection_EF conn, ALARM alarm) { try { conn.ALARM.Add(alarm); conn.SaveChanges(); } catch (Exception ex) { logger.Warn(ex); throw; } }
public void DeleteAlarmByAlarmID(DBConnection_EF conn, ALARM alarm) { try { conn.ALARM.Remove(alarm); conn.SaveChanges(); } catch (Exception ex) { logger.Warn(ex); throw; } }
/// <summary> /// Inserts the alarm. /// </summary> /// <param name="conn">The connection.</param> /// <param name="alarm">The alarm.</param> public bool insertAlarm(DBConnection_EF conn, ALARM alarm) { try { conn.ALARM.Add(alarm); conn.SaveChanges(); return(true); } catch (Exception ex) { logger.Warn(ex); return(false); throw; } }
//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 virtual ALARM resetAlarmReport(string eq_id, string error_code) { lock (lock_obj_alarm) { using (DBConnection_EF con = DBConnection_EF.GetUContext()) { ALARM alarm = alarmDao.getSetAlarm(con, eq_id, error_code); if (alarm != null) { alarm.ALAM_STAT = ProtocolFormat.OHTMessage.ErrorStatus.ErrReset; alarm.CLEAR_DATE_TIME = DateTime.Now; alarmDao.updateAlarm(con, alarm); CheckSetAlarm(); } return(alarm); } } }
public ALARM resetAlarmReport(string eq_id, string error_code) { lock (lock_obj_alarm) { using (DBConnection_EF con = DBConnection_EF.GetUContext()) { ALARM alarm = alarmDao.getSetAlarm(con, eq_id, error_code); if (alarm != null) { string strNow = BCFUtility.formatDateTime(DateTime.Now, SCAppConstants.TimestampFormat_19); alarm.ALAM_STAT = ProtocolFormat.OHTMessage.ErrorStatus.ErrReset; alarm.END_TIME = strNow; alarmDao.updateAlarm(con, alarm); CheckSetAlarm(); } return(alarm); } } }
public void InsertAlarmCCSM(ALARM alarm) { var dmAlarm = GetDMAlarm(alarm.ERL, alarm.HOST, "VETINH"); var dmVeTinh = GetDMVeTinh(alarm.DLU, alarm.HOST); if (dmAlarm.Rows.Count > 0 && dmVeTinh.Rows.Count > 0) { string sql = String.Format("INSERT INTO PSTNAlarmTapTrung VALUES('{0}','{1}', '', CONVERT(datetime, '{2}', 103),'{3}', '{4}', '{5}', '{6}', '', '{7}', '{7}', '', '{8}', '{9}', '{10}', '')", alarm.HOST, dmVeTinh.Rows[0]["MaVT"], alarm.dateEvent, "", "Cap " + dmAlarm.Rows[0]["CapDo"], dmVeTinh.Rows[0]["MaVT"] + ":" + dmAlarm.Rows[0]["Name"], alarm.startDate.Value.ToString("dd/MM/yyyy HH:mm:ss"), alarm.isSuccess, alarm.DLU, dmAlarm.Rows[0]["LoaiCCSM"], alarm.HOST + "_" + alarm.DLU + "_" + alarm.ERL + "_" + alarm.dateEvent.ToString("yyyyMMddHHmmss")); sqlQueryExecutor = new SqlServerSqlQueryExecutor(Properties.Settings.Default.Server, 1433, Properties.Settings.Default.Database, Properties.Settings.Default.User, Properties.Settings.Default.Pass); sqlQueryExecutor.ExecuteUpdate(sql); var lsAlarm = GetAlarmBeginCCSM(alarm); if (lsAlarm.Rows.Count > 0) { string sql1 = String.Format("UPDATE PSTNAlarmTapTrung SET MaClear = '{0}' WHERE MaSend = {1}", alarm.HOST + lsAlarm.Rows[0]["MaSend"], lsAlarm.Rows[0]["MaSend"]); sqlQueryExecutor = new SqlServerSqlQueryExecutor(Properties.Settings.Default.Server, 1433, Properties.Settings.Default.Database, Properties.Settings.Default.User, Properties.Settings.Default.Pass); sqlQueryExecutor.ExecuteUpdate(sql1); } } }
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); } }
public abstract bool S6F11SendAlarmSet(ACMD_MCS CMD_MCS, ALARM ALARM, string unitid, string unitstate, string RecoveryOption);
public abstract bool S6F11SendAlarmCleared(ACMD_MCS CMD_MCS, ALARM ALARM, string unitid, string unitstate);
public void ProcessAlarmReport(AVEHICLE vh, string err_code, ErrorStatus status, string errorDesc) { try { string node_id = vh.NODE_ID; string vh_id = vh.VEHICLE_ID; //string mcs_cmd_id_1 = SCUtility.Trim(vh.TRANSFER_ID_1, true); //string mcs_cmd_id_2 = SCUtility.Trim(vh.TRANSFER_ID_2, true); List <string> effect_tran_cmd_ids = tryGetEffectTransferCommnadID(vh); bool is_all_alarm_clear = SCUtility.isMatche(err_code, "0") && status == ErrorStatus.ErrReset; //List<ALARM> alarms = null; List <ALARM> alarms = new List <ALARM>(); 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: DEVICE_NAME_AGV, Data: $"Process vehicle alarm report.alarm code:{err_code},alarm status{status},error desc:{errorDesc}", VehicleID: vh.VEHICLE_ID, CST_ID_L: vh.CST_ID_L, CST_ID_R: vh.CST_ID_R); ALARM alarm = null; if (is_all_alarm_clear) { alarms = scApp.AlarmBLL.resetAllAlarmReport(vh_id); scApp.AlarmBLL.resetAllAlarmReport2Redis(vh_id); } else { switch (status) { case ErrorStatus.ErrSet: //將設備上報的Alarm填入資料庫。 //alarm = scApp.AlarmBLL.setAlarmReport(node_id, vh_id, err_code, errorDesc, mcs_cmd_id_1, mcs_cmd_id_2); alarm = scApp.AlarmBLL.setAlarmReport(node_id, vh_id, err_code, errorDesc, effect_tran_cmd_ids); //將其更新至Redis,保存目前所發生的Alarm scApp.AlarmBLL.setAlarmReport2Redis(alarm); //alarms = new List<ALARM>() { alarm }; if (alarm != null) { alarms.Add(alarm); } break; case ErrorStatus.ErrReset: //將設備上報的Alarm從資料庫刪除。 alarm = scApp.AlarmBLL.resetAlarmReport(vh_id, err_code); //將其更新至Redis,保存目前所發生的Alarm scApp.AlarmBLL.resetAlarmReport2Redis(alarm); //alarms = new List<ALARM>() { alarm }; if (alarm != null) { alarms.Add(alarm); } break; } } tx.Complete(); } } scApp.getRedisCacheManager().ExecuteTransaction(); //通知有Alarm的資訊改變。 if (alarms != null && alarms.Count > 0) { //scApp.getNatsManager().PublishAsync(SCAppConstants.NATS_SUBJECT_CURRENT_ALARM, new byte[0]); line.NotifyAlarmListChange(); } foreach (ALARM report_alarm in alarms) { if (report_alarm == null) { continue; } if (report_alarm.ALAM_LVL == E_ALARM_LVL.Warn) { continue; } //需判斷Alarm是否存在如果有的話則需再判斷MCS是否有Disable該Alarm的上報 if (scApp.AlarmBLL.IsReportToHost(report_alarm.ALAM_CODE)) { string alarm_code = report_alarm.ALAM_CODE; //scApp.ReportBLL.ReportAlarmHappend(eqpt.VEHICLE_ID, alarm.ALAM_STAT, alarm.ALAM_CODE, alarm.ALAM_DESC, out reportqueues); string transfer_id = tryGetCurrentTransferCommand(vh); List <AMCSREPORTQUEUE> reportqueues = new List <AMCSREPORTQUEUE>(); if (report_alarm.ALAM_STAT == ErrorStatus.ErrSet) { scApp.ReportBLL.ReportAlarmHappend(vh.VEHICLE_ID, transfer_id, report_alarm.ALAM_STAT, alarm_code, report_alarm.ALAM_DESC, reportqueues); } else { scApp.ReportBLL.ReportAlarmCleared(vh.VEHICLE_ID, transfer_id, report_alarm.ALAM_STAT, alarm_code, report_alarm.ALAM_DESC, reportqueues); } scApp.ReportBLL.newSendMCSMessage(reportqueues); LogHelper.Log(logger: logger, LogLevel: LogLevel.Debug, Class: nameof(VehicleService), Device: DEVICE_NAME_AGV, Data: $"do report alarm to mcs,vh:{vh.VEHICLE_ID} alarm code:{err_code},alarm status{status}", VehicleID: vh.VEHICLE_ID, CST_ID_L: vh.CST_ID_L, CST_ID_R: vh.CST_ID_R); } } } catch (Exception ex) { LogHelper.Log(logger: logger, LogLevel: LogLevel.Warn, Class: nameof(VehicleService), Device: DEVICE_NAME_AGV, Data: ex, VehicleID: vh.VEHICLE_ID, CST_ID_L: vh.CST_ID_L, CST_ID_R: vh.CST_ID_R); } }
public void ProcessAlarmReport(string eqptID, string err_code, ErrorStatus status, string errorDesc) { try { string eq_id = eqptID; bool is_all_alarm_clear = SCUtility.isMatche(err_code, "0") && status == ErrorStatus.ErrReset; //List<ALARM> alarms = null; List <ALARM> alarms = new List <ALARM>(); 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: DEVICE_NAME_AGV, Data: $"Process eq alarm report.alarm code:{err_code},alarm status{status},error desc:{errorDesc}"); ALARM alarm = null; if (is_all_alarm_clear) { alarms = scApp.AlarmBLL.resetAllAlarmReport(eq_id); scApp.AlarmBLL.resetAllAlarmReport2Redis(eq_id); } else { switch (status) { case ErrorStatus.ErrSet: //將設備上報的Alarm填入資料庫。 alarm = scApp.AlarmBLL.setAlarmReport(eq_id, err_code, errorDesc); //將其更新至Redis,保存目前所發生的Alarm scApp.AlarmBLL.setAlarmReport2Redis(alarm); //alarms = new List<ALARM>() { alarm }; if (alarm != null) { alarms.Add(alarm); } break; case ErrorStatus.ErrReset: //將設備上報的Alarm從資料庫刪除。 alarm = scApp.AlarmBLL.resetAlarmReport(eq_id, err_code); //將其更新至Redis,保存目前所發生的Alarm scApp.AlarmBLL.resetAlarmReport2Redis(alarm); //alarms = new List<ALARM>() { alarm }; if (alarm != null) { alarms.Add(alarm); } break; } } tx.Complete(); } } scApp.getRedisCacheManager().ExecuteTransaction(); //通知有Alarm的資訊改變。 if (alarms != null && alarms.Count > 0) { //scApp.getNatsManager().PublishAsync(SCAppConstants.NATS_SUBJECT_CURRENT_ALARM, new byte[0]); line.NotifyAlarmListChange(); } foreach (ALARM report_alarm in alarms) { if (report_alarm == null) { continue; } if (report_alarm.ALAM_LVL == E_ALARM_LVL.Warn) { continue; } //需判斷Alarm是否存在如果有的話則需再判斷MCS是否有Disable該Alarm的上報 if (scApp.AlarmBLL.IsReportToHost(report_alarm.ALAM_CODE)) { string alarm_code = report_alarm.ALAM_CODE; 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, reportqueues); scApp.ReportBLL.ReportAlarmHappend(eq_id, "", report_alarm.ALAM_STAT, alarm_code, report_alarm.ALAM_DESC, reportqueues); } else { //scApp.ReportBLL.ReportAlarmCleared("", "", report_alarm.ALAM_STAT, alarm_code, report_alarm.ALAM_DESC, reportqueues); scApp.ReportBLL.ReportAlarmCleared(eq_id, "", report_alarm.ALAM_STAT, alarm_code, report_alarm.ALAM_DESC, reportqueues); } scApp.ReportBLL.newSendMCSMessage(reportqueues); LogHelper.Log(logger: logger, LogLevel: LogLevel.Debug, Class: nameof(VehicleService), Device: DEVICE_NAME_AGV, Data: $"do report alarm to mcs,eq:{eq_id} alarm code:{err_code},alarm status{status}"); } } } catch (Exception ex) { LogHelper.Log(logger: logger, LogLevel: LogLevel.Warn, Class: nameof(VehicleService), Device: DEVICE_NAME_AGV, Data: ex); } }
public ALARMObjToShow(ALARM alarmObj) { alarm_obj = alarmObj; }
public override bool S6F11SendAlarmCleared(ACMD_MCS CMD_MCS, ALARM ALARM, string unitid, string unitstate) { return(true); }
public override bool S6F11SendAlarmSet(ACMD_MCS CMD_MCS, ALARM ALARM, string unitid, string unitstate, string RecoveryOption) { return(true); }
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(); } }