//This program builds Markdown and docs for all kinds of data using System.Collections.Generic; using System.ComponentModel; using System.Globalization; using System.Reflection; using System.Reflection.PortableExecutable; using System.Text; using MewtocolNet; using MewtocolNet.DocAttributes; Thread.CurrentThread.CurrentUICulture = CultureInfo.InvariantCulture; Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; Console.WriteLine("Building docs for PLC types..."); var entryLoc = Assembly.GetEntryAssembly(); ArgumentNullException.ThrowIfNull(entryLoc); string filePath = Path.Combine(entryLoc.Location, @"..\..\..\..\Docs\plctypes.md"); Console.WriteLine($"{filePath}"); StringBuilder markdownBuilder = new StringBuilder(); var plcs = Enum.GetValues(typeof(PlcType)).Cast().OrderBy(x => x.ToString()); void WritePlcTypeTable(IEnumerable vals) { var groups = vals.GroupBy(x => x.ToNameDecompose()[0].Group) .SelectMany(grouping => grouping.OrderBy(b => (int)b)) .GroupBy(x => x.ToNameDecompose()[0].Group); markdownBuilder.AppendLine(""); bool isFirstIt = true; foreach (var group in groups) { group.OrderBy(x => (int)x); bool isFirstGroup = true; foreach (var enu in group) { ParsedPlcName[] decomposed = null!; string cpuOrMachCode = null!; decomposed = enu.ToNameDecompose(); cpuOrMachCode = ((int)enu).ToString("X2"); ArgumentNullException.ThrowIfNull(decomposed); //first iteration if (isFirstIt) { markdownBuilder.AppendLine(""); markdownBuilder.AppendLine($""); markdownBuilder.AppendLine($""); markdownBuilder.AppendLine($""); markdownBuilder.AppendLine($""); markdownBuilder.AppendLine($""); markdownBuilder.AppendLine($""); markdownBuilder.AppendLine($""); markdownBuilder.AppendLine(""); isFirstIt = false; } if(isFirstGroup) { markdownBuilder.AppendLine(""); markdownBuilder.AppendLine($""); markdownBuilder.AppendLine(""); isFirstGroup = false; } foreach (var decomp in decomposed) { markdownBuilder.AppendLine(""); markdownBuilder.AppendLine($""); markdownBuilder.AppendLine($""); markdownBuilder.AppendLine($""); if(enu.IsDiscontinued()) { markdownBuilder.AppendLine($""); markdownBuilder.AppendLine($""); } else { markdownBuilder.AppendLine($""); } markdownBuilder.AppendLine($""); markdownBuilder.AppendLine($""); markdownBuilder.AppendLine(""); } } isFirstIt = false; } markdownBuilder.AppendLine("
TypeCapacityCodeEnumDCNTEXRTTested
📟 {group.Key}
{(decomp.SubTypes.Length == 0 ? "-" : string.Join(", ", decomp.SubTypes))} {decomp.Size}k 0x{cpuOrMachCode}{enu.ToString()}⚠️{enu.ToString()} {(enu.IsEXRTPLC() ? "✅" : "❌")} {(enu.WasTestedLive() ? "✅" : "❌")}
"); markdownBuilder.AppendLine("\n"); } markdownBuilder.AppendLine($"# PLC Type Table"); markdownBuilder.AppendLine($"All supported PLC types for auto recognition are listed in this table. " + $"Other ones might also be supported but are shown as unknown in the library"); markdownBuilder.AppendLine($"> Discontinued PLCs
"); markdownBuilder.AppendLine($"> These are PLCs that are no longer sold by Panasonic. Marked with ⚠️\n"); markdownBuilder.AppendLine($"> EXRT PLCs
"); markdownBuilder.AppendLine($"> These are PLCs that utilize the basic `%EE#RT` and `%EE#EX00RT` command. All newer models do this. Old models only use the `%EE#RT` command.\n"); WritePlcTypeTable(plcs); File.WriteAllText(filePath, markdownBuilder.ToString());