ba9015fac8
- HeidenhainControlFamily + HeidenhainControlFamilies.Classify (Contracts): one authority, ported from pyLSV2 (MIT) dat_cls.py VersionInfo.control (strip spaces, case-insensitive prefix, ITNC530 first). Families: ITnc530, Tnc (640/620/320/128), Tnc7, Lathe (CNC PILOT 640 / MANUALplus 620), MillPlus, LegacyTnc (426/430, not a pyLSV2 class), Unknown. - New additive read-only leaf Controller/Family (String, Identity feature, derived from the same R_VR reply: no extra request). Lsv2Versions.Family is computed, so record equality and the #831 identity-change rediscovery signal are unchanged. Probe message + /hosts diagnostics (<host>.family). - DATA gate now goes through SupportsDataPath(family) (pyLSV2 client.py read_data_path is iTNC-only): non-iTNC and Unknown => Capabilities/DataLogin Unsupported, DATA login never sent. Replaces the "model contains itnc" substring check (same result on the real iTNC530 controls). - No per-family selector pre-gates: pyLSV2's TNC 640 observations (27/28/51/30-34 unknown telegram, 25/26 need DNC) are already handled by the reply-driven refusal/suppression path; tests pin it. - Lsv2ReadOnlyPolicy, HeidenhainTagWritable and the no-IWritable rule are untouched. - Simulator: per-family ControlProfiles (strings from the pyLSV2 README tables / protocol.rst), both R_VR field counts, 124-byte R_PR; HeidenhainControlFamilyTests (classification, gates, decoding, wire log inside the read-only set, refused selectors asked once). - docs/drivers/Heidenhain.md: Control families matrix (iTNC 530 hardware-proven; the rest per pyLSV2, hardware-unproven) + open questions (C_CC buffer size, encrypted passwords, R_RI 20/21). Claude-Session: https://claude.ai/code/session_01GT67AD99zQQqpLCVm3p7xk
135 lines
7.6 KiB
C#
135 lines
7.6 KiB
C#
using ZB.MOM.WW.OtOpcUa.Core.Abstractions;
|
|
|
|
namespace ZB.MOM.WW.OtOpcUa.Driver.Heidenhain;
|
|
|
|
/// <summary>The three acquisition cadences a Heidenhain tag can ride.</summary>
|
|
public enum HeidenhainPollGroup
|
|
{
|
|
/// <summary>Execution/program state, program, overrides, axes (<c>Polling.StatusMs</c>).</summary>
|
|
Status,
|
|
|
|
/// <summary>Configured PLC / DATA bindings (<c>Polling.CustomMs</c>).</summary>
|
|
Custom,
|
|
|
|
/// <summary>Identity, tool, alarms, timers and capability strings (<c>Polling.SlowMs</c>).</summary>
|
|
Slow,
|
|
|
|
/// <summary>The alarm-list walk behind <c>ALARM:</c> Part 9 conditions (<c>Polling.AlarmMs</c>, lmxopcua#831).</summary>
|
|
Alarm,
|
|
}
|
|
|
|
/// <summary>One fixed-namespace leaf: its address, OPC data type, rank, cadence and the feature that serves it.</summary>
|
|
/// <param name="Address">The device-relative address, e.g. <c>Status/ExecutionState</c>.</param>
|
|
/// <param name="DataType">The OPC UA data type the driver publishes.</param>
|
|
/// <param name="IsArray">True for the variable-length array leaves (axes, alarms).</param>
|
|
/// <param name="Group">The poll cadence.</param>
|
|
/// <param name="Feature">
|
|
/// The feature the leaf is acquired through (one wire read per feature per batch); for a
|
|
/// <c>Capabilities/</c> leaf the feature whose state it reports.
|
|
/// </param>
|
|
public sealed record HeidenhainCatalogEntry(
|
|
string Address, DriverDataType DataType, bool IsArray, HeidenhainPollGroup Group, string Feature)
|
|
{
|
|
/// <summary>True for a local <c>Capabilities/</c> string, which never causes a wire read.</summary>
|
|
public bool IsCapability => Address.StartsWith(HeidenhainCatalog.CapabilitiesFolder + "/", StringComparison.Ordinal);
|
|
}
|
|
|
|
/// <summary>
|
|
/// The stable, general-purpose device-relative namespace (ported from the ignitionoee v0.20.3 reference
|
|
/// <c>HeidenhainTags</c>). Fixed leaves avoid control-dependent path churn; axes use aligned name and
|
|
/// position arrays. There is no OEE mapping here — raw controller enums and units are preserved.
|
|
/// </summary>
|
|
public static class HeidenhainCatalog
|
|
{
|
|
/// <summary>The capability-string folder.</summary>
|
|
public const string CapabilitiesFolder = "Capabilities";
|
|
|
|
/// <summary>Feature id for the version / identity reply.</summary>
|
|
public const string IdentityFeature = "Identity";
|
|
|
|
/// <summary>Feature id reported for the R_PR memory layout used by PLC bindings.</summary>
|
|
public const string PlcLayoutFeature = "PlcLayout";
|
|
|
|
/// <summary>Feature id reported for the optional DNC login.</summary>
|
|
public const string DncLoginFeature = "DncLogin";
|
|
|
|
/// <summary>Feature id of the alarm-list walk (<c>R_RI 27/28</c>) — shared by the <c>Alarms/*</c> leaves and <c>ALARM:</c> conditions.</summary>
|
|
public const string AlarmsFeature = "Alarms";
|
|
|
|
/// <summary>Feature id reported for the opt-in DATA login.</summary>
|
|
public const string DataLoginFeature = "DataLogin";
|
|
|
|
/// <summary>Experimental timer leaf names, in selector order (30..34).</summary>
|
|
public static readonly IReadOnlyList<string> TimerNames =
|
|
["NcUptime", "MachineUptime", "MachineRuntime", "Spindle0Runtime", "Spindle1Runtime"];
|
|
|
|
/// <summary>Feature-state strings published on <c>Capabilities/</c> leaves.</summary>
|
|
public static class States
|
|
{
|
|
public const string Unknown = "Unknown";
|
|
public const string Supported = "Supported";
|
|
public const string Disabled = "Disabled";
|
|
public const string AccessDenied = "AccessDenied";
|
|
public const string Unsupported = "Unsupported";
|
|
public const string InvalidData = "InvalidData";
|
|
public const string CommunicationLost = "CommunicationLost";
|
|
public const string ConfigurationError = "ConfigurationError";
|
|
}
|
|
|
|
/// <summary>Every fixed leaf, value leaves first then the capability strings.</summary>
|
|
public static IReadOnlyList<HeidenhainCatalogEntry> Entries { get; } = Build();
|
|
|
|
private static readonly IReadOnlyDictionary<string, HeidenhainCatalogEntry> ByAddress =
|
|
Entries.ToDictionary(e => e.Address, StringComparer.Ordinal);
|
|
|
|
/// <summary>Looks up a fixed leaf by its exact (case-sensitive) address.</summary>
|
|
/// <param name="address">The address.</param>
|
|
/// <param name="entry">The entry, when found.</param>
|
|
/// <returns>True when <paramref name="address"/> is a fixed leaf.</returns>
|
|
public static bool TryGet(string address, [System.Diagnostics.CodeAnalysis.NotNullWhen(true)] out HeidenhainCatalogEntry? entry)
|
|
=> ByAddress.TryGetValue(address, out entry);
|
|
|
|
/// <summary>The value features (excluding capability-only features), in catalog order.</summary>
|
|
public static IReadOnlyList<string> ValueFeatures { get; } =
|
|
Entries.Where(e => !e.IsCapability).Select(e => e.Feature).Distinct().ToList();
|
|
|
|
private static List<HeidenhainCatalogEntry> Build()
|
|
{
|
|
var list = new List<HeidenhainCatalogEntry>();
|
|
void Add(string folder, DriverDataType type, bool array, HeidenhainPollGroup group, string feature, params string[] names)
|
|
{
|
|
foreach (var n in names) list.Add(new($"{folder}/{n}", type, array, group, feature));
|
|
}
|
|
|
|
Add("Controller", DriverDataType.String, false, HeidenhainPollGroup.Slow, IdentityFeature, "Model", "NcVersion", "PlcVersion", "Options");
|
|
// Derived locally from the same R_VR reply (HeidenhainControlFamilies.Classify) — no extra wire request.
|
|
Add("Controller", DriverDataType.String, false, HeidenhainPollGroup.Slow, IdentityFeature, "Family");
|
|
Add("Status", DriverDataType.Int32, false, HeidenhainPollGroup.Status, "Execution", "ExecutionState");
|
|
Add("Status", DriverDataType.Int32, false, HeidenhainPollGroup.Status, "ProgramState", "ProgramState");
|
|
Add("Program", DriverDataType.String, false, HeidenhainPollGroup.Status, "Program", "Main", "Current");
|
|
Add("Program", DriverDataType.Int64, false, HeidenhainPollGroup.Status, "Program", "Line");
|
|
Add("Overrides", DriverDataType.Float64, false, HeidenhainPollGroup.Status, "Overrides", "Feed", "Spindle", "Rapid");
|
|
Add("Axes", DriverDataType.String, true, HeidenhainPollGroup.Status, "Axes", "Names");
|
|
Add("Axes", DriverDataType.Float64, true, HeidenhainPollGroup.Status, "Axes", "Positions");
|
|
Add("Tool", DriverDataType.Int64, false, HeidenhainPollGroup.Slow, "Tool", "Number");
|
|
Add("Tool", DriverDataType.Int32, false, HeidenhainPollGroup.Slow, "Tool", "Index", "AxisCode");
|
|
Add("Tool", DriverDataType.Float64, false, HeidenhainPollGroup.Slow, "Tool", "Length", "Radius");
|
|
Add("Alarms", DriverDataType.Int32, true, HeidenhainPollGroup.Slow, "Alarms", "Classes", "Groups", "Numbers");
|
|
Add("Alarms", DriverDataType.String, true, HeidenhainPollGroup.Slow, "Alarms", "Messages");
|
|
Add("Alarms", DriverDataType.Int32, false, HeidenhainPollGroup.Slow, "Alarms", "Count");
|
|
foreach (var t in TimerNames)
|
|
Add("Timers", DriverDataType.Int64, false, HeidenhainPollGroup.Slow, TimerFeature(t), t);
|
|
|
|
var features = list.Select(e => e.Feature).Distinct().ToList();
|
|
features.AddRange([PlcLayoutFeature, DncLoginFeature, DataLoginFeature]);
|
|
foreach (var f in features)
|
|
list.Add(new($"{CapabilitiesFolder}/{f}", DriverDataType.String, false, HeidenhainPollGroup.Slow, f));
|
|
return list;
|
|
}
|
|
|
|
/// <summary>The feature id of an experimental timer leaf.</summary>
|
|
/// <param name="timerName">One of <see cref="TimerNames"/>.</param>
|
|
/// <returns><c>Timer_<name></c>.</returns>
|
|
public static string TimerFeature(string timerName) => "Timer_" + timerName;
|
|
}
|