Skip to content

Commit

Permalink
Fixed a number of errors in generated outputs.
Browse files Browse the repository at this point in the history
  • Loading branch information
randy-armstrong committed Jan 27, 2023
1 parent a2d7913 commit c7a9be1
Show file tree
Hide file tree
Showing 15 changed files with 706 additions and 491 deletions.
1 change: 1 addition & 0 deletions ModelCompiler Solution Debug.sln
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Files", "Solution
BuildEngineeringUnits.bat = BuildEngineeringUnits.bat
BuildStandardTypes.bat = BuildStandardTypes.bat
CompileNodeSets.bat = CompileNodeSets.bat
PublishNodeSet.bat = PublishNodeSet.bat
TestNodeSets.bat = TestNodeSets.bat
UpdateLicense.bat = UpdateLicense.bat
EndProjectSection
Expand Down
2 changes: 2 additions & 0 deletions ModelCompiler Solution.sln
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Files", "Solution
ProjectSection(SolutionItems) = preProject
BuildEngineeringUnits.bat = BuildEngineeringUnits.bat
BuildStandardTypes.bat = BuildStandardTypes.bat
CompileNodeSets.bat = CompileNodeSets.bat
PublishModel.bat = PublishModel.bat
PublishNodeSet.bat = PublishNodeSet.bat
UpdateLicense.bat = UpdateLicense.bat
EndProjectSection
EndProject
Expand Down
36 changes: 32 additions & 4 deletions Opc.Ua.ModelCompiler/ModelCompilerApplication.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public static void Run(string[] args)
app.Command("compile", (e) => Compile(e));
app.Command("units", (e) => Units(e));
app.Command("update-headers", (e) => UpdateHeaders(e));
app.Command("compile-nodesets", (e) => Test(e));
app.Command("compile-nodesets", (e) => CompileNodeSets(e));

app.OnExecute(() =>
{
Expand Down Expand Up @@ -306,14 +306,25 @@ private static void GenerateCode(string inputPath, string outputPath, NodeSetInf
var relativePath = new FileInfo(nodeset.FileName).DirectoryName.Substring(new DirectoryInfo(inputPath).FullName.Length);

var output = Path.Join(outputPath, relativePath);
Directory.CreateDirectory(output);

if (!Directory.Exists(output))
{
Directory.CreateDirectory(output);
}

var documentation = new FileInfo(nodeset.FileName.Replace(".xml", ".documentation.csv"));

if (documentation.Exists)
{
documentation.CopyTo(Path.Join(output, $"{nodeset.Prefix}.NodeSet2.documentation.csv"));
}

generator.GenerateMultipleFiles(output, false, exclusions, false);

WriteLine($"NodeSet ({nodeset.ModelUri}) code generated ({output}).", ConsoleColor.DarkGreen);
}

private static void Test(CommandLineApplication app)
private static void CompileNodeSets(CommandLineApplication app)
{
app.Description = "Searches a directory tree for nodesets and generates code for the specified model URIs.";
app.HelpOption("-?|-h|--help");
Expand All @@ -328,6 +339,11 @@ private static void Test(CommandLineApplication app)
"The path to the directory to use to write the generated files.",
CommandOptionType.SingleValue);

app.Option(
$"-{OptionsNames.OutputPrefix}",
"The prefix on generated files.",
CommandOptionType.SingleValue);

app.Option(
$"-{OptionsNames.ModelUris}",
"The URI of the model to generate.",
Expand Down Expand Up @@ -375,7 +391,6 @@ private static void Test(CommandLineApplication app)
continue;
}
found.Add(modelUri);
Dictionary<string, NodeSetInfo> dependencies = new();
Expand All @@ -387,6 +402,11 @@ private static void Test(CommandLineApplication app)
WriteLine($"NodeSet ({nodeset.ModelUri}) dependencies found.", ConsoleColor.DarkYellow);
if (!String.IsNullOrEmpty(options.OutputPrefix))
{
nodeset.Prefix = options.OutputPrefix;
}
try
{
GenerateCode(input.FullName, options.OutputPath, nodeset, dependencies);
Expand Down Expand Up @@ -561,6 +581,7 @@ private static class OptionsNames
public const string ModelPublicationDate = "pd";
public const string ReleaseCandidate = "rc";
public const string ModelUris = "uri";
public const string OutputPrefix = "prefix";
}

private class OptionValues
Expand All @@ -585,6 +606,7 @@ private class OptionValues
public string Annex1Path;
public string Annex2Path;
public IList<string> ModelUris;
public string OutputPrefix;
}

private static void AddCompileOptions(CommandLineApplication app)
Expand Down Expand Up @@ -653,6 +675,11 @@ private static void AddCompileOptions(CommandLineApplication app)
$"-{OptionsNames.ReleaseCandidate}",
"Indicates that a release candidate nodeset is being generated.",
CommandOptionType.NoValue);

app.Option(
$"-{OptionsNames.OutputPrefix}",
"The prefix to use on the generated files names.",
CommandOptionType.SingleValue);
}

private static OptionValues GetCompileOptions(CommandLineApplication app)
Expand All @@ -671,6 +698,7 @@ private static OptionValues GetCompileOptions(CommandLineApplication app)
ModelPublicationDate = app.GetOption(OptionsNames.ModelPublicationDate),
ReleaseCandidate = app.IsOptionSet(OptionsNames.ReleaseCandidate),
ModelUris = app.GetOptionList(OptionsNames.ModelUris),
OutputPrefix = app.GetOption(OptionsNames.OutputPrefix),
};

var path = app.GetOption(OptionsNames.GenerateIdentifierFile);
Expand Down
Loading

0 comments on commit c7a9be1

Please sign in to comment.