Beispiel #1
0
        /// <summary>
        /// Encoder
        /// </summary>
        /// <param name="supplier"> Equipment supplier </param>
        public Encoder(string supplier)
        {
            ContainerSet containerSet;

            try
            {
                Supplier = supplier.ToUpper();

                containerSet = new ContainerSet();

                dtCommand = new DataTable();

                if (File.Exists(System.AppDomain.CurrentDomain.BaseDirectory + "ParameterList.xml"))
                {
                    containerSet.TableFormatting(ref dtCommand, System.AppDomain.CurrentDomain.BaseDirectory + "ParameterList.xml");
                }
                else
                {
                    throw new Exception("SANWA.Utility.Encoder\r\nException: Parameter List not exists.");
                }

                Aligner  = new EncoderAligner(Supplier, dtCommand);
                Robot    = new EncoderRobot(Supplier, dtCommand);
                OCR      = new EncoderOCR(Supplier, dtCommand);
                LoadPort = new EncoderLoadPort(Supplier, dtCommand, EncoderLoadPort.CommandMode.TDK_A);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.ToString());
            }
            finally
            {
                containerSet = null;
            }
        }
Beispiel #2
0
        public AlarmMapping()
        {
            ContainerSet containerSet;
            string       strSql = string.Empty;
            DBUtil       dBUtil = new DBUtil();
            Dictionary <string, object> keyValues = new Dictionary <string, object>();

            try
            {
                containerSet = new ContainerSet();

                dtCode = new DataTable();

                strSql = "SELECT * FROM view_alarm_code WHERE equipment_model_id = @equipment_model_id";

                keyValues.Add("@equipment_model_id", Config.SystemConfig.Get().SystemMode);

                dtCode = dBUtil.GetDataTable(strSql, keyValues);

                if (dtCode.Rows.Count < 0)
                {
                    throw new Exception("SANWA.Utility.AlarmMapping\r\nException: Code List not exists.");
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex.StackTrace, ex);
                throw new Exception(ex.ToString());
            }
            finally
            {
                containerSet = null;
            }
        }
Beispiel #3
0
        public AlarmMapping()
        {
            ContainerSet containerSet;

            try
            {
                containerSet = new ContainerSet();

                dtCode = new DataTable();

                if (File.Exists(System.AppDomain.CurrentDomain.BaseDirectory + "Code.xml"))
                {
                    containerSet.TableFormatting(ref dtCode, System.AppDomain.CurrentDomain.BaseDirectory + "Code.xml");
                }
                else
                {
                    throw new Exception("SANWA.Utility.AlarmMapping\r\nException: Code List not exists.");
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.ToString());
            }
            finally
            {
                containerSet = null;
            }
        }
Beispiel #4
0
        private string CommandAssembly(string CommandType, string Command, params string[] Parameter)
        {
            string        strCommand                = string.Empty;
            string        strCommandFormat          = string.Empty;
            string        strCommandFormatParameter = string.Empty;
            ContainerSet  container;
            StringBuilder sbTemp;

            try
            {
                container = new ContainerSet();
                sbTemp    = new StringBuilder();

                //var query = (from a in dtRobotCommand.AsEnumerable()
                //             where a.Field<string>("Equipment_Type") == "ORC"
                //                && a.Field<string>("Equipment_Supplier") == Supplier
                //                && a.Field<string>("Command_Type") == CommandType
                //                && a.Field<string>("Action_Function") == Command
                //             select a).ToList();

                //if (query.Count == 0)
                //{
                //    throw new RowNotInTableException();
                //}

                //dtTemp = query.CopyToDataTable();
                //dtTemp.DefaultView.Sort = "Parameter_Order ASC";
                //dvTemp = dtTemp.DefaultView;

                switch (Supplier)
                {
                case "COGNEX":

                    if (Command.Equals("Read"))
                    {
                        strCommandFormat = container.StringFormat("READ({0})", Parameter) + Environment.NewLine;
                    }
                    else
                    {
                        throw new NotSupportedException();
                    }

                    break;

                case "HST":

                    if (Command.Equals("Read"))
                    {
                        strCommandFormat = string.Format("{0}{1}{2}{3}{4}", "SM", ((char)34).ToString(), "READ", ((char)34).ToString(), "0");
                    }
                    else if (Command.Equals("OnlineStatus"))
                    {
                        strCommandFormat = string.Format("SO{0}", Parameter);
                    }
                    else if (Command.Equals("GetOnline"))
                    {
                        strCommandFormat = "GO";
                    }
                    else
                    {
                        throw new NotSupportedException();
                    }

                    break;

                default:
                    throw new NotImplementedException();
                }

                strCommand = strCommandFormat + strCommandFormatParameter;
            }
            catch (Exception ex)
            {
                throw new Exception(ex.ToString());
            }

            return(strCommand);
        }
Beispiel #5
0
        private string CommandAssembly(string Supplier, string Address, string Sequence, string CommandType, string Command, params string[] Parameter)
        {
            string        strCommand                = string.Empty;
            string        strCommandFormat          = string.Empty;
            string        strCommandFormatParameter = string.Empty;
            DataTable     dtTemp;
            DataView      dvTemp;
            ContainerSet  container;
            StringBuilder sbTemp;

            string[] strsParameter;

            try
            {
                container = new ContainerSet();
                sbTemp    = new StringBuilder();

                var query = (from a in dtRobotCommand.AsEnumerable()
                             where a.Field <string>("Equipment_Type") == "Aligner" &&
                             a.Field <string>("Equipment_Supplier") == Supplier &&
                             a.Field <string>("Command_Type") == CommandType &&
                             a.Field <string>("Action_Function") == Command
                             select a).ToList();

                if (query.Count == 0)
                {
                    throw new RowNotInTableException();
                }

                dtTemp = query.CopyToDataTable();
                dtTemp.DefaultView.Sort = "Parameter_Order ASC";
                dvTemp = dtTemp.DefaultView;

                switch (Supplier)
                {
                case "SANWA":

                    if (Parameter != null && Parameter.Length != 0)
                    {
                        if ((dvTemp.Table.Rows[0]["Parameter_ID"].ToString().Equals("Null")) && (Parameter.Length != dtTemp.Rows.Count))
                        {
                            sbTemp.Append("Equipment Type : Robot");
                            sbTemp.AppendFormat("Equipment Supplier : {0}", Supplier);
                            sbTemp.AppendFormat("Command Type : {0}", CommandType);
                            sbTemp.AppendFormat("Command : {0}", Command);
                            sbTemp.Append("Parameter list and setting list are not the same.");
                            throw new Exception(sbTemp.ToString());
                        }
                    }

                    strsParameter = Parameter;

                    for (int i = 0; i < dvTemp.Table.Rows.Count; i++)
                    {
                        Int32 itTemp = 0;

                        if (!dvTemp.Table.Rows[i]["Parameter_ID"].ToString().Equals("Null"))
                        {
                            if (int.Parse(dvTemp.Table.Rows[i]["Min_Value"].ToString()) > int.Parse(Parameter[i].ToString()))
                            {
                                throw new Exception("Exceed the minimum.");
                            }

                            if (int.Parse(dvTemp.Table.Rows[i]["Max_Value"].ToString()) < int.Parse(Parameter[i].ToString()))
                            {
                                throw new Exception("Exceed the maximum.");
                            }

                            if (dvTemp.Table.Rows[i]["Data_Value"].ToString().Equals(string.Empty))
                            {
                                if (dvTemp.Table.Rows[i]["Is_Fill"].ToString().Equals("Y"))
                                {
                                    itTemp = int.Parse(Parameter[i].ToString());

                                    if (Command.Equals("Angle"))
                                    {
                                        strsParameter[i] = itTemp.ToString().PadRight(6, '0');
                                    }
                                    else
                                    {
                                        strsParameter[i] = itTemp.ToString("D" + dvTemp.Table.Rows[i]["Values_length"].ToString());
                                    }
                                }
                            }
                            else
                            {
                                if (dvTemp.Table.Rows[i]["Data_Value"].ToString().IndexOf(Parameter[i].ToString()) < 0)
                                {
                                    throw new Exception(dvTemp.Table.Rows[i]["Parameter_ID"].ToString() + ": Setting value error.");
                                }
                            }
                        }
                    }

                    strCommandFormat = container.StringFormat(dtTemp.Rows[0]["Command_Format"].ToString(), new string[] { Address, Sequence });

                    if (strsParameter != null && strsParameter.Length != 0)
                    {
                        strCommandFormatParameter = container.StringFormat(dtTemp.Select(), strsParameter);
                    }

                    break;

                case "KAWASAKI":

                    if (Parameter != null && Parameter.Length != 0)
                    {
                        if ((dvTemp.Table.Rows[0]["Parameter_ID"].ToString().Equals("Null") || dvTemp.Table.Rows[0]["Parameter_ID"].ToString().Equals("Data") || dvTemp.Table.Rows[0]["Parameter_ID"].ToString().Equals("DateTime")
                             ) && (Parameter.Length != dtTemp.Rows.Count))
                        {
                            sbTemp.Append("Equipment Type : Robot");
                            sbTemp.AppendFormat("Equipment Supplier : {0}", Supplier);
                            sbTemp.AppendFormat("Command Type : {0}", CommandType);
                            sbTemp.AppendFormat("Command : {0}", Command);
                            sbTemp.Append("Parameter list and setting list are not the same.");
                            throw new Exception(sbTemp.ToString());
                        }
                    }

                    strsParameter = Parameter;

                    for (int i = 0; i < dvTemp.Table.Rows.Count; i++)
                    {
                        Int32 itTemp = 0;

                        if (!dvTemp.Table.Rows[i]["Parameter_ID"].ToString().Equals("Null") || !dvTemp.Table.Rows[i]["Parameter_ID"].ToString().Equals("Data"))
                        {
                            // * Value mode
                            if (dvTemp.Table.Rows[i]["Data_Value"].ToString().Equals(string.Empty))
                            {
                                if (int.Parse(dvTemp.Table.Rows[i]["Min_Value"].ToString()) > int.Parse(Parameter[i].ToString()))
                                {
                                    throw new Exception("Exceed the minimum.");
                                }

                                if (int.Parse(dvTemp.Table.Rows[i]["Max_Value"].ToString()) < int.Parse(Parameter[i].ToString()))
                                {
                                    throw new Exception("Exceed the maximum.");
                                }

                                if (dvTemp.Table.Rows[i]["Data_Value"].ToString().Equals(string.Empty))
                                {
                                    if (dvTemp.Table.Rows[i]["Is_Fill"].ToString().Equals("Y"))
                                    {
                                        itTemp           = int.Parse(Parameter[i].ToString());
                                        strsParameter[i] = itTemp.ToString("D" + dvTemp.Table.Rows[i]["Values_length"].ToString());
                                    }
                                }
                                else
                                {
                                    if (dvTemp.Table.Rows[i]["Data_Value"].ToString().IndexOf(Parameter[i].ToString()) < 0)
                                    {
                                        throw new Exception(dvTemp.Table.Rows[i]["Parameter_ID"].ToString() + ": Setting value error.");
                                    }
                                }
                            }
                            // * string mode
                            else
                            {
                                if (dvTemp.Table.Rows[i]["Data_Value"].ToString().IndexOf(strsParameter[i].ToString()) < 0)
                                {
                                    throw new Exception(dvTemp.Table.Rows[i]["Data_Value"].ToString() + ": Out of setting range.");
                                }
                            }

                            if (dvTemp.Table.Rows[i]["Parameter_ID"].ToString().Equals("DateTime"))
                            {
                                strsParameter[i] = Convert.ToDateTime(strsParameter[i]).ToString("yy/MM/dd HH:mm:ss");
                            }
                        }
                    }

                    sbTemp = new StringBuilder();
                    for (int i = 0; i < strsParameter.Length; i++)
                    {
                        sbTemp.Append(strsParameter[i].ToString());
                        sbTemp.Append(",");
                    }

                    strCommandFormat = container.StringFormat(dtTemp.Rows[0]["Command_Format"].ToString(), new string[] { sbTemp.ToString().TrimEnd(','), strCommandFormatParameter });


                    break;

                default:
                    throw new NotImplementedException();
                }

                strCommand = strCommandFormat + strCommandFormatParameter;
            }
            catch (Exception ex)
            {
                throw new Exception(ex.ToString());
            }

            return(strCommand + "\r");
        }
Beispiel #6
0
        private string CommandAssembly(string Supplier, string CommandType, string Command, params string[] Parameter)
        {
            string        strCommand                = string.Empty;
            string        strCommandFormat          = string.Empty;
            string        strCommandFormatParameter = string.Empty;
            DataTable     dtTemp;
            DataView      dvTemp;
            ContainerSet  container;
            StringBuilder sbTemp;

            try
            {
                container = new ContainerSet();
                sbTemp    = new StringBuilder();

                var query = (from a in dtRobotCommand.AsEnumerable()
                             where a.Field <string>("Equipment_Type") == "LoadPort" &&
                             a.Field <string>("Equipment_Supplier") == Supplier &&
                             a.Field <string>("Command_Type") == CommandType &&
                             a.Field <string>("Action_Function") == Command
                             select a).ToList();

                if (query.Count == 0)
                {
                    throw new RowNotInTableException();
                }

                dtTemp = query.CopyToDataTable();
                dtTemp.DefaultView.Sort = "Parameter_Order ASC";
                dvTemp = dtTemp.DefaultView;

                switch (Supplier)
                {
                case "TDK":

                    switch (cmdMode)
                    {
                    case CommandMode.TDK_A:
                        strCommandFormat = TDK_A(dtTemp.Rows[0]["Command_Format"].ToString());
                        break;

                    case CommandMode.TDK_B:
                        strCommandFormat = TDK_B(dtTemp.Rows[0]["Command_Format"].ToString());
                        break;;
                    }

                    break;

                default:
                    throw new NotImplementedException();
                }

                strCommand = strCommandFormat + strCommandFormatParameter;
            }
            catch (Exception ex)
            {
                throw new Exception(ex.ToString());
            }

            return(strCommand);
        }