public config_controllers() { DBUtil dBUtil; string strSql = string.Empty; List <CDBContainer> Temp = new List <CDBContainer>(); try { dBUtil = new DBUtil(); strSql = "select * from config_controller order by node_id asc "; Temp = dBUtil.GetDataList(DBUtil.QueryContainer.DBController, strSql, null).ToList(); if (Temp.Count == 0) { throw new Exception("This statement is the read config exception message."); } foreach (var item in Temp) { switch (((DBController)item).Node_id.ToString()) { case "Aligner01": Aligner01 = ((DBController)item); break; case "Aligner02": Aligner02 = ((DBController)item); break; case "LoadPort01": LoadPort01 = ((DBController)item); break; case "LoadPort02": LoadPort02 = ((DBController)item); break; case "LoadPort03": LoadPort03 = ((DBController)item); break; case "LoadPort04": LoadPort04 = ((DBController)item); break; case "LoadPort05": LoadPort05 = ((DBController)item); break; case "LoadPort06": LoadPort06 = ((DBController)item); break; case "LoadPort07": LoadPort07 = ((DBController)item); break; case "LoadPort08": LoadPort08 = ((DBController)item); break; case "Robot01": Robot01 = ((DBController)item); break; case "Robot02": Robot02 = ((DBController)item); break; case "OCR01": OCR01 = ((DBController)item); break; case "OCR02": OCR02 = ((DBController)item); break; } } } catch (Exception ex) { throw new Exception(ex.ToString()); } }
/// <summary> /// Get alarm message /// </summary> /// <param name="node_id"> 設備系統代碼 </param> /// <param name="error_message"> 錯誤訊息 </param> /// <returns></returns> public AlarmMessage Get(string node_id, string error_message) { AlarmMessage alarm; DataTable dtTemp; string strAlarmAxis = string.Empty; string strAlarmAxisEnglish = string.Empty; string strCode28 = string.Empty; //int itFirst = 0; //int itCode28 = 0; string strErrorCode = string.Empty; string strSql = string.Empty; DBUtil dBUtil = new DBUtil(); string supplier = string.Empty; string eqp_type = string.Empty; string address = string.Empty; try { strSql = "select * from config_node where node_id = '" + node_id + "' and equipment_model_id = '" + SANWA.Utility.Config.SystemConfig.Get().SystemMode + "'"; dtTemp = dBUtil.GetDataTable(strSql, null); if (dtTemp.Rows.Count > 0) { supplier = dtTemp.Rows[0]["vendor"].ToString(); eqp_type = dtTemp.Rows[0]["node_type"].ToString(); address = dtTemp.Rows[0]["sn_no"].ToString(); } else { supplier = "SANWA"; eqp_type = "SYSTEM"; address = "0"; } alarm = new AlarmMessage(); alarm.Return_Code_ID = error_message; // * Special rule switch (supplier.ToUpper()) { //case "SANWA": // int s = 0; // if (int.TryParse(error_message.Substring(0, 1), out s)) // { // itFirst = s; // strCode28 = Convert.ToString(itFirst, 2); // itCode28 = int.Parse(strCode28.Substring(strCode28.Length - 1, 1)); // if (itCode28 == 1) // { // strSql = "SELECT * " + // "FROM config_list_item " + // "WHERE list_type = 'SANWA_CODE' " + // " AND list_value = '" + error_message.Substring(5, 1) + "'" + // "ORDER BY sort_sequence ASC"; // dtTemp = dBUtil.GetDataTable(strSql, null); // if (dtTemp.Rows.Count > 0) // { // strAlarmAxis = dtTemp.Rows[0]["list_name"].ToString(); // strAlarmAxisEnglish = dtTemp.Rows[0]["list_name_en"].ToString(); // } // else // { // throw new Exception("SANWA.Utility.AlarmMapping\r\nException: Alarm Axis Code not exists."); // } // strErrorCode = error_message.Substring(0, 5) + "0" + error_message.Substring(6, 2); // } // else // { // strErrorCode = error_message; // } // } // else // { // strErrorCode = error_message; // } // break; //case "TDK": //case "KAWASAKI": //case "ATEL": // strErrorCode = error_message; // break; //case "ASYST": // for (int i = 0; i < error_message.Split(' ').Length; i++) // { // if (i >= 2) // { // if (strErrorCode.Length == 0) // { // strErrorCode = error_message.Split(' ')[i].ToString(); // } // else // { // strErrorCode = strErrorCode + " " + error_message.Split(' ')[i].ToString(); // } // } // } // break; default: strErrorCode = error_message; break; } var query = (from a in dtCode.AsEnumerable() where a.Field <string>("node_type") == eqp_type.ToUpper() && a.Field <string>("vendor") == supplier.ToUpper() && a.Field <string>("return_code").ToUpper() == strErrorCode.ToUpper() && a.Field <string>("device_address_id") == address select a).ToList(); if (query.Count > 0) { dtTemp = query.CopyToDataTable(); alarm.CodeID = strAlarmAxis == string.Empty ? dtTemp.Rows[0]["sys_code_id"].ToString() : dtTemp.Rows[0]["device_code_id"].ToString() + alarm.Return_Code_ID; alarm.IsStop = dtTemp.Rows[0]["Is_stop"].ToString() == "Y" ? true : false; alarm.Code_Type = dtTemp.Rows[0]["return_code_type"].ToString(); alarm.Code_Name = dtTemp.Rows[0]["Code_Name"].ToString(); alarm.Code_Cause = strAlarmAxis == string.Empty ? dtTemp.Rows[0]["Code_Desc"].ToString() : strAlarmAxis + " " + dtTemp.Rows[0]["Code_Desc"].ToString(); alarm.Code_Cause_English = strAlarmAxisEnglish == string.Empty ? dtTemp.Rows[0]["Code_Desc_EN"].ToString() : strAlarmAxisEnglish + " " + dtTemp.Rows[0]["Code_Desc_EN"].ToString(); alarm.Position = dtTemp.Rows[0]["location"].ToString(); alarm.Code_Group = dtTemp.Rows[0]["category"].ToString(); } else { alarm.CodeID = error_message; alarm.IsStop = false; alarm.Code_Type = error_message; alarm.Code_Name = error_message; alarm.Code_Cause = "未知"; alarm.Code_Cause_English = "unknown"; alarm.Position = string.Empty; alarm.Code_Group = "UNDEFINITION"; } } catch (Exception ex) { throw new Exception(ex.ToString()); } return(alarm); }