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:
Michal Buzik 2025-11-12 12:34:29 +01:00
parent f1e6e94450
commit 99ccabc142
30 changed files with 6809 additions and 3779 deletions

View File

@ -2,6 +2,7 @@
/// Copyright (c) 2013-2022 Sensus Slovensko a.s. /// Copyright (c) 2013-2022 Sensus Slovensko a.s.
/// ///
using System.Collections.Generic; using System.Collections.Generic;
using TBF.Rig.Generic;
using TBF.Rig.GenericDevices; using TBF.Rig.GenericDevices;
namespace TBF.Rig namespace TBF.Rig
@ -25,7 +26,8 @@ namespace TBF.Rig
{ {
for (int i = 0; i < Sequences.ProcessData.WMsCount; i++) for (int i = 0; i < Sequences.ProcessData.WMsCount; i++)
{ {
RegisterReaders[i] = TbfComponents.FindComponent(entity.GetSensor(i), components) as IRegReader; IComponent findComponent = TbfComponents.FindComponent(entity.GetSensor(i), components);
RegisterReaders[i] = findComponent as IRegReader;
} }
} }
} }

View File

@ -27,7 +27,7 @@ namespace TBF.Rig.RegisterReaders.IPerlReader
SmartCommunicationForm.TestMethodCfg = new TestMethodCfg(null); // default values for iPerlCommunication SmartCommunicationForm.TestMethodCfg = new TestMethodCfg(null); // default values for iPerlCommunication
foreach(var head in ProcessData.IperlHeadsUni) foreach(var head in ProcessData.SmartHeadsUni)
{ {
if (head != null && head.Name == config.Name) { Ctrl.ISmartReader = head; } if (head != null && head.Name == config.Name) { Ctrl.ISmartReader = head; }
} }

View File

@ -27,7 +27,7 @@ namespace TBF.Rig.RegisterReaders.PoseidonReader
//TODO fix possibility set test method in config //TODO fix possibility set test method in config
//iPerlCommunicationForm.cfg = new TestMethodCfg(null); // default values for iPerlCommunication //iPerlCommunicationForm.cfg = new TestMethodCfg(null); // default values for iPerlCommunication
foreach(var head in ProcessData.IperlHeadsUni) foreach(var head in ProcessData.SmartHeadsUni)
{ {
if (head != null && head.Name == config.Name) { _iSmartReader = head; } if (head != null && head.Name == config.Name) { _iSmartReader = head; }
} }

View File

