mirror of
https://github.com/OpenLogics/MewtocolNet.git
synced 2025-12-06 03:01:24 +00:00
Added missing F functions set
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Runtime.Serialization.Formatters.Binary;
|
using System.Runtime.Serialization.Formatters.Binary;
|
||||||
|
using System.Text;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
@@ -290,7 +291,7 @@ internal class Program {
|
|||||||
|
|
||||||
if(descrText != null) {
|
if(descrText != null) {
|
||||||
|
|
||||||
descrText = descrText.SanitizeLinebreakFormatting();
|
descrText = descrText.SanitizeLinebreakFormatting().Replace("\"", "\\\"");
|
||||||
|
|
||||||
functionIns.Description = descrText;
|
functionIns.Description = descrText;
|
||||||
|
|
||||||
@@ -318,10 +319,89 @@ internal class Program {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var funcsJson = JsonSerializer.Serialize(functions, new JsonSerializerOptions { WriteIndented = true });
|
BuildFunctionNamesDictFile(functions);
|
||||||
|
|
||||||
File.WriteAllText("./function_names.json", funcsJson);
|
}
|
||||||
|
|
||||||
|
static void BuildFunctionNamesDictFile (Dictionary<string, FPFunction> dict) {
|
||||||
|
|
||||||
|
var sb = new StringBuilder();
|
||||||
|
|
||||||
|
sb.AppendLine("using System.Collections.Generic;\n");
|
||||||
|
sb.AppendLine("namespace MewtocolNet.AutoGeneratedData {\n");
|
||||||
|
|
||||||
|
sb.AppendLine("\tpublic class FPFunction {\n");
|
||||||
|
|
||||||
|
sb.AppendLine("\t\tpublic string RedundantName { get; private set; }\n");
|
||||||
|
sb.AppendLine("\t\tpublic string Description { get; private set; }\n");
|
||||||
|
sb.AppendLine("\t\tpublic Dictionary<string, string[]> ParametersIn { get; private set; }\n");
|
||||||
|
sb.AppendLine("\t\tpublic Dictionary<string, string[]> ParametersOut { get; private set; }\n");
|
||||||
|
|
||||||
|
sb.AppendLine("\t\tpublic static readonly Dictionary<string, FPFunction> functions = new Dictionary<string, FPFunction> {\n");
|
||||||
|
|
||||||
|
foreach (var item in dict) {
|
||||||
|
|
||||||
|
sb.AppendLine($"\t\t\t{{ \"{item.Key}\", new FPFunction {{");
|
||||||
|
|
||||||
|
if(item.Value.RedundantName != null)
|
||||||
|
sb.AppendLine($"\t\t\t\tRedundantName = \"{item.Value.RedundantName}\",");
|
||||||
|
|
||||||
|
if(item.Value.Description != null)
|
||||||
|
sb.AppendLine($"\t\t\t\tDescription = \"{item.Value.Description}\",");
|
||||||
|
|
||||||
|
if (item.Value.ParametersIn != null) {
|
||||||
|
|
||||||
|
sb.AppendLine("\t\t\t\tParametersIn = new Dictionary<string, string[]> {");
|
||||||
|
|
||||||
|
foreach (var paramIn in item.Value.ParametersIn) {
|
||||||
|
|
||||||
|
sb.AppendLine($"\t\t\t\t\t{{ \"{paramIn.Key}\", new string[] {{");
|
||||||
|
|
||||||
|
foreach (var paramType in paramIn.Value) {
|
||||||
|
|
||||||
|
sb.AppendLine($"\t\t\t\t\t\t\"{paramType}\",");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
sb.AppendLine("\t\t\t\t\t}},");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
sb.AppendLine("\t\t\t\t},");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item.Value.ParametersOut != null) {
|
||||||
|
|
||||||
|
sb.AppendLine("\t\t\t\tParametersOut = new Dictionary<string, string[]> {");
|
||||||
|
|
||||||
|
foreach (var paramOut in item.Value.ParametersOut) {
|
||||||
|
|
||||||
|
sb.AppendLine($"\t\t\t\t\t{{ \"{paramOut.Key}\", new string[] {{");
|
||||||
|
|
||||||
|
foreach (var paramType in paramOut.Value) {
|
||||||
|
|
||||||
|
sb.AppendLine($"\t\t\t\t\t\t\"{paramType}\",");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
sb.AppendLine("\t\t\t\t\t}},");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
sb.AppendLine("\t\t\t\t},");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
sb.AppendLine($"\t\t\t}}}},");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
sb.AppendLine("\t\t};\n");
|
||||||
|
sb.AppendLine("\t}\n");
|
||||||
|
sb.AppendLine("}");
|
||||||
|
|
||||||
|
File.WriteAllText("../../../../MewtocolNet/AutoGeneratedData/FPFunction.cs", sb.ToString());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
5326
MewtocolNet/AutoGeneratedData/FPFunction.cs
Normal file
5326
MewtocolNet/AutoGeneratedData/FPFunction.cs
Normal file
File diff suppressed because it is too large
Load Diff
@@ -44,4 +44,8 @@
|
|||||||
<PackageReference Include="System.IO.Ports" Version="7.0.0" />
|
<PackageReference Include="System.IO.Ports" Version="7.0.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Folder Include="AutoGeneratedData\" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using System.IO;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
|
using MewtocolNet.AutoGeneratedData;
|
||||||
|
|
||||||
namespace MewtocolNet.ProgramParsing {
|
namespace MewtocolNet.ProgramParsing {
|
||||||
|
|
||||||
@@ -46,17 +47,6 @@ namespace MewtocolNet.ProgramParsing {
|
|||||||
{ "R901E", "sys_bPulse1min" },
|
{ "R901E", "sys_bPulse1min" },
|
||||||
};
|
};
|
||||||
|
|
||||||
static readonly Dictionary<string, string> stepFunctions = new Dictionary<string, string> {
|
|
||||||
{ "F0", "MV" },
|
|
||||||
{ "F1", "DMV" },
|
|
||||||
{ "F2", "MVN" },
|
|
||||||
{ "F3", "DMVN" },
|
|
||||||
{ "F5", "BTM" },
|
|
||||||
{ "F8", "DMV2" },
|
|
||||||
{ "F11", "COPY" },
|
|
||||||
{ "F61", "DCMP" }
|
|
||||||
};
|
|
||||||
|
|
||||||
// ST R50_1 21 AC => WR system area start was set to 50
|
// ST R50_1 21 AC => WR system area start was set to 50
|
||||||
// ST R57_1 91 AC => WR system area start was set to 57
|
// ST R57_1 91 AC => WR system area start was set to 57
|
||||||
// ST R901_3 F7 FF 53 A9
|
// ST R901_3 F7 FF 53 A9
|
||||||
@@ -196,7 +186,33 @@ namespace MewtocolNet.ProgramParsing {
|
|||||||
|
|
||||||
private string GetFunctionName (string funcName) {
|
private string GetFunctionName (string funcName) {
|
||||||
|
|
||||||
return stepFunctions.ContainsKey(funcName) ? $"{funcName} ({stepFunctions[funcName]})" : funcName;
|
var found = FPFunction.functions.FirstOrDefault(x => x.Key.StartsWith(funcName));
|
||||||
|
|
||||||
|
if (!found.Equals(default(KeyValuePair<string, FPFunction>))) {
|
||||||
|
|
||||||
|
var sb = new StringBuilder();
|
||||||
|
|
||||||
|
var splt = found.Key.Split('_');
|
||||||
|
|
||||||
|
sb.Append($"{splt[0]} (*{splt[1]}*)");
|
||||||
|
|
||||||
|
if(found.Value.ParametersIn.Count > 0) {
|
||||||
|
|
||||||
|
sb.Append($" IN: {found.Value.ParametersIn.Count}");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (found.Value.ParametersOut.Count > 0) {
|
||||||
|
|
||||||
|
sb.Append($" OUT: {found.Value.ParametersOut.Count}");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return sb.ToString();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return funcName;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,15 +3,18 @@
|
|||||||
public enum PlcVarType {
|
public enum PlcVarType {
|
||||||
|
|
||||||
BOOL,
|
BOOL,
|
||||||
|
WORD,
|
||||||
INT,
|
INT,
|
||||||
UINT,
|
UINT,
|
||||||
|
DWORD,
|
||||||
DINT,
|
DINT,
|
||||||
UDINT,
|
UDINT,
|
||||||
REAL,
|
REAL,
|
||||||
TIME,
|
TIME,
|
||||||
|
DATE_AND_TIME,
|
||||||
|
DATE,
|
||||||
|
TIME_OF_DAY,
|
||||||
STRING,
|
STRING,
|
||||||
WORD,
|
|
||||||
DWORD
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user