| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 | using Aitex.Common.Util;using Aitex.Core.Common;using Aitex.Core.RT.Log;using MECF.Framework.Common.CommonData;using MECF.Framework.Common.CommonData.Rinse;using MECF.Framework.Common.SubstrateTrackings;using MECF.Framework.Common.WaferHolder;using System;using System.Collections.Generic;using System.IO;using System.Threading.Tasks;namespace CyberX8_RT.Modules.Rinse{    public class RinseLotTrackUtil    {        /// <summary>        /// CSV文件分隔符        /// </summary>        private const char CVS_SPLIT_CHAR = ',';        /// <summary>        /// 导出至csv        /// </summary>        /// <param name="moduleName"></param>        /// <param name="datas"></param>        public static async void ExportRinseLotTrack(string moduleName, List<RinseLotTrackData> datas,LotTrackFileHeaderCommonData headerData, bool isAuto, bool isRetry)        {            await Task.Run(() =>            {                try                {                    if (datas == null || datas.Count == 0) return;                    string strPath;                    FileInfo fi;                    if (isAuto)                    {                        WaferHolderInfo whInfo = WaferHolderManager.Instance.GetWaferHolder(moduleName);                        if (whInfo == null) return;                        WaferInfo waferInfoA = WaferManager.Instance.GetWaferByWaferId(whInfo.WaferAId);                        WaferInfo waferInfoB = WaferManager.Instance.GetWaferByWaferId(whInfo.WaferBId);                        if (waferInfoA != null && !string.IsNullOrEmpty(waferInfoA.LotId))                        {                            strPath = waferInfoA.LotTrackPath;                        }                        else if (waferInfoB != null && !string.IsNullOrEmpty(waferInfoB.LotId))                        {                            strPath = waferInfoB.LotTrackPath;                        }                        else                        {                            LOG.WriteLog(eEvent.ERR_PREWET, moduleName, $"{moduleName} is failed to write LotTrackDatas");                            return;                        }                        fi = new FileInfo(PathManager.GetLotTrackFilePath() + strPath);                    }                    else                    {                        strPath = $"{moduleName}_M{DateTime.Now.ToString("MM")}_D{DateTime.Now.ToString("dd")}_H{DateTime.Now.ToString("HH")}_M{DateTime.Now.ToString("mm")}_S{DateTime.Now.ToString("ss")}.csv";                        fi = new FileInfo(PathManager.GetLotTrackFilePath() + $"Manual\\{DateTime.Now.Year}\\{DateTime.Now.Month}\\" + strPath);                    }                    //目录不存在则创建                    if (!fi.Directory.Exists)                    {                        fi.Directory.Create();                    }                    FileStream fs = new FileStream(fi.FullName, System.IO.FileMode.Append, System.IO.FileAccess.Write);                    StreamWriter sw = new StreamWriter(fs, System.Text.Encoding.UTF8);                    if (!isAuto)                    {                        sw.WriteLine(fi.FullName);                        sw.WriteLine($"Date:{DateTime.Now.ToShortDateString()}");                        sw.WriteLine($"ToolID:{headerData.ToolID}");                        sw.WriteLine($"SW Version:{headerData.SoftWareVersion}");                        sw.WriteLine($"Sequence Recipe:{headerData.SequenceRecipe}");                    }                    if ((!isRetry && isAuto) || !isAuto)                    {                        if (headerData.ProcessTransferList != null)                        {                            foreach (var item in headerData.ProcessTransferList)                            {                                sw.WriteLine(item);                            }                        }                        sw.WriteLine(moduleName);                        sw.WriteLine($"Recipe:{headerData.Recipe}");                        sw.WriteLine($"SingleWafer:{headerData.IsSingleWafe}");                        sw.WriteLine($"ProcessTime:{headerData.ProcessTime}");                        sw.Write(CVS_SPLIT_CHAR);                        string str = $"TimeStamp{CVS_SPLIT_CHAR}StateMachine{CVS_SPLIT_CHAR}WaterLevel{CVS_SPLIT_CHAR}DIFillEnabled{CVS_SPLIT_CHAR}" +                            $"DumpEnabled{CVS_SPLIT_CHAR}WaterPressure{CVS_SPLIT_CHAR}Resistivity";                        sw.WriteLine(str);                    }                                            for (int i = 0; i < datas.Count; i++)                    {                        RinseLotTrackData data = datas[i];                        string tmp = $"{CVS_SPLIT_CHAR}{data.TimeStamp.ToString("HH:mm:ss")}{CVS_SPLIT_CHAR}{data.StateMachine}{CVS_SPLIT_CHAR}{data.WaterLevel}" +                            $"{CVS_SPLIT_CHAR}{data.DIFillEnabled}{CVS_SPLIT_CHAR}{data.DumpEnabled}{CVS_SPLIT_CHAR}{data.WaterPressure}{CVS_SPLIT_CHAR}{data.Resistivity.ToString("F2")}";                        sw.WriteLine(tmp);                    }                    sw.WriteLine("");                    sw.Close();                    fs.Close();                }                catch                {                    LOG.WriteLog(eEvent.ERR_RINSE, moduleName, $"{moduleName} LotTrack file writing is failed!");                }            });                    }    }}
 |