Skip to content

Commit

Permalink
Allow a specific prefixDoc for Modules within Modules
Browse files Browse the repository at this point in the history
  • Loading branch information
Waldemar Porscha committed May 26, 2024
1 parent 016304d commit dfa4510
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 4 deletions.
34 changes: 34 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,40 @@
"console": "internalConsole",
"stopAtEntry": false
},
{
"name": "Debug TestXML",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceFolder}/bin/Debug/net6.0/OpenKNXproducer.dll",
"args": [
"create",
"--Debug",
"--HeaderFileName",
"../OFM-TestXML/include/knxprod.h",
"../OFM-TestXML/src/TestXML"
],
"cwd": "${workspaceFolder}",
"console": "internalConsole",
"stopAtEntry": false
},
{
"name": "Debug InternetServices",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceFolder}/bin/Debug/net6.0/OpenKNXproducer.dll",
"args": [
"create",
"--Debug",
"--HeaderFileName",
"../OAM-InternetServices/include/knxprod.h",
"../OAM-InternetServices/src/InternetServicesESP32-Test"
],
"cwd": "${workspaceFolder}",
"console": "internalConsole",
"stopAtEntry": false
},
{
"name": "Debug SOM-UP (temp)",
"type": "coreclr",
Expand Down
6 changes: 3 additions & 3 deletions AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@

[assembly: System.Reflection.AssemblyCompanyAttribute("OpenKNX")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("3.3.2.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("3.3.2")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("3.3.3.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("3.3.3")]
[assembly: System.Reflection.AssemblyProductAttribute("OpenKNXproducer")]
[assembly: System.Reflection.AssemblyTitleAttribute("OpenKNXproducer")]
[assembly: System.Reflection.AssemblyVersionAttribute("3.3.2.0")]
[assembly: System.Reflection.AssemblyVersionAttribute("3.3.3.0")]
2 changes: 2 additions & 0 deletions DefineContent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public class DefineContent
private string mConfigTransferName = "";

public string prefix = "LOG";
public string prefixDoc = "LOG";
public int KoOffset = 1;
public int KoSingleOffset;
public int KoBlockSize = 0;
Expand Down Expand Up @@ -57,6 +58,7 @@ public static DefineContent Factory(XmlNode iDefineNode)
else
{
lResult.prefix = lPrefix;
lResult.prefixDoc = iDefineNode.NodeAttr("prefixDoc", lPrefix);
lResult.header = iDefineNode.NodeAttr("header");

if (!int.TryParse(iDefineNode.NodeAttr("NumChannels"), out lResult.NumChannels)) lResult.NumChannels = 0;
Expand Down
13 changes: 13 additions & 0 deletions MemoryManager.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
class MemoryManager
{
const int cMemSize = 32768;
byte[] mMemory = new byte[cMemSize];

public MemoryManager() { }

public bool WriteMemory(string iParameterName, int iOffset, int iBitOffset, int iSizeInBit)
{
bool lResult = false;
return lResult;
}
}
46 changes: 45 additions & 1 deletion ProcessInclude.cs
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ static void ProcessHelpContext(DefineContent iDefine, XmlNode iTargetNode, Proce
{
XmlNode lParameter = lParameterLookup[lId];
string lText = lParameter.NodeAttr("Text");
lText = ParseDocumentation.GetChapterId(lText, iDefine.prefix);
lText = ParseDocumentation.GetChapterId(lText, iDefine.prefixDoc);
// Console.WriteLine(lText);
lAttribute.Value = lText;
}
Expand Down Expand Up @@ -1526,12 +1526,56 @@ public bool LoadAdvanced(string iFileName)
{
using StringReader sr = new(lFileData);
mDocument.Load(sr);
// ResolveNaming();
ResolveIncludes(lCurrentDir);
}
}
return lIsNew;
}

private readonly Dictionary<string, string> mParameterNames = new();
private readonly Dictionary<string, string> mComObjectNames = new();

const char cNameMarker = '#';

public void ResolveNaming()
{
XmlNodeList lParameters = mDocument.SelectNodes("//ApplicationProgram/Static/Parameters//Parameter");
foreach (XmlNode lParameter in lParameters)
{
string lName = cNameMarker + lParameter.NodeAttr("Name") + cNameMarker;
string lId = lParameter.NodeAttr("Id");
mParameterNames.Add(lName, lId);
}
XmlNodeList lIdAttributes = mDocument.SelectNodes($"*//@*[contains(.,'{cNameMarker}')]");
foreach (XmlNode lIdAttribute in lIdAttributes)
{
string lValue = lIdAttribute.Value;
string lRefIdSuffix = "";
if (lValue.Length < 5 || !lValue.StartsWith(cNameMarker) || (!lValue.EndsWith(cNameMarker) && lValue[^3] != cNameMarker))
continue;
if (!lValue.EndsWith(cNameMarker))
{
lRefIdSuffix = lValue[^2..];
lValue = lValue[..^2];
}
if (mParameterNames.ContainsKey(lValue))
{
lValue = mParameterNames[lValue];
if (lRefIdSuffix != "")
{
lValue = lValue + "_R" + lValue[lValue.IndexOf("-%T")..] + lRefIdSuffix;
}
lIdAttribute.Value = lValue;
}
else
{
Program.Message(true, "Attribute {0} with Value {1} could not be replaced, use original key for this object", lIdAttribute.Name, lIdAttribute.Value);
}
}

}

public static string ReplaceXmlns(string iXmlString)
{
if (iXmlString.Contains("oldxmlns"))
Expand Down

0 comments on commit dfa4510

Please sign in to comment.