HelperEDADatabase

HelperEAFProgramData
HelperCompass
HelperInfinityQS
HelperSerial
HelperTCP
dotnet_analyzer_diagnostic
This commit is contained in:
2024-04-16 10:32:55 -07:00
parent e0f591e987
commit 27ba309e88
37 changed files with 4956 additions and 80 deletions

178
Helpers/EDA/Common.cs Normal file
View File

@ -0,0 +1,178 @@
using System.Text;
namespace File_Watcher.Helpers.EDA;
[Serializable]
public class Common
{
public string? ConfigurationProductiveState { get; set; }
public string? ConfigurationState { get; set; }
public string? ContainerName { get; set; }
public ModuleInstanceTypeName? ObjectType { get; set; }
public string? UnitName { get; set; }
//
public string Filename { get; set; }
public string StartTimeFormat { get; set; }
public string[] StoragePaths { get; set; }
//
public List<string[]> GeneralTriggers { get; set; }
public List<string[]> LogisticsAttributes { get; set; }
public List<string[]> LogisticsColumns { get; set; }
public string LogisticsEquipmentAlias { get; set; }
public List<string?[]> LogisticsTriggers { get; set; }
public Dictionary<int, List<string[]>> LogisticsTriggersCallDefinitionAttributes { get; set; }
public Dictionary<int, string[]> LogisticsTriggersKeysKeyMapping { get; set; }
public List<string?[]> Parameters { get; set; }
public string ParametersAsCsv { get; set; }
public string Source { get; set; }
public List<string[]> StartTriggersDCP { get; set; }
public List<string[]> StopTriggersDCP { get; set; }
[Obsolete("Only for DeserializeObject")]
public Common()
{
Parameters = [];
ObjectType = null;
StoragePaths = [];
GeneralTriggers = [];
StopTriggersDCP = [];
LogisticsColumns = [];
Source = string.Empty;
StartTriggersDCP = [];
LogisticsTriggers = [];
Filename = string.Empty;
UnitName = string.Empty;
LogisticsAttributes = [];
ContainerName = string.Empty;
ParametersAsCsv = string.Empty;
StartTimeFormat = string.Empty;
ConfigurationState = string.Empty;
LogisticsTriggersKeysKeyMapping = [];
LogisticsEquipmentAlias = string.Empty;
ConfigurationProductiveState = string.Empty;
LogisticsTriggersCallDefinitionAttributes = [];
}
public Common(ModuleInstanceTypeName objectType, object unitName, object containerName, object configurationState, object configurationProductiveState)
{
Parameters = [];
StoragePaths = [];
GeneralTriggers = [];
StopTriggersDCP = [];
LogisticsColumns = [];
Source = string.Empty;
StartTriggersDCP = [];
LogisticsTriggers = [];
Filename = string.Empty;
ObjectType = objectType;
LogisticsAttributes = [];
ParametersAsCsv = string.Empty;
StartTimeFormat = string.Empty;
UnitName = unitName.ToString();
LogisticsTriggersKeysKeyMapping = [];
LogisticsEquipmentAlias = string.Empty;
ContainerName = containerName.ToString();
LogisticsTriggersCallDefinitionAttributes = [];
ConfigurationState = configurationState.ToString();
ConfigurationProductiveState = configurationProductiveState.ToString();
}
public void Update(PDSFConfiguration configuration)
{
if (configuration.Settings.StoragePaths is null)
StoragePaths = [];
else
StoragePaths = configuration.Settings.StoragePaths;
StartTimeFormat = configuration.Settings.StartTimeFormat;
Filename = configuration.Settings.Filename;
//
Source = configuration.DataCollection.Source;
LogisticsEquipmentAlias = configuration.DataCollection.Logistics.EquipmentAlias;
//if (LogisticsEquipmentAlias == "R47-PLC")
//{ }
foreach (PDSFConfigurationDataCollectionLogisticsAttribute item in from l in configuration.DataCollection.Logistics.Attributes orderby l.Use descending, l.Order select l)
LogisticsAttributes.Add([item.Use.ToString(), item.Order.ToString("000"), item.Key, item.Placeholder]);
foreach (PDSFConfigurationDataCollectionLogisticsColumn item in configuration.DataCollection.Logistics.Columns)
LogisticsColumns.Add([item.ID.ToString(), item.Prefix]);
foreach (PDSFConfigurationDataCollectionParameter1 item in from l in configuration.DataCollection.VirtualParameters orderby l.Use descending, l.Order select l)
{
if (item?.Conditions is null)
continue;
if (string.IsNullOrEmpty(item.Alias) && !string.IsNullOrEmpty(item.Conditions.ConditionModel?.Name))
{
if (item.Use)
Parameters.Add([item.Use.ToString(), item.Order.ToString("000"), item.FullName, item.Conditions?.ConditionModel?.Name, item.HardWareId, item.Description, item.Conditions?.ConditionModel?.Formula, true.ToString(), (configuration.DataCollection.Logistics.Columns.Length + 1 + item.Order).ToString("000")]);
else
Parameters.Add([item.Use.ToString(), item.Order.ToString("000"), item.FullName, item.Conditions?.ConditionModel?.Name, item.HardWareId, item.Description, string.Empty, true.ToString(), (configuration.DataCollection.Logistics.Columns.Length + 1 + item.Order).ToString("000")]);
}
else
{
if (item.Use)
Parameters.Add([item.Use.ToString(), item.Order.ToString("000"), item.FullName, item.Alias, item.HardWareId, item.Description, item.Conditions?.ConditionModel?.Formula, true.ToString(), (configuration.DataCollection.Logistics.Columns.Length + 1 + item.Order).ToString("000")]);
else
Parameters.Add([item.Use.ToString(), item.Order.ToString("000"), item.FullName, item.Alias, item.HardWareId, item.Description, string.Empty, true.ToString(), (configuration.DataCollection.Logistics.Columns.Length + 1 + item.Order).ToString("000")]);
}
}
foreach (PDSFConfigurationDataCollectionParameter item in from l in configuration.DataCollection.Parameters orderby l.Use descending, l.Order select l)
{
if (string.IsNullOrEmpty(item.Alias) && !string.IsNullOrEmpty(item.Conditions?.ConditionModel?.Name))
{
if (item.Use)
Parameters.Add([item.Use.ToString(), item.Order.ToString("000"), item.FullName, item.Conditions?.ConditionModel?.Name, item.HardWareId, item.Description, item.Conditions?.ConditionModel?.Formula, false.ToString(), (configuration.DataCollection.Logistics.Columns.Length + 1 + item.Order).ToString("000")]);
else
Parameters.Add([item.Use.ToString(), item.Order.ToString("000"), item.FullName, item.Conditions?.ConditionModel?.Name, item.HardWareId, item.Description, string.Empty, false.ToString(), (configuration.DataCollection.Logistics.Columns.Length + 1 + item.Order).ToString("000")]);
}
else
{
if (item is null)
continue;
if (item.Use)
Parameters.Add([item.Use.ToString(), item.Order.ToString("000"), item.FullName, item.Alias, item.HardWareId, item.Description, item.Conditions?.ConditionModel?.Formula, false.ToString(), (configuration.DataCollection.Logistics.Columns.Length + 1 + item.Order).ToString("000")]);
else
Parameters.Add([item.Use.ToString(), item.Order.ToString("000"), item.FullName, item.Alias, item.HardWareId, item.Description, string.Empty, false.ToString(), (configuration.DataCollection.Logistics.Columns.Length + 1 + item.Order).ToString("000")]);
}
}
Parameters = (from l in Parameters orderby l[0] descending, l[1] select l).ToList();
StringBuilder text = new();
//text.AppendLine("\"AliasName\";\"Condition\";\"EventId\";\"ExceptionId\";\"Formula\";\"HardwareId\";\"OrderId\";\"ParameterName\";\"Remark\";\"ReportName\";\"SourceId\";\"Use\"");
//"Test";"";"";"";"";"";"1";"MICROSCOPE01/MET08MESMICROSCOPE/Test";"";"MICROSCOPE01/MET08MESMICROSCOPE/FileRead";"";"True""
_ = text.AppendLine("\"Use\";\"OrderId\";\"ReportName\";\"ParameterName\";\"AliasName\";\"HardwareId\";\"Remark\";\"Formula\"");
foreach (string?[] parameter in Parameters)
{
for (int i = 0; i < 7; i++)
_ = text.Append('"').Append(parameter[i]).Append("\";");
_ = text.Remove(text.Length - 1, 1);
_ = text.AppendLine();
}
ParametersAsCsv = text.ToString();
foreach (PDSFConfigurationDataCollectionGeneralTriggers item in configuration.DataCollection.GeneralTriggers)
{
foreach (PDSFConfigurationDataCollectionGeneralTriggersVariableModel gv in item.GlobalVariables)
GeneralTriggers.Add([item.Name, gv.Name, gv.ParameterName, gv.Formula]);
}
{
PDSFConfigurationDataCollectionStartTriggersDCP item = configuration.DataCollection.StartTriggers.DCP;
if (item is not null)
StartTriggersDCP.Add([item.Name, item.Rule, item.ResolveGlobalVariableBeforeTrigger.ToString()]);
}
if (configuration.DataCollection.Logistics.Triggers.UpdateTrigger is not null)
{
foreach (PDSFConfigurationDataCollectionLogisticsTriggersUpdateTriggerLogisticRequest item in configuration.DataCollection.Logistics.Triggers.UpdateTrigger.LogisticRequest)
{
LogisticsTriggers.Add([item.Name.ToString(), item.LogisticsColumn.Fixed.ToString(), item.Rule, item.Keys.Scenario, item.Keys.DefaultJobIndex.ToString(), item.Keys.DefaultCarrierIndex.ToString(), item.Keys.DefaultSlotIndex.ToString(), item.DataPool.ToString()]);
if (item.Keys.KeyMapping is not null)
LogisticsTriggersKeysKeyMapping.Add(item.Name, [item.Keys.KeyMapping.KeyName, item.Keys.KeyMapping.ParameterName, item.Keys.KeyMapping.Formula]);
LogisticsTriggersCallDefinitionAttributes.Add(item.Name, []);
foreach (PDSFConfigurationDataCollectionLogisticsTriggersUpdateTriggerLogisticRequestCallDefinitionLogisticCallDefinitionAttribute att in item.CallDefinition.Attributes)
LogisticsTriggersCallDefinitionAttributes[item.Name].Add([att.LogisticsKey, att.Source, att.MappedParameterName, att.Formula]);
}
}
{
PDSFConfigurationDataCollectionStopTriggersDCP item = configuration.DataCollection.StopTriggers.DCP;
if (item is not null)
StopTriggersDCP.Add([item.Name, item.Rule, item.ResolveGlobalVariableBeforeTrigger.ToString(), item.ResetGlobalVariablesAfterTrigger.ToString()]);
}
}
}

