318 lines
14 KiB
C#

using Adaptation.Shared;
using Infineon.Yoda;
using System;
using System.Collections.Generic;
namespace Adaptation.Si
{
public class LDS2559Send
{
public enum FieldName
{
IFX_SERVICE,
KEYS,
PARAMETER,
SETTINGS,
PARAMETERNAME,
VALUE
}
public class Settings
{
public string MODE { get; set; }
public int COMTIMEOUT { get; set; }
public string DATE { get; private set; }
public int KEY { get; set; }
public int LDS { get; set; }
public string SENDER { get; set; }
public Settings(string ifxSubjectPrefix, Logistics logistics)
{
MODE = "FULL";
COMTIMEOUT = 10;
KEY = 0;
switch (ifxSubjectPrefix)
{
case "VIH_D": LDS = 2599; break;
case "VIH_P": LDS = 2500; break;
default: LDS = -1; break;
}
SENDER = Environment.MachineName;
DATE = logistics.DateTimeFromSequence.ToString("yyyyMMddHHmmss");
}
}
public class Value
{
public DataKeys DataKeys { get; set; }
public string VALUE { get; set; }
public Value(Logistics logistics)
{
DataKeys = new DataKeys(logistics);
}
}
public class Parameter
{
public ExtractorKeys ExtractorKeys { get; set; }
public DataKeys DataKeys { get; set; }
public string COMMENT { get; set; }
public double? LSL { get; set; }
public string PARAMETERNAME { get; set; }
public double? TSL { get; set; }
public string UNIT { get; set; }
public double? USL { get; set; }
public string VALUE { get; set; }
public Parameter(Logistics logistics)
{
ExtractorKeys = new ExtractorKeys(logistics);
DataKeys = new DataKeys(logistics);
}
public Parameter(Logistics logistics, string parameterName, string value)
{
ExtractorKeys = new ExtractorKeys(logistics);
DataKeys = new DataKeys(logistics);
PARAMETERNAME = parameterName;
VALUE = value;
}
public Parameter(Logistics logistics, ExtendedParameter extendedParameter)
{
ExtractorKeys = new ExtractorKeys(logistics);
DataKeys = new DataKeys(logistics);
PARAMETERNAME = extendedParameter.DiplayName;
LSL = extendedParameter.LSL;
TSL = extendedParameter.TSL;
UNIT = extendedParameter.Unit;
USL = extendedParameter.USL;
VALUE = extendedParameter.Value;
}
}
public class DataKeys
{
public string Employee { get; set; } //1
public string SID { get; set; } //2
public string WaferRegion { get; set; } //3
public string WaferScribe { get; set; } //4
public string WaferPosition { get; set; } //5
public string X { get; set; } //6
public string Y { get; set; } //7
public string EAFCellInstance { get; set; } //8
public string EAFReference { get; set; } //9
public string IQSReference { get; set; } //10
public DataKeys(Logistics logistics, IScopeInfo scopeInfo = null, string sID = null)
{
if (scopeInfo is null)
{
SID = null;
EAFReference = null;
IQSReference = null;
EAFCellInstance = null;
}
else
{
if (string.IsNullOrEmpty(sID))
SID = "-";
else
SID = sID;
EAFReference = scopeInfo.EquipmentType.ToString();
if (string.IsNullOrEmpty(scopeInfo.QueryFilter))
IQSReference = null;
else
IQSReference = scopeInfo.QueryFilter;
if (logistics is null)
EAFCellInstance = null;
else
EAFCellInstance = logistics.JobID;
}
}
}
public class ExtractorKeys
{
public string Lot { get; set; } //1
public string ToolID { get; set; } //2
public string Process { get; set; } //3
public string WaferID { get; set; } //4
public string Part { get; set; } //5
public string Recipe { get; set; } //6
public string ProcessFlow { get; set; } //7
public ExtractorKeys(Logistics logistics, IScopeInfo scopeInfo = null)
{
if (scopeInfo is null)
{
ToolID = null;
Lot = null;
Part = null;
}
else
{
ToolID = logistics.MesEntity;
Lot = "-";
Part = "-";
}
}
}
public class DATA
{
public string IFX_SERVICE { get; set; }
public ExtractorKeys ExtractorKeys { get; set; }
public DataKeys DataKeys { get; set; }
public Parameter Parameter { get; set; }
public Settings Settings { get; set; }
public DATA(string ifxSubjectPrefix, Logistics logistics, IScopeInfo scopeInfo, string sID)
{
ExtractorKeys = new ExtractorKeys(logistics, scopeInfo);
DataKeys = new DataKeys(logistics, scopeInfo, sID);
Parameter = new Parameter(logistics);
Settings = new Settings(ifxSubjectPrefix, logistics);
}
internal static IfxDoc GetIfxDoc(string service, string value, DataKeys dataKeys, ExtractorKeys extractorKeys, Settings settings)
{
IfxDoc result = new IfxDoc();
if (!string.IsNullOrEmpty(service))
result.Add(string.Concat(FieldName.IFX_SERVICE), service);
if (!(value is null))
{
if (string.IsNullOrEmpty(value))
result.Add(string.Concat(FieldName.VALUE), "-");
else
result.Add(string.Concat(FieldName.VALUE), value);
}
if (!(dataKeys is null))
{
if (!string.IsNullOrEmpty(dataKeys.EAFCellInstance))
result.Add(string.Concat(FieldName.KEYS, "/", nameof(LDS2559Send.DataKeys.EAFCellInstance)), dataKeys.EAFCellInstance);
if (!string.IsNullOrEmpty(dataKeys.EAFReference))
result.Add(string.Concat(FieldName.KEYS, "/", nameof(LDS2559Send.DataKeys.EAFReference)), dataKeys.EAFReference);
if (!string.IsNullOrEmpty(dataKeys.Employee))
result.Add(string.Concat(FieldName.KEYS, "/", nameof(LDS2559Send.DataKeys.Employee)), dataKeys.Employee);
if (!string.IsNullOrEmpty(dataKeys.IQSReference))
result.Add(string.Concat(FieldName.KEYS, "/", nameof(LDS2559Send.DataKeys.IQSReference)), dataKeys.IQSReference);
if (!string.IsNullOrEmpty(dataKeys.SID))
result.Add(string.Concat(FieldName.KEYS, "/", nameof(LDS2559Send.DataKeys.SID)), dataKeys.SID);
if (!string.IsNullOrEmpty(dataKeys.WaferPosition))
result.Add(string.Concat(FieldName.KEYS, "/", nameof(LDS2559Send.DataKeys.WaferPosition)), dataKeys.WaferPosition);
if (!string.IsNullOrEmpty(dataKeys.WaferRegion))
result.Add(string.Concat(FieldName.KEYS, "/", nameof(LDS2559Send.DataKeys.WaferRegion)), dataKeys.WaferRegion);
if (!string.IsNullOrEmpty(dataKeys.WaferScribe))
result.Add(string.Concat(FieldName.KEYS, "/", nameof(LDS2559Send.DataKeys.WaferScribe)), dataKeys.WaferScribe);
if (!string.IsNullOrEmpty(dataKeys.X))
result.Add(string.Concat(FieldName.KEYS, "/", nameof(LDS2559Send.DataKeys.X)), dataKeys.X);
if (!string.IsNullOrEmpty(dataKeys.Y))
result.Add(string.Concat(FieldName.KEYS, "/", nameof(LDS2559Send.DataKeys.Y)), dataKeys.Y);
}
if (!(extractorKeys is null))
{
if (!string.IsNullOrEmpty(extractorKeys.Lot))
result.Add(string.Concat(FieldName.KEYS, "/", nameof(LDS2559Send.ExtractorKeys.Lot)), extractorKeys.Lot);
if (!string.IsNullOrEmpty(extractorKeys.Part))
result.Add(string.Concat(FieldName.KEYS, "/", nameof(LDS2559Send.ExtractorKeys.Part)), extractorKeys.Part);
if (!string.IsNullOrEmpty(extractorKeys.Process))
result.Add(string.Concat(FieldName.KEYS, "/", nameof(LDS2559Send.ExtractorKeys.Process)), extractorKeys.Process);
if (!string.IsNullOrEmpty(extractorKeys.ProcessFlow))
result.Add(string.Concat(FieldName.KEYS, "/", nameof(LDS2559Send.ExtractorKeys.ProcessFlow)), extractorKeys.ProcessFlow);
if (!string.IsNullOrEmpty(extractorKeys.Recipe))
result.Add(string.Concat(FieldName.KEYS, "/", nameof(LDS2559Send.ExtractorKeys.Recipe)), extractorKeys.Recipe);
if (!string.IsNullOrEmpty(extractorKeys.ToolID))
result.Add(string.Concat(FieldName.KEYS, "/", nameof(LDS2559Send.ExtractorKeys.ToolID)), extractorKeys.ToolID);
if (!string.IsNullOrEmpty(extractorKeys.WaferID))
result.Add(string.Concat(FieldName.KEYS, "/", nameof(LDS2559Send.ExtractorKeys.WaferID)), extractorKeys.WaferID);
}
if (!(settings is null))
{
result.Add(string.Concat(FieldName.SETTINGS, "/", nameof(LDS2559Send.Settings.MODE)), settings.MODE);
result.Add(string.Concat(FieldName.SETTINGS, "/", nameof(LDS2559Send.Settings.COMTIMEOUT)), settings.COMTIMEOUT);
result.Add(string.Concat(FieldName.SETTINGS, "/", nameof(LDS2559Send.Settings.DATE)), settings.DATE);
result.Add(string.Concat(FieldName.SETTINGS, "/", nameof(LDS2559Send.Settings.KEY)), settings.KEY);
result.Add(string.Concat(FieldName.SETTINGS, "/", nameof(LDS2559Send.Settings.LDS)), settings.LDS);
result.Add(string.Concat(FieldName.SETTINGS, "/", nameof(LDS2559Send.Settings.SENDER)), settings.SENDER);
}
return result;
}
public IfxDoc GetIfxDoc(List<IfxDoc> parameters)
{
IfxDoc result = GetIfxDoc("EVALUATESPCDATA", value: null, dataKeys: DataKeys, extractorKeys: ExtractorKeys, settings: Settings);
result.Add(string.Concat(FieldName.PARAMETER), parameters.ToArray());
return result;
}
}
public class ParameterCollection
{
public List<Parameter> Collection { get; set; }
public ParameterCollection()
{
Collection = new List<Parameter>();
}
public IfxDoc GetIfxDoc()
{
IfxDoc value;
IfxDoc result = new IfxDoc();
Parameter parameter;
List<IfxDoc> values = new List<IfxDoc>();
for (int i = 0; i < Collection.Count; i++)
{
parameter = Collection[i];
if (i == 0)
{
if (parameter.TSL.HasValue & parameter.USL.HasValue && parameter.TSL.Value > parameter.USL.Value)
parameter.USL = parameter.TSL.Value;
if (parameter.TSL.HasValue & parameter.LSL.HasValue && parameter.TSL.Value < parameter.LSL.Value)
parameter.LSL = parameter.TSL.Value;
//
if (parameter.LSL.HasValue & parameter.USL.HasValue && parameter.LSL.Value > parameter.USL.Value && parameter.USL.Value == 0)
parameter.USL = null;
//
if (parameter.USL.HasValue & parameter.LSL.HasValue && parameter.USL.Value < parameter.LSL.Value)
throw new Exception();
if (parameter.LSL.HasValue & parameter.USL.HasValue && parameter.LSL.Value > parameter.USL.Value)
throw new Exception();
//
if (parameter.LSL.HasValue)
result.Add(nameof(Parameter.LSL), parameter.LSL);
if (!string.IsNullOrEmpty(parameter.PARAMETERNAME))
result.Add(string.Concat(FieldName.PARAMETERNAME), parameter.PARAMETERNAME);
if (parameter.TSL.HasValue)
result.Add(nameof(Parameter.TSL), parameter.TSL.Value);
if (!string.IsNullOrEmpty(parameter.UNIT))
result.Add(nameof(Parameter.UNIT), parameter.UNIT);
if (parameter.USL.HasValue)
result.Add(nameof(Parameter.USL), parameter.USL.Value);
}
value = DATA.GetIfxDoc(service: string.Empty, value: parameter.VALUE, dataKeys: parameter.DataKeys, extractorKeys: parameter.ExtractorKeys, settings: null);
values.Add(value);
}
result.Add(string.Concat(FieldName.VALUE), values.ToArray());
return result;
}
}
}
}