@ -42,23 +42,20 @@ namespace TBF.Rig.RegisterReaders.PoseidonReader
public const int StartEndFilterSamplesCount2 = 20; /// StartEndFilterSamplesCount = 2 * StartEndFilterSamplesCount2 + 1 public const int StartEndFilterSamplesCount2 = 20; /// StartEndFilterSamplesCount = 2 * StartEndFilterSamplesCount2 + 1
public const int FeatureVectorSize = 9; public const int FeatureVectorSize = 9;
readonly iPerlReaderUNI.IPerlCfg _iPerlCfg; readonly PoseidonCfg _poseidonCfg;
public int RfidComPortNr { get { return _iPerlCfg.RfidComPortNr; } } public int RfidComPortNr { get { return _poseidonCfg.RfidComPortNr; } }
public int OptoComPortNr { get { return _iPerlCfg.OptoComPortNr; } } public int OptoComPortNr { get { return _poseidonCfg.OptoComPortNr; } }
public int MuxBoardNrOrGroup14 { get { return _iPerlCfg.MuxBoardNr; } } public MeterType MeterType { get { return _poseidonCfg.MeterType; } }
public int Group { get { return _iPerlCfg.Group; } } public string CommInterface { get { return _poseidonCfg.CommunicationInterface.ToString(); } }
public MeterType MeterType { get { return _iPerlCfg.MeterType; } }
public string CommInterface { get { return _iPerlCfg.CommunicationInterface.ToString(); } }
public double CalibTarget { get { return _iPerlCfg.ProcParams.CalibTarget; } } public double CalibTarget { get { return _poseidonCfg.ProcParams.CalibTarget; } }
public ushort FactorLimitLo { get { return (ushort)_iPerlCfg.ProcParams.FactorLimitLo; } } public ushort FactorLimitLo { get { return (ushort)_poseidonCfg.ProcParams.FactorLimitLo; } }
public ushort FactorLimitHi { get { return (ushort)_iPerlCfg.ProcParams.FactorLimitHi; } } public ushort FactorLimitHi { get { return (ushort)_poseidonCfg.ProcParams.FactorLimitHi; } }
public Counting InitFlowDir { get { return (_iPerlCfg != null && _iPerlCfg.ProcParams != null) ? _iPerlCfg.ProcParams.Counting : Counting.Arbitrary; } } public Counting InitFlowDir { get { return (_poseidonCfg != null && _poseidonCfg.ProcParams != null) ? _poseidonCfg.ProcParams.Counting : Counting.Arbitrary; } }
string simulatedPcbNr = null; string simulatedPcbNr = null;
public string Name { get; set; }
/// Properties set by the Begin and the End form /// Properties set by the Begin and the End form
public string SerialNr public string SerialNr
@ -240,7 +237,7 @@ namespace TBF.Rig.RegisterReaders.PoseidonReader
public SmartReader(Generic.IComponentCfg cfg) public SmartReader(Generic.IComponentCfg cfg)
: base(cfg) : base(cfg)
{ {
_iPerlCfg = cfg as iPerlReaderUNI.IPerlCfg; _poseidonCfg = cfg as PoseidonCfg;
} }
@ -275,9 +272,9 @@ namespace TBF.Rig.RegisterReaders.PoseidonReader
/// Check whether head is connected, working /// Check whether head is connected, working
try try
{ {
if (_iPerlCfg != null) if (_poseidonCfg != null)
{ {
OpenOptoSerialPort($"COM{_iPerlCfg.OptoComPortNr}", 9600, Parity.None, 8, StopBits.One, OpenOptoSerialPort($"COM{_poseidonCfg.OptoComPortNr}", 9600, Parity.None, 8, StopBits.One,
Handshake.None); Handshake.None);
CloseOptoSerialPort(); CloseOptoSerialPort();
log.FatalFormat($"{Name} initialized: {this}"); log.FatalFormat($"{Name} initialized: {this}");
@ -1059,7 +1056,7 @@ namespace TBF.Rig.RegisterReaders.PoseidonReader
{ {
try try
{ {
OpenOptoSerialPort($"COM{_iPerlCfg.OptoComPortNr}", 9600, Parity.None, 8, StopBits.One, Handshake.None); OpenOptoSerialPort($"COM{_poseidonCfg.OptoComPortNr}", 9600, Parity.None, 8, StopBits.One, Handshake.None);
} }
catch (Exception) catch (Exception)
{ {
@ -1110,12 +1107,12 @@ namespace TBF.Rig.RegisterReaders.PoseidonReader
/// <returns>true when type is OK</returns> /// <returns>true when type is OK</returns>
public bool VerifyIPerlType() public bool VerifyIPerlType()
{ {
if (_iPerlCfg.MeterType == MeterType.AutoDetect || CalibrationStruct == null) if (_poseidonCfg.MeterType == MeterType.AutoDetect || CalibrationStruct == null)
{ {
return true; return true;
} }
return _iPerlCfg.MeterType == CalibrationStruct.MeterType; return _poseidonCfg.MeterType == CalibrationStruct.MeterType;
} }
public static double UnitVolume(VolumeUnits units) public static double UnitVolume(VolumeUnits units)
@ -1131,13 +1128,13 @@ namespace TBF.Rig.RegisterReaders.PoseidonReader
public double ScalingFactor() public double ScalingFactor()
{ {
if ((_iPerlCfg.MeterType == MeterType.AutoDetect) && (CalibrationStruct != null)) if ((_poseidonCfg.MeterType == MeterType.AutoDetect) && (CalibrationStruct != null))
{ {
return ScalingFactor(CalibrationStruct.MeterType); return ScalingFactor(CalibrationStruct.MeterType);
} }
else if (_iPerlCfg.MeterType != MeterType.AutoDetect) else if (_poseidonCfg.MeterType != MeterType.AutoDetect)
{ {
return ScalingFactor(_iPerlCfg.MeterType); return ScalingFactor(_poseidonCfg.MeterType);
} }
else else
{ {
@ -1389,10 +1386,10 @@ namespace TBF.Rig.RegisterReaders.PoseidonReader
public void ResetNfcInterface(bool? nfc_on = null) public void ResetNfcInterface(bool? nfc_on = null)
{ {
if (_iPerlCfg.HeadCommunicationComPortNr == 0) return; if (_poseidonCfg.HeadCommunicationComPortNr == 0) return;
SERIAL_Driver _SERIAL_Driver_Head_Config = new SERIAL_Driver(); SERIAL_Driver _SERIAL_Driver_Head_Config = new SERIAL_Driver();
_SERIAL_Driver_Head_Config.OpenConnection($"COM{_iPerlCfg.HeadCommunicationComPortNr}", 9600, 8, Parity.None, StopBits.One); _SERIAL_Driver_Head_Config.OpenConnection($"COM{_poseidonCfg.HeadCommunicationComPortNr}", 9600, 8, Parity.None, StopBits.One);
NFCHeadConfig _NFCHead_Config = new NFCHeadConfig(_SERIAL_Driver_Head_Config); NFCHeadConfig _NFCHead_Config = new NFCHeadConfig(_SERIAL_Driver_Head_Config);
if (nfc_on == null || nfc_on == false) _NFCHead_Config.NFCHeadConfig_SetInterface(false); // set RFID interface if (nfc_on == null || nfc_on == false) _NFCHead_Config.NFCHeadConfig_SetInterface(false); // set RFID interface

View File

@ -23,9 +23,9 @@ namespace TBF.Rig.RegisterReaders.PoseidonReader
SmartCommunicationForm.TestMethodCfg = new iPerlReaderUNI.TestMethodCfg(null); // default values for iPerlCommunication SmartCommunicationForm.TestMethodCfg = new iPerlReaderUNI.TestMethodCfg(null); // default values for iPerlCommunication
if (ProcessData.IperlHeadsUni != null) if (ProcessData.SmartHeadsUni != null)
{ {
foreach (var head in ProcessData.IperlHeadsUni) foreach (var head in ProcessData.SmartHeadsUni)
{ {
if (head != null && head.Name == config.Name) if (head != null && head.Name == config.Name)
{ {

View File

@ -30,7 +30,7 @@ namespace TBF.Rig.RegisterReaders.iPerlReaderUNI
SmartCommunicationForm.TestMethodCfg = new TestMethodCfg(null); // default values for iPerlCommunication SmartCommunicationForm.TestMethodCfg = new TestMethodCfg(null); // default values for iPerlCommunication
foreach(var head in ProcessData.IperlHeadsUni) foreach(var head in ProcessData.SmartHeadsUni)
{ {
if (head != null && head.Name == config.Name) { Ctrl.ISmartReader = head; } if (head != null && head.Name == config.Name) { Ctrl.ISmartReader = head; }
} }

View File

@ -111,7 +111,7 @@ namespace TBF.Rig.Sequences
/// iPERL related state variables to be saved after each completed test /// iPERL related state variables to be saved after each completed test
/// ///
public static IList<TestMethods.iPerlCommunication.iPerlHead.IperlHead> IperlHeads; public static IList<TestMethods.iPerlCommunication.iPerlHead.IperlHead> IperlHeads;
public static IList<ISmartReader> IperlHeadsUni; public static IList<ISmartReader> SmartHeadsUni;
public static bool IsQ2PreCorrectionCalculated; public static bool IsQ2PreCorrectionCalculated;
public static int CalculatedQ2PreCorrectionLR; public static int CalculatedQ2PreCorrectionLR;
public static int CalculatedQ2PreCorrectionRL; public static int CalculatedQ2PreCorrectionRL;
@ -177,10 +177,10 @@ namespace TBF.Rig.Sequences
} }
#endif #endif
/////// IperlHeadsUni - added for support of smart meters /////// IperlHeadsUni - added for support of smart meters
writer.Write(IperlHeadsUni.Count); writer.Write(SmartHeadsUni.Count);
for (int i = 0; i < IperlHeadsUni.Count; i++) for (int i = 0; i < SmartHeadsUni.Count; i++)
{ {
IperlHeadsUni[i].WriteBinary(writer); SmartHeadsUni[i].WriteBinary(writer);
} }
log.WarnFormat("Process data succesfully saved to file {0}", PDataFileName); log.WarnFormat("Process data succesfully saved to file {0}", PDataFileName);
} }
@ -260,9 +260,9 @@ namespace TBF.Rig.Sequences
int iPerlHeadsCountUni = reader.ReadInt32(); int iPerlHeadsCountUni = reader.ReadInt32();
for (int i = 0; i < iPerlHeadsCountUni; i++) for (int i = 0; i < iPerlHeadsCountUni; i++)
{ {
if (IperlHeadsUni != null && i < IperlHeadsUni.Count) if (SmartHeadsUni != null && i < SmartHeadsUni.Count)
{ {
IperlHeadsUni[i].ReadBinary(reader); SmartHeadsUni[i].ReadBinary(reader);
} }
else else
{ {

View File

@ -156,7 +156,7 @@ namespace TBF.Rig
TestMethod2Class = new Dictionary<string, string>(); TestMethod2Class = new Dictionary<string, string>();
ProcessData.IperlHeads = new List<TestMethods.iPerlCommunication.iPerlHead.IperlHead>(); ProcessData.IperlHeads = new List<TestMethods.iPerlCommunication.iPerlHead.IperlHead>();
ProcessData.IperlHeadsUni = new List<ISmartReader>(); ProcessData.SmartHeadsUni = new List<ISmartReader>();
SequenceBase.FlowMeters = new List<IFlowMeter>(); SequenceBase.FlowMeters = new List<IFlowMeter>();
SequenceBase.RegVPositions = new List<RegValvePosition>(); SequenceBase.RegVPositions = new List<RegValvePosition>();
SequenceBase.PumpsWithFM = new List<IPumpFM>(); SequenceBase.PumpsWithFM = new List<IPumpFM>();
@ -165,7 +165,6 @@ namespace TBF.Rig
LoopStartNames = new List<string>(); LoopStartNames = new List<string>();
LoopEndNames = new List<string>(); LoopEndNames = new List<string>();
ProcessData.IperlHeads = new List<TestMethods.iPerlCommunication.iPerlHead.IperlHead>();
} }
/// <summary> /// <summary>
@ -278,9 +277,14 @@ namespace TBF.Rig
TestMethod2Class.Add(cmpnt.Name, cmpnt.ClassName); TestMethod2Class.Add(cmpnt.Name, cmpnt.ClassName);
} }
if (cmpnt is TestMethods.iPerlCommunication.iPerlHead.IperlHead) if (cmpnt is TestMethods.iPerlCommunication.iPerlHead.IperlHead iPerlHead)
{ {
ProcessData.IperlHeads.Add(cmpnt as TestMethods.iPerlCommunication.iPerlHead.IperlHead); ProcessData.IperlHeads.Add(iPerlHead);
}
if (cmpnt is ISmartReader smartReader) // All SmartReader components are added to the list of SmartReaders
{
ProcessData.SmartHeadsUni.Add(smartReader);
} }
if (cmpnt is IFlowMeter) SequenceBase.FlowMeters.Add(cmpnt as IFlowMeter); if (cmpnt is IFlowMeter) SequenceBase.FlowMeters.Add(cmpnt as IFlowMeter);

View File

@ -203,6 +203,7 @@ namespace TBF.Rig
new TestMethods.S640Communication.S640StartFactory(), new TestMethods.S640Communication.S640StartFactory(),
new TestMethods.S640Communication.S640EndFactory(), new TestMethods.S640Communication.S640EndFactory(),
new TestMethods.SensitivityTest.Factory(), new TestMethods.SensitivityTest.Factory(),
new TestMethods.SmartMeterFlyingStartMassCollection.Factory(),
new TestMethods.StandingStart.Single.Factory(), new TestMethods.StandingStart.Single.Factory(),
new TestMethods.StandingStart.Compound.Factory(), new TestMethods.StandingStart.Compound.Factory(),
new TestMethods.StandingStart.HeatMeters.Factory(), new TestMethods.StandingStart.HeatMeters.Factory(),

View File

@ -0,0 +1,28 @@
///
/// Copyright (c) 2015-2016 Sensus Metering Systems
///
using System.Collections.Generic;
using TBF.Rig.Generic;
using TBF.Rig.TestMethods.iPerlCommunication;
namespace TBF.Rig.TestMethods.SmartMeterFlyingStartMassCollection
{
public class Factory : IComponentFactory
{
public string ClassName { get { return GetType().Namespace.Substring(8); } }
public override string ToString() { return ClassName; }
public IComponent DummyComponent() { return new TestMethod(); }
public IComponent GetComponent(IComponentCfg cfg, IList<IComponent> components) { return new TestMethod(cfg); }
public IComponentCfg DefaultConfig() { return new TestMethodCfg(this); }
public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component)
{
return ComponentCfgBase.CreateFromDbEntity(TestMethodCfg.Serializer, component, this);
}
}
}

View File

@ -0,0 +1,205 @@
///
/// Copyright (c) 2015-2022 Sensus Slovensko a.s.
///
using System.Collections.Generic;
using System.IO;
using System.Xml.Serialization;
using Common;
using Config.Entities;
using TBF.Resources;
using TBF.Rig.Generic;
using TBF.Rig.TestMethods.iPerlCommunication;
using TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication;
namespace TBF.Rig.TestMethods.SmartMeterFlyingStartMassCollection
{
public class SmartCommunicationParams : TestParamsBase, ITestParams
{
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(SmartCommunicationParams) })[0];
public override XmlSerializer GetSerializer() { return Serializer; }
//public string Activity { get; set; } /// Communication activity
//public bool SimultWithPrevious { get; set; }
//public bool SimultWithNext { get; set; }
public override void InitializeAll()
{
Activity = "Read Configuration";
SimultWithPrevious = false;
SimultWithNext = false;
}
string[] paramNames = new string[]
{
Strings.Activity,
Strings.Simultaneous_with_previous_step,
Strings.Simultaneous_with_next_step,
};
public override string ParamName(int i) { return paramNames[i]; }
public override int ParamsCount() { return paramNames.Length; }
public override ICollection<string> ParamValues(int i)
{
if (i == 0)
{
var retVal = new List<string>();
retVal.Add(iPerlCommunicationConstants.ReadConfigurationStr);
retVal.Add(string.Format("{0} A0", iPerlCommunicationConstants.SetTestModeStr));
retVal.Add(string.Format("{0} A4", iPerlCommunicationConstants.SetTestModeStr));
retVal.Add(iPerlCommunicationConstants.ReadCalibrationStr);
retVal.Add(iPerlCommunicationConstants.ReadCalibrationV4Str);
retVal.Add(iPerlCommunicationConstants.NormalizeCalibrationFactorStr);
retVal.Add(iPerlCommunicationConstants.NormalizeCalibrationV4FactorsStr);
retVal.Add(iPerlCommunicationConstants.GetDefaultQ2CorrectionsStr);
retVal.Add(iPerlCommunicationConstants.ReadQ2CorrectionStr);
retVal.Add(iPerlCommunicationConstants.ResetQ2CorrectionStr);
retVal.Add(iPerlCommunicationConstants.WriteDefaultQ2CorrectionsStr);
retVal.Add(iPerlCommunicationConstants.InitOrReadQ2CorrectionsStr);
retVal.Add(iPerlCommunicationConstants.WriteCalibrationFactorStr);
retVal.Add(iPerlCommunicationConstants.WriteCalibrationV4FactorsStr);
retVal.Add(iPerlCommunicationConstants.WriteQ2CorrectionStr);
retVal.Add(iPerlCommunicationConstants.WriteQ2CorrectionAltStr);
retVal.Add(iPerlCommunicationConstants.WriteQ2CorrectionGreeceStr);
retVal.Add(iPerlCommunicationConstants.WriteQ2CorrectionRLStr);
retVal.Add(iPerlCommunicationConstants.WriteQ2CorrectionLRStr);
retVal.Add(iPerlCommunicationConstants.WriteQ2CorrectionIncl05Str);
retVal.Add(iPerlCommunicationConstants.WriteQ2CorrectionAltIncl05Str);
retVal.Add(iPerlCommunicationConstants.WriteQ2CorrectionPlusIncl05Str);
retVal.Add(iPerlCommunicationConstants.WriteQ2CorrectionPlusAltIncl05Str);
retVal.Add(iPerlCommunicationConstants.WriteQ2CorrectionGreeceIncl05Str);
retVal.Add(iPerlCommunicationConstants.WriteQ2CorrectionRLIncl05Str);
retVal.Add(iPerlCommunicationConstants.WriteQ2CorrectionLRIncl05Str);
retVal.Add(iPerlCommunicationConstants.Q2correctedFromCmd + "Qx");
retVal.Add(iPerlCommunicationConstants.StrictQ2ErrorCheckStr + "Qx");
retVal.Add(iPerlCommunicationConstants.Q2correctionCheckCmd);
retVal.Add(iPerlCommunicationConstants.IperlCheckCmd);
retVal.Add(iPerlCommunicationConstants.UpdateBothQ2FactorsTestRLOnlyStr);
retVal.Add(iPerlCommunicationConstants.UpdateBothQ2FactorsTestLROnlyStr);
retVal.Add(iPerlCommunicationConstants.UpdateQ2CorrectionsStr);
retVal.Add(iPerlCommunicationConstants.ConditnlUpdateQ2CorrectionsStr);
retVal.Add(iPerlCommunicationConstants.ConditnlUpdateQ2CorrRLStr);
retVal.Add(iPerlCommunicationConstants.ConditnlUpdateQ2CorrLRStr);
retVal.Add("Q2 corrected from Q2adj");
retVal.Add("Q2 correction check Q2bc Q2ac");
retVal.Add(iPerlCommunicationConstants.SetActiveModeStr);
retVal.Add("---");
retVal.Add(iPerlCommunicationConstants.Reset2HzCorrectionStr);
retVal.Add(iPerlCommunicationConstants.Write2HzCorrectionStr);
retVal.Add(iPerlCommunicationConstants.DewaReworkRLStr);
retVal.Add(iPerlCommunicationConstants.DewaReworkLRStr);
retVal.Add(iPerlCommunicationConstants.StartTestingSealedMetersStr);
retVal.Add(iPerlCommunicationConstants.EndTestingSealedMetersStr);
retVal.Add(string.Format("{0} if enabled", iPerlCommunicationConstants.ReadConfigurationStr));
retVal.Add(string.Format("{0} 80", iPerlCommunicationConstants.SetTestModeStr));
retVal.Add("iPerl_check prevWorkStep direction q2factors");
for (ConditionID id = ConditionID.A; id < ConditionID.Count; id++)
{
retVal.Add(string.Format(SequenceConditionOp.ConditionNameFmt, id));
}
return retVal;
}
else
{
return new string[] { Strings.yes, Strings.no };
}
}
public override string ToString(int i)
{
switch (i)
{
case 0: return Activity;
case 1: return (SimultWithPrevious ? Strings.yes : Strings.no);
case 2: return (SimultWithNext ? Strings.yes : Strings.no);
default: return string.Empty;
}
}
public CfgUpdateFlags UpdateParam(int i, string strValue)
{
switch (i)
{
case 0: Activity = strValue; return CfgUpdateFlags.None;
case 1: SimultWithPrevious = strValue.ToLower().Equals(Strings.yes.ToLower()); return CfgUpdateFlags.None;
case 2: SimultWithNext = strValue.ToLower().Equals(Strings.yes.ToLower()); return CfgUpdateFlags.None;
default: return CfgUpdateFlags.None;
}
}
public bool ValidateParam(int i, string strValue, out string message)
{
message = string.Empty;
switch (i)
{
case 0:
return true;
case 1:
case 2:
if (strValue.Equals(Strings.yes) || strValue.Equals(Strings.no)) return true;
break;
default:
message = "Invalid index";
return false;
}
message = ParamName(i) + " is invalid";
return false;
}
void CopyContentTo(SmartCommunicationParams prms)
{
prms.Activity = this.Activity;
prms.SimultWithPrevious = this.SimultWithPrevious;
prms.SimultWithNext = this.SimultWithNext;
}
public IParamsProvider Clone()
{
SmartCommunicationParams pars = new SmartCommunicationParams();
CopyContentTo(pars);
return pars;
}
public override void UpdateFromDbEntity(ComponentTest dbEntity)
{
if (dbEntity == null) return;
try
{
SmartCommunicationParams tmp = Serializer.Deserialize(new StringReader(dbEntity.Parameters)) as SmartCommunicationParams;
testParamsEntity = dbEntity;
componentName = dbEntity.CmpntName;
test = dbEntity.Test;
if (tmp != null) tmp.CopyContentTo(this);
}
catch
{
}
}
/// <summary>
/// Parameterless constructor initializes the parameters
/// </summary>
public SmartCommunicationParams()
{
}
public SmartCommunicationParams(bool initialize)
{
if (initialize) InitializeAll();
}
public SmartCommunicationParams(ComponentTest testParamsEntity, string componentName, Test test)
{
this.testParamsEntity = testParamsEntity;
this.componentName = componentName;
this.test = test;
}
}
}

View File

@ -0,0 +1,958 @@
///
/// Copyright (c) 2015-2023 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using System.Drawing;
using Common;
using Config.Entities;
using log4net;
using RestClient;
using Results.Entities;
using TBF.Resources;
using TBF.Rig.Generic;
using TBF.Rig.Sequences;
//using TBF.Rig.TestMethods.iPerlCommunication;
using TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication;
using TBF.UiBridge;
/// Point definition
namespace TBF.Rig.TestMethods.SmartMeterFlyingStartMassCollection
{
public class SmartCommunicationSeq : SequenceBase
{
private static readonly ILog log = LogManager.GetLogger(typeof(SmartCommunicationSeq));
public const string Q2correctedFromCmd = "Q2 corrected from ";
public const string StrictQ2ErrorCheckStr = "Strict Q2 error check ";
public const string Q2correctionCheckCmd = "Q2 correction check ";
public const string IperlCheckCmd = "iPERL_check ";
public const string SimulateCmd = "simulate ";
System.Windows.Forms.Form modelessDlg;
///
delegate void SmartCommFormDlgt(SmartCommunicationSeq myRef, TestMethod method, Test test, SmartCommunicationParams testParams);
///
void OpenSmartCommForm(SmartCommunicationSeq myRef, TestMethod method, Test test, SmartCommunicationParams testParams)
{
myRef.modelessDlg = new SmartCommunicationForm(method, test, testParams);
myRef.modelessDlg.Show();
}
void CloseSmartCommForm()
{
UiBridge.Bridge.OnCloseModelessForm(this, null);
modelessDlg = null;
}
/// <summary>
/// Flying start mass collection method sequence
/// </summary>
/// <param name="test">Test entity</param>
/// <returns>
/// Event.Done . . . . . . . OK
/// Event.UiCmdStop . . . . Stopped by the user using the on-screen button STOP
/// Event.OpArgumentError . Target flow is out of range
/// Event.Error . . . . . . Unspecified error
/// </returns>
public IList<Event> Execute(Test test, int repetitionNr, TestMethod method, ITestParams testParams)
{
TestMethodCfg cfg = method.Cfg as TestMethodCfg;
IList<Event> e; /// Events from currently running operations
checkUiOp = new Operations.CheckUIOp(true); /// Runs in more then one state
modelessDlg = null;
processDataLoggingOp = new TBF.Rig.Operations.ProcessDataLoggingOp(processDataLogger, this, false);
string cmd;
if (testParams.Activity.ToLower().Equals(cmd = iPerlCommunicationConstants.GetDefaultQ2CorrectionsStr.ToLower()))
{
TestProgressEventArgs.SetEstimatedTimes(new int[] { 0, 0, 0, 30, 0, 30, 0, 0 });
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, Progress.JustStarted));
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, Progress.FlowSetting));
/// Get 'wmType' from IperlHead procedure parameters
int wmType = 0;
#if IPERL
/*foreach (var wm in ProcessData.BatchRslts.Batch.WaterMeters)
{
if (wm != null && !wm.Disabled && wm.WMTypeId() > 0)
{
wmType = wm.WMTypeId();
break;
}
}*/
#endif
// if (cfg.UseWebService)
// {
// IsQ2PreCorrectionCalculated = GetQ2PreCorrectionsOrBackups(cfg, wmType, out CalculatedQ2PreCorrectionLR, out CalculatedQ2PreCorrectionRL);
// }
/// Generate test results
Results.Entities.TestRslt tstRslt = BatchRslts.GetTestRslt(test.Name, 0);
if (tstRslt != null)
{
tstRslt.StartTime = DateTime.Now;
tstRslt.TestDone = true;
foreach (var wm in BatchRslts.Batch.WaterMeters)
{
if (!wm.Disabled)
{
foreach(var mtr in wm.MeterTestRslts)
{
if (mtr.TestRslt == tstRslt)
{
mtr.Passed = !cfg.UseWebService || IsQ2PreCorrectionCalculated;
mtr.TestDone = true;
break;
}
}
}
}
}
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, Progress.Completed));
Bridge.OnTestCompleted(this, new TestCompletedEventArgs(test.Name, ProcessData.BatchRslts.GetTestRslt(test.Name, 0)));
allResults.Info(TestResult2CsvLine(test.Name, 0)); /// Append the results to the CSV-file
return new List<Event> { Event.Done };
}
else if (testParams.Activity.ToLower().Contains(cmd = Q2correctedFromCmd.ToLower()))
{
TestProgressEventArgs.SetEstimatedTimes(new int[] { 0, 0, 0, 30, 0, 30, 0, 0 });
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, Progress.JustStarted));
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, Progress.FlowSetting));
string[] args = testParams.Activity.Substring(cmd.Length).Split(new char[] { ' ' });
string fromTestName = (args.Length >= 1) ? args[0] : string.Empty;
bool isPlus = (args.Length >= 2) ? args[1].ToLower().Contains("plus") : false;
MakeQ2CorrectedFrom(test.Name, fromTestName, isPlus);
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, Progress.Completed));
Bridge.OnTestCompleted(this, new TestCompletedEventArgs(test.Name, ProcessData.BatchRslts.GetTestRslt(test.Name, 0)));
allResults.Info(TestResult2CsvLine(test.Name, 0)); /// Append the results to the CSV-file
return new List<Event> { Event.Done };
}
else if (testParams.Activity.ToLower().Contains(cmd = StrictQ2ErrorCheckStr.ToLower()))
{
TestProgressEventArgs.SetEstimatedTimes(new int[] { 0, 0, 0, 30, 0, 30, 0, 0 });
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, Progress.JustStarted));
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, Progress.FlowSetting));
string fromTestName = testParams.Activity.Substring(cmd.Length);
StrictQ2ErrorCheck(test.Name, fromTestName);
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, Progress.Completed));
Bridge.OnTestCompleted(this, new TestCompletedEventArgs(test.Name, ProcessData.BatchRslts.GetTestRslt(test.Name, 0)));
allResults.Info(TestResult2CsvLine(test.Name, 0)); /// Append the results to the CSV-file
return new List<Event> { Event.Done };
}
else if (testParams.Activity.ToLower().Contains(cmd = Q2correctionCheckCmd.ToLower()))
{
TestProgressEventArgs.SetEstimatedTimes(new int[] { 0, 0, 0, 30, 0, 30, 0, 0 });
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, Progress.JustStarted));
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, Progress.FlowSetting));
string[] testNames = testParams.Activity.Substring(cmd.Length).Split(new char[] { ' ' });
if (testNames.Length >= 2)
{
CheckQ2Correction(test.Name, testNames[0], testNames[1]);
}
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, Progress.Completed));
Bridge.OnTestCompleted(this, new TestCompletedEventArgs(test.Name, ProcessData.BatchRslts.GetTestRslt(test.Name, 0)));
allResults.Info(TestResult2CsvLine(test.Name, 0)); /// Append the results to the CSV-file
return new List<Event> { Event.Done };
}
else if (testParams.Activity.ToLower().Contains(cmd = IperlCheckCmd.ToLower()))
{
TestProgressEventArgs.SetEstimatedTimes(new int[] { 0, 0, 0, 30, 0, 30, 0, 0 });
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, Progress.JustStarted));
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, Progress.FlowSetting));
string[] args = testParams.Activity.Substring(cmd.Length).Split(new char[] { ' ' });
//int maxTestIndex = (ProcessData.BenchInfo is TBF.Rig.DataContainer.BenchInfo.Component)
// ? (ProcessData.BenchInfo as TBF.Rig.DataContainer.BenchInfo.Component).MaxTestIndex
// : int.MaxValue;
Results.Entities.TestRslt tstRslt = ProcessData.BatchRslts.GetTestRslt(test.Name, 0);
if (tstRslt != null)
{
tstRslt.StartTime = DateTime.Now;
int wrongMetersCount = 0;
string message = string.Empty;
for (int i = 0; i < BatchRslts.WMPositionsCount; i++)
{
Results.Entities.WaterMeter wm = BatchRslts.Batch.WaterMeters[i];
Results.Entities.MeterTestRslt mtr = ProcessData.BatchRslts.GetMeterTestRslt(test.Name, i, CompoundMeterId.Single);
///// Reference to iPerl water meter or null:
//TestMethods.iPerlCommunication.iPerlHead.IperlHead iPerlHead = ((sensPath.RegisterReaders != null) && (i < sensPath.RegisterReaders.Length))
// ? (sensPath.RegisterReaders[i] as TestMethods.iPerlCommunication.iPerlHead.IperlHead)
// : null;
if ((wm != null) && (mtr != null))
{
int errorIndicators = 0;
bool anyErrorOfThisMeter = false;
foreach (var arg in args)
{
#if TURA_SPECIAL
if (arg.ToLower() == "q2factors")
{
if ((wm.ProdQ2CorrRL != wm.Q2CorrRL) || (wm.ProdQ2CorrLR != wm.Q2CorrLR))
{
anyErrorOfThisMeter = true;
message += string.Format("Q2 korekčné faktory vodomera {0} nesedia{1}", wm.WMPosition, Environment.NewLine);
errorIndicators |= (int)ErrorFlagMask.E26; /// Q2 correction factors not valid
}
}
#endif
if (arg.ToLower() == "direction")
{
//if (wm.Pruefindex > maxTestIndex)
//{
// anyErrorOfThisMeter = true;
// message += string.Format("Príliš veľa opakovaní testu vodomera {0}{1}", wm.WMPosition, Environment.NewLine);
// errorIndicators |= (int)ErrorFlagMask.E27; /// Wrong direction (positive/negative counting)
//}
}
if (arg.ToLower() == "prevworkstep")
{
if (wm.LastRecordIsNok)
{
wm.ErrorFlags |= (int)ErrorFlagMask.E28; /// Set E28
}
if ((wm.ErrorFlags & (int)ErrorFlagMask.E28) != 0)
{
anyErrorOfThisMeter = true;
message += string.Format("iPerl{0} : Predchádzajúci krok nebol zaznamenaný{1}", wm.WMPosition, Environment.NewLine);
errorIndicators |= (int)ErrorFlagMask.E28; /// Previous workstep missing or NOK (production tracing)
}
}
}
mtr.TestDone = true;
mtr.ErrorIndicators = errorIndicators;
///
if (anyErrorOfThisMeter)
{
/// This iPerl check did not pass
mtr.Passed = false;
wrongMetersCount++;
}
else
{
/// Check passed OK
mtr.Passed = true;
}
}
}
tstRslt.EndTime = DateTime.Now;
tstRslt.TestDone = true;
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, Progress.Completed));
Bridge.OnTestCompleted(this, new TestCompletedEventArgs(test.Name, tstRslt));
allResults.Info(TestResult2CsvLine(test.Name, 0)); /// Append the results to the CSV-file
if (wrongMetersCount >= cfg.IperlCheckErrorsToStop)
{
State.Create("iPerlCommunicationSeq : Show check result")
.AddOperation(new Operations.LargeMessageBoxOp(message))
.EnterState();
do
{
e = StateMachine.WaitRunDevsRunOps();
}
while (!e.Contains(Event.Continue) && !e.Contains(Event.Abort));
if (e.Contains(Event.Abort))
{
Bridge.OnError(this, string.Format("Niečo nie je v poriadku !"));
return new List<Event> { Event.UiCmdStop };
}
}
}
return new List<Event> { Event.Done };
}
else if (testParams.Activity.ToLower().Contains(cmd = SimulateCmd))
{
TestProgressEventArgs.SetEstimatedTimes(new int[] { 0, 0, 0, 30, 0, 30, 0, 0 });
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, Progress.JustStarted));
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, Progress.FlowSetting));
if (testParams.Activity.ToLower().Contains("q3")) MakeSimulated(test, 1, 0, -0.5f);
else if (testParams.Activity.Substring(cmd.Length).ToLower() == "q2") MakeSimulated(test, 1, 0, 0.5f);
else if (testParams.Activity.Substring(cmd.Length).ToLower() == "q1") MakeSimulated(test, 1, 0, -5.1f);
else if (testParams.Activity.Substring(cmd.Length).ToLower() == "compound ok") MakeSimulatedCompound(test, 1, 0, 0.7f, 1.0f);
else if (testParams.Activity.Substring(cmd.Length).ToLower() == "compound nok") MakeSimulatedCompound(test, 1, 0, 4.7f, 0.9f);
else if (testParams.Activity.Substring(cmd.Length).ToLower() == "compound rise") MakeSimulatedCompound(test, 1, 0, 0.7f, 0.0f);
else if (testParams.Activity.Substring(cmd.Length).ToLower() == "compound fall") MakeSimulatedCompound(test, 1, 0, 0.7f, 0.9f);
else if (testParams.Activity.Substring(cmd.Length).ToLower() == "iperls")
{
string[] pcbNrs = new string[] { "831232435539", "831232435562", "831232435587",
"831232432141", "831232432497", "831232763641" };
TestRslt tstRslt = BatchRslts.GetTestRslt(test.Name, test.Part);
if (tstRslt != null)
{
Results.Utils.GetCounterStates(tstRslt, Program.LocalSettings.Counters);
/// Auxiliary results ... not required
/// Main results
tstRslt.MethodClass = TbfComponents.FindComponent(test.Method).ClassName;
tstRslt.TestDone = true;
tstRslt.StartTime = tstRslt.Batch.StartTime;
tstRslt.EndTime = DateTime.Now;
tstRslt.FlowSetTime = 0;
tstRslt.MassOfEvapWater = 0;
tstRslt.TestTime = 1;
for (int i = 0; i < BatchRslts.Batch.WaterMeters.Count; i++)
{
MeterTestRslt meterRslt =
BatchRslts.GetMeterTestRslt(test.Name, i, CompoundMeterId.Single);
if (meterRslt != null)
{
meterRslt.WaterMeter.SerialNr = pcbNrs[i % pcbNrs.Length];
meterRslt.Passed = true;
meterRslt.TestDone = true;
}
//if (iperlHeads[i] != null)
//{
// iperlHeads[i].CommFailed = iperlHeads[i].Disabled = false;
// iperlHeads[i].SerialNr = pcbNrs[i % pcbNrs.Length];
//}
}
}
}
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, Progress.Completed));
Bridge.OnTestCompleted(this, new TestCompletedEventArgs(test.Name, ProcessData.BatchRslts.GetTestRslt(Common.Utils.GetTestName(test.Name, 1, 1), 0)));
allResults.Info(TestResult2CsvLine(test.Name, 0)); /// Append the results to the CSV-file
//------------------------------------------------
Bridge.OnActivity(this, testParams.Activity);
//------------------------------------------------
State.Create(string.Format("iPerlCommunicationSeq : {0}", testParams.Activity))
.AddOperation(checkUiOp)
.EnterState();
e = StateMachine.WaitRunDevsRunOps();
if (TestAndLogUiCmdStop(test, e))
{
return new List<Event> { Event.UiCmdStop };
}
}
else
{
///
/// Show the modeless dialog with error indication
///
string componentName = (method as IComponent)?.Name ?? string.Empty;
Program.MainWnd.Invoke(new SmartCommFormDlgt(OpenSmartCommForm), new object[] { this, componentName, test, testParams });
//------------------------------------------------
Bridge.OnActivity(this, Strings.iPerl_Communication_in_progress);
//------------------------------------------------
bool stopPressed = false; /// true when STOP button pressed
bool completed = false;
State.Create("iPerlCommunicationSeq : Wait until the entry form is closed")
.AddOperation(checkUiOp)
.EnterState();
do {
e = StateMachine.WaitRunDevsRunOps();
stopPressed = TestAndLogUiCmdStop(test, e);
completed = (modelessDlg is GenericDevices.IHasCompleted)
&& (modelessDlg as GenericDevices.IHasCompleted).Completed;
}
while (!stopPressed && !completed);
if (stopPressed)
{
CloseSmartCommForm();
return new List<Event> { Event.UiCmdStop };
}
else
{
TBF.UiBridge.Bridge.OnTestProgress(null, new TBF.UiBridge.TestProgressEventArgs(test.Name, Progress.Completed));
}
/// Test 'Quit'
modelessDlg = null; /// Modeless dialog is closed now
}
return new List<Event> { Event.Done };
}
/// <summary>
/// Read default Q2 correction factors from a REST service (= Web service).
/// </summary>
/// <param name="cfg">iPerlCommunication component configuration</param>
/// <param name="wmType">Water meter type (WZ Typ)</param>
/// <param name="q2PreCorrectionLR">Default Q2 correction LR</param>
/// <param name="q2PreCorrectionRL">Default Q2 correction RL</param>
/// <returns>true when successful</returns>
static bool ReadCorrectionsFromWebService(TestMethodCfg cfg, int wmType, out int q2PreCorrectionLR, out int q2PreCorrectionRL)
{
if (wmType == 0)
{
/// No REST service call when wmType == 0, factors are 0
q2PreCorrectionLR = 0;
q2PreCorrectionRL = 0;
return true;
}
try
{
GetQ2PreCorrectionClient client = new GetQ2PreCorrectionClient(cfg.BaseUrl);
client.GetToken("ReadUser", "sensus", "https://deluh1web03.world.fluidtechnology.net/SensusCore/api/v1/Locations/1/Login2").Wait();
Q2PreCorrection response = client.GetQ2Correction(string.Format(cfg.RelativeUrl, wmType)).Result;
if (response != null && response.AreDataCalculated)
{
q2PreCorrectionLR = response.CorrLR;
q2PreCorrectionRL = response.CorrRL;
log.WarnFormat("Q2 corrections from a REST client for WM Type = {0} are: LR = {1}, RL = {2}", wmType, q2PreCorrectionLR, q2PreCorrectionRL);
return true;
}
else
{
log.ErrorFormat("Failed to obtain Q2 corrections from a REST client for WM Type = {0}", wmType);
q2PreCorrectionLR = 0;
q2PreCorrectionRL = 0;
return false;
}
}
catch (Exception exc)
{
log.ErrorFormat("Failed to obtain Q2 corrections from a REST client for WM Type = {0}: {1}", wmType, exc.Message);
q2PreCorrectionLR = 0;
q2PreCorrectionRL = 0;
return false;
}
}
/// <summary>
/// Obtain Q2 correction factors from a REST service or from local settings (stored backup values)
/// </summary>
/// <param name="cfg">iPerlCommunication component configuration</param>
/// <param name="wmType">Water meter type (WZ Typ)</param>
/// <param name="q2PreCorrectionLR">Default Q2 correction LR</param>
/// <param name="q2PreCorrectionRL">Default Q2 correction RL</param>
/// <returns>true when successful</returns>
// public static bool GetQ2PreCorrectionsOrBackups(TestMethodCfg cfg, int wmType, out int q2PreCorrectionLR, out int q2PreCorrectionRL)
// {
// /// Get Q2 pre-correction values from REST service
// //bool restOK = ReadCorrectionsFromWebService(cfg, wmType, out q2PreCorrectionLR, out q2PreCorrectionRL);
//
// /// Store / load Q2 pre-correction values
// Point storedValue;
// if (restOK)
// {
// /// Q2 pre-correction values were successfully obtained from a REST service for the specified wmType
// if (!Program.LocalSettings.Q2PreCorrections.TryGetValue(wmType, out storedValue))
// {
// /// No Q2 pre-correction values in the dictionary for the specified wmType => save them
// Program.LocalSettings.Q2PreCorrections.Add(wmType, new Point(q2PreCorrectionLR, q2PreCorrectionRL));
// log.WarnFormat("Q2 corrections added to dictionary for WM Type = {0}: LR = {1}, RL = {2}", wmType, q2PreCorrectionLR, q2PreCorrectionRL);
// }
// else if (storedValue.X != q2PreCorrectionLR || storedValue.Y != q2PreCorrectionRL)
// {
// /// Different Q2 pre-correction values in the dictionary for the specified wmType => overwrite them with ones from the REST service
// Program.LocalSettings.Q2PreCorrections[wmType] = new Point(q2PreCorrectionLR, q2PreCorrectionRL);
// log.WarnFormat("Q2 corrections modified in dictionary for WM Type = {0}: LR = {1}, RL = {2}", wmType, q2PreCorrectionLR, q2PreCorrectionRL);
// }
// else
// {
// /// Q2 pre-correction values in the dictionary are the same and were not changed
// log.WarnFormat("Q2 corrections in dictionary for WM Type = {0} are the same and were not changed", wmType, q2PreCorrectionLR, q2PreCorrectionRL);
// }
// }
// else
// {
// /// No Q2 pre-correction values from a REST service => read the dictionary
// if (Program.LocalSettings.Q2PreCorrections.TryGetValue(wmType, out storedValue))
// {
// /// Q2 pre-correction values successfully read from the dictionary
// q2PreCorrectionLR = storedValue.X;
// q2PreCorrectionRL = storedValue.Y;
// log.WarnFormat("Q2 corrections loaded from dictionary for WM Type = {0}: LR = {1}, RL = {2}", wmType, q2PreCorrectionLR, q2PreCorrectionRL);
// }
// else
// {
// /// Q2 pre-correction values not found in the dictionary => use zeros
// q2PreCorrectionLR = 0;
// q2PreCorrectionRL = 0;
// log.ErrorFormat("Q2 corrections not found in the dictionary for WM Type = {0}, using zeros", wmType, q2PreCorrectionLR, q2PreCorrectionRL);
//
// /// Everything failed => using zero values
// return false;
// }
// }
//
// /// Q2 pre-corections were obtained from REST service or stored backup values were used
// return true;
// }
/// <summary>
/// Virtually apply Q2 correction to a test used for the correction calculation.
/// </summary>
/// <param name="testName">This test name</param>
/// <param name="oriTestRslt">Name of Q2 test done before Q2 correction (Q2adj)</param>
/// <remarks>Assuming this test does not have multiple parts (part = 0)</remarks>
void MakeQ2CorrectedFrom(string testName, string oriTestName, bool isPlus = false)
{
Results.Entities.TestRslt oriTestRslt = ProcessData.BatchRslts.GetTestRslt(oriTestName, 0);
Results.Entities.TestRslt tstRslt = ProcessData.BatchRslts.GetTestRslt(testName, 0);
if (oriTestRslt == null || tstRslt == null) return;
tstRslt.Components = oriTestRslt.Components;
/// Auxiliary results, as in SequenceBase.UpdateTemoPressDensAmb()
tstRslt.AmbTempMean = oriTestRslt.AmbTempMean;
tstRslt.AmbTempStart = oriTestRslt.AmbTempStart;
tstRslt.AmbTempEnd = oriTestRslt.AmbTempEnd;
tstRslt.AmbTempMin = oriTestRslt.AmbTempMin;
tstRslt.AmbTempMax = oriTestRslt.AmbTempMax;
tstRslt.AmbPressMean = oriTestRslt.AmbPressMean;
tstRslt.AmbPressStart = oriTestRslt.AmbPressStart;
tstRslt.AmbPressEnd = oriTestRslt.AmbPressEnd;
tstRslt.AmbPressMin = oriTestRslt.AmbPressMin;
tstRslt.AmbPressMax = oriTestRslt.AmbPressMax;
tstRslt.AmbHumiMean = oriTestRslt.AmbHumiMean;
tstRslt.AmbHumiStart = oriTestRslt.AmbHumiStart;
tstRslt.AmbHumiEnd = oriTestRslt.AmbHumiEnd;
tstRslt.AmbHumiMin = oriTestRslt.AmbHumiMin;
tstRslt.AmbHumiMax = oriTestRslt.AmbHumiMax;
tstRslt.PressUpMean = oriTestRslt.PressUpMean;
tstRslt.PressUpStart = oriTestRslt.PressUpStart;
tstRslt.PressUpEnd = oriTestRslt.PressUpEnd;
tstRslt.PressUpMin = oriTestRslt.PressUpMin;
tstRslt.PressUpMax = oriTestRslt.PressUpMax;
tstRslt.PressDownMean = oriTestRslt.PressDownMean;
tstRslt.PressDownStart = oriTestRslt.PressDownStart;
tstRslt.PressDownEnd = oriTestRslt.PressDownEnd;
tstRslt.PressDownMin = oriTestRslt.PressDownMin;
tstRslt.PressDownMax = oriTestRslt.PressDownMax;
tstRslt.PressDeltaMean = oriTestRslt.PressDeltaMean;
tstRslt.PressDeltaStart = oriTestRslt.PressDeltaStart;
tstRslt.PressDeltaEnd = oriTestRslt.PressDeltaEnd;
tstRslt.PressDeltaMin = oriTestRslt.PressDeltaMin;
tstRslt.PressDeltaMax = oriTestRslt.PressDeltaMax;
tstRslt.ConductMean = oriTestRslt.ConductMean;
tstRslt.ConductStart = oriTestRslt.ConductStart;
tstRslt.ConductEnd = oriTestRslt.ConductEnd;
tstRslt.ConductMin = oriTestRslt.ConductMin;
tstRslt.ConductMax = oriTestRslt.ConductMax;
tstRslt.TempUpMean = oriTestRslt.TempUpMean;
tstRslt.TempUpStart = oriTestRslt.TempUpStart;
tstRslt.TempUpEnd = oriTestRslt.TempUpEnd;
tstRslt.TempUpMin = oriTestRslt.TempUpMin;
tstRslt.TempUpMax = oriTestRslt.TempUpMax;
tstRslt.TempDownMean = oriTestRslt.TempDownMean;
tstRslt.TempDownStart = oriTestRslt.TempDownStart;
tstRslt.TempDownEnd = oriTestRslt.TempDownEnd;
tstRslt.TempDownMin = oriTestRslt.TempDownMin;
tstRslt.TempDownMax = oriTestRslt.TempDownMax;
tstRslt.TempDivMean = oriTestRslt.TempDivMean;
tstRslt.TempDivStart = oriTestRslt.TempDivStart;
tstRslt.TempDivEnd = oriTestRslt.TempDivEnd;
tstRslt.TempDivMin = oriTestRslt.TempDivMin;
tstRslt.TempDivMax = oriTestRslt.TempDivMax;
tstRslt.DensityIn = oriTestRslt.DensityIn;
tstRslt.DensityLine = oriTestRslt.DensityLine;
tstRslt.DensityDiv = oriTestRslt.DensityDiv;
tstRslt.StartTime = oriTestRslt.StartTime;
tstRslt.EndTime = oriTestRslt.EndTime;
tstRslt.FlowSetTime = oriTestRslt.FlowSetTime;
tstRslt.TestTime = oriTestRslt.TestTime;
tstRslt.PulsesMaster = oriTestRslt.PulsesMaster;
tstRslt.ConstMasterRaw = oriTestRslt.ConstMasterRaw;
tstRslt.ConstMaster = oriTestRslt.ConstMaster;
tstRslt.MassStartRaw = oriTestRslt.MassStartRaw;
tstRslt.MassStart = oriTestRslt.MassStart;
tstRslt.MassEndRaw = oriTestRslt.MassEndRaw;
tstRslt.MassEnd = oriTestRslt.MassEnd;
tstRslt.MassOfEvapWater = oriTestRslt.MassOfEvapWater;
//tstRslt.FlowMass = oriTestRslt.FlowMass;
//tstRslt.FlowVolume = oriTestRslt.FlowVolume;
tstRslt.VolumeCTV = oriTestRslt.VolumeCTV;
tstRslt.VolumeMaster = oriTestRslt.VolumeMaster;
tstRslt.ErrorMaster = oriTestRslt.ErrorMaster;
tstRslt.FlowMean = oriTestRslt.FlowMean;
tstRslt.FlowMin = oriTestRslt.FlowMin;
tstRslt.FlowMax = oriTestRslt.FlowMax;
tstRslt.Custom1 = oriTestRslt.Custom1;
tstRslt.Custom2 = oriTestRslt.Custom2;
tstRslt.Custom3 = oriTestRslt.Custom3;
tstRslt.Custom4 = oriTestRslt.Custom4;
tstRslt.Custom5 = oriTestRslt.Custom5;
tstRslt.Custom6 = oriTestRslt.Custom6;
tstRslt.Custom7 = oriTestRslt.Custom7;
tstRslt.Custom8 = oriTestRslt.Custom8;
for (int i = 0; i < ProcessData.BatchRslts.WMPositionsCount; i++)
{
// Fix for CS7036: Added the missing 'meterId' argument to the GetMeterTestRslt method call.
var q3mtr = ProcessData.BatchRslts.GetMeterTestRslt("Q3", i, CompoundMeterId.SingleOrCompound);
double q3error = (q3mtr != null) ? q3mtr.Error : 0;
Results.Entities.MeterTestRslt oriMeterRslt = ProcessData.BatchRslts.GetMeterTestRslt(oriTestName, i, CompoundMeterId.SingleOrCompound);
Results.Entities.MeterTestRslt meterRslt = ProcessData.BatchRslts.GetMeterTestRslt(testName, i, CompoundMeterId.SingleOrCompound);
/// Reference to iPerl water meter or null:
TestMethods.iPerlCommunication.iPerlHead.IperlHead iPerl = ((sensPath != null) && (sensPath.RegisterReaders != null) && (i < sensPath.RegisterReaders.Length))
? (sensPath.RegisterReaders[i] as TestMethods.iPerlCommunication.iPerlHead.IperlHead)
: null;
if (iPerl != null && meterRslt != null && oriMeterRslt != null)
{
#if ORACLE_DB
meterRslt.ErrorBC = oriMeterRslt.Error;
#endif
meterRslt.PulsesMeter = oriMeterRslt.PulsesMeter;
meterRslt.PulsesMaster = oriMeterRslt.PulsesMaster;
meterRslt.PulsesPerLiter = oriMeterRslt.PulsesPerLiter;
meterRslt.VolumeRef = oriMeterRslt.VolumeRef;
meterRslt.TestTime = oriMeterRslt.TestTime;
if (q3error * oriMeterRslt.Error < 0)
{
/// iPerl with Q2 correction => generate an artificial error equal to +1/10 of the original one (relative to Q2 target error)
meterRslt.Error = 0.1 * oriMeterRslt.Error;
}
else
{
/// iPerl with Q2 correction => generate an artificial error equal to -1/10 of the original one (relative to Q2 target error)
meterRslt.Error = - 0.1 * oriMeterRslt.Error;
}
meterRslt.VolumeMeter = meterRslt.VolumeRef * (100.0 + meterRslt.Error) / 100.0;
double signature = (oriMeterRslt.VolumeEnd > oriMeterRslt.VolumeStart) ? (+1) : (-1);
meterRslt.VolumeStart = oriMeterRslt.VolumeStart;
meterRslt.VolumeEnd = meterRslt.VolumeStart + signature * meterRslt.VolumeMeter;
meterRslt.Passed = (meterRslt.Error >= tstRslt.ErrLimLo() + tstRslt.ErrLimMargin()
&& meterRslt.Error <= tstRslt.ErrLimHi() - tstRslt.ErrLimMargin());
meterRslt.TestDone = true;
tstRslt.TestDone = true;
}
}
}
/// <summary>
/// Evaluate a given Q2 test result agains stricter error limits when Oruefindex == 1.
/// </summary>
/// <param name="testName">This test name</param>
/// <param name="oriTestRslt">Name of Q2 test done before Q2 correction (Q2adj)</param>
/// <remarks>Assuming this test does not have multiple parts (part = 0)</remarks>
void StrictQ2ErrorCheck(string testName, string oriTestName)
{
Results.Entities.TestRslt oriTestRslt = ProcessData.BatchRslts.GetTestRslt(oriTestName, 0);
Results.Entities.TestRslt tstRslt = ProcessData.BatchRslts.GetTestRslt(testName, 0);
if (oriTestRslt == null || tstRslt == null) return;
tstRslt.Components = oriTestRslt.Components;
/// Auxiliary results, as in SequenceBase.UpdateTemoPressDensAmb()
tstRslt.AmbTempMean = oriTestRslt.AmbTempMean;
tstRslt.AmbTempStart = oriTestRslt.AmbTempStart;
tstRslt.AmbTempEnd = oriTestRslt.AmbTempEnd;
tstRslt.AmbTempMin = oriTestRslt.AmbTempMin;
tstRslt.AmbTempMax = oriTestRslt.AmbTempMax;
tstRslt.AmbPressMean = oriTestRslt.AmbPressMean;
tstRslt.AmbPressStart = oriTestRslt.AmbPressStart;
tstRslt.AmbPressEnd = oriTestRslt.AmbPressEnd;
tstRslt.AmbPressMin = oriTestRslt.AmbPressMin;
tstRslt.AmbPressMax = oriTestRslt.AmbPressMax;
tstRslt.AmbHumiMean = oriTestRslt.AmbHumiMean;
tstRslt.AmbHumiStart = oriTestRslt.AmbHumiStart;
tstRslt.AmbHumiEnd = oriTestRslt.AmbHumiEnd;
tstRslt.AmbHumiMin = oriTestRslt.AmbHumiMin;
tstRslt.AmbHumiMax = oriTestRslt.AmbHumiMax;
tstRslt.PressUpMean = oriTestRslt.PressUpMean;
tstRslt.PressUpStart = oriTestRslt.PressUpStart;
tstRslt.PressUpEnd = oriTestRslt.PressUpEnd;
tstRslt.PressUpMin = oriTestRslt.PressUpMin;
tstRslt.PressUpMax = oriTestRslt.PressUpMax;
tstRslt.PressDownMean = oriTestRslt.PressDownMean;
tstRslt.PressDownStart = oriTestRslt.PressDownStart;
tstRslt.PressDownEnd = oriTestRslt.PressDownEnd;
tstRslt.PressDownMin = oriTestRslt.PressDownMin;
tstRslt.PressDownMax = oriTestRslt.PressDownMax;
tstRslt.PressDeltaMean = oriTestRslt.PressDeltaMean;
tstRslt.PressDeltaStart = oriTestRslt.PressDeltaStart;
tstRslt.PressDeltaEnd = oriTestRslt.PressDeltaEnd;
tstRslt.PressDeltaMin = oriTestRslt.PressDeltaMin;
tstRslt.PressDeltaMax = oriTestRslt.PressDeltaMax;
tstRslt.ConductMean = oriTestRslt.ConductMean;
tstRslt.ConductStart = oriTestRslt.ConductStart;
tstRslt.ConductEnd = oriTestRslt.ConductEnd;
tstRslt.ConductMin = oriTestRslt.ConductMin;
tstRslt.ConductMax = oriTestRslt.ConductMax;
tstRslt.TempUpMean = oriTestRslt.TempUpMean;
tstRslt.TempUpStart = oriTestRslt.TempUpStart;
tstRslt.TempUpEnd = oriTestRslt.TempUpEnd;
tstRslt.TempUpMin = oriTestRslt.TempUpMin;
tstRslt.TempUpMax = oriTestRslt.TempUpMax;
tstRslt.TempDownMean = oriTestRslt.TempDownMean;
tstRslt.TempDownStart = oriTestRslt.TempDownStart;
tstRslt.TempDownEnd = oriTestRslt.TempDownEnd;
tstRslt.TempDownMin = oriTestRslt.TempDownMin;
tstRslt.TempDownMax = oriTestRslt.TempDownMax;
tstRslt.TempDivMean = oriTestRslt.TempDivMean;
tstRslt.TempDivStart = oriTestRslt.TempDivStart;
tstRslt.TempDivEnd = oriTestRslt.TempDivEnd;
tstRslt.TempDivMin = oriTestRslt.TempDivMin;
tstRslt.TempDivMax = oriTestRslt.TempDivMax;
tstRslt.DensityIn = oriTestRslt.DensityIn;
tstRslt.DensityLine = oriTestRslt.DensityLine;
tstRslt.DensityDiv = oriTestRslt.DensityDiv;
tstRslt.StartTime = oriTestRslt.StartTime;
tstRslt.EndTime = oriTestRslt.EndTime;
tstRslt.FlowSetTime = oriTestRslt.FlowSetTime;
tstRslt.TestTime = oriTestRslt.TestTime;
tstRslt.PulsesMaster = oriTestRslt.PulsesMaster;
tstRslt.ConstMasterRaw = oriTestRslt.ConstMasterRaw;
tstRslt.ConstMaster = oriTestRslt.ConstMaster;
tstRslt.MassStartRaw = oriTestRslt.MassStartRaw;
tstRslt.MassStart = oriTestRslt.MassStart;
tstRslt.MassEndRaw = oriTestRslt.MassEndRaw;
tstRslt.MassEnd = oriTestRslt.MassEnd;
tstRslt.MassOfEvapWater = oriTestRslt.MassOfEvapWater;
//tstRslt.FlowMass = oriTestRslt.FlowMass;
//tstRslt.FlowVolume = oriTestRslt.FlowVolume;
tstRslt.VolumeCTV = oriTestRslt.VolumeCTV;
tstRslt.VolumeMaster = oriTestRslt.VolumeMaster;
tstRslt.ErrorMaster = oriTestRslt.ErrorMaster;
tstRslt.FlowMean = oriTestRslt.FlowMean;
tstRslt.FlowMin = oriTestRslt.FlowMin;
tstRslt.FlowMax = oriTestRslt.FlowMax;
tstRslt.Custom1 = oriTestRslt.Custom1;
tstRslt.Custom2 = oriTestRslt.Custom2;
tstRslt.Custom3 = oriTestRslt.Custom3;
tstRslt.Custom4 = oriTestRslt.Custom4;
tstRslt.Custom5 = oriTestRslt.Custom5;
tstRslt.Custom6 = oriTestRslt.Custom6;
tstRslt.Custom7 = oriTestRslt.Custom7;
tstRslt.Custom8 = oriTestRslt.Custom8;
for (int i = 0; i < ProcessData.BatchRslts.WMPositionsCount; i++)
{
Results.Entities.MeterTestRslt oriMeterRslt = ProcessData.BatchRslts.GetMeterTestRslt(oriTestName, i, CompoundMeterId.Single);
Results.Entities.MeterTestRslt meterRslt = ProcessData.BatchRslts.GetMeterTestRslt(testName, i, CompoundMeterId.Single);
/// Reference to iPerl water meter or null:
TestMethods.iPerlCommunication.iPerlHead.IperlHead iPerl = ((sensPath != null) && (sensPath.RegisterReaders != null) && (i < sensPath.RegisterReaders.Length))
? (sensPath.RegisterReaders[i] as TestMethods.iPerlCommunication.iPerlHead.IperlHead)
: null;
if (meterRslt != null && oriMeterRslt != null)
{
#if ORACLE_DB
meterRslt.ErrorBC = oriMeterRslt.Error;
#endif
meterRslt.PulsesMeter = oriMeterRslt.PulsesMeter;
meterRslt.PulsesMaster = oriMeterRslt.PulsesMaster;
meterRslt.PulsesPerLiter = oriMeterRslt.PulsesPerLiter;
meterRslt.VolumeRef = oriMeterRslt.VolumeRef;
meterRslt.TestTime = oriMeterRslt.TestTime;
if (iPerl != null && ProcessData.BatchRslts.Batch.WaterMeters[i] != null &&
!ProcessData.BatchRslts.Batch.WaterMeters[i].Disabled)
{
/// Either no iPerl head or no Q2 correction
meterRslt.Error = oriMeterRslt.Error;
meterRslt.VolumeMeter = oriMeterRslt.VolumeMeter;
meterRslt.VolumeStart = oriMeterRslt.VolumeStart;
meterRslt.VolumeEnd = oriMeterRslt.VolumeEnd;
#if ORACLE_DB
if ((ProcessData.BatchRslts.Batch.WaterMeters[i].Pruefindex % 100) == 1)
{
meterRslt.Passed = (oriMeterRslt.Error >= tstRslt.ErrLimLo() + tstRslt.ErrLimMargin()
&& oriMeterRslt.Error <= tstRslt.ErrLimHi() - tstRslt.ErrLimMargin());
}
else
#endif
{
meterRslt.Passed = oriMeterRslt.Passed;
}
meterRslt.TestDone = true;
tstRslt.TestDone = true;
}
}
}
}
/// <summary>
/// Check results of 2 tests: before Q2 correction and after Q2 correction.
/// Evaluate whether Q2 correction works OK.
/// </summary>
/// <param name="testName">This test name</param>
/// <param name="testNameQ2bc">Name of Q2 test done before correction</param>
/// <param name="testNameQ2ac">Name of Q2 test done after correction</param>
/// <remarks>Assuming these tests do not have multiple parts (part = 0)</remarks>
void CheckQ2Correction(string testName, string testNameQ2bc, string testNameQ2ac)
{
Results.Entities.TestRslt tstRslt = ProcessData.BatchRslts.GetTestRslt(testName, 0);
Results.Entities.TestRslt testRsltQ2bc = ProcessData.BatchRslts.GetTestRslt(testNameQ2bc, 0);
Results.Entities.TestRslt testRsltQ2ac = ProcessData.BatchRslts.GetTestRslt(testNameQ2ac, 0);
if ((tstRslt == null) || (testRsltQ2bc == null) || (testRsltQ2ac == null)) return;
tstRslt.Components = testRsltQ2ac.Components;
/// Auxiliary results, as in SequenceBase.UpdateTemoPressDensAmb()
tstRslt.AmbTempMean = testRsltQ2ac.AmbTempMean;
tstRslt.AmbTempStart = testRsltQ2ac.AmbTempStart;
tstRslt.AmbTempEnd = testRsltQ2ac.AmbTempEnd;
tstRslt.AmbTempMin = testRsltQ2ac.AmbTempMin;
tstRslt.AmbTempMax = testRsltQ2ac.AmbTempMax;
tstRslt.AmbPressMean = testRsltQ2ac.AmbPressMean;
tstRslt.AmbPressStart = testRsltQ2ac.AmbPressStart;
tstRslt.AmbPressEnd = testRsltQ2ac.AmbPressEnd;
tstRslt.AmbPressMin = testRsltQ2ac.AmbPressMin;
tstRslt.AmbPressMax = testRsltQ2ac.AmbPressMax;
tstRslt.AmbHumiMean = testRsltQ2ac.AmbHumiMean;
tstRslt.AmbHumiStart = testRsltQ2ac.AmbHumiStart;
tstRslt.AmbHumiEnd = testRsltQ2ac.AmbHumiEnd;
tstRslt.AmbHumiMin = testRsltQ2ac.AmbHumiMin;
tstRslt.AmbHumiMax = testRsltQ2ac.AmbHumiMax;
tstRslt.PressUpMean = testRsltQ2ac.PressUpMean;
tstRslt.PressUpStart = testRsltQ2ac.PressUpStart;
tstRslt.PressUpEnd = testRsltQ2ac.PressUpEnd;
tstRslt.PressUpMin = testRsltQ2ac.PressUpMin;
tstRslt.PressUpMax = testRsltQ2ac.PressUpMax;
tstRslt.PressDownMean = testRsltQ2ac.PressDownMean;
tstRslt.PressDownStart = testRsltQ2ac.PressDownStart;
tstRslt.PressDownEnd = testRsltQ2ac.PressDownEnd;
tstRslt.PressDownMin = testRsltQ2ac.PressDownMin;
tstRslt.PressDownMax = testRsltQ2ac.PressDownMax;
tstRslt.PressDeltaMean = testRsltQ2ac.PressDeltaMean;
tstRslt.PressDeltaStart = testRsltQ2ac.PressDeltaStart;
tstRslt.PressDeltaEnd = testRsltQ2ac.PressDeltaEnd;
tstRslt.PressDeltaMin = testRsltQ2ac.PressDeltaMin;
tstRslt.PressDeltaMax = testRsltQ2ac.PressDeltaMax;
tstRslt.ConductMean = testRsltQ2ac.ConductMean;
tstRslt.ConductStart = testRsltQ2ac.ConductStart;
tstRslt.ConductEnd = testRsltQ2ac.ConductEnd;
tstRslt.ConductMin = testRsltQ2ac.ConductMin;
tstRslt.ConductMax = testRsltQ2ac.ConductMax;
tstRslt.TempUpMean = testRsltQ2ac.TempUpMean;
tstRslt.TempUpStart = testRsltQ2ac.TempUpStart;
tstRslt.TempUpEnd = testRsltQ2ac.TempUpEnd;
tstRslt.TempUpMin = testRsltQ2ac.TempUpMin;
tstRslt.TempUpMax = testRsltQ2ac.TempUpMax;
tstRslt.TempDownMean = testRsltQ2ac.TempDownMean;
tstRslt.TempDownStart = testRsltQ2ac.TempDownStart;
tstRslt.TempDownEnd = testRsltQ2ac.TempDownEnd;
tstRslt.TempDownMin = testRsltQ2ac.TempDownMin;
tstRslt.TempDownMax = testRsltQ2ac.TempDownMax;
tstRslt.TempDivMean = testRsltQ2ac.TempDivMean;
tstRslt.TempDivStart = testRsltQ2ac.TempDivStart;
tstRslt.TempDivEnd = testRsltQ2ac.TempDivEnd;
tstRslt.TempDivMin = testRsltQ2ac.TempDivMin;
tstRslt.TempDivMax = testRsltQ2ac.TempDivMax;
tstRslt.DensityIn = testRsltQ2ac.DensityIn;
tstRslt.DensityLine = testRsltQ2ac.DensityLine;
tstRslt.DensityDiv = testRsltQ2ac.DensityDiv;
tstRslt.StartTime = testRsltQ2ac.StartTime;
tstRslt.EndTime = testRsltQ2ac.EndTime;
tstRslt.FlowSetTime = testRsltQ2ac.FlowSetTime;
tstRslt.TestTime = testRsltQ2ac.TestTime;
tstRslt.PulsesMaster = testRsltQ2ac.PulsesMaster;
tstRslt.ConstMasterRaw = testRsltQ2ac.ConstMasterRaw;
tstRslt.ConstMaster = testRsltQ2ac.ConstMaster;
tstRslt.MassStartRaw = testRsltQ2ac.MassStartRaw;
tstRslt.MassStart = testRsltQ2ac.MassStart;
tstRslt.MassEndRaw = testRsltQ2ac.MassEndRaw;
tstRslt.MassEnd = testRsltQ2ac.MassEnd;
tstRslt.MassOfEvapWater = testRsltQ2ac.MassOfEvapWater;
//tstRslt.FlowMass = testRsltQ2ac.FlowMass;
//tstRslt.FlowVolume = testRsltQ2ac.FlowVolume;
tstRslt.VolumeCTV = testRsltQ2ac.VolumeCTV;
tstRslt.VolumeMaster = testRsltQ2ac.VolumeMaster;
tstRslt.ErrorMaster = testRsltQ2ac.ErrorMaster;
tstRslt.FlowMean = testRsltQ2ac.FlowMean;
tstRslt.FlowMin = testRsltQ2ac.FlowMin;
tstRslt.FlowMax = testRsltQ2ac.FlowMax;
tstRslt.Custom1 = testRsltQ2ac.Custom1;
tstRslt.Custom2 = testRsltQ2ac.Custom2;
tstRslt.Custom3 = testRsltQ2ac.Custom3;
tstRslt.Custom4 = testRsltQ2ac.Custom4;
tstRslt.Custom5 = testRsltQ2ac.Custom5;
tstRslt.Custom6 = testRsltQ2ac.Custom6;
tstRslt.Custom7 = testRsltQ2ac.Custom7;
tstRslt.Custom8 = testRsltQ2ac.Custom8;
for (int i = 0; i < ProcessData.BatchRslts.WMPositionsCount; i++)
{
Results.Entities.MeterTestRslt meterRslt = ProcessData.BatchRslts.GetMeterTestRslt(testName, i, CompoundMeterId.Single);
Results.Entities.MeterTestRslt meterRsltQ2bc = ProcessData.BatchRslts.GetMeterTestRslt(testNameQ2bc, i, CompoundMeterId.Single);
Results.Entities.MeterTestRslt meterRsltQ2ac = ProcessData.BatchRslts.GetMeterTestRslt(testNameQ2ac, i, CompoundMeterId.Single);
if ((meterRslt != null) && (meterRsltQ2bc != null) && (meterRsltQ2ac != null))
{
meterRslt.PulsesMeter = meterRsltQ2ac.PulsesMeter;
meterRslt.PulsesMaster = meterRsltQ2ac.PulsesMaster;
meterRslt.PulsesPerLiter = meterRsltQ2ac.PulsesPerLiter;
meterRslt.VolumeRef = meterRsltQ2ac.VolumeRef;
meterRslt.TestTime = meterRsltQ2ac.TestTime;
meterRslt.VolumeStart = meterRsltQ2ac.VolumeStart;
meterRslt.VolumeEnd = meterRsltQ2ac.VolumeEnd;
meterRslt.VolumeMeter = meterRsltQ2ac.VolumeMeter;
meterRslt.Error = meterRsltQ2ac.Error;
meterRslt.TestDone = meterRsltQ2ac.TestDone;
tstRslt.TestDone = true;
if (((meterRsltQ2bc.Error < -0.51) && (meterRsltQ2ac.Error < meterRsltQ2bc.Error)) ||
((meterRsltQ2bc.Error > +0.51) && (meterRsltQ2ac.Error > meterRsltQ2bc.Error)))
{
meterRslt.Passed = false; /// Q2 correction check failed
}
else
{
meterRslt.Passed = true; /// Q2 correction check passed
}
}
}
}
}
}