453
Helpers/EDA/DCP.cs Normal file
View File

@ -0,0 +1,453 @@
using System.Dynamic;
using System.Text;
using System.Text.Json;
namespace File_Watcher.Helpers.EDA;
public class DCP
{
internal static string GetEdaObjectToHtml(string edaObjectFile, Common common)
{
StringBuilder result = new();
string title = string.Concat(Path.GetFileName(edaObjectFile), " - ", common.Source);
_ = result.AppendLine("<!DOCTYPE html>");
_ = result.AppendLine("<html lang=\"en\">");
_ = result.AppendLine("<head>");
_ = result.AppendLine("<style>table, th, td{border:1px solid black;} td{padding:2px}</style>");
_ = result.Append("<title>").Append(title).AppendLine("</title>");
_ = result.AppendLine("</head>");
_ = result.AppendLine("<body>");
_ = result.AppendLine("<table>");
_ = result.AppendLine("<tr>");
_ = result.Append("<th nowrap>").Append("Unit Name").AppendLine("</th>");
_ = result.Append("<th nowrap>").Append("Container Name").AppendLine("</th>");
_ = result.Append("<th nowrap>").Append("Configuration State").AppendLine("</th>");
_ = result.Append("<th nowrap>").Append("Configuration Productive State").AppendLine("</th>");
_ = result.Append("<th nowrap>").Append("LogisticsEquipmentAlias").AppendLine("</th>");
_ = result.Append("<th nowrap>").Append("Source").AppendLine("</th>");
_ = result.Append("<th nowrap>").Append("StoragePath(s)").AppendLine("</th>");
_ = result.Append("<th nowrap>").Append("StartTimeFormat").AppendLine("</th>");
_ = result.Append("<th nowrap>").Append("Filename").AppendLine("</th>");
_ = result.AppendLine("</tr>");
_ = result.AppendLine("<tr>");
_ = result.Append("<td nowrap>").Append(common.UnitName).AppendLine("</td>");
_ = result.Append("<td nowrap>").Append(common.ContainerName).AppendLine("</td>");
_ = result.Append("<td nowrap>").Append(common.ConfigurationState).AppendLine("</td>");
_ = result.Append("<td nowrap>").Append(common.ConfigurationProductiveState).AppendLine("</td>");
_ = result.Append("<td nowrap>").Append(common.LogisticsEquipmentAlias).AppendLine("</td>");
_ = result.Append("<td nowrap>").Append(common.Source).AppendLine("</td>");
_ = result.Append("<td nowrap>").Append(string.Join("</br >", common.StoragePaths)).AppendLine("</td>");
_ = result.Append("<td nowrap>").Append(common.StartTimeFormat).AppendLine("</td>");
_ = result.Append("<td nowrap>").Append(common.Filename).AppendLine("</td>");
_ = result.AppendLine("</tr>");
_ = result.AppendLine("</table>");
_ = result.AppendLine("<hr>");
_ = result.AppendLine("<table>");
_ = result.AppendLine("<tr>");
_ = result.Append("<th nowrap>").Append("Use").AppendLine("</th>");
_ = result.Append("<th nowrap>").Append("Order").AppendLine("</th>");
_ = result.Append("<th nowrap>").Append("Key").AppendLine("</th>");
_ = result.Append("<th nowrap>").Append("Placeholder").AppendLine("</th>");
_ = result.AppendLine("</tr>");
foreach (string[] item in common.LogisticsAttributes)
{
if (item.Length > 2 && !item[2].StartsWith("Z_"))
{
_ = result.AppendLine("<tr>");
foreach (string value in item)
_ = result.Append("<td nowrap>").Append(value).AppendLine("</td>");
_ = result.AppendLine("</tr>");
}
}
_ = result.AppendLine("</table>");
_ = result.AppendLine("<hr>");
_ = result.AppendLine("<table>");
_ = result.AppendLine("<tr>");
_ = result.Append("<th nowrap>").Append("ID").AppendLine("</th>");
_ = result.Append("<th nowrap>").Append("Prefix").AppendLine("</th>");
_ = result.AppendLine("</tr>");
foreach (string[] item in common.LogisticsColumns)
{
_ = result.AppendLine("<tr>");
foreach (string value in item)
_ = result.Append("<td nowrap>").Append(value).AppendLine("</td>");
_ = result.AppendLine("</tr>");
}
_ = result.AppendLine("</table>");
_ = result.AppendLine("<hr>");
_ = result.AppendLine("<table>");
_ = result.AppendLine("<tr>");
_ = result.Append("<th nowrap>").Append("Use").AppendLine("</th>");
_ = result.Append("<th nowrap>").Append("Order").AppendLine("</th>");
_ = result.Append("<th nowrap>").Append("FullName").AppendLine("</th>");
_ = result.Append("<th nowrap>").Append("Alias").AppendLine("</th>");
_ = result.Append("<th nowrap>").Append("HardWareId").AppendLine("</th>");
_ = result.Append("<th nowrap>").Append("Description").AppendLine("</th>");
_ = result.Append("<th nowrap>").Append("Formula").AppendLine("</th>");
_ = result.Append("<th nowrap>").Append("Virtual").AppendLine("</th>");
_ = result.Append("<th nowrap>").Append("Column#").AppendLine("</th>");
_ = result.AppendLine("</tr>");
foreach (string?[] item in common.Parameters)
{
_ = result.AppendLine("<tr>");
foreach (string? value in item)
_ = result.Append("<td nowrap>").Append(value).AppendLine("</td>");
_ = result.AppendLine("</tr>");
}
_ = result.AppendLine("</table>");
_ = result.AppendLine("<hr>");
_ = result.AppendLine("<table>");
_ = result.AppendLine("<tr>");
_ = result.Append("<th nowrap>").Append("Parent Name").AppendLine("</th>");
_ = result.Append("<th nowrap>").Append("Name").AppendLine("</th>");
_ = result.Append("<th nowrap>").Append("ParameterName").AppendLine("</th>");
_ = result.Append("<th nowrap>").Append("Formula").AppendLine("</th>");
_ = result.AppendLine("</tr>");
foreach (string[] item in common.GeneralTriggers)
{
_ = result.AppendLine("<tr>");
foreach (string value in item)
_ = result.Append("<td nowrap>").Append(value).AppendLine("</td>");
_ = result.AppendLine("</tr>");
}
_ = result.AppendLine("</table>");
_ = result.AppendLine("<hr>");
_ = result.AppendLine("<table>");
_ = result.AppendLine("<tr>");
_ = result.Append("<th nowrap>").Append("Name").AppendLine("</th>");
_ = result.Append("<th nowrap>").Append("Rule").AppendLine("</th>");
_ = result.Append("<th nowrap>").Append("ResolveGlobalVariableBeforeTrigger").AppendLine("</th>");
_ = result.AppendLine("</tr>");
foreach (string[] item in common.StartTriggersDCP)
{
_ = result.AppendLine("<tr>");
foreach (string value in item)
_ = result.Append("<td nowrap>").Append(value).AppendLine("</td>");
_ = result.AppendLine("</tr>");
}
_ = result.AppendLine("</table>");
_ = result.AppendLine("<hr>");
_ = result.AppendLine("<table>");
_ = result.AppendLine("<tr>");
_ = result.Append("<th nowrap>").Append("Name").AppendLine("</th>");
_ = result.Append("<th nowrap>").Append("Fixed").AppendLine("</th>");
_ = result.Append("<th nowrap>").Append("Rule").AppendLine("</th>");
_ = result.Append("<th nowrap>").Append("Scenario").AppendLine("</th>");
_ = result.Append("<th nowrap>").Append("DefaultJobIndex").AppendLine("</th>");
_ = result.Append("<th nowrap>").Append("DefaultCarrierIndex").AppendLine("</th>");
_ = result.Append("<th nowrap>").Append("DefaultSlotIndex").AppendLine("</th>");
_ = result.Append("<th nowrap>").Append("DataPool").AppendLine("</th>");
_ = result.AppendLine("</tr>");
foreach (string?[] item in common.LogisticsTriggers)
{
if (item is null)
continue;
_ = result.AppendLine("<tr>");
foreach (string? value in item)
_ = result.Append("<td nowrap>").Append(value).AppendLine("</td>");
_ = result.AppendLine("<td>");
_ = result.AppendLine("<table>");
_ = result.AppendLine("<tr>");
_ = result.Append("<th nowrap>").Append("KeyName").AppendLine("</th>");
_ = result.Append("<th nowrap>").Append("ParameterName").AppendLine("</th>");
_ = result.Append("<th nowrap>").Append("Formula").AppendLine("</th>");
_ = result.AppendLine("</tr>");
foreach (KeyValuePair<int, string[]> keyValuePair in common.LogisticsTriggersKeysKeyMapping)
{
_ = result.AppendLine("<tr>");
foreach (string value in keyValuePair.Value)
_ = result.Append("<td nowrap>").Append(value).AppendLine("</td>");
_ = result.AppendLine("</tr>");
}
_ = result.AppendLine("</table>");
_ = result.AppendLine("</td>");
_ = result.AppendLine("<td>");
_ = result.AppendLine("<table>");
_ = result.AppendLine("<tr>");
_ = result.Append("<th nowrap>").Append("LogisticsKey").AppendLine("</th>");
_ = result.Append("<th nowrap>").Append("Source").AppendLine("</th>");
_ = result.Append("<th nowrap>").Append("MappedParameterName").AppendLine("</th>");
_ = result.Append("<th nowrap>").Append("Formula").AppendLine("</th>");
_ = result.AppendLine("</tr>");
foreach (KeyValuePair<int, List<string[]>> keyValuePair in common.LogisticsTriggersCallDefinitionAttributes)
{
foreach (string[] values in keyValuePair.Value)
{
if (values.Length > 0 && !values[0].StartsWith("Z_"))
{
_ = result.AppendLine("<tr>");
foreach (string value in values)
_ = result.Append("<td nowrap>").Append(value).AppendLine("</td>");
_ = result.AppendLine("</tr>");
}
}
}
_ = result.AppendLine("</table>");
_ = result.AppendLine("</td>");
_ = result.AppendLine("</tr>");
}
_ = result.AppendLine("</table>");
_ = result.AppendLine("<hr>");
_ = result.AppendLine("<table>");
_ = result.AppendLine("<tr>");
_ = result.Append("<th nowrap>").Append("Name").AppendLine("</th>");
_ = result.Append("<th nowrap>").Append("Rule").AppendLine("</th>");
_ = result.Append("<th nowrap>").Append("ResolveGlobalVariableBeforeTrigger").AppendLine("</th>");
_ = result.Append("<th nowrap>").Append("ResetGlobalVariablesAfterTrigger").AppendLine("</th>");
_ = result.AppendLine("</tr>");
foreach (string[] item in common.StopTriggersDCP)
{
_ = result.AppendLine("<tr>");
foreach (string value in item)
_ = result.Append("<td nowrap>").Append(value).AppendLine("</td>");
_ = result.AppendLine("</tr>");
}
_ = result.AppendLine("</table>");
_ = result.AppendLine("<hr>");
_ = result.AppendLine("</body>");
_ = result.AppendLine("</html>");
return result.ToString();
}
private static string? ReplaceNull(object @object)
{
if (@object is null)
return string.Empty;
else
return @object.ToString();
}
private static void TextResolveEntry(StringBuilder result, dynamic expandoObject, int level, string super, int? i, bool group)
{
level += 1;
foreach (dynamic entry in expandoObject)
{
if (entry.Value is ExpandoObject)
TextResolveEntry(result, entry.Value, level, string.Concat(super, " : ", entry.Key), i, group);
else
{
if (entry.Value is not ICollection<object>)
{
if (i is null)
result.Append(level).Append(") ").Append(super).Append(" : ").Append(entry.Key).Append("--->").AppendLine(ReplaceNull(entry.Value));
else
result.Append(level).Append(") ").Append(super).Append(" : ").Append(entry.Key).Append("[").Append(i.Value).Append("]--->").AppendLine(ReplaceNull(entry.Value));
}
else
{
if (!group)
{
for (i = 0; i.Value < entry.Value.Count; i++)
{
if (entry.Value[i.Value] is ExpandoObject)
TextResolveEntry(result, entry.Value[i.Value], level, string.Concat(super, " : ", entry.Key), i.Value, group);
else
result.Append(level).Append(") ").Append(super).Append(" : ").Append(entry.Key).Append("[").Append(i.Value).Append("]--->").AppendLine(ReplaceNull(entry.Value[i.Value]));
}
}
else
{
for (i = 0; i.Value < entry.Value.Count; i++)
{
if (entry.Value[i.Value] is not ExpandoObject)
result.Append(level).Append(") ").Append(super).Append(" : ").Append(entry.Key).Append("[").Append(i.Value).Append("]--->").AppendLine(ReplaceNull(entry.Value[i.Value]));
}
for (i = 0; i.Value < entry.Value.Count; i++)
{
if (entry.Value[i.Value] is ExpandoObject)
TextResolveEntry(result, entry.Value[i.Value], level, string.Concat(super, " : ", entry.Key), i.Value, group);
}
}
i = null;
}
}
}
level -= 1;
if (level == 0)
{ }
}
internal static string GetText(string edaObjectFile, Common common, string json)
{
StringBuilder result = new();
if (result.Length > 0) //Skipping because System.Text.Json changed the way Expando works
{
string title = string.Concat(Path.GetFileName(edaObjectFile), " - ", common.Source);
dynamic? expandoObject = JsonSerializer.Deserialize<ExpandoObject>(json);
_ = result.AppendLine(title);
_ = result.AppendLine("Loop -> \"Normal\"");
_ = result.AppendLine(edaObjectFile);
_ = result.AppendLine();
TextResolveEntry(result, expandoObject, 0, string.Empty, null, group: false);
_ = result.AppendLine();
_ = result.AppendLine();
_ = result.AppendLine();
_ = result.AppendLine(title);
_ = result.AppendLine("Loop -> \"Grouped\"");
_ = result.AppendLine(edaObjectFile);
_ = result.AppendLine();
TextResolveEntry(result, expandoObject, 0, string.Empty, null, group: true);
}
return result.ToString();
}
internal static string GetEdaObjectToDMSGridFormat(string edaObjectFile, Common common, bool useAlias)
{
StringBuilder result = new();
if (string.IsNullOrEmpty(edaObjectFile))
{ }
string? value;
string[] segments;
int? recordStart = null;
bool hasRecordStart = false;
string name = string.Concat(common.LogisticsEquipmentAlias, "_", common.ContainerName);
_ = result.AppendLine("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>");
_ = result.Append("<Format Name=\"").Append(name).Append("\">").AppendLine();
_ = result.AppendLine(" <General RecordStart=\"\" RecordLength=\"0\" ReadCommand=\"\" DecimalSeparator=\".\">");
_ = result.AppendLine(" <RecordTerminator>&lt;13&gt;&lt;10&gt;</RecordTerminator>");
_ = result.AppendLine(" <ColumnSeparator>&lt;9&gt;</ColumnSeparator>");
_ = result.AppendLine(" </General>");
_ = result.AppendLine(" <Fields>");
for (int i = 0; i < common.Parameters.Count; i++)
{
if (common.Parameters[i][3] == "RECORD_START")
{
hasRecordStart = true;
break;
}
}
for (int i = 0; i < common.Parameters.Count; i++)
{
if (recordStart is null && common.Parameters[i][3] == "RECORD_START")
recordStart = i;
if ((!hasRecordStart || (hasRecordStart && recordStart.HasValue)) && common.Parameters[i][0] == "True")
{
if (useAlias && !string.IsNullOrEmpty(common.Parameters[i][3]))
{
value = common.Parameters[i][3];
value ??= string.Empty;
name = value.Replace("'", string.Empty);
}
else
{
value = common.Parameters[i][2];
value ??= string.Empty;
segments = value.Split('/');
name = segments[^1];
}
_ = result.Append(" <Field Name=\"").Append(name).Append("\" ColumnNumber=\"").Append(i + common.LogisticsColumns.Count + 2).Append("\" StartPosition=\"\" Length=\"\" DataType=\"Text\" NullReplacement=\"\" />").AppendLine();
}
}
_ = result.AppendLine(" </Fields>");
_ = result.AppendLine(" <Conditions>");
_ = result.AppendLine(" <Column />");
_ = result.AppendLine(" <Row>");
_ = result.AppendLine(" <Condition>");
_ = result.AppendLine(" <SkipHeaderCount>7</SkipHeaderCount>");
_ = result.AppendLine(" <SkipRowFilter>0</SkipRowFilter>");
_ = result.AppendLine(" <SkipRowValue>");
_ = result.AppendLine(" </SkipRowValue>");
_ = result.AppendLine(" </Condition>");
_ = result.AppendLine(" </Row>");
_ = result.AppendLine(" </Conditions>");
_ = result.AppendLine("</Format>");
return result.ToString();
}
internal static string GetEdaObjectToAPCParameter(string edaObjectFile, Common common)
{
StringBuilder result = new();
if (string.IsNullOrEmpty(edaObjectFile))
{ }
string? value;
string parameter;
string[] segments;
string parameterSub35;
_ = result.AppendLine("ExportFileVersion=1.0.6");
_ = result.AppendLine("ExportFromTabsheet=Para");
_ = result.AppendLine("FieldName\tLongName\tMatchMode\tEquipment\tName\tPdsfNameConvCol\tPdsfNameDataType\tType\tChamberInfo\tUnifiedPara\tDateFormat\tUsername\tId\tWorkcenterId\tSite\tArea\tWorkcenter\tValidFrom\tValidTo");
_ = result.AppendLine("TIME_PREV_DIFF\tTIME_PREV_DIFF\tEXACT\t*\tTIME_PREV_DIFF\t\tNUMERIC\tRUN\t\tTIME_PREV_DIFF\t\tPHARES\t95069\t4571\tMesa\t\t\t4/15/2020 6:10 PM");
_ = result.AppendLine("TIME\tTIME\tEXACT\t*\tTIME\t\tNUMERIC\tRUN\t\tTIME\t\tPHARES\t95070\t4571\tMesa\t\t\t4/15/2020 6:10 PM");
for (int i = 0; i < common.Parameters.Count; i++)
{
if (common.Parameters[i][0] == "True")
{
value = common.Parameters[i][2];
value ??= string.Empty;
segments = value.Split('/');
parameter = segments[^1];
if (parameter.Length < 35)
parameterSub35 = parameter;
else
parameterSub35 = parameter[..35];
_ = result.Append(parameterSub35).Append("\tDIVERSE\tEXACT\t*\t").Append(parameterSub35).AppendLine("\t\tNUMERIC\tRUN\t\t\t\tPHARES\t9000000012\t4571\tMesa\t\t\t4/15/2020 6:10 PM");
}
}
_ = result.AppendLine();
_ = result.AppendLine();
_ = result.AppendLine();
for (int i = 0; i < common.Parameters.Count; i++)
{
if (common.Parameters[i][0] == "True")
{
value = common.Parameters[i][2];
value ??= string.Empty;
segments = value.Split('/');
parameter = segments[^1];
_ = result.Append(parameter).Append("\tDIVERSE\tEXACT\t*\t").Append(parameter).AppendLine("\t\tNUMERIC\tRUN\t\t\t\tPHARES\t9000000012\t4571\tMesa\t\t\t4/15/2020 6:10 PM");
}
}
return result.ToString();
}
internal static string GetEdaObjectToAPCRunKeyNumber(string edaObjectFile, Common common)
{
StringBuilder result = new();
if (string.IsNullOrEmpty(edaObjectFile))
{ }
string? value;
string parameter;
string[] segments;
string parameterSub21;
string parameterSub35;
_ = result.AppendLine("ExportFileVersion=1.0.6");
_ = result.AppendLine("ExportFromTabsheet=Run-Keynumbers");
_ = result.AppendLine("FeatureName\tShortName\tChamber\tComments\tVarMode\tPara\tExclude0\tTrigOn1\tTrigOn2\tTrigOn3\tTrigOff1\tTrigOff2\tTrigOff3\tTrigDelay\tTrigNorm\tTrigNvl\tTrigTrg\tAddCondOn\tActive\tFilter1\tFilter2\tFilter3\tFilter4\tUnit\tId\tWorkcenterId\tSite\tArea\tWorkcenter\tUsername\tValidFrom\tValidTo");
for (int i = 0; i < common.Parameters.Count; i++)
{
if (common.Parameters[i][0] == "True")
{
value = common.Parameters[i][2];
value ??= string.Empty;
segments = value.Split('/');
parameter = segments[^1];
if (parameter.Length < 35)
parameterSub35 = parameter;
else
parameterSub35 = parameter[..35];
if (parameter.Length < 21)
parameterSub21 = parameter;
else
parameterSub21 = parameter[..21];
_ = result.Append(parameterSub21).Append("_MIN\t").Append(parameterSub21).Append("_MIN\t\t\tMIN\t").Append(parameterSub35).AppendLine("\t0\tTIME\t=\tRUNSTART\tTIME\t=\tRUNEND\t\t\t\t\t\t1\t\t\t\t\t\t-1\t-1\t\t\t\tECPHARES\t5/2/2017 2:44 PM");
}
}
_ = result.AppendLine();
_ = result.AppendLine();
_ = result.AppendLine();
for (int i = 0; i < common.Parameters.Count; i++)
{
if (common.Parameters[i][0] == "True")
{
value = common.Parameters[i][2];
value ??= string.Empty;
segments = value.Split('/');
parameter = segments[^1];
_ = result.Append(parameter).Append("_MIN\t").Append(parameter).Append("_MIN\t\t\tMIN\t").Append(parameter).AppendLine("\t0\tTIME\t=\tRUNSTART\tTIME\t=\tRUNEND\t\t\t\t\t\t1\t\t\t\t\t\t-1\t-1\t\t\t\tECPHARES\t5/2/2017 2:44 PM");
}
}
return result.ToString();
}
}

2502
Helpers/EDA/EDA - A.cs Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,6 @@
namespace File_Watcher.Helpers.EDA;
public enum ModuleInstanceTypeName
{
Pdsf
}