refactor(historian): single-parse ExtractTagHistorize + review-nit tests/docs
Stop parsing TagConfig twice per tag on the deploy hot path: Phase7Composer's equipment-tag Select lambda is now block-bodied (captures isHistorized/historianTagname once), and DeploymentArtifact.BuildEquipmentTagPlans captures locals before result.Add. Add wrong-type-historianTagname InlineData to ExtractTagHistorizeTests. Extend the parity round-trip fixture with a 4th tag (isHistorized:false + JSON-null tagname) exercising the artifact-side private guard path. Align DeploymentArtifact's ExtractTagHistorize doc-comment with the composer-side phrasing (ExtractTagFullName / ExtractTagAlarm cross-reference).
This commit is contained in:
@@ -335,18 +335,22 @@ public static class Phase7Composer
|
||||
.OrderBy(t => t.EquipmentId, StringComparer.Ordinal)
|
||||
.ThenBy(t => t.FolderPath ?? string.Empty, StringComparer.Ordinal) // coalesce so the sort matches the artifact-decode side exactly
|
||||
.ThenBy(t => t.Name, StringComparer.Ordinal)
|
||||
.Select(t => new EquipmentTagPlan(
|
||||
TagId: t.TagId,
|
||||
EquipmentId: t.EquipmentId!,
|
||||
DriverInstanceId: t.DriverInstanceId,
|
||||
FolderPath: t.FolderPath ?? string.Empty,
|
||||
Name: t.Name,
|
||||
DataType: t.DataType,
|
||||
FullName: ExtractTagFullName(t.TagConfig),
|
||||
Writable: t.AccessLevel == TagAccessLevel.ReadWrite,
|
||||
Alarm: ExtractTagAlarm(t.TagConfig),
|
||||
IsHistorized: ExtractTagHistorize(t.TagConfig).IsHistorized,
|
||||
HistorianTagname: ExtractTagHistorize(t.TagConfig).HistorianTagname))
|
||||
.Select(t =>
|
||||
{
|
||||
var (isHistorized, historianTagname) = ExtractTagHistorize(t.TagConfig);
|
||||
return new EquipmentTagPlan(
|
||||
TagId: t.TagId,
|
||||
EquipmentId: t.EquipmentId!,
|
||||
DriverInstanceId: t.DriverInstanceId,
|
||||
FolderPath: t.FolderPath ?? string.Empty,
|
||||
Name: t.Name,
|
||||
DataType: t.DataType,
|
||||
FullName: ExtractTagFullName(t.TagConfig),
|
||||
Writable: t.AccessLevel == TagAccessLevel.ReadWrite,
|
||||
Alarm: ExtractTagAlarm(t.TagConfig),
|
||||
IsHistorized: isHistorized,
|
||||
HistorianTagname: historianTagname);
|
||||
})
|
||||
.ToList();
|
||||
|
||||
// Per-equipment tag base = the shared substring-before-first-dot across each equipment's
|
||||
|
||||
@@ -437,6 +437,7 @@ public static class DeploymentArtifact
|
||||
// ordinary equipment tags now (GalaxyMxGateway is a standard Equipment-kind driver).
|
||||
if (!equipmentNamespaces.Contains(nsId)) continue;
|
||||
|
||||
var (isHistorized, historianTagname) = ExtractTagHistorize(tagConfig);
|
||||
result.Add(new EquipmentTagPlan(
|
||||
TagId: tagId!,
|
||||
EquipmentId: equipmentId!,
|
||||
@@ -447,8 +448,8 @@ public static class DeploymentArtifact
|
||||
FullName: ExtractTagFullName(tagConfig),
|
||||
Writable: writable,
|
||||
Alarm: ExtractTagAlarm(tagConfig),
|
||||
IsHistorized: ExtractTagHistorize(tagConfig).IsHistorized,
|
||||
HistorianTagname: ExtractTagHistorize(tagConfig).HistorianTagname));
|
||||
IsHistorized: isHistorized,
|
||||
HistorianTagname: historianTagname));
|
||||
}
|
||||
|
||||
result.Sort((a, b) =>
|
||||
@@ -678,7 +679,8 @@ public static class DeploymentArtifact
|
||||
/// the <c>isHistorized</c> bool (absent / not a bool / non-object root / blank / malformed ⇒
|
||||
/// <c>false</c>) and the optional <c>historianTagname</c> string override (absent / not a string /
|
||||
/// whitespace-or-empty ⇒ <c>null</c>, meaning the historian tagname defaults to the tag's FullName,
|
||||
/// resolved later). The raw string value is used — not trimmed. Never throws. The live-edit side
|
||||
/// resolved later). The raw string value is used — not trimmed — matching <c>ExtractTagFullName</c> /
|
||||
/// <c>ExtractTagAlarm</c>. Never throws. The live-edit side
|
||||
/// (<c>Phase7Composer.ExtractTagHistorize</c>) MUST parse identically (byte-parity).</summary>
|
||||
private static (bool IsHistorized, string? HistorianTagname) ExtractTagHistorize(string? tagConfig)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user