View File

@ -0,0 +1,208 @@
///
/// Copyright (c) 2015-2022 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using Common;
using Config.Entities;
using log4net;
using TBF.Resources;
using TBF.Rig.GenericDevices;
using TBF.Rig.Sequences;
using TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication;
using TBF.UiBridge;
namespace TBF.Rig.TestMethods.SmartMeterFlyingStartMassCollection
{
public class TestMethod : SmartComponentBase, ISimultTestMethod, ISequenceCondition, ISessionDataMngmnt
{
private static readonly ILog log = LogManager.GetLogger(typeof(TestMethod));
protected static readonly ILog rfidDataLogger = LogManager.GetLogger("RfidData");
public override string ToString() { return string.Format("{0}({1})", ClassName, Cfg.ToString(-1)); }
public bool CanTest(MetersKind meters) { return meters == MetersKind.Single; }
public bool DoTransitions() { return false; }
public bool SimultWithPrevious { get { return _testMethodCfg.TestParams.SimultWithPrevious; } }
public bool SimultWithNext { get { return _testMethodCfg.TestParams.SimultWithNext; } }
#region Configuration Change Handling
public static void OnCfgChange(object sender, CfgChangeArgs args)
{
if (CfgChangeHandler == null) return;
try { CfgChangeHandler(sender, args); }
catch (Exception e) { log.Error("CfgChangeHandler(...) failed", e); }
}
public static event EventHandler<CfgChangeArgs> CfgChangeHandler;
public override void StartChangeHandler()
{
CfgChangeHandler += delegate(object sender, CfgChangeArgs args)
{
TestMethodCfg tmpCfg = args.Cfg as TestMethodCfg;
if (tmpCfg != null && tmpCfg.Name.Equals(Name))
{
if (args.Command == CfgChangeCmd.CfgChange)
{
_testMethodCfg.CommTimeout = tmpCfg.CommTimeout;
_testMethodCfg.DelayBetweenRetries = tmpCfg.DelayBetweenRetries;
_testMethodCfg.MaxCommRetries = tmpCfg.MaxCommRetries;
_testMethodCfg.IperlCheckErrorsToStop = tmpCfg.IperlCheckErrorsToStop;
_testMethodCfg.UseWebService = tmpCfg.UseWebService;
_testMethodCfg.BaseUrl = tmpCfg.BaseUrl;
_testMethodCfg.RelativeUrl = tmpCfg.RelativeUrl;
}
}
};
}
#endregion Configuration Change Handling
readonly TestMethodCfg _testMethodCfg;
public bool[] IperlCommMilestone;
IList<IOperation> sequenceConditionOps;
public TestMethod()
{
CreateMilestonesAndConditions();
}
public TestMethod(Generic.IComponentCfg cfg)
: base(cfg)
{
_testMethodCfg = cfg as TestMethodCfg;
CreateMilestonesAndConditions();
}
void CreateMilestonesAndConditions()
{
// IperlCommMilestone = new bool[(int)ConditionID.Count];
//
// sequenceConditionOps = new List<IOperation>();
// for (ConditionID id = ConditionID.A; id < ConditionID.Count; id++)
// {
// sequenceConditionOps.Add(new SequenceConditionOp(this, id));
// }
}
/// IDevice interface - only Initialize() is used
public override void Initialize()
{
if (DebugLevel == DebugMode.Normal)
{
rfidDataLogger.Fatal("------------------------------------------------------------------------");
rfidDataLogger.FatalFormat("Test Bench Framework ver. {0}", Program.Version);
log.FatalFormat("{0} initialized: {1}", Name, this);
}
else
{
log.FatalFormat("{0} simulated: {1}", Name, this);
}
}
public IList<Event> Execute(Test test, int repetNr, bool isLastRepetition)
{
if (DebugLevel == DebugMode.Normal)
{
return (new SmartCommunicationSeq()).Execute(test, repetNr, this, _testMethodCfg.TestParams);
}
else
{
/// DebugLevel == DebugMode.Simulate
(new SmartCommunicationSeq()).MakeSimulatedTrivial(test, repetNr, test.Part);
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, 1, Progress.Completed));
Bridge.OnTestCompleted(this, new TestCompletedEventArgs(test.Name, ProcessData.BatchRslts.GetTestRslt(Common.Utils.GetTestName(test.Name, 1, 1), 0)));
return new List<Event> { Event.Done };
}
}
public int ConditionsCount
{
get
{
return 0;
//return (int)ConditionID.Count;
}
}
public string ConditionName(int i)
{
return String.Empty;
//return (i >= 0 && i < (int)ConditionID.Count) ? ConditionOp(i).ToString() : string.Empty;
}
public IOperation ConditionOp(int i)
{
return null;
//return (i >= 0 && i < (int)ConditionID.Count) ? sequenceConditionOps[i] : null;
}
public void StartSession()
{
/// Clear milestones
if (IperlCommMilestone != null)
{
for (int i = 0; i < IperlCommMilestone.Length; i++)
{
IperlCommMilestone[i] = false;
}
}
}
public void SaveMark(object o)
{
/// No marks
}
public void EndSession()
{
/// Nothing at the end of session
}
public bool CheckDeviceCaps(Test test, OutputPath devices, out string message)
{
if (!(StateMachine.ControlBoardMain is ControlBoard.Uni.UniCB))
{
/// Control board does not support this method
message = string.Format("{0}: {1}", test.Name, Strings.Test_bench_does_not_suport_selected_test_method);
return false;
}
if (!(devices.FlowMeter is TBF.Rig.GenericDevices.IFlowMeter))
{
/// Flow meter is missing
message = string.Format("{0}: {1}", test.Name, Strings.Missing_a_flow_meter);
return false;
}
if (!(devices.RegValve is GenericDevices.IRegValve))
{
/// Regulation valve is missing
message = string.Format("{0}: {1}", test.Name, Strings.Missing_a_regulation_valve);
return false;
}
message = string.Empty;
return true;
}
public override void MeterCommMilestone(int iItem, bool bValue)
{
throw new NotImplementedException();
}
public override bool IsMeterCommMilestone(int iItem)
{
throw new NotImplementedException();
}
}
}

View File

@ -0,0 +1,96 @@
///
/// Copyright (c) 2015-2021 Sensus Slovensko a.s.
///
using System.Collections.Generic;
using System.IO.Ports;
using System.Xml.Serialization;
using Common;
using Config.Entities;
using TBF.Rig.Generic;
using TBF.Rig.RegisterReaders.CommonRR.IPerl;
using TBF.Rig.TestMethods.iPerlCommunication;
namespace TBF.Rig.TestMethods.SmartMeterFlyingStartMassCollection
{
[XmlRoot("TestMethodCfg")] // Add this attribute to match the XML root
public class TestMethodCfg : ComponentCfgBase, IiPerlTestMethodCfg
{
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(TestMethodCfg) })[0];
public override XmlSerializer GetSerializer() { return Serializer; }
public IComponentCfgCtrl GetControl(IList<Config.Entities.Component> cmpntEntities) { return new SmartMeterFlyingStartMassCollection.TestMethodCfgCtrl(); }
//
public override IParamsProvider GetRuntimeTestParamsProvider() { return TestParams; }
public override IParamsProvider CreateTestParamsProvider() { return new SmartCommunicationParams(true); }
public override IParamsProvider GetUITestParamsProvider(Test test)
{
return (test.Method == Name) ? base.GetUITestParamsProvider(test) : null;
}
/// Private parameterless constructor invoked by all other (public) constructors
TestMethodCfg()
{
Name = "iPerlCommunication";
ParentName = string.Empty;
CommTimeout = 1800; /// ms
MaxCommRetries = 4;
WaitTimeAfterFailure = 2200;
PassThroughWaitTime = 1500;
NrThreads = 2; /// 1, 2 or 4 threads
IperlCheckErrorsToStop = 10;
MciTimeoutMs = 4000; // ms, NFC interface
BaudRate = 57600; // NFC Interface
DataBits = 8; // NFC Interface
ParityBit = Parity.None; // NFC Interface
StopBits = StopBits.Two; // NFC Interface
TestParams = CreateTestParamsProvider() as SmartCommunicationParams;
}
public TestMethodCfg(IComponentFactory factory)
: this()
{
this.Factory = factory;
}
public string ToString(int i)
{
return string.Format("Name={0}, CommTimeout={1}, MaxRetries={2}, NrThreads={3}", Name, CommTimeout, MaxCommRetries, NrThreads);
}
public int DelayBetweenRetries { get; set; }
public int MaxCommRetries { get; set; }
public int WaitTimeAfterFailure { get; set; }
public int PassThroughWaitTime { get; set; }
public int NrThreads { get; set; }
public int CommTimeout { get; set; }
public int IperlCheckErrorsToStop { get; set; }
public int MciTimeoutMs { get; set; }
public int BaudRate { get; set; }
public int DataBits { get; set; }
public Parity ParityBit { get; set; }
public StopBits StopBits { get; set; }
public int DfltQ2c_15_rl { get; set; }
public int DfltQ2c_15_lr { get; set; }
public int DfltQ2c_20_rl { get; set; }
public int DfltQ2c_20_lr { get; set; }
public int DfltQ2c_25_63_rl { get; set; }
public int DfltQ2c_25_63_lr { get; set; }
public int DfltQ2c_25_10_rl { get; set; }
public int DfltQ2c_25_10_lr { get; set; }
public int DfltQ2c_32_rl { get; set; }
public int DfltQ2c_32_lr { get; set; }
public int DfltQ2c_40_rl { get; set; }
public int DfltQ2c_40_lr { get; set; }
public bool UseWebService { get; set; }
public string BaseUrl { get; set; }
public string RelativeUrl { get; set; }
///Remember to Ignore in XmlSerializer !!
[XmlIgnore]
public ITestParams TestParams { get; set; }
}
}

View File

@ -0,0 +1,300 @@
///
/// Copyright (c) 2015-2020 Sensus Slovensko a.s.
///
using System;
using System.Windows.Forms;
using Common;
using TBF.Resources;
using TBF.Rig.Generic;
using TBF.Rig.TestMethods.iPerlCommunication;
namespace TBF.Rig.TestMethods.SmartMeterFlyingStartMassCollection
{
public partial class TestMethodCfgCtrl : Configs.ConfigCtrlUtils, IComponentCfgCtrl
{
public bool ShowMore { get { return false; } }
TestMethodCfg config;
public IComponentCfg Config
{
get { return config as IComponentCfg; }
set
{
config = value as TestMethodCfg;
Redraw();
}
}
public TestMethodCfgCtrl()
{
InitializeComponent();
}
private void EntryFormCfgCtrl_Load(object sender, EventArgs e)
{
Redraw();
}
public void Closing()
{
}
void Redraw()
{
if (config == null) return; /// Control was not loaded, settings were not changed
classNameLabel.Text = config.Factory.ClassName;
nameTextBox.Text = config.Name;
commTimeoutTextBox.Text = config.CommTimeout.ToString();
maxCommRetriesTextBox.Text = config.MaxCommRetries.ToString();
delayBetweenRetriesTextBox.Text = config.DelayBetweenRetries.ToString();
nrThreadsTextBox.Text = config.NrThreads.ToString();
iperlCheckErrorsToStopTextBox.Text = config.IperlCheckErrorsToStop.ToString();
textBox15rl.Text = config.DfltQ2c_15_rl.ToString();
textBox15lr.Text = config.DfltQ2c_15_lr.ToString();
textBox20rl.Text = config.DfltQ2c_20_rl.ToString();
textBox20lr.Text = config.DfltQ2c_20_lr.ToString();
textBox25_63rl.Text = config.DfltQ2c_25_63_rl.ToString();
textBox25_63lr.Text = config.DfltQ2c_25_63_lr.ToString();
textBox25_10rl.Text = config.DfltQ2c_25_10_rl.ToString();
textBox25_10lr.Text = config.DfltQ2c_25_10_lr.ToString();
textBox32rl.Text = config.DfltQ2c_32_rl.ToString();
textBox32lr.Text = config.DfltQ2c_32_lr.ToString();
textBox40rl.Text = config.DfltQ2c_40_rl.ToString();
textBox40lr.Text = config.DfltQ2c_40_lr.ToString();
useWebServiceCheckBox.Checked = config.UseWebService;
baseUrlTextBox.Text = config.BaseUrl;
relativeUrlTextBox.Text = config.RelativeUrl;
}
public void Unlock()
{
nameTextBox.Enabled = true;
commTimeoutTextBox.Enabled = true;
maxCommRetriesTextBox.Enabled = true;
delayBetweenRetriesTextBox.Enabled = true;
nrThreadsTextBox.Enabled = true;
iperlCheckErrorsToStopTextBox.Enabled = true;
textBox15rl.Enabled = true;
textBox15lr.Enabled = true;
textBox20rl.Enabled = true;
textBox20lr.Enabled = true;
textBox25_63rl.Enabled = true;
textBox25_63lr.Enabled = true;
textBox25_10rl.Enabled = true;
textBox25_10lr.Enabled = true;
textBox32rl.Enabled = true;
textBox32lr.Enabled = true;
textBox40rl.Enabled = true;
textBox40lr.Enabled = true;
useWebServiceCheckBox.Enabled = true;
ManageCheckGroupBox(useWebServiceCheckBox, useWebServiceGroupBox);
baseUrlTextBox.Enabled = useWebServiceCheckBox.Enabled;
relativeUrlTextBox.Enabled = useWebServiceCheckBox.Enabled;
}
public CfgUpdateFlags VerifyCfg(ref string message)
{
CfgUpdateFlags flags = CfgUpdateFlags.None;
int dummy;
if (!int.TryParse(commTimeoutTextBox.Text, out dummy) || dummy < 500 || dummy > 5000)
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "'Comm. timeout' should be in range 500 .. 5000";
}
if (!int.TryParse(maxCommRetriesTextBox.Text, out dummy) || dummy < 1 || dummy > 10)
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "'Max. retries' should be in range 1 .. 10";
}
if (!int.TryParse(delayBetweenRetriesTextBox.Text, out dummy) || dummy < 0 || dummy > 5000)
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "'Comm. timeout' should be in range 0 .. 5000";
}
if (!int.TryParse(nrThreadsTextBox.Text, out dummy) || (dummy != 1 && dummy != 2 && dummy != 4))
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "'Nr. threads' should be 1, 2 or 4";
}
if (!int.TryParse(iperlCheckErrorsToStopTextBox.Text, out dummy) || ((dummy < 1) && (dummy > 40)))
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + string.Format(Strings.Invalid_0, iperlCheckErrorsToStopLabel.Text);
}
if (!int.TryParse(textBox15rl.Text, out dummy) || dummy < -50 || dummy > 50)
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "Default Q2 correction factor DN15 RL should be in range -50 .. 50";
}
if (!int.TryParse(textBox15lr.Text, out dummy) || dummy < -50 || dummy > 50)
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "Default Q2 correction factor DN15 LR should be in range -50 .. 50";
}
if (!int.TryParse(textBox20rl.Text, out dummy) || dummy < -50 || dummy > 50)
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "Default Q2 correction factor DN20 RL should be in range -50 .. 50";
}
if (!int.TryParse(textBox20lr.Text, out dummy) || dummy < -50 || dummy > 50)
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "Default Q2 correction factor DN20 LR should be in range -50 .. 50";
}
if (!int.TryParse(textBox25_63rl.Text, out dummy) || dummy < -50 || dummy > 50)
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "Default Q2 correction factor DN25 Q3 6.3 RL should be in range -50 .. 50";
}
if (!int.TryParse(textBox25_63lr.Text, out dummy) || dummy < -50 || dummy > 50)
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "Default Q2 correction factor DN25 Q3 6.3 LR should be in range -50 .. 50";
}
if (!int.TryParse(textBox25_10rl.Text, out dummy) || dummy < -50 || dummy > 50)
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "Default Q2 correction factor DN25 Q3 10 RL should be in range -50 .. 50";
}
if (!int.TryParse(textBox25_10lr.Text, out dummy) || dummy < -50 || dummy > 50)
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "Default Q2 correction factor DN25 Q3 10 LR should be in range -50 .. 50";
}
if (!int.TryParse(textBox32rl.Text, out dummy) || dummy < -50 || dummy > 50)
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "Default Q2 correction factor DN32 RL should be in range -50 .. 50";
}
if (!int.TryParse(textBox32lr.Text, out dummy) || dummy < -50 || dummy > 50)
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "Default Q2 correction factor DN32 LR should be in range -50 .. 50";
}
if (!int.TryParse(textBox40rl.Text, out dummy) || dummy < -50 || dummy > 50)
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "Default Q2 correction factor DN40 RL should be in range -50 .. 50";
}
if (!int.TryParse(textBox40lr.Text, out dummy) || dummy < -50 || dummy > 50)
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "Default Q2 correction factor DN40 LR should be in range -50 .. 50";
}
return flags;
}
public CfgUpdateFlags UpdateCfg()
{
CfgUpdateFlags flags = CfgUpdateFlags.None;
if (config == null) return CfgUpdateFlags.Error; /// Control was not loaded, settings were not changed
if (config.Name != nameTextBox.Text)
{
config.Name = nameTextBox.Text;
flags |= (CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd);
}
var CommTimeout = config.CommTimeout;;
var MaxCommRetries = config.MaxCommRetries;
var DelayBetweenRetries = config.DelayBetweenRetries;
var NrThreads = config.NrThreads;
var IperlCheckErrorsToStop = config.IperlCheckErrorsToStop;
var DfltQ2c_15_rl = config.DfltQ2c_15_rl;
var DfltQ2c_15_lr = config.DfltQ2c_15_lr;
var DfltQ2c_20_rl = config.DfltQ2c_20_rl;
var DfltQ2c_20_lr = config.DfltQ2c_20_lr;
var DfltQ2c_25_63_rl = config.DfltQ2c_25_63_rl;
var DfltQ2c_25_63_lr = config.DfltQ2c_25_63_lr;
var DfltQ2c_25_10_rl = config.DfltQ2c_25_10_rl;
var DfltQ2c_25_10_lr = config.DfltQ2c_25_10_lr;
var DfltQ2c_32_rl = config.DfltQ2c_32_rl;
var DfltQ2c_32_lr = config.DfltQ2c_32_lr;
var DfltQ2c_40_rl = config.DfltQ2c_40_rl;
var DfltQ2c_40_lr = config.DfltQ2c_40_lr;
var UseWebService = config.UseWebService;
var BaseUrl = config.BaseUrl;
var RelativeUrl = config.RelativeUrl;
flags |= UpdateDifferent(ref CommTimeout, commTimeoutTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
flags |= UpdateDifferent(ref MaxCommRetries, maxCommRetriesTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
flags |= UpdateDifferent(ref DelayBetweenRetries, delayBetweenRetriesTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
flags |= UpdateDifferent(ref NrThreads, nrThreadsTextBox.Text, CfgUpdateFlags.RestartRqrd | CfgUpdateFlags.AnyChange);
flags |= UpdateDifferent(ref IperlCheckErrorsToStop, iperlCheckErrorsToStopTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
flags |= UpdateDifferent(ref DfltQ2c_15_rl, textBox15rl.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
flags |= UpdateDifferent(ref DfltQ2c_15_lr, textBox15lr.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
flags |= UpdateDifferent(ref DfltQ2c_20_rl, textBox20rl.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
flags |= UpdateDifferent(ref DfltQ2c_20_lr, textBox20lr.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
flags |= UpdateDifferent(ref DfltQ2c_25_63_rl, textBox25_63rl.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
flags |= UpdateDifferent(ref DfltQ2c_25_63_lr, textBox25_63lr.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
flags |= UpdateDifferent(ref DfltQ2c_25_10_rl, textBox25_10rl.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
flags |= UpdateDifferent(ref DfltQ2c_25_10_lr, textBox25_10lr.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
flags |= UpdateDifferent(ref DfltQ2c_32_rl, textBox32rl.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
flags |= UpdateDifferent(ref DfltQ2c_32_lr, textBox32lr.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
flags |= UpdateDifferent(ref DfltQ2c_40_rl, textBox40rl.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
flags |= UpdateDifferent(ref DfltQ2c_40_lr, textBox40lr.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
flags |= UpdateDifferent(ref UseWebService, useWebServiceCheckBox.Checked, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
flags |= UpdateDifferent(ref BaseUrl, baseUrlTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
flags |= UpdateDifferent(ref RelativeUrl, relativeUrlTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
config.CommTimeout = CommTimeout;
config.MaxCommRetries = MaxCommRetries;
config.DelayBetweenRetries = DelayBetweenRetries;
config.NrThreads = NrThreads;
config.IperlCheckErrorsToStop = IperlCheckErrorsToStop;
config.DfltQ2c_15_rl = DfltQ2c_15_rl;
config.DfltQ2c_15_lr = DfltQ2c_15_lr;
config.DfltQ2c_20_rl = DfltQ2c_20_rl;
config.DfltQ2c_20_lr = DfltQ2c_20_lr;
config.DfltQ2c_25_63_rl = DfltQ2c_25_63_rl;
config.DfltQ2c_25_63_lr = DfltQ2c_25_63_lr;
config.DfltQ2c_25_10_rl = DfltQ2c_25_10_rl;
config.DfltQ2c_25_10_lr = DfltQ2c_25_10_lr;
config.DfltQ2c_32_rl = DfltQ2c_32_rl;
config.DfltQ2c_32_lr = DfltQ2c_32_lr;
config.DfltQ2c_40_rl = DfltQ2c_40_rl;
config.DfltQ2c_40_lr = DfltQ2c_40_lr;
config.UseWebService = UseWebService;
config.BaseUrl = BaseUrl;
config.RelativeUrl = RelativeUrl;
if ((flags & CfgUpdateFlags.InvokeCfgChange) != 0)
{
TestMethod.OnCfgChange(this, new CfgChangeArgs(CfgChangeCmd.CfgChange, config));
}
return flags;
}
private void ManageCheckGroupBox(CheckBox chk, GroupBox grp)
{
/// Make sure the CheckBox isn't in the GroupBox. This will only happen the first time.
if (chk.Parent == grp)
{
grp.Parent.Controls.Add(chk); /// Reparent the CheckBox so it's not in the GroupBox.
chk.Location = new System.Drawing.Point(chk.Left + grp.Left, chk.Top + grp.Top); /// Adjust the CheckBox's location.
chk.BringToFront(); /// Move the CheckBox to the top of the stacking order.
}
/// Enable or disable the GroupBox.
grp.Enabled = chk.Checked;
}
private void useWebServiceCheckBox_CheckedChanged(object sender, EventArgs e)
{
useWebServiceGroupBox.Enabled = useWebServiceCheckBox.Checked;
}
}
}

View File

@ -0,0 +1,520 @@
///
/// Copyright (c) 2015 Sensus Metering Systems
/// Author: Milan Hanajík
///
namespace TBF.Rig.TestMethods.SmartMeterFlyingStartMassCollection
{
partial class TestMethodCfgCtrl
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.nameTextBox = new System.Windows.Forms.TextBox();
this.nameLabel = new System.Windows.Forms.Label();
this.classNameLabel = new System.Windows.Forms.Label();
this.commTimeoutTextBox = new System.Windows.Forms.TextBox();
this.commTimeoutLabel = new System.Windows.Forms.Label();
this.maxCommRetriesTextBox = new System.Windows.Forms.TextBox();
this.maxNrRetriesLabel = new System.Windows.Forms.Label();
this.nrThreadsTextBox = new System.Windows.Forms.TextBox();
this.nrThreadsLabel = new System.Windows.Forms.Label();
this.iperlCheckErrorsToStopTextBox = new System.Windows.Forms.TextBox();
this.iperlCheckErrorsToStopLabel = new System.Windows.Forms.Label();
this.delayBetweenRetriesTextBox = new System.Windows.Forms.TextBox();
this.delayBetweenRetriesLabel = new System.Windows.Forms.Label();
this.relativeUrlTextBox = new System.Windows.Forms.TextBox();
this.relativeUrlLabel = new System.Windows.Forms.Label();
this.baseUrlTextBox = new System.Windows.Forms.TextBox();
this.baseUrlLabel = new System.Windows.Forms.Label();
this.useWebServiceCheckBox = new System.Windows.Forms.CheckBox();
this.useWebServiceGroupBox = new System.Windows.Forms.GroupBox();
this.dfltQ2corrFactorsGroupBox = new System.Windows.Forms.GroupBox();
this.label8 = new System.Windows.Forms.Label();
this.label7 = new System.Windows.Forms.Label();
this.label6 = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.textBox40lr = new System.Windows.Forms.TextBox();
this.textBox32lr = new System.Windows.Forms.TextBox();
this.textBox25_10lr = new System.Windows.Forms.TextBox();
this.textBox25_63lr = new System.Windows.Forms.TextBox();
this.textBox20lr = new System.Windows.Forms.TextBox();
this.textBox15lr = new System.Windows.Forms.TextBox();
this.textBox40rl = new System.Windows.Forms.TextBox();
this.textBox32rl = new System.Windows.Forms.TextBox();
this.textBox25_10rl = new System.Windows.Forms.TextBox();
this.textBox25_63rl = new System.Windows.Forms.TextBox();
this.textBox20rl = new System.Windows.Forms.TextBox();
this.textBox15rl = new System.Windows.Forms.TextBox();
this.useWebServiceGroupBox.SuspendLayout();
this.dfltQ2corrFactorsGroupBox.SuspendLayout();
this.SuspendLayout();
//
// nameTextBox
//
this.nameTextBox.Enabled = false;
this.nameTextBox.Location = new System.Drawing.Point(237, 31);
this.nameTextBox.Name = "nameTextBox";
this.nameTextBox.Size = new System.Drawing.Size(130, 20);
this.nameTextBox.TabIndex = 2;
//
// nameLabel
//
this.nameLabel.AutoSize = true;
this.nameLabel.Location = new System.Drawing.Point(23, 34);
this.nameLabel.Name = "nameLabel";
this.nameLabel.Size = new System.Drawing.Size(35, 13);
this.nameLabel.TabIndex = 1;
this.nameLabel.Text = "Name";
//
// classNameLabel
//
this.classNameLabel.AutoSize = true;
this.classNameLabel.Location = new System.Drawing.Point(234, 11);
this.classNameLabel.Name = "classNameLabel";
this.classNameLabel.Size = new System.Drawing.Size(83, 13);
this.classNameLabel.TabIndex = 0;
this.classNameLabel.Text = "ComonentName";
//
// commTimeoutTextBox
//
this.commTimeoutTextBox.Enabled = false;
this.commTimeoutTextBox.Location = new System.Drawing.Point(237, 53);
this.commTimeoutTextBox.Name = "commTimeoutTextBox";
this.commTimeoutTextBox.Size = new System.Drawing.Size(45, 20);
this.commTimeoutTextBox.TabIndex = 4;
//
// commTimeoutLabel
//
this.commTimeoutLabel.AutoSize = true;
this.commTimeoutLabel.Location = new System.Drawing.Point(23, 56);
this.commTimeoutLabel.Name = "commTimeoutLabel";
this.commTimeoutLabel.Size = new System.Drawing.Size(98, 13);
this.commTimeoutLabel.TabIndex = 3;
this.commTimeoutLabel.Text = "Comm. timeout [ms]";
//
// maxCommRetriesTextBox
//
this.maxCommRetriesTextBox.Enabled = false;
this.maxCommRetriesTextBox.Location = new System.Drawing.Point(237, 75);
this.maxCommRetriesTextBox.Name = "maxCommRetriesTextBox";
this.maxCommRetriesTextBox.Size = new System.Drawing.Size(45, 20);
this.maxCommRetriesTextBox.TabIndex = 6;
//
// maxNrRetriesLabel
//
this.maxNrRetriesLabel.AutoSize = true;
this.maxNrRetriesLabel.Location = new System.Drawing.Point(23, 78);
this.maxNrRetriesLabel.Name = "maxNrRetriesLabel";
this.maxNrRetriesLabel.Size = new System.Drawing.Size(61, 13);
this.maxNrRetriesLabel.TabIndex = 5;
this.maxNrRetriesLabel.Text = "Max. retries";
//
// nrThreadsTextBox
//
this.nrThreadsTextBox.Enabled = false;
this.nrThreadsTextBox.Location = new System.Drawing.Point(237, 119);
this.nrThreadsTextBox.Name = "nrThreadsTextBox";
this.nrThreadsTextBox.Size = new System.Drawing.Size(45, 20);
this.nrThreadsTextBox.TabIndex = 10;
//
// nrThreadsLabel
//
this.nrThreadsLabel.AutoSize = true;
this.nrThreadsLabel.Location = new System.Drawing.Point(23, 122);
this.nrThreadsLabel.Name = "nrThreadsLabel";
this.nrThreadsLabel.Size = new System.Drawing.Size(59, 13);
this.nrThreadsLabel.TabIndex = 9;
this.nrThreadsLabel.Text = "Nr. threads";
//
// iperlCheckErrorsToStopTextBox
//
this.iperlCheckErrorsToStopTextBox.Enabled = false;
this.iperlCheckErrorsToStopTextBox.Location = new System.Drawing.Point(237, 141);
this.iperlCheckErrorsToStopTextBox.Name = "iperlCheckErrorsToStopTextBox";
this.iperlCheckErrorsToStopTextBox.Size = new System.Drawing.Size(45, 20);
this.iperlCheckErrorsToStopTextBox.TabIndex = 13;
//
// iperlCheckErrorsToStopLabel
//
this.iperlCheckErrorsToStopLabel.AutoSize = true;
this.iperlCheckErrorsToStopLabel.Location = new System.Drawing.Point(23, 144);
this.iperlCheckErrorsToStopLabel.Name = "iperlCheckErrorsToStopLabel";
this.iperlCheckErrorsToStopLabel.Size = new System.Drawing.Size(202, 13);
this.iperlCheckErrorsToStopLabel.TabIndex = 12;
this.iperlCheckErrorsToStopLabel.Text = "iperl_check errors count to stop the cycle";
//
// delayBetweenRetriesTextBox
//
this.delayBetweenRetriesTextBox.Enabled = false;
this.delayBetweenRetriesTextBox.Location = new System.Drawing.Point(237, 97);
this.delayBetweenRetriesTextBox.Name = "delayBetweenRetriesTextBox";
this.delayBetweenRetriesTextBox.Size = new System.Drawing.Size(45, 20);
this.delayBetweenRetriesTextBox.TabIndex = 8;
//
// delayBetweenRetriesLabel
//
this.delayBetweenRetriesLabel.AutoSize = true;
this.delayBetweenRetriesLabel.Location = new System.Drawing.Point(23, 100);
this.delayBetweenRetriesLabel.Name = "delayBetweenRetriesLabel";
this.delayBetweenRetriesLabel.Size = new System.Drawing.Size(131, 13);
this.delayBetweenRetriesLabel.TabIndex = 7;
this.delayBetweenRetriesLabel.Text = "Delay between retries [ms]";
//
// relativeUrlTextBox
//
this.relativeUrlTextBox.Enabled = false;
this.relativeUrlTextBox.Location = new System.Drawing.Point(89, 50);
this.relativeUrlTextBox.Name = "relativeUrlTextBox";
this.relativeUrlTextBox.Size = new System.Drawing.Size(298, 20);
this.relativeUrlTextBox.TabIndex = 18;
//
// relativeUrlLabel
//
this.relativeUrlLabel.AutoSize = true;
this.relativeUrlLabel.Location = new System.Drawing.Point(13, 53);
this.relativeUrlLabel.Name = "relativeUrlLabel";
this.relativeUrlLabel.Size = new System.Drawing.Size(71, 13);
this.relativeUrlLabel.TabIndex = 17;
this.relativeUrlLabel.Text = "Relative URL";
//
// baseUrlTextBox
//
this.baseUrlTextBox.Enabled = false;
this.baseUrlTextBox.Location = new System.Drawing.Point(89, 24);
this.baseUrlTextBox.Name = "baseUrlTextBox";
this.baseUrlTextBox.Size = new System.Drawing.Size(298, 20);
this.baseUrlTextBox.TabIndex = 16;
//
// baseUrlLabel
//
this.baseUrlLabel.AutoSize = true;
this.baseUrlLabel.Location = new System.Drawing.Point(13, 27);
this.baseUrlLabel.Name = "baseUrlLabel";
this.baseUrlLabel.Size = new System.Drawing.Size(56, 13);
this.baseUrlLabel.TabIndex = 15;
this.baseUrlLabel.Text = "Base URL";
//
// useWebServiceCheckBox
//
this.useWebServiceCheckBox.AutoSize = true;
this.useWebServiceCheckBox.Enabled = false;
this.useWebServiceCheckBox.Location = new System.Drawing.Point(15, 0);
this.useWebServiceCheckBox.Name = "useWebServiceCheckBox";
this.useWebServiceCheckBox.Size = new System.Drawing.Size(189, 17);
this.useWebServiceCheckBox.TabIndex = 14;
this.useWebServiceCheckBox.Text = "Use web service for default values";
this.useWebServiceCheckBox.UseVisualStyleBackColor = true;
this.useWebServiceCheckBox.CheckedChanged += new System.EventHandler(this.useWebServiceCheckBox_CheckedChanged);
//
// useWebServiceGroupBox
//
this.useWebServiceGroupBox.Controls.Add(this.baseUrlTextBox);
this.useWebServiceGroupBox.Controls.Add(this.useWebServiceCheckBox);
this.useWebServiceGroupBox.Controls.Add(this.relativeUrlTextBox);
this.useWebServiceGroupBox.Controls.Add(this.relativeUrlLabel);
this.useWebServiceGroupBox.Controls.Add(this.baseUrlLabel);
this.useWebServiceGroupBox.Location = new System.Drawing.Point(11, 266);
this.useWebServiceGroupBox.Name = "useWebServiceGroupBox";
this.useWebServiceGroupBox.Size = new System.Drawing.Size(404, 83);
this.useWebServiceGroupBox.TabIndex = 0;
this.useWebServiceGroupBox.TabStop = false;
//
// dfltQ2corrFactorsGroupBox
//
this.dfltQ2corrFactorsGroupBox.Controls.Add(this.label8);
this.dfltQ2corrFactorsGroupBox.Controls.Add(this.label7);
this.dfltQ2corrFactorsGroupBox.Controls.Add(this.label6);
this.dfltQ2corrFactorsGroupBox.Controls.Add(this.label5);
this.dfltQ2corrFactorsGroupBox.Controls.Add(this.label4);
this.dfltQ2corrFactorsGroupBox.Controls.Add(this.label3);
this.dfltQ2corrFactorsGroupBox.Controls.Add(this.label2);
this.dfltQ2corrFactorsGroupBox.Controls.Add(this.label1);
this.dfltQ2corrFactorsGroupBox.Controls.Add(this.textBox40lr);
this.dfltQ2corrFactorsGroupBox.Controls.Add(this.textBox32lr);
this.dfltQ2corrFactorsGroupBox.Controls.Add(this.textBox25_10lr);
this.dfltQ2corrFactorsGroupBox.Controls.Add(this.textBox25_63lr);
this.dfltQ2corrFactorsGroupBox.Controls.Add(this.textBox20lr);
this.dfltQ2corrFactorsGroupBox.Controls.Add(this.textBox15lr);
this.dfltQ2corrFactorsGroupBox.Controls.Add(this.textBox40rl);
this.dfltQ2corrFactorsGroupBox.Controls.Add(this.textBox32rl);
this.dfltQ2corrFactorsGroupBox.Controls.Add(this.textBox25_10rl);
this.dfltQ2corrFactorsGroupBox.Controls.Add(this.textBox25_63rl);
this.dfltQ2corrFactorsGroupBox.Controls.Add(this.textBox20rl);
this.dfltQ2corrFactorsGroupBox.Controls.Add(this.textBox15rl);
this.dfltQ2corrFactorsGroupBox.Location = new System.Drawing.Point(11, 175);
this.dfltQ2corrFactorsGroupBox.Name = "dfltQ2corrFactorsGroupBox";
this.dfltQ2corrFactorsGroupBox.Size = new System.Drawing.Size(404, 85);
this.dfltQ2corrFactorsGroupBox.TabIndex = 14;
this.dfltQ2corrFactorsGroupBox.TabStop = false;
this.dfltQ2corrFactorsGroupBox.Text = "Default Q2 correction factors";
//
// label8
//
this.label8.AutoSize = true;
this.label8.Location = new System.Drawing.Point(344, 17);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(35, 13);
this.label8.TabIndex = 19;
this.label8.Text = "DN40";
//
// label7
//
this.label7.AutoSize = true;
this.label7.Location = new System.Drawing.Point(289, 17);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(35, 13);
this.label7.TabIndex = 18;
this.label7.Text = "DN32";
//
// label6
//
this.label6.AutoSize = true;
this.label6.Location = new System.Drawing.Point(233, 17);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(45, 13);
this.label6.TabIndex = 17;
this.label6.Text = "...Q3 10";
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(163, 17);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(70, 13);
this.label5.TabIndex = 16;
this.label5.Text = "DN25 Q3 6.3";
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(121, 17);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(35, 13);
this.label4.TabIndex = 15;
this.label4.Text = "DN20";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(65, 17);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(35, 13);
this.label3.TabIndex = 14;
this.label3.Text = "DN15";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(22, 57);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(24, 13);
this.label2.TabIndex = 13;
this.label2.Text = "L-R";
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(22, 34);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(24, 13);
this.label1.TabIndex = 12;
this.label1.Text = "R-L";
//
// textBox40lr
//
this.textBox40lr.Enabled = false;
this.textBox40lr.Location = new System.Drawing.Point(337, 54);
this.textBox40lr.Name = "textBox40lr";
this.textBox40lr.Size = new System.Drawing.Size(50, 20);
this.textBox40lr.TabIndex = 11;
//
// textBox32lr
//
this.textBox32lr.Enabled = false;
this.textBox32lr.Location = new System.Drawing.Point(281, 54);
this.textBox32lr.Name = "textBox32lr";
this.textBox32lr.Size = new System.Drawing.Size(50, 20);
this.textBox32lr.TabIndex = 10;
//
// textBox25_10lr
//
this.textBox25_10lr.Enabled = false;
this.textBox25_10lr.Location = new System.Drawing.Point(225, 54);
this.textBox25_10lr.Name = "textBox25_10lr";
this.textBox25_10lr.Size = new System.Drawing.Size(50, 20);
this.textBox25_10lr.TabIndex = 9;
//
// textBox25_63lr
//
this.textBox25_63lr.Enabled = false;
this.textBox25_63lr.Location = new System.Drawing.Point(169, 54);
this.textBox25_63lr.Name = "textBox25_63lr";
this.textBox25_63lr.Size = new System.Drawing.Size(50, 20);
this.textBox25_63lr.TabIndex = 8;
//
// textBox20lr
//
this.textBox20lr.Enabled = false;
this.textBox20lr.Location = new System.Drawing.Point(113, 54);
this.textBox20lr.Name = "textBox20lr";
this.textBox20lr.Size = new System.Drawing.Size(50, 20);
this.textBox20lr.TabIndex = 7;
//
// textBox15lr
//
this.textBox15lr.Enabled = false;
this.textBox15lr.Location = new System.Drawing.Point(57, 54);
this.textBox15lr.Name = "textBox15lr";
this.textBox15lr.Size = new System.Drawing.Size(50, 20);
this.textBox15lr.TabIndex = 6;
//
// textBox40rl
//
this.textBox40rl.Enabled = false;
this.textBox40rl.Location = new System.Drawing.Point(337, 31);
this.textBox40rl.Name = "textBox40rl";
this.textBox40rl.Size = new System.Drawing.Size(50, 20);
this.textBox40rl.TabIndex = 5;
//
// textBox32rl
//
this.textBox32rl.Enabled = false;
this.textBox32rl.Location = new System.Drawing.Point(281, 31);
this.textBox32rl.Name = "textBox32rl";
this.textBox32rl.Size = new System.Drawing.Size(50, 20);
this.textBox32rl.TabIndex = 4;
//
// textBox25_10rl
//
this.textBox25_10rl.Enabled = false;
this.textBox25_10rl.Location = new System.Drawing.Point(225, 31);
this.textBox25_10rl.Name = "textBox25_10rl";
this.textBox25_10rl.Size = new System.Drawing.Size(50, 20);
this.textBox25_10rl.TabIndex = 3;
//
// textBox25_63rl
//
this.textBox25_63rl.Enabled = false;
this.textBox25_63rl.Location = new System.Drawing.Point(169, 31);
this.textBox25_63rl.Name = "textBox25_63rl";
this.textBox25_63rl.Size = new System.Drawing.Size(50, 20);
this.textBox25_63rl.TabIndex = 2;
//
// textBox20rl
//
this.textBox20rl.Enabled = false;
this.textBox20rl.Location = new System.Drawing.Point(113, 31);
this.textBox20rl.Name = "textBox20rl";
this.textBox20rl.Size = new System.Drawing.Size(50, 20);
this.textBox20rl.TabIndex = 1;
//
// textBox15rl
//
this.textBox15rl.Enabled = false;
this.textBox15rl.Location = new System.Drawing.Point(57, 31);
this.textBox15rl.Name = "textBox15rl";
this.textBox15rl.Size = new System.Drawing.Size(50, 20);
this.textBox15rl.TabIndex = 0;
//
// TestMethodCfgCtrl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.dfltQ2corrFactorsGroupBox);
this.Controls.Add(this.useWebServiceGroupBox);
this.Controls.Add(this.delayBetweenRetriesTextBox);
this.Controls.Add(this.delayBetweenRetriesLabel);
this.Controls.Add(this.iperlCheckErrorsToStopTextBox);
this.Controls.Add(this.iperlCheckErrorsToStopLabel);
this.Controls.Add(this.nrThreadsTextBox);
this.Controls.Add(this.nrThreadsLabel);
this.Controls.Add(this.maxCommRetriesTextBox);
this.Controls.Add(this.maxNrRetriesLabel);
this.Controls.Add(this.commTimeoutTextBox);
this.Controls.Add(this.commTimeoutLabel);
this.Controls.Add(this.nameTextBox);
this.Controls.Add(this.nameLabel);
this.Controls.Add(this.classNameLabel);
this.Name = "TestMethodCfgCtrl";
this.Size = new System.Drawing.Size(427, 363);
this.Load += new System.EventHandler(this.EntryFormCfgCtrl_Load);
this.useWebServiceGroupBox.ResumeLayout(false);
this.useWebServiceGroupBox.PerformLayout();
this.dfltQ2corrFactorsGroupBox.ResumeLayout(false);
this.dfltQ2corrFactorsGroupBox.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.TextBox nameTextBox;
private System.Windows.Forms.Label nameLabel;
private System.Windows.Forms.Label classNameLabel;
private System.Windows.Forms.TextBox commTimeoutTextBox;
private System.Windows.Forms.Label commTimeoutLabel;
private System.Windows.Forms.TextBox maxCommRetriesTextBox;
private System.Windows.Forms.Label maxNrRetriesLabel;
private System.Windows.Forms.TextBox nrThreadsTextBox;
private System.Windows.Forms.Label nrThreadsLabel;
private System.Windows.Forms.TextBox iperlCheckErrorsToStopTextBox;
private System.Windows.Forms.Label iperlCheckErrorsToStopLabel;
private System.Windows.Forms.TextBox delayBetweenRetriesTextBox;
private System.Windows.Forms.Label delayBetweenRetriesLabel;
private System.Windows.Forms.TextBox relativeUrlTextBox;
private System.Windows.Forms.Label relativeUrlLabel;
private System.Windows.Forms.TextBox baseUrlTextBox;
private System.Windows.Forms.Label baseUrlLabel;
private System.Windows.Forms.CheckBox useWebServiceCheckBox;
private System.Windows.Forms.GroupBox useWebServiceGroupBox;
private System.Windows.Forms.GroupBox dfltQ2corrFactorsGroupBox;
private System.Windows.Forms.Label label8;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox textBox40lr;
private System.Windows.Forms.TextBox textBox32lr;
private System.Windows.Forms.TextBox textBox25_10lr;
private System.Windows.Forms.TextBox textBox25_63lr;
private System.Windows.Forms.TextBox textBox20lr;
private System.Windows.Forms.TextBox textBox15lr;
private System.Windows.Forms.TextBox textBox40rl;
private System.Windows.Forms.TextBox textBox32rl;
private System.Windows.Forms.TextBox textBox25_10rl;
private System.Windows.Forms.TextBox textBox25_63rl;
private System.Windows.Forms.TextBox textBox20rl;
private System.Windows.Forms.TextBox textBox15rl;
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -15,7 +15,7 @@ using TestMethodCfg = TBF.Rig.RegisterReaders.iPerlReaderUNI.TestMethodCfg;
namespace TBF.Rig.TestMethods.SmartTest namespace TBF.Rig.TestMethods.SmartTest
{ {
public class TestMethod : SmartComponentBase, ISimultTestMethod, ISequenceCondition, ISessionDataMngmnt, ISmartTestMethod public class TestMethod : SmartComponentBase, ISimultTestMethod, ISequenceCondition, ISessionDataMngmnt
{ {
private static readonly ILog log = LogManager.GetLogger(typeof(TestMethod)); private static readonly ILog log = LogManager.GetLogger(typeof(TestMethod));
protected static readonly ILog rfidDataLogger = LogManager.GetLogger("RfidData"); protected static readonly ILog rfidDataLogger = LogManager.GetLogger("RfidData");
@ -73,7 +73,7 @@ namespace TBF.Rig.TestMethods.SmartTest
#endregion Configuration Change Handling #endregion Configuration Change Handling
readonly TestMethodCfg testMethodCfg; public readonly TestMethodCfg testMethodCfg;
public bool[] IperlCommMilestone; public bool[] IperlCommMilestone;
IList<IOperation> sequenceConditionOps; IList<IOperation> sequenceConditionOps;

View File

@ -9,11 +9,12 @@ using Config.Entities;
using TBF.Rig.Generic; using TBF.Rig.Generic;
using TBF.Rig.GenericDevices; using TBF.Rig.GenericDevices;
using TBF.Rig.Sequences; using TBF.Rig.Sequences;
using TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication;
using TBF.UiBridge; using TBF.UiBridge;
namespace TBF.Rig.TestMethods.iPerlCommunication namespace TBF.Rig.TestMethods.iPerlCommunication
{ {
public class TestMethod : ComponentBase, ISimultTestMethod, ISequenceCondition, ISessionDataMngmnt public class TestMethod : SmartComponentBase, ISimultTestMethod, ISequenceCondition, ISessionDataMngmnt
{ {
private static readonly ILog log = LogManager.GetLogger(typeof(TestMethod)); private static readonly ILog log = LogManager.GetLogger(typeof(TestMethod));
protected static readonly ILog rfidDataLogger = LogManager.GetLogger("RfidData"); protected static readonly ILog rfidDataLogger = LogManager.GetLogger("RfidData");
@ -164,5 +165,15 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
message = "Device capabilities check not implemented."; message = "Device capabilities check not implemented.";
return true; return true;
} }
public override void MeterCommMilestone(int iItem, bool bValue)
{
throw new NotImplementedException();
}
public override bool IsMeterCommMilestone(int iItem)
{
throw new NotImplementedException();
}
} }
} }

View File

@ -9,6 +9,7 @@ using Common;
using Config.Entities; using Config.Entities;
using TBF.Rig.Generic; using TBF.Rig.Generic;
using TBF.Rig.RegisterReaders.CommonRR.IPerl; using TBF.Rig.RegisterReaders.CommonRR.IPerl;
using TBF.Rig.TestMethods.SmartMeterFlyingStartMassCollection;
namespace TBF.Rig.TestMethods.iPerlCommunication namespace TBF.Rig.TestMethods.iPerlCommunication
{ {
@ -31,7 +32,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
/// Private parameterless constructor invoked by all other (public) constructors /// Private parameterless constructor invoked by all other (public) constructors
TestMethodCfg_IPerl() TestMethodCfg_IPerl()
{ {
Name = "iPerlCommunication"; Name = "SmartCommunication";
ParentName = string.Empty; ParentName = string.Empty;
CommTimeout = 1800; /// ms CommTimeout = 1800; /// ms
MaxCommRetries = 4; MaxCommRetries = 4;

View File

@ -14,6 +14,7 @@ using Sensus.iPerl.NfcHandler;
using NHibernate; using NHibernate;
using Renci.SshNet; using Renci.SshNet;
using System.Linq; using System.Linq;
using System.Text.RegularExpressions;
using System.Xml; using System.Xml;
using System.Xml.Linq; // This line is correct and does not need to be changed. using System.Xml.Linq; // This line is correct and does not need to be changed.
using System.Windows; using System.Windows;
@ -53,13 +54,38 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead
public iPerlHead.MeterType MeterType { get { return iperlHeadCfg.MeterType; } } public iPerlHead.MeterType MeterType { get { return iperlHeadCfg.MeterType; } }
public string CommInterface { get { return iperlHeadCfg.CommunicationInterface.ToDescription(); } } 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 public int Position
{ {
get get
{ {
int firstDigitPos = Name.IndexOfAny(new char[] { '1', '2', '3', '4', '5', '6', '7', '8', '9', '0' }); //BUMI this is a hack to get the position from the name
int position; // but it is not working for all cases !!!!!
return (firstDigitPos < 0) ? 0 : (int.TryParse(Name.Substring(firstDigitPos), out position) ? position : 0); // - 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; } } public RegisterReaderType RegisterReaderType { get { return RegisterReaderType.DataStream; } }

View File

@ -6,16 +6,22 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Windows.Forms; using System.Windows.Forms;
using Config.Entities; using Config.Entities;
using log4net; using log4net;
using NHibernate.Util;
using TBF.Resources; using TBF.Resources;
using TBF.Rig.Generic; using TBF.Rig.Generic;
using TBF.Rig.RegisterReaders.CommonRR.IPerl; using TBF.Rig.RegisterReaders.CommonRR.IPerl;
using TBF.Rig.RegisterReaders.iPerlReaderUNI; using TBF.Rig.RegisterReaders.iPerlReaderUNI;
using TBF.Rig.RegisterReaders.PoseidonReader;
using TBF.Rig.Sequences; using TBF.Rig.Sequences;
using TBF.Rig.TestMethods.iPerlCommunication.iPerlHead;
using TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication.common; using TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication.common;
using TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication.implementations; using TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication.implementations;
using TBF.Tools;
using CheckBoxImage = TBF.Boxes.CheckBoxImage; using CheckBoxImage = TBF.Boxes.CheckBoxImage;
//using TestMethodCfg = TBF.Rig.RegisterReaders.iPerlReaderUNI.TestMethodCfg; //using TestMethodCfg = TBF.Rig.RegisterReaders.iPerlReaderUNI.TestMethodCfg;
@ -81,21 +87,151 @@ namespace TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication
static IList<int> waterMeterPositions0; /// keeps original 0-based indices in RegisterReaders list static IList<int> waterMeterPositions0; /// keeps original 0-based indices in RegisterReaders list
static int commonWMType; static int commonWMType;
//share form to correction solver
public IList<ISmartReader> Heads { get => iperlHeads; }
public ILog Log { get => SmartCommunicationForm.log; }
public ILog RfidDataLogger { get => SmartCommunicationForm.rfidDataLogger; }
public Label ActivityLabel { get => this.activityLabel; }
public Label[] Labels { get => this.labels; }
public PictureBox[] Counters { get => this.counters; }
public TextBox[] Messages { get => this.messages; }
public CheckBoxImage[] CheckBoxes { get => this.checkBoxes; }
public int[] CkbIndex { get => SmartCommunicationForm.ckbIndex; }
public bool[] CkbState { get => SmartCommunicationForm.ckbState; }
/// ///
/// RFID multiplexer PCB / RFID serial port and worker thread related variables /// RFID multiplexer PCB / RFID serial port and worker thread related variables
/// ///
private static ICorrections _corrections; private static List<ICorrections> _corrections;
private static ICorrections Correction
private static ICorrections GetNewCorrections(SmartCommunicationForm form)
{ {
Object version = new IPerlCorrections(form, log, rfidDataLogger); get
//TODO BUMI - work with !!!!!!!!!!!!!! ProcessData.IperlHeads; {
if (string.IsNullOrEmpty(SelectedTypeReader) && _corrections.Count > 0)
{
return _corrections.First();
}
if (version is IPerlCorrections) foreach (ICorrections correction in _corrections)
return new IPerlCorrections(form, log, rfidDataLogger); {
else if (SelectedTypeReader == correction.TypeIdentificatorName())
return new PoseidonCorrections(form, log, rfidDataLogger); {
return correction;
}
}
if (_corrections.Count > 0)
{
return _corrections.First();
}
return null;
}
}
private List<string> TypeReaders
{
get { return IdentifyReaderTypes(); }
}
public static string SelectedTypeReader { get; set; }
private List<ICorrections> GetNewCorrectionList(ISmartTestMethod componentBase ,
TestMethodCfg cfg, IList<Test> tests, IList<ITestParams> multiTestParams)
{
List<ICorrections> correctionsList = new List<ICorrections>();
foreach (var smartHead in ProcessData.SmartHeadsUni)
{
try{
if (smartHead is IperlHead iperlHead)
{
if (correctionsList.Any(x => x is IPerlCorrections))
continue;
correctionsList.Add(new IPerlCorrections( this,componentBase, cfg, tests, multiTestParams));
continue;
}
if (smartHead is SmartReader smartReader)
{
if (correctionsList.Any(x => x is SmartReader))
continue;
correctionsList.Add(new PoseidonCorrections(this));
continue;
}
throw new Exception("Unknown smart head type");
}
catch (Exception e)
{
log.Error("IdentifyReaderTypes()", e);
}
}
return correctionsList;
}
private static List<ICorrections> GetNewCorrectionList(SmartCommunicationForm form)
{
List<ICorrections> correctionsList = new List<ICorrections>();
foreach (var smartHead in ProcessData.SmartHeadsUni)
{
try{
if (smartHead is IperlHead iperlHead)
{
if (correctionsList.Any(x => x is IPerlCorrections))
continue;
correctionsList.Add(new IPerlCorrections(form));
continue;
}
if (smartHead is SmartReader smartReader)
{
if (correctionsList.Any(x => x is SmartReader))
continue;
correctionsList.Add(new PoseidonCorrections(form));
continue;
}
throw new Exception("Unknown smart head type");
}
catch (Exception e)
{
log.Error("IdentifyReaderTypes()", e);
}
}
return correctionsList;
}
public static List<string> IdentifyReaderTypes()
{
List<string> typeReaders = new List<string>();
foreach (var smartHead in ProcessData.SmartHeadsUni)
{
try
{
if (typeReaders.Contains(smartHead.ClassName))
continue;
if (smartHead is IperlHead iperlHead)
{
typeReaders.Add(iperlHead.ClassName);
continue;
}
if (smartHead is SmartReader smartReader)
{
typeReaders.Add(smartReader.ClassName);
continue;
}
throw new Exception("Unknown smart head type");
}
catch (Exception e)
{
log.Error("IdentifyReaderTypes()", e);
}
}
return typeReaders;
} }
public static ITestMethodCfg? TestMethodCfg public static ITestMethodCfg? TestMethodCfg
@ -103,9 +239,7 @@ namespace TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication
get get
{ {
return _corrections != null? return Correction?.Cfg;
_corrections.Cfg :
null;
} }
set set
{ {
@ -116,12 +250,15 @@ namespace TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication
return; return;
} }
if (_corrections == null) if (_corrections == null || _corrections.Count == 0)
{ {
_corrections = GetNewCorrections(null); _corrections = GetNewCorrectionList(null);
} }
_corrections.Cfg = value; foreach (var correction in _corrections)
{
correction.Cfg = value;
}
} }
@ -150,7 +287,8 @@ namespace TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication
: this() : this()
{ {
//TODO get corrections based on defined meter //TODO get corrections based on defined meter
_corrections = new IPerlCorrections(this, log, rfidDataLogger); // default iPerl Head communication params _corrections = GetNewCorrectionList(this); // default iPerl Head communication params
InitializeMeterTypeItems();
if (isCheckBoxesEditMode) if (isCheckBoxesEditMode)
{ {
checkBoxesEditMode = true; checkBoxesEditMode = true;
@ -159,9 +297,13 @@ namespace TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication
ShuffleTextBoxes(ProcessData.WMsCount, ProcessData.LineSize); ShuffleTextBoxes(ProcessData.WMsCount, ProcessData.LineSize);
this.ContextMenu = _corrections.GetContextMenu(); this.ContextMenu = Correction.GetContextMenu();
} }
InitializeWaterMeterData();
if (iperlHeads.Count <= 0)
UpdateHeads();
} }
@ -184,7 +326,12 @@ namespace TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication
checkBoxesEditMode = false; checkBoxesEditMode = false;
//TODO get corrections based on defined meter //TODO get corrections based on defined meter
_corrections = new PoseidonCorrections(this, log, rfidDataLogger, componentBase as ISmartTestMethod,componentBase.Cfg as TestMethodCfg,tests,multiTestParams); _corrections = GetNewCorrectionList(componentBase as ISmartTestMethod,
componentBase.Cfg as TestMethodCfg, tests, multiTestParams);
InitializeMeterTypeItems();
UpdateHeads();
//_corrections = new PoseidonCorrections(this, log, rfidDataLogger, componentBase as ISmartTestMethod,componentBase.Cfg as TestMethodCfg,tests,multiTestParams);
if (multiTestParams.Count > 0) if (multiTestParams.Count > 0)
@ -228,6 +375,91 @@ namespace TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication
StartForceCloseHandler(); StartForceCloseHandler();
InitializeWaterMeterData();
}
private void UpdateHeads()
{
iperlHeads?.Clear();
if (iperlHeads == null) iperlHeads = new List<ISmartReader>();
waterMeterPositions0?.Clear();
if (waterMeterPositions0 == null) waterMeterPositions0 = new List<int>();
//iperlHeads = ProcessData.SmartHeadsUni;
string comparedTypeReader = SelectedTypeReader;
if (string.IsNullOrEmpty(SelectedTypeReader))
{
comparedTypeReader = ProcessData.SmartHeadsUni?.First()?.GetType().Name;
}
ICorrections corre = null;
foreach (ICorrections correction in _corrections)
{
if (correction.TypeIdentificatorName() == SelectedTypeReader)
{
corre = correction;
break;
}
}
if (corre != null)
{
int wmPos = 0;
foreach (var smartHead in ProcessData.SmartHeadsUni)
{
if (corre.IsFamilyOfSmartReader(smartHead))
{
iperlHeads.Add(smartHead);
waterMeterPositions0.Add(wmPos);
wmPos++;
if (wmPos >= ProcessData.WMsCount) break;
}
}
}
}
private void InitializeMeterTypeItems()
{
if (_corrections.Count >= 0)
{
meterTypeComboBox.Items.Clear();
int iItem = 0;
foreach (ICorrections correction in _corrections)
{
string name = correction?.TypeIdentificatorName();
if (string.IsNullOrEmpty(name))
{
name = iItem.ToString();
}
meterTypeComboBox.Items.Add(name);
if (iItem == 0)
SelectedTypeReader = name;
iItem++;
}
meterTypeComboBox.Visible = true;
meterTypeComboBox.Enabled = true;
meterTypeComboBox.SelectedIndex = 0;
}
}
private void InitializeWaterMeterData()
{
InitializeSmartReaderLists();
if (iperlHeads.Count <= 0)
UpdateHeads();
WaterMetersCount = iperlHeads.Count;
ShuffleTextBoxes(WaterMetersCount, ProcessData.LineSize);
Correction.PrepareForTestsActivities(WaterMetersCount);
}
/// <summary>
/// this part works fine if we are on <b>test loop</b>
/// - because ProcessData.RegisterReaders is initialized in test loop
/// </summary>
private static void InitializeSmartReaderLists()
{
iperlHeads = new List<ISmartReader>(); iperlHeads = new List<ISmartReader>();
waterMeterPositions0 = new List<int>(); waterMeterPositions0 = new List<int>();
/// ///
@ -235,17 +467,13 @@ namespace TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication
{ {
ISmartReader iperlHead = ProcessData.RegisterReaders[wmPos] as ISmartReader; ISmartReader iperlHead = ProcessData.RegisterReaders[wmPos] as ISmartReader;
if (iperlHead != null) if (iperlHead != null) // what if iperlHead should be null
{ {
iperlHeads.Add(iperlHead); iperlHeads.Add(iperlHead);
waterMeterPositions0.Add(wmPos); waterMeterPositions0.Add(wmPos);
} }
} }
WaterMetersCount = iperlHeads.Count;
ShuffleTextBoxes(WaterMetersCount, ProcessData.LineSize);
_corrections.PrepareForTestsActivities();
} }
/// <summary> /// <summary>
@ -261,7 +489,7 @@ namespace TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication
private void DoOnCommCompleted(object sender, CommCompletedEventArgs data) private void DoOnCommCompleted(object sender, CommCompletedEventArgs data)
{ {
_corrections.DoOnCommCompleted(sender, data, waterMeterPositions0); Correction.DoOnCommCompleted(sender, data, waterMeterPositions0);
} }
@ -314,7 +542,7 @@ namespace TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication
if (wmsCount < textBoxesCount && lineSize > 0) if (wmsCount < textBoxesCount && lineSize > 0)
{ {
int nrLines = (wmsCount + lineSize - 1) / lineSize; int nrLines = (wmsCount + lineSize - 1) / lineSize;
int gap = (textBoxesCount - wmsCount) / nrLines; int gap = nrLines==0? 0 : (textBoxesCount - wmsCount) / nrLines;
for (int i = 0; i < ckbIndex.Length; i++) for (int i = 0; i < ckbIndex.Length; i++)
{ {
@ -339,7 +567,7 @@ namespace TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication
textBoxesCount = wmsCount; textBoxesCount = wmsCount;
} }
int count = checkBoxesEditMode ? textBoxesCount : Math.Min(textBoxesCount, _corrections.GetHeadsCount()); int count = checkBoxesEditMode ? textBoxesCount : Math.Min(textBoxesCount, Correction.GetHeadsCount());
for (int j = 0; j < count; j++) for (int j = 0; j < count; j++)
{ {
labels[j].Text = (j + 1).ToString(); labels[j].Text = (j + 1).ToString();
@ -377,7 +605,7 @@ namespace TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication
} }
private void iPerlCommunicationForm_Load(object sender, EventArgs e) private void SmartCommunicationForm_Load(object sender, EventArgs e)
{ {
Localize(); Localize();
@ -392,7 +620,11 @@ namespace TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication
samplePictureBox3.Visible = false; samplePictureBox3.Visible = false;
} }
_corrections.Load(labels,counters,messages,checkBoxes,ckbIndex,ckbState, iperlHeads,textBoxesCount,checkBoxesEditMode ); if (_corrections.Count > 0)//enable combo for choose SmartMeter
{
meterTypeComboBox.Visible = true;
}
Correction.Load(labels,counters,messages,checkBoxes,ckbIndex,ckbState, iperlHeads,textBoxesCount,checkBoxesEditMode );
/// ///
/// Set location and checkbox states to values stored in local settings /// Set location and checkbox states to values stored in local settings
@ -407,7 +639,7 @@ namespace TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication
/// Regular activity (not a checkbox edit mode invoked from TBF menu) /// Regular activity (not a checkbox edit mode invoked from TBF menu)
/// Reset opto-data indication /// Reset opto-data indication
for (int i = 0; i < _corrections.GetHeadsCount(); i++) for (int i = 0; i < Correction.GetHeadsCount(); i++)
{ {
counters[i].BackColor = iPerlCommunicationConstants.OptoNokColor; counters[i].BackColor = iPerlCommunicationConstants.OptoNokColor;
} }
@ -416,7 +648,7 @@ namespace TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication
currentGroup++; currentGroup++;
int wtId = 0; int wtId = 0;
foreach (var wt in _corrections.GetAllThreads()) foreach (var wt in Correction.GetAllThreads())
{ {
wt.Start(new Boxes.IntBox(wtId++)); /// Start worker threads !!! wt.Start(new Boxes.IntBox(wtId++)); /// Start worker threads !!!
} }
@ -442,7 +674,7 @@ namespace TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication
CommCompletedHandler = null; CommCompletedHandler = null;
AllCompletedHandler = null; AllCompletedHandler = null;
_corrections?.StopWorkerThreads(true); Correction?.StopWorkerThreads(true);
forcedClose = true; forcedClose = true;
DialogResult = DialogResult.Cancel; DialogResult = DialogResult.Cancel;
@ -458,17 +690,12 @@ namespace TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication
/// <param name="threadData">Thread ID (integer) wrapped into IntBox</param> /// <param name="threadData">Thread ID (integer) wrapped into IntBox</param>
void Worker(object threadData) void Worker(object threadData)
{ {
Correction?.Worker(threadData);
if (_corrections != null)
{
_corrections.Worker(threadData);
}
} }
void StartDataStreamProcessingForActiveMeters(int iMultiTestParamsItem) void StartDataStreamProcessingForActiveMeters(int iMultiTestParamsItem)
{ {
_corrections.StartDataStreamProcessingForActiveMeters(iMultiTestParamsItem); Correction?.StartDataStreamProcessingForActiveMeters(iMultiTestParamsItem);
} }
/// <summary> /// <summary>
@ -615,7 +842,7 @@ namespace TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication
CommCompletedHandler = null; CommCompletedHandler = null;
AllCompletedHandler = null; AllCompletedHandler = null;
_corrections?.NormalClose(waterMeterPositions0); Correction?.NormalClose(waterMeterPositions0);
long checkboxStates = GetCheckBoxStates(); long checkboxStates = GetCheckBoxStates();
if (Program.LocalSettings.iPerlCommunicationsFormLeft != Location.X || if (Program.LocalSettings.iPerlCommunicationsFormLeft != Location.X ||
@ -636,5 +863,12 @@ namespace TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication
} }
private void meterTypeComboBox_SelectedIndexChanged(object sender, EventArgs e)
{
ComboBox senderCombo = sender as ComboBox;
if (senderCombo == null) return;
SelectedTypeReader = senderCombo.SelectedItem?.ToString();
UpdateHeads();
}
} }
} }

View File

@ -12,13 +12,15 @@ namespace TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication.common
{ {
public interface ICorrections public interface ICorrections
{ {
public string TypeIdentificatorName();
public DateTime StartTime { get; set; } public DateTime StartTime { get; set; }
public int StartTimeSec { get; set; } public int StartTimeSec { get; set; }
public SmartCommunicationForm ParentFrom { get; set; } public SmartCommunicationForm ParentFrom { get; set; }
public ITestMethodCfg Cfg { get ; set ; } public ITestMethodCfg Cfg { get ; set ; }
public IList<ITestParams> MultiTestParams {get ;} public IList<ITestParams> MultiTestParams {get ;}
public IList<Config.Entities.Test> Tests {get ;} public IList<Config.Entities.Test> Tests { get ; set; }
IList<ISmartReader> iperlHeads { get; }
public void Worker(object threadData); public void Worker(object threadData);
public bool WorkerActivity(string currentActivity, ISmartReader iHead, WaterMeter wm, Test currentTest, public bool WorkerActivity(string currentActivity, ISmartReader iHead, WaterMeter wm, Test currentTest,
@ -46,7 +48,7 @@ namespace TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication.common
ICorrections GetNewCorrection(); ICorrections GetNewCorrection();
void GetGroup(); void GetGroup();
ContextMenu GetContextMenu(); ContextMenu GetContextMenu();
void PrepareForTestsActivities(); void PrepareForTestsActivities(int waterMeterPositions0);
void Load(Label[] labels, PictureBox[] counters, TextBox[] messages, CheckBoxImage[] checkBoxes, int[] ckbIndex, void Load(Label[] labels, PictureBox[] counters, TextBox[] messages, CheckBoxImage[] checkBoxes, int[] ckbIndex,
bool[] ckbState, IList<ISmartReader> iperlHeads, int textBoxesCount, bool checkBoxesEditMode); bool[] ckbState, IList<ISmartReader> iperlHeads, int textBoxesCount, bool checkBoxesEditMode);
@ -54,5 +56,6 @@ namespace TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication.common
void StartDataStreamProcessingForActiveMeters(int iMultiTestParamsItem); void StartDataStreamProcessingForActiveMeters(int iMultiTestParamsItem);
public void DoOnCommCompleted(object sender, CommCompletedEventArgs data,IList<int> waterMeterPositions0); public void DoOnCommCompleted(object sender, CommCompletedEventArgs data,IList<int> waterMeterPositions0);
public void NormalClose(IList<int> waterMeterPositions0); public void NormalClose(IList<int> waterMeterPositions0);
bool IsFamilyOfSmartReader(ISmartReader smartHead);
} }
} }

View File

@ -1,15 +1,15 @@
using System.IO; using System.IO;
using Common; using Common;
using TBF.Rig.GenericDevices;
using TBF.Rig.RegisterReaders.CommonRR; using TBF.Rig.RegisterReaders.CommonRR;
namespace TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication.common namespace TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication.common
{ {
public interface ISmartReader public interface ISmartReader : IRegReader
{ {
public string Name { get; } new string Name { get; }
new DebugMode DebugLevel { get; set; }
public string SerialNr { get; } public string SerialNr { get; }
int Position { get; }
public DebugMode DebugLevel { get; set; }
public string CommInterface { get; } public string CommInterface { get; }
public int RfidComPortNr { get; } public int RfidComPortNr { get; }

View File

@ -37,8 +37,8 @@ namespace TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication.implementations
{ {
public class IPerlCorrections : ICorrections public class IPerlCorrections : ICorrections
{ {
ILog log; ILog log {get => ParentFrom?.Log;}
ILog rfidDataLogger; ILog rfidDataLogger{get => ParentFrom?.RfidDataLogger;}
static int currentActivityStep; static int currentActivityStep;
static int currentGroup; static int currentGroup;
@ -56,6 +56,11 @@ namespace TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication.implementations
static IList<int> muxBrdOrGroup14Nrs; static IList<int> muxBrdOrGroup14Nrs;
static bool stopWorkerThreads; static bool stopWorkerThreads;
public string TypeIdentificatorName()
{
return "iPerl";
}
/// form -> worker thread /// form -> worker thread
@ -89,7 +94,7 @@ namespace TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication.implementations
public int GetHeadsCount() public int GetHeadsCount()
{ {
return iperlHeads.Count; return iperlHeads != null ? iperlHeads.Count : 0;
} }
public int StartTimeSec { get; set; } public int StartTimeSec { get; set; }
@ -114,52 +119,40 @@ namespace TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication.implementations
public IList<Config.Entities.Test> Tests public IList<Config.Entities.Test> Tests
{ {
get => tests; get => tests; set => tests = value;
} }
static IList<ISmartReader> iperlHeads; public IList<ISmartReader> iperlHeads { get => ParentFrom.Heads; }
private Label activityLabel;
private Label[] labels; private Label activityLabel { get => ParentFrom?.ActivityLabel;}
private PictureBox[] counters; private Label[] labels { get => ParentFrom?.Labels; }
private TextBox[] messages; private PictureBox[] counters{get => ParentFrom?.Counters;}
private CheckBoxImage[] checkBoxes; private TextBox[] messages{get => ParentFrom?.Messages;}
private int[] ckbIndex; private CheckBoxImage[] checkBoxes{get => ParentFrom?.CheckBoxes;}
private bool[] ckbState; private int[] ckbIndex{get => ParentFrom?.CkbIndex;}
private bool[] ckbState{get => ParentFrom?.CkbState;}
public IPerlCorrections(SmartCommunicationForm parent, ILog log, ILog rfidDataLogger) public IPerlCorrections(SmartCommunicationForm parent)
{ {
this.ParentFrom = parent; this.ParentFrom = parent;
TBF.Rig.RegisterReaders.iPerlReaderUNI.Factory factory = new Factory(); TBF.Rig.RegisterReaders.iPerlReaderUNI.Factory factory = new Factory();
this.testMethod = new TestMethod(factory.DefaultConfig()); TestMethod method = new TestMethod(factory.DefaultConfig());
this.rfidDataLogger = rfidDataLogger; this.testMethod = method;
this.log = log; this.Cfg = method.testMethodCfg;
} }
public IPerlCorrections(SmartCommunicationForm parent, ILog log, ILog rfidDataLogger, ISmartTestMethod testMethod, public IPerlCorrections(SmartCommunicationForm parent, ISmartTestMethod testMethod,
ITestMethodCfg cfg, IList<Config.Entities.Test> tests, IList<ITestParams> multiTestParams, ITestMethodCfg cfg, IList<Config.Entities.Test> tests, IList<ITestParams> multiTestParams)
Label activityLabel
, Label[] labels, PictureBox[] counters, TextBox[] messages, CheckBoxImage[] checkBoxes, int[] ckbIndex,
bool[] ckbState, IList<ISmartReader> iperlHeads)
{ {
this.ParentFrom = parent; this.ParentFrom = parent;
this.rfidDataLogger = rfidDataLogger;
this.log = log;
this.testMethod = testMethod; this.testMethod = testMethod;
this.tests = tests; this.tests = tests;
this.cfg = cfg; this.cfg = cfg;
this.multiTestParams = multiTestParams; this.multiTestParams = multiTestParams;
this.activityLabel = activityLabel;
this.labels = labels;
this.counters = counters;
this.messages = messages;
this.checkBoxes = checkBoxes;
this.ckbIndex = ckbIndex;
this.ckbState = ckbState;
IPerlCorrections.iperlHeads = iperlHeads;
} }
@ -302,26 +295,43 @@ namespace TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication.implementations
private async void OnClick_Optical_Heads_Settings_Menu(object sender, EventArgs e) private async void OnClick_Optical_Heads_Settings_Menu(object sender, EventArgs e)
{ {
MenuItem menuItem = (MenuItem)sender; // Validate sender
activityLabel.Text = menuItem.Text; if (!(sender is MenuItem menuItem))
List<Task> tasks = new List<Task>();
foreach (var iSmartReader in ProcessData.IperlHeadsUni)
{ {
var iHead = (IperlHead)iSmartReader; log?.Error("OnClick_Optical_Heads_Settings_Menu: sender is not a MenuItem");
if (!checkBoxes[iHead.Position - 1].Checked) return;
}
if (activityLabel != null)
activityLabel.Text = menuItem.Text;
List<Task> tasks = new List<Task>();
foreach (var iSmartReader in ProcessData.SmartHeadsUni)
{
if (!(iSmartReader is IperlHead iHead))
{ {
if (iHead.Position - 1 < messages.Length) messages[iHead.Position - 1].Text = ""; continue;//ignore different types of heads
}
int position = iHead.Position - 1;
if (position < 0 || position >= checkBoxes.Length || position >= messages.Length)
{
continue; // Skip this head if position is out of range
}
if (!checkBoxes[position].Checked)
{
if (position < messages.Length) messages[position].Text = "";
continue; continue;
} }
messages[iHead.Position - 1].Text = $"COM{iHead.RfidComPortNr}"; messages[position].Text = $"COM{iHead.RfidComPortNr}";
Application.DoEvents(); // Refresh UI Application.DoEvents(); // Refresh UI
tasks.Add(Task.Run(async () => tasks.Add(Task.Run(async () =>
{ {
string result = await ProcessTask(iHead, menuItem.Tag); string result = await ProcessTask(iHead, menuItem.Tag);
ParentFrom?.Invoke((Action)(() => ParentFrom?.Invoke((Action)(() =>
{ {
messages[iHead.Position - 1].Text = result; messages[position].Text = result;
Application.DoEvents(); // Refresh UI Application.DoEvents(); // Refresh UI
})); }));
@ -410,7 +420,7 @@ namespace TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication.implementations
} }
public void PrepareForTestsActivities() public void PrepareForTestsActivities(int waterMeterPositions0)
{ {
StartTime = DateTime.Now; StartTime = DateTime.Now;
StartTimeSec = StateMachine.Time; StartTimeSec = StateMachine.Time;
@ -425,26 +435,45 @@ namespace TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication.implementations
/// group numbers are >=1, lastGroup == 0 means there is no group /// group numbers are >=1, lastGroup == 0 means there is no group
lastGroup = 0; lastGroup = 0;
foreach (var iSmartReader in iperlHeads) if (iperlHeads != null)
{ {
var iPerl = (SmartReader)iSmartReader; foreach (var iSmartReader in iperlHeads)
if (iPerl.Group > lastGroup) lastGroup = iPerl.Group; {
try
{
var iPerl = iSmartReader as IperlHead;
if (iPerl != null && iPerl.Group > lastGroup) lastGroup = iPerl.Group;
}
catch (Exception E)
{
log.ErrorFormat("PrepareForTestsActivities: {0}", E.Message);
}
}
} }
workerThreads = new List<Thread>(); workerThreads = new List<Thread>();
for (int i = 0; i < Cfg.NrThreads; i++) if (Cfg != null)
{ {
Thread thread = new Thread(Worker); for (int i = 0; i < Cfg.NrThreads; i++)
thread.CurrentCulture = CultureInfo.CurrentCulture; {
thread.CurrentUICulture = CultureInfo.CurrentUICulture; Thread thread = new Thread(Worker);
workerThreads.Add(thread); thread.CurrentCulture = CultureInfo.CurrentCulture;
thread.CurrentUICulture = CultureInfo.CurrentUICulture;
workerThreads.Add(thread);
}
} }
muxBrdOrGroup14Nrs = new List<int>(); muxBrdOrGroup14Nrs = new List<int>();
foreach (SmartReader iPerl in iperlHeads) if (iperlHeads != null)
{ {
if (!muxBrdOrGroup14Nrs.Contains(iPerl.MuxBoardNrOrGroup14)) foreach (ISmartReader iPerl in iperlHeads)
muxBrdOrGroup14Nrs.Add(iPerl.MuxBoardNrOrGroup14); {
if (iPerl is IperlHead ihead)
{
if (!muxBrdOrGroup14Nrs.Contains(ihead.MuxBoardNrOrGroup14))
muxBrdOrGroup14Nrs.Add(ihead.MuxBoardNrOrGroup14);
}
}
} }
log.WarnFormat("nrThreads = {0}", workerThreads.Count); log.WarnFormat("nrThreads = {0}", workerThreads.Count);
@ -492,13 +521,19 @@ namespace TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication.implementations
/// </summary> /// </summary>
/// <param name="iperlHead">Water meter (iPerlHead) object</param> /// <param name="iperlHead">Water meter (iPerlHead) object</param>
/// <returns>Value returned by readRequestPort(...)</returns> /// <returns>Value returned by readRequestPort(...)</returns>
public static int ReadRequestPort(ITestMethodCfg cfg, ISmartReader smartHead, MessageID messageID, public static int ReadRequestPort(ITestMethodCfg cfgMethod, ISmartReader smartHead, MessageID messageID,
MCI_Protocol.StructName structName, int offset, int length, out byte[] buffer) MCI_Protocol.StructName structName, int offset, int length, out byte[] buffer)
{ {
Thread.Sleep(Math.Max(250, cfg.DelayBetweenRetries)); TestMethodCfg_IPerl cfg = cfgMethod as TestMethodCfg_IPerl;
if (cfg == null)
{
if (smartHead.Cfg is TestMethodCfg_IPerl cfg2) cfg = cfg2;
}
Thread.Sleep(cfg == null ? 250 : Math.Max(250, cfg.DelayBetweenRetries));
if (smartHead.DebugLevel == DebugMode.FailureDuringOperation) smartHead.DebugLevel = DebugMode.Normal; if (smartHead.DebugLevel == DebugMode.FailureDuringOperation) smartHead.DebugLevel = DebugMode.Normal;
if (smartHead is SmartReader iperlHead) if (smartHead is IperlHead iperlHead)
{ {
if (iperlHead.DebugLevel != DebugMode.Normal) // Simulation if (iperlHead.DebugLevel != DebugMode.Normal) // Simulation
@ -506,7 +541,7 @@ namespace TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication.implementations
return SimulationServices.ReadRequest(iperlHead, messageID, offset, length, out buffer); return SimulationServices.ReadRequest(iperlHead, messageID, offset, length, out buffer);
} }
if (iperlHead.CommInterface == CommunicationInterface.NFC) // NFC Interface if (iperlHead.CommInterface == CommunicationInterface.NFC.ToDescription()) // NFC Interface
{ {
return NfcServices.ReadRequest(cfg, iperlHead, structName, offset, length, out buffer); return NfcServices.ReadRequest(cfg, iperlHead, structName, offset, length, out buffer);
} }
@ -2553,6 +2588,17 @@ namespace TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication.implementations
} }
private static readonly List<Type> SupportedReaders = new List<Type>()
{
typeof(IperlHead),
typeof(TestMethods.iPerlCommunication.iPerlHead.Factory)
};
public bool IsFamilyOfSmartReader(ISmartReader smartHead)
{
return SupportedReaders.Any(type =>
type.FullName == smartHead?.GetType().FullName);
}
/// <summary> /// <summary>
/// Update test result representing RFID communication success/failure /// Update test result representing RFID communication success/failure
/// </summary> /// </summary>

View File

@ -1,5 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.Threading; using System.Threading;
using System.Windows.Forms; using System.Windows.Forms;
using Config.Entities; using Config.Entities;
@ -7,10 +8,12 @@ using log4net;
using Results.Entities; using Results.Entities;
using TBF.Rig.Generic; using TBF.Rig.Generic;
using TBF.Rig.RegisterReaders.CommonRR.IPerl; using TBF.Rig.RegisterReaders.CommonRR.IPerl;
using TBF.Rig.RegisterReaders.iPerlReaderUNI; using TBF.Rig.RegisterReaders.PoseidonCmdStartStop;
using TBF.Rig.RegisterReaders.PoseidonReader;
using TBF.Rig.TestMethods.SmartTest; using TBF.Rig.TestMethods.SmartTest;
using TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication.common; using TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication.common;
using CheckBoxImage = TBF.Boxes.CheckBoxImage; using CheckBoxImage = TBF.Boxes.CheckBoxImage;
using Factory = TBF.Rig.RegisterReaders.iPerlReaderUNI.Factory;
namespace TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication.implementations namespace TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication.implementations
{ {
@ -30,6 +33,12 @@ namespace TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication.implementations
private IList<ITestParams> multiTestParams; private IList<ITestParams> multiTestParams;
private SmartCommunicationForm _parentFrom; private SmartCommunicationForm _parentFrom;
public string TypeIdentificatorName()
{
return "Poseidon";
}
public DateTime StartTime { get; set; } public DateTime StartTime { get; set; }
public int StartTimeSec { get; set; } public int StartTimeSec { get; set; }
@ -43,7 +52,13 @@ namespace TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication.implementations
public IList<ITestParams> MultiTestParams { get => multiTestParams; set => multiTestParams = value; } public IList<ITestParams> MultiTestParams { get => multiTestParams; set => multiTestParams = value; }
public IList<Test> Tests { get => tests; } public IList<Test> Tests { get => tests; set => tests = value; }
public IList<ISmartReader> iperlHeads { get => ParentFrom.Heads;}
public void Worker(object threadData) public void Worker(object threadData)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
@ -91,11 +106,12 @@ namespace TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication.implementations
throw new NotImplementedException(); throw new NotImplementedException();
} }
public void PrepareForTestsActivities() public void PrepareForTestsActivities( int waterMeterPositions0)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
public void Load(Label[] labels, PictureBox[] counters, TextBox[] messages, CheckBoxImage[] checkBoxes, int[] ckbIndex, public void Load(Label[] labels, PictureBox[] counters, TextBox[] messages, CheckBoxImage[] checkBoxes, int[] ckbIndex,
bool[] ckbState, IList<ISmartReader> iperlHeads, int textBoxesCount, bool checkBoxesEditMode) bool[] ckbState, IList<ISmartReader> iperlHeads, int textBoxesCount, bool checkBoxesEditMode)
{ {
@ -122,7 +138,21 @@ namespace TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication.implementations
throw new NotImplementedException(); throw new NotImplementedException();
} }
public PoseidonCorrections(SmartCommunicationForm parent, ILog log, ILog rfidDataLogger) private static readonly List<Type> SupportedReaders = new List<Type>()
{
typeof(RegisterReaders.PoseidonReader.Factory),
typeof(RegisterReaders.PoseidonReader.SmartReader),
typeof(RegisterReaders.PoseidonCmdStartStop.Factory),
};
public bool IsFamilyOfSmartReader(ISmartReader smartHead)
{
return SupportedReaders.Any(type =>
type.FullName == smartHead?.GetType().FullName);
}
private IList<ISmartReader> Heads { get => ParentFrom.Heads; }
public PoseidonCorrections(SmartCommunicationForm parent)
{ {
this.ParentFrom = parent; this.ParentFrom = parent;
TBF.Rig.RegisterReaders.iPerlReaderUNI.Factory factory = new Factory(); TBF.Rig.RegisterReaders.iPerlReaderUNI.Factory factory = new Factory();

View File

@ -1605,6 +1605,17 @@
<Compile Include="Rig\TestMethods\S640Communication\S640Start.cs" /> <Compile Include="Rig\TestMethods\S640Communication\S640Start.cs" />
<Compile Include="Rig\TestMethods\S640Communication\S640StartCfg.cs" /> <Compile Include="Rig\TestMethods\S640Communication\S640StartCfg.cs" />
<Compile Include="Rig\TestMethods\S640Communication\S640StartFactory.cs" /> <Compile Include="Rig\TestMethods\S640Communication\S640StartFactory.cs" />
<Compile Include="Rig\TestMethods\SmartMeterFlyingStartMassCollection\SmartCommunicationParams.cs" />
<Compile Include="Rig\TestMethods\SmartMeterFlyingStartMassCollection\SmartCommunicationSeq.cs" />
<Compile Include="Rig\TestMethods\SmartMeterFlyingStartMassCollection\TestMethod.cs" />
<Compile Include="Rig\TestMethods\SmartMeterFlyingStartMassCollection\TestMethodCfgCtrl.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Rig\TestMethods\SmartMeterFlyingStartMassCollection\TestMethodCfgCtrl.designer.cs">
<DependentUpon>TestMethodCfgCtrl.cs</DependentUpon>
</Compile>
<Compile Include="Rig\TestMethods\SmartMeterFlyingStartMassCollection\Factory.cs" />
<Compile Include="Rig\TestMethods\SmartMeterFlyingStartMassCollection\TestMethodCfg.cs" />
<Compile Include="Rig\TestMethods\SmartTest\SequenceConditionOp.cs" /> <Compile Include="Rig\TestMethods\SmartTest\SequenceConditionOp.cs" />
<Compile Include="Rig\TestMethods\SmartTest\TestMethod.cs" /> <Compile Include="Rig\TestMethods\SmartTest\TestMethod.cs" />
<Compile Include="Rig\TestMethods\SmartTest\TestMethodCfgCtrl.cs"> <Compile Include="Rig\TestMethods\SmartTest\TestMethodCfgCtrl.cs">
@ -3420,6 +3431,9 @@
<EmbeddedResource Include="Rig\TestMethods\S640Communication\S640CommForm.resx"> <EmbeddedResource Include="Rig\TestMethods\S640Communication\S640CommForm.resx">
<DependentUpon>S640CommForm.cs</DependentUpon> <DependentUpon>S640CommForm.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="Rig\TestMethods\SmartMeterFlyingStartMassCollection\TestMethodCfgCtrl.resx">
<DependentUpon>TestMethodCfgCtrl.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Rig\TestMethods\SmartTest\TestMethodCfgCtrl.resx"> <EmbeddedResource Include="Rig\TestMethods\SmartTest\TestMethodCfgCtrl.resx">
<DependentUpon>TestMethodCfgCtrl.cs</DependentUpon> <DependentUpon>TestMethodCfgCtrl.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>

View File

@ -101,7 +101,7 @@ namespace TBFTests.Rig.RegisterReaders.PoseidonReader
public void Cleanup() public void Cleanup()
{ {
// Clean up the static reference // Clean up the static reference
ProcessData.IperlHeadsUni = null; ProcessData.SmartHeadsUni = null;
} }
[TestInitialize] [TestInitialize]
@ -137,7 +137,7 @@ namespace TBFTests.Rig.RegisterReaders.PoseidonReader
.SetupGet(n => n.Name) .SetupGet(n => n.Name)
.Returns(cfgName); .Returns(cfgName);
ProcessData.IperlHeadsUni = new List<ISmartReader> { headMock.Object }; ProcessData.SmartHeadsUni = new List<ISmartReader> { headMock.Object };
UniHeadTestCtrl uniHeadTestCtrl = new UniHeadTestCtrl(config); UniHeadTestCtrl uniHeadTestCtrl = new UniHeadTestCtrl(config);
@ -173,7 +173,7 @@ namespace TBFTests.Rig.RegisterReaders.PoseidonReader
.SetupGet(n => n.Name) .SetupGet(n => n.Name)
.Returns(cfgName); .Returns(cfgName);
ProcessData.IperlHeadsUni = new List<ISmartReader> { headMock.Object }; ProcessData.SmartHeadsUni = new List<ISmartReader> { headMock.Object };
UniHeadTestCtrl uniHeadTestCtrl = new UniHeadTestCtrl(config); UniHeadTestCtrl uniHeadTestCtrl = new UniHeadTestCtrl(config);