Smart meters support MainWnd dialog (must be finished - mouse right click), test supports Poseidon RegisterReader

Refactor `ISmartReader` and related classes to support `SmartHeadsUni`. Remove redundant `IperlHeadsUni` references and introduce `SmartMeterFlyingStartMassCollection` functionality. Enhance regex-based head position extraction.
This commit is contained in:
2025-11-12 12:34:29 +01:00
parent f1e6e94450
commit 99ccabc142
30 changed files with 6809 additions and 3779 deletions
@@ -14,6 +14,7 @@ using Sensus.iPerl.NfcHandler;
using NHibernate;
using Renci.SshNet;
using System.Linq;
using System.Text.RegularExpressions;
using System.Xml;
using System.Xml.Linq; // This line is correct and does not need to be changed.
using System.Windows;
@@ -53,13 +54,38 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead
public iPerlHead.MeterType MeterType { get { return iperlHeadCfg.MeterType; } }
public string CommInterface { get { return iperlHeadCfg.CommunicationInterface.ToDescription(); } }
static int? ExtractPreferredNumber(string input)
{
if (string.IsNullOrEmpty(input))
return null;
// Match all sequences of digits
var matches = Regex.Matches(input, @"\d+");
if (matches.Count == 0)
return null;
// Prefer the last one if there are multiple
string selected = matches[matches.Count - 1].Value; // last element
return int.Parse(selected);
}
/// <summary>
/// this is a hack to get the position from the name
/// name must consist only with digit describing order of the meter
/// </summary>
public int Position
{
get
{
int firstDigitPos = Name.IndexOfAny(new char[] { '1', '2', '3', '4', '5', '6', '7', '8', '9', '0' });
int position;
return (firstDigitPos < 0) ? 0 : (int.TryParse(Name.Substring(firstDigitPos), out position) ? position : 0);
//BUMI this is a hack to get the position from the name
// but it is not working for all cases !!!!!
// - what stupid prediction (what index should be used?? see: 'S4iPerl1' or ...)
int? extractPreferredNumber = ExtractPreferredNumber(Name);
if (extractPreferredNumber.HasValue)
return extractPreferredNumber.Value;
return 0;
}
}
public RegisterReaderType RegisterReaderType { get { return RegisterReaderType.DataStream; } }