123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- using Aitex.Common.Util;
- using Aitex.Core.Common;
- using Aitex.Core.RT.Log;
- using MECF.Framework.Common.CommonData;
- using MECF.Framework.Common.CommonData.Prewet;
- 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.Prewet
- {
- public class PrewetLotTrackUtil
- {
- /// <summary>
- /// CSV文件分隔符
- /// </summary>
- private const char CVS_SPLIT_CHAR = ',';
- /// <summary>
- /// 导出至csv
- /// </summary>
- /// <param name="moduleName"></param>
- /// <param name="datas"></param>
- public static async void ExportPrewetLotTrack(string moduleName, List<PrewetLotTrackData> 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 (waferInfoA != null && !string.IsNullOrEmpty(waferInfoA.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}Pressure{CVS_SPLIT_CHAR}Flow{CVS_SPLIT_CHAR}PumpMode{CVS_SPLIT_CHAR}" +
- $"CurrentScan{CVS_SPLIT_CHAR}ScanOn{CVS_SPLIT_CHAR}PressureTarget{CVS_SPLIT_CHAR}ValveState{CVS_SPLIT_CHAR}PumpSpeed{CVS_SPLIT_CHAR}PumpControlCurrent";
- sw.WriteLine(str);
- }
-
- for (int i = 0; i < datas.Count; i++)
- {
- PrewetLotTrackData data = datas[i];
- string tmp = $"{CVS_SPLIT_CHAR}{data.TimeStamp.ToString("HH:mm:ss")}{CVS_SPLIT_CHAR}{data.StateMachine}{CVS_SPLIT_CHAR}{data.Pressure.ToString("F3")}{CVS_SPLIT_CHAR}{data.Flow.ToString("F3")}" +
- $"{CVS_SPLIT_CHAR}{data.PumpMode}{CVS_SPLIT_CHAR}{data.CurrentScan}{CVS_SPLIT_CHAR}{data.ScanOn}{CVS_SPLIT_CHAR}{data.PressureTarget.ToString("F3")}{CVS_SPLIT_CHAR}" +
- $"{data.ValveState}{CVS_SPLIT_CHAR}{data.PumpSpeed}{CVS_SPLIT_CHAR}{data.PumpControlCurrent.ToString("F3")}";
- sw.WriteLine(tmp);
- }
- sw.WriteLine("");
- sw.Close();
- fs.Close();
- }
- catch
- {
- LOG.WriteLog(eEvent.ERR_PREWET, moduleName, $"{moduleName} LotTrack file writing is failed!");
- }
- });
-
- }
- }
- }
|