/**
         * dataTemp : 資料來源為  (UInt16[])ValueRead.getText()
         **/
        /// <summary>
        /// Converts to string.
        /// </summary>
        /// <param name="dataTemp">The data temporary.</param>
        /// <param name="iStartIndex">Start index of the i.</param>
        /// <param name="iEndIndex">End index of the i.</param>
        /// <returns>String.</returns>
        public String convertToString(UInt16[] dataTemp, int iStartIndex, int iEndIndex)
        {
            int[] rangeData = BCFUtility.getArrayRange(dataTemp, iStartIndex, iEndIndex);

            foreach (int loopInt in rangeData)
            {
                if (loopInt != 0)
                {
                    return(((String)BCFUtility.convertInt2TextByType(vr.MPLCConfigDevice.DeviceBitCount,
                                                                     Type.GetType("System.String"), rangeData)).Trim());
                }
            }

            return(" ");
        }
        /**
         * dataTemp : 資料來源為  (UInt16[])ValueRead.getText()
         **/
        /// <summary>
        /// Converts to date time.
        /// </summary>
        /// <param name="dataTemp">The data temporary.</param>
        /// <param name="iStartIndex">Start index of the i.</param>
        /// <param name="iEndIndex">End index of the i.</param>
        /// <returns>DateTime.</returns>
        public DateTime convertToDateTime(UInt16[] dataTemp, int iStartIndex, int iEndIndex)
        {
            int[]  rangeData  = BCFUtility.getArrayRange(dataTemp, iStartIndex, iEndIndex);
            String sTimeArray = (String)BCFUtility.convertInt2TextByType(vr.MPLCConfigDevice.DeviceBitCount, Type.GetType("System.String"), rangeData);

            try
            {
                IFormatProvider timeStyle = new System.Globalization.CultureInfo("zh-TW", true);
                return(DateTime.ParseExact(sTimeArray, "yyyyMMddHHmmssff", timeStyle));
            }
            catch (Exception ex)
            {
                logger.Error(ex, "Exception:");
                //格式錯誤
            }

            return(new DateTime());
        }
 /**
  * dataTemp : 資料來源為  (UInt16[])ValueRead.getText()
  **/
 /// <summary>
 /// Converts to booleans.
 /// </summary>
 /// <param name="dataTemp">The data temporary.</param>
 /// <param name="iStartIndex">Start index of the i.</param>
 /// <param name="iEndIndex">End index of the i.</param>
 /// <returns>Boolean[].</returns>
 public Boolean[] convertToBooleans(UInt16[] dataTemp, int iStartIndex, int iEndIndex)
 {
     int[] rangeData = BCFUtility.getArrayRange(dataTemp, iStartIndex, iEndIndex);
     return((Boolean[])BCFUtility.convertInt2TextByType(vr.MPLCConfigDevice.DeviceBitCount, Type.GetType("System.Boolean[]"), rangeData));
 }
        /// <summary>
        /// Analyzes the process data item.
        /// </summary>
        /// <param name="dataItem">The data item.</param>
        private void analyzeProcessDataItem(UInt16[] dataItem)
        {
            ProcessDataConfigHandler handler = eqpt.getProcessDataConfigHandler();

            if (handler == null)
            {
                return;
            }
            List <ProcessDataType> procDataTypeList = handler.ProcDataTypeList;

            if (procDataTypeList == null)
            {
                return;
            }
            int           beginIndex = 0;
            StringBuilder sb         = new StringBuilder();

            sb.AppendLine();
            sb.AppendLine(string.Format("[Name:Lot ID][Value:{0}]", Lot_ID));
            sb.AppendLine(string.Format("[Name:Operator ID][Value:{0}]", Operator_ID));
            sb.AppendLine(string.Format("[Name:PPID][Value:{0}]", PPID));
            sb.AppendLine(string.Format("[Name:Prod ID][Value:{0}]", Prod_ID));
            sb.AppendLine(string.Format("[Name:Glass ID][Value:{0}]", Glass_ID));
            foreach (ProcessDataType dataType in procDataTypeList)
            {
                string name = dataType.Name;
                //A0.01 Begin
                if (String.Compare(name.Trim(), ProcessDataConfigHandler.SPARE_FORMAT.Trim(), true) == 0)
                {
                    beginIndex = beginIndex + 1;
                    continue;
                }
                //A0.01 End
                int    wordCount = dataType.WordCount;
                int[]  dataAry   = new int[wordCount];
                string valueStr  = string.Empty;
                try
                {
                    Array.Copy(dataItem, beginIndex, dataAry, 0, wordCount);
                    beginIndex = beginIndex + wordCount;
                    if (dataType.ItemType == ProcessDataType.DataItemType.BCD)
                    {
//                        int trussCount = dataType.TrussCount;
                        double     multiplier    = dataType.Multiplier;
                        bool       isContainSign = dataType.IsContainSign;
                        BCD_Common bcd           = BCD_Common.toBCD_Common(dataAry, wordCount, multiplier, isContainSign);
                        double     realValue     = bcd.RealValue;
                        valueStr = Convert.ToString(realValue);
                        sb.AppendLine(string.Format("[Name:{0}][Value:{1}]", name, realValue));
                    }
                    else if (dataType.ItemType == ProcessDataType.DataItemType.ASCII)
                    {
                        string realStr = BCFUtility.convertIntAry2String(dataAry);
                        valueStr = realStr;
                        sb.AppendLine(string.Format("[Name:{0}][Value:{1}]", name, realStr));
                    }
                    else if (dataType.ItemType == ProcessDataType.DataItemType.INT)
                    {
                        double multiplier = dataType.Multiplier;
                        if (dataType.IsContainSign)
                        {
                            double doubleVal = 0;
                            if (dataAry.Length > 2)
                            {
                                //3個word以上,使用Int64
                                //64 bit(4 word)
                                Int64 val = (Int64)BCFUtility.convertInt2TextByType(16, typeof(System.Int64), dataAry);
                                doubleVal = val * multiplier;
                            }
                            else if (dataAry.Length > 1)
                            {
                                //2個word,使用Int32
                                //32 bit(2 word)
                                Int32 val = (Int32)BCFUtility.convertInt2TextByType(16, typeof(System.Int32), dataAry);
                                doubleVal = val * multiplier;
                            }
                            else
                            {
                                //1個word,使用Int16
                                //16 bit(1 word)
                                Int16 val = (Int16)BCFUtility.convertInt2TextByType(16, typeof(System.Int16), dataAry);
                                doubleVal = val * multiplier;
                            }
//                            Int16 val = (Int16)BCFUtility.convertInt2TextByType(16, typeof(System.Int16), dataAry);
//                            double doubleVal = val * multiplier;
                            valueStr = Convert.ToString(doubleVal);
                        }
                        else
                        {
                            double doubleVal = 0;
                            if (dataAry.Length > 2)
                            {
                                //3個word以上,使用UInt64
                                //64 bit(4 word)
                                UInt64 val = (UInt64)BCFUtility.convertInt2TextByType(16, typeof(System.UInt64), dataAry);
                                doubleVal = val * multiplier;
                            }
                            else if (dataAry.Length > 1)
                            {
                                //2個word,使用UInt32
                                //32 bit(2 word)
                                UInt32 val = (UInt32)BCFUtility.convertInt2TextByType(16, typeof(System.UInt32), dataAry);
                                doubleVal = val * multiplier;
                            }
                            else
                            {
                                //1個word,使用UInt16
                                //16 bit(1 word)
                                UInt16 val = (UInt16)BCFUtility.convertInt2TextByType(16, typeof(System.UInt16), dataAry);
                                doubleVal = val * multiplier;
                            }
//                            UInt16 val = (UInt16)BCFUtility.convertInt2TextByType(16, typeof(System.UInt16), dataAry);
//                            double doubleVal = val * multiplier;
                            valueStr = Convert.ToString(doubleVal);
                        }
                        sb.AppendLine(string.Format("[Name:{0}][Value:{1}]", name, valueStr));
                    }
                }
                catch (Exception ex)
                {
                    sb.AppendLine(string.Format("[Name:{0}][Exception:{1}]", name, ex));
                }
                DataItemList.Add(new KeyValuePair <string, string>(name, valueStr));
            }
            procDataLog.Info(sb.ToString());
        }