Compare commits

...

4 Commits

15 changed files with 3069 additions and 77 deletions

View File

@ -9,6 +9,7 @@ using log4net;
using log4net.Repository.Hierarchy;
using TBF.Rig.Generic;
using TBF.Rig.Sequences;
using TBF.Rig.TestMethods.GenesisFullCommunication;
namespace TBF.Rig
{
@ -192,7 +193,8 @@ namespace TBF.Rig
new TestMethods.FlyingStartFirstRepetWithMassColl.HeatMeters.Factory(),
new TestMethods.FlyingStartTankCollection.Single.Factory(),
new TestMethods.FlyingStartTankCollection.Compound.Factory(),
new TestMethods.GenesisCommunication.GenesisHead.Factory(),
new TestMethods.GenesisCommunication.GenesisHead.Factory(), // german implementation of the Genesis communication protocol
new Factory(),
new TestMethods.GrabImage.Factory(),
new TestMethods.iPerlCommunication.TestMethodFactory(), /// iPerlCommunication
new TestMethods.LeakTest.Factory(),

View File

@ -4,9 +4,9 @@
using System.Collections.Generic;
using TBF.Rig.Generic;
using TBF.Rig.TestMethods.iPerlCommunication;
using TBF.Rig.TestMethods.GenesisCommunication;
namespace TBF.Rig.TestMethods.GenesisCommunication
namespace TBF.Rig.TestMethods.GenesisFullCommunication
{
public class Factory : IComponentFactory
{

View File

@ -11,11 +11,11 @@ using TBF.Resources;
using TBF.Rig.Generic;
using TBF.Rig.TestMethods.iPerlCommunication;
namespace TBF.Rig.TestMethods.GenesisCommunication
namespace TBF.Rig.TestMethods.GenesisFullCommunication
{
public class iPerlCommunicationParams : TestParamsBase, IParamsProvider, ITestParams
public class GenesisCommunicationParams : TestParamsBase, IParamsProvider, ITestParams
{
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(iPerlCommunicationParams) })[0];
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(GenesisCommunicationParams) })[0];
public override XmlSerializer GetSerializer() { return Serializer; }
public string Activity
@ -157,7 +157,7 @@ namespace TBF.Rig.TestMethods.GenesisCommunication
return false;
}
void CopyContentTo(iPerlCommunicationParams prms)
void CopyContentTo(GenesisCommunicationParams prms)
{
prms.Activity = this.Activity;
prms.SimultWithPrevious = this.SimultWithPrevious;
@ -166,7 +166,7 @@ namespace TBF.Rig.TestMethods.GenesisCommunication
public IParamsProvider Clone()
{
iPerlCommunicationParams pars = new iPerlCommunicationParams();
GenesisCommunicationParams pars = new GenesisCommunicationParams();
CopyContentTo(pars);
return pars;
}
@ -176,7 +176,7 @@ namespace TBF.Rig.TestMethods.GenesisCommunication
if (dbEntity == null) return;
try
{
iPerlCommunicationParams tmp = Serializer.Deserialize(new StringReader(dbEntity.Parameters)) as iPerlCommunicationParams;
GenesisCommunicationParams tmp = Serializer.Deserialize(new StringReader(dbEntity.Parameters)) as GenesisCommunicationParams;
testParamsEntity = dbEntity;
componentName = dbEntity.CmpntName;
@ -192,16 +192,16 @@ namespace TBF.Rig.TestMethods.GenesisCommunication
/// <summary>
/// Parameterless constructor initializes the parameters
/// </summary>
public iPerlCommunicationParams()
public GenesisCommunicationParams()
{
}
public iPerlCommunicationParams(bool initialize)
public GenesisCommunicationParams(bool initialize)
{
if (initialize) InitializeAll();
}
public iPerlCommunicationParams(ComponentTest testParamsEntity, string componentName, Test test)
public GenesisCommunicationParams(ComponentTest testParamsEntity, string componentName, Test test)
{
this.testParamsEntity = testParamsEntity;
this.componentName = componentName;

View File

@ -14,10 +14,12 @@ 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.GenesisCommunication
namespace TBF.Rig.TestMethods.GenesisFullCommunication
{
public class GenesisCommunicationSeq : SequenceBase
{
@ -32,15 +34,17 @@ namespace TBF.Rig.TestMethods.GenesisCommunication
System.Windows.Forms.Form modelessDlg;
///
delegate void iPerlCommFormDlgt(GenesisCommunicationSeq myRef, iPerlCommunication.TestMethod method, Test test, iPerlCommunicationParams testParams);
delegate void IPerlCommFormDlgt(GenesisCommunicationSeq myRef, TestMethod method, Test test, GenesisCommunicationParams testParams);
///
void OpenIPerlCommForm(GenesisCommunicationSeq myRef, iPerlCommunication.TestMethod method, Test test, iPerlCommunicationParams testParams)
void OpenIPerlCommForm(GenesisCommunicationSeq myRef, TestMethod method, Test test, GenesisCommunicationParams testParams)
{
//TODO solve this wia SmartCommunicationForm
throw new NotImplementedException();
myRef.modelessDlg = new SmartCommunicationForm(method, test, testParams);
myRef.modelessDlg.Show();
//myRef.modelessDlg = new iPerlCommunicationForm(method, test, testParams);
//myRef.modelessDlg.Show();
}
@ -373,7 +377,7 @@ namespace TBF.Rig.TestMethods.GenesisCommunication
///
/// Show the modeless dialog with error indication
///
Program.MainWnd.Invoke(new iPerlCommFormDlgt(OpenIPerlCommForm), new object[] { this, method, test, testParams });
Program.MainWnd.Invoke(new IPerlCommFormDlgt(OpenIPerlCommForm), new object[] { this, method, test, testParams });
//------------------------------------------------
Bridge.OnActivity(this, Strings.iPerl_Communication_in_progress);

View File

@ -2,7 +2,7 @@
/// Copyright (c) 2022 Sensus Slovensko a.s.
///
namespace TBF.Rig.TestMethods.GenesisCommunication
namespace TBF.Rig.TestMethods.GenesisFullCommunication
{
public enum ConditionID
{

View File

@ -9,12 +9,10 @@ using Config.Entities;
using log4net;
using TBF.Rig.GenericDevices;
using TBF.Rig.Sequences;
using TBF.Rig.TestMethods.iPerlCommunication;
using TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication;
using TBF.UiBridge;
using iPerlCommunicationSeq = TBF.Rig.TestMethods.iPerlCommunication.iPerlCommunicationSeq;
namespace TBF.Rig.TestMethods.GenesisCommunication
namespace TBF.Rig.TestMethods.GenesisFullCommunication
{
public class TestMethod : SmartComponentBase, ISimultTestMethod, ISequenceCondition, ISessionDataMngmnt, ITestMethodSmart
{

View File

@ -9,13 +9,12 @@ using Common;
using Config.Entities;
using TBF.Rig.Generic;
using TBF.Rig.RegisterReaders.CommonRR.IPerl;
using TBF.Rig.TestMethods.iPerlCommunication;
namespace TBF.Rig.TestMethods.GenesisCommunication
namespace TBF.Rig.TestMethods.GenesisFullCommunication
{
[XmlRoot("TestMethodCfg")] // Add this attribute to match the XML root
public class TestMethodCfg : ComponentCfgBase, IiPerlTestMethodCfg
public class TestMethodCfg : ComponentCfgBase, ITestMethodCfg/*IComponentCfg*/
{
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(TestMethodCfg) })[0];
public override XmlSerializer GetSerializer() { return Serializer; }
@ -24,7 +23,7 @@ namespace TBF.Rig.TestMethods.GenesisCommunication
//
public override IParamsProvider GetRuntimeTestParamsProvider() { return TestParams; }
public override IParamsProvider CreateTestParamsProvider() { return new iPerlCommunicationParams(true); }
public override IParamsProvider CreateTestParamsProvider() { return new GenesisCommunicationParams(true); }
public override IParamsProvider GetUITestParamsProvider(Test test)
{
return (test.Method == Name) ? base.GetUITestParamsProvider(test) : null;
@ -33,7 +32,7 @@ namespace TBF.Rig.TestMethods.GenesisCommunication
/// Private parameterless constructor invoked by all other (public) constructors
TestMethodCfg()
{
Name = "SmartCommunication";
Name = "GenesisFullCommunication";
ParentName = string.Empty;
CommTimeout = 1800; /// ms
MaxCommRetries = 4;
@ -47,7 +46,7 @@ namespace TBF.Rig.TestMethods.GenesisCommunication
ParityBit = Parity.None; // NFC Interface
StopBits = StopBits.Two; // NFC Interface
TestParams = CreateTestParamsProvider() as iPerlCommunicationParams;
TestParams = CreateTestParamsProvider() as GenesisCommunicationParams;
}
public TestMethodCfg(IComponentFactory factory)

View File

@ -8,19 +8,19 @@ using Common;
using TBF.Resources;
using TBF.Rig.Generic;
namespace TBF.Rig.TestMethods.GenesisCommunication
namespace TBF.Rig.TestMethods.GenesisFullCommunication
{
public partial class TestMethodCfgCtrl : Configs.ConfigCtrlUtils, IComponentCfgCtrl
{
public bool ShowMore { get { return false; } }
iPerlCommunication.TestMethodCfg config;
TestMethodCfg config;
public IComponentCfg Config
{
get { return config as IComponentCfg; }
set
{
config = value as iPerlCommunication.TestMethodCfg;
config = value as TestMethodCfg;
Redraw();
}
}

View File

@ -2,7 +2,7 @@
/// Copyright (c) 2015 Sensus Metering Systems
/// Author: Milan Hanajík
///
namespace TBF.Rig.TestMethods.GenesisCommunication
namespace TBF.Rig.TestMethods.GenesisFullCommunication
{
partial class TestMethodCfgCtrl
{

View File

@ -14,7 +14,9 @@ using log4net;
using NHibernate.Util;
using TBF.Resources;
using TBF.Rig.Generic;
using TBF.Rig.GenericDevices;
using TBF.Rig.RegisterReaders.CommonRR.IPerl;
using TBF.Rig.RegisterReaders.GenesisRegReader.implementations;
using TBF.Rig.RegisterReaders.iPerlReaderUNI;
using TBF.Rig.RegisterReaders.PoseidonReader;
using TBF.Rig.Sequences;
@ -157,6 +159,14 @@ namespace TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication
correctionsList.Add(new PoseidonCorrections(this,log, rfidDataLogger, componentBase, cfg, tests, multiTestParams));
continue;
}
if (smartHead is GenesisSmartReader genSmartReader)
{
if (correctionsList.Any(x => x is GenesisSmartReader))
continue;
correctionsList.Add(new GenesisCorrections( this,componentBase, cfg, tests, multiTestParams));
continue;
}
throw new Exception("Unknown smart head type");
}
@ -189,6 +199,14 @@ namespace TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication
correctionsList.Add(new PoseidonCorrections(form));
continue;
}
if (smartHead is GenesisSmartReader genSmartReader)
{
if (correctionsList.Any(x => x is GenesisSmartReader))
continue;
correctionsList.Add(new GenesisCorrections(form));
continue;
}
throw new Exception("Unknown smart head type");
}
@ -223,6 +241,12 @@ namespace TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication
typeReaders.Add(smartReader.ClassName);
continue;
}
if (smartHead is GenesisSmartReader genSmartReader)
{
typeReaders.Add(genSmartReader.ClassName);
continue;
}
throw new Exception("Unknown smart head type");
}
@ -327,7 +351,13 @@ namespace TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication
{
checkBoxesEditMode = false;
ITestMethodCfg cfg = (componentBase as ITestMethodCfg);
ITestMethodSmart smart = (componentBase as ITestMethodSmart);
ITestMethodCfg cfg = (componentBase as ITestMethodCfg);
if (smart != null && cfg == null)
{
cfg = (componentBase.Cfg as ITestMethodCfg);
}
ISmartTestMethod smartTestMethod = componentBase as ISmartTestMethod;
//TODO get corrections based on defined meter
@ -410,7 +440,8 @@ namespace TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication
if (iperlHeads == null) iperlHeads = new List<ISmartReader>();
waterMeterPositions0?.Clear();
if (waterMeterPositions0 == null) waterMeterPositions0 = new List<int>();
//iperlHeads = ProcessData.SmartHeadsUni;
//TODO BUMI check
iperlHeads = ProcessData.SmartHeadsUni;
string comparedTypeReader = SelectedTypeReader;
if (string.IsNullOrEmpty(SelectedTypeReader))
{
@ -460,25 +491,47 @@ namespace TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication
private void InitializeMeterTypeItems()
{
if (_corrections.Count >= 0)
meterTypeComboBox.Items.Clear();
if (_corrections == null || _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;
meterTypeComboBox.Visible = false;
meterTypeComboBox.Enabled = false;
SelectedTypeReader = null;
return;
}
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;
initializingMeterTypes = true;
try
{
// fill items...
if (meterTypeComboBox.Items.Count > 0)
meterTypeComboBox.SelectedIndex = 0;
}
finally
{
initializingMeterTypes = false;
}
}
@ -491,7 +544,7 @@ namespace TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication
WaterMetersCount = iperlHeads.Count;
ShuffleTextBoxes(WaterMetersCount, ProcessData.LineSize);
Correction.PrepareForTestsActivities(WaterMetersCount);
Correction?.PrepareForTestsActivities(WaterMetersCount);
}
/// <summary>
@ -530,7 +583,7 @@ namespace TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication
private void DoOnCommCompleted(object sender, CommCompletedEventArgs data)
{
Correction.DoOnCommCompleted(sender, data, waterMeterPositions0);
Correction?.DoOnCommCompleted(sender, data, waterMeterPositions0);
}
@ -572,7 +625,7 @@ namespace TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication
textBoxesCount = wmsCount;
}
int count = checkBoxesEditMode ? textBoxesCount : Math.Min(textBoxesCount, Correction.GetHeadsCount());
int count = checkBoxesEditMode ? textBoxesCount : Math.Min(textBoxesCount, Correction?.GetHeadsCount() ?? 0);
for (int j = 0; j < count; j++)
{
labels[j].Text = (j + 1).ToString();
@ -674,11 +727,15 @@ namespace TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication
samplePictureBox3.Visible = false;
}
if (_corrections.Count > 0)//enable combo for choose SmartMeter
if (_corrections != null && _corrections.Count > 0)
{
meterTypeComboBox.Visible = true;
}
Correction.Load(labels,counters,messages,checkBoxes,ckbIndex,ckbState, iperlHeads,textBoxesCount,checkBoxesEditMode );
else
{
meterTypeComboBox.Visible = false;
}
Correction?.Load(labels,counters,messages,checkBoxes,ckbIndex,ckbState, iperlHeads,textBoxesCount,checkBoxesEditMode );
///
/// Set location and checkbox states to values stored in local settings
@ -693,7 +750,7 @@ namespace TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication
/// Regular activity (not a checkbox edit mode invoked from TBF menu)
/// Reset opto-data indication
for (int i = 0; i < Correction.GetHeadsCount(); i++)
for (int i = 0; i < (Correction?.GetHeadsCount() ?? 0); i++)
{
counters[i].BackColor = iPerlCommunicationConstants.OptoNokColor;
}
@ -702,11 +759,14 @@ namespace TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication
//currentGroup++;
int wtId = 0;
foreach (var wt in Correction.GetAllThreads())
{
wt.Start(new Boxes.IntBox(wtId++)); /// Start worker threads !!!
}
}
if (Correction?.GetAllThreads() != null)
{
foreach (var wt in Correction?.GetAllThreads())
{
wt.Start(new Boxes.IntBox(wtId++)); /// Start worker threads !!!
}
}
}
}
@ -917,13 +977,32 @@ namespace TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication
}
private bool initializingMeterTypes;
private void meterTypeComboBox_SelectedIndexChanged(object sender, EventArgs e)
{
if (initializingMeterTypes)
return;
ComboBox senderCombo = sender as ComboBox;
if (senderCombo == null) return;
if (senderCombo == null)
return;
SelectedTypeReader = senderCombo.SelectedItem?.ToString();
UpdateHeads();
SmartCommunicationForm_Load(this, EventArgs.Empty);
Correction?.Load(
labels,
counters,
messages,
checkBoxes,
ckbIndex,
ckbState,
iperlHeads,
textBoxesCount,
checkBoxesEditMode
);
}
}
}

View File

@ -1735,16 +1735,16 @@
<Compile Include="Rig\TestMethods\GenesisCommunication\GenesisHead\OptoTelegramRaw.cs" />
<Compile Include="Rig\TestMethods\GenesisCommunication\GenesisHead\ProcParams.cs" />
<Compile Include="Rig\TestMethods\GenesisCommunication\GenesisHead\StatusStruct.cs" />
<Compile Include="Rig\TestMethods\GenesisCommunication\Factory.cs" />
<Compile Include="Rig\TestMethods\GenesisCommunication\GenesisCommunicationSeq.cs" />
<Compile Include="Rig\TestMethods\GenesisCommunication\iPerlCommunicationParams.cs" />
<Compile Include="Rig\TestMethods\GenesisCommunication\SequenceConditionOp.cs" />
<Compile Include="Rig\TestMethods\GenesisCommunication\TestMethod.cs" />
<Compile Include="Rig\TestMethods\GenesisCommunication\TestMethodCfg.cs" />
<Compile Include="Rig\TestMethods\GenesisCommunication\TestMethodCfgCtrl.cs">
<Compile Include="Rig\TestMethods\GenesisFullCommunication\Factory.cs" />
<Compile Include="Rig\TestMethods\GenesisFullCommunication\GenesisCommunicationSeq.cs" />
<Compile Include="Rig\TestMethods\GenesisFullCommunication\GenesisCommunicationParams.cs" />
<Compile Include="Rig\TestMethods\GenesisFullCommunication\SequenceConditionOp.cs" />
<Compile Include="Rig\TestMethods\GenesisFullCommunication\TestMethod.cs" />
<Compile Include="Rig\TestMethods\GenesisFullCommunication\TestMethodCfg.cs" />
<Compile Include="Rig\TestMethods\GenesisFullCommunication\TestMethodCfgCtrl.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Rig\TestMethods\GenesisCommunication\TestMethodCfgCtrl.designer.cs">
<Compile Include="Rig\TestMethods\GenesisFullCommunication\TestMethodCfgCtrl.designer.cs">
<DependentUpon>TestMethodCfgCtrl.cs</DependentUpon>
</Compile>
<Compile Include="Rig\TestMethods\iPerlCommunication\AllCompletedEventArgs.cs" />
@ -2316,6 +2316,7 @@
<Compile Include="Rig\Uni\SharedDialogs\SmartMetersCommunication\common\ICorrections.cs" />
<Compile Include="Rig\Uni\SharedDialogs\SmartMetersCommunication\common\ISmartReader.cs" />
<Compile Include="Rig\Uni\SharedDialogs\SmartMetersCommunication\implementations\EnumExtensions.cs" />
<Compile Include="Rig\Uni\SharedDialogs\SmartMetersCommunication\implementations\GenesisCorrections.cs" />
<Compile Include="Rig\Uni\SharedDialogs\SmartMetersCommunication\implementations\IPerlASICCorrections.cs" />
<Compile Include="Rig\Uni\SharedDialogs\SmartMetersCommunication\implementations\IPerlCorrections.cs" />
<Compile Include="Rig\Uni\SharedDialogs\SmartMetersCommunication\implementations\PoseidonCorrections.cs" />
@ -3675,7 +3676,7 @@
<DependentUpon>TestMethodCfgCtrl.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Rig\TestMethods\GenesisCommunication\GenesisHead\GenesisHeadCfgCtrl.resx" />
<EmbeddedResource Include="Rig\TestMethods\GenesisCommunication\TestMethodCfgCtrl.resx">
<EmbeddedResource Include="Rig\TestMethods\GenesisFullCommunication\TestMethodCfgCtrl.resx">
<DependentUpon>TestMethodCfgCtrl.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Rig\TestMethods\GrabImage\GrabImageCfgCtrl.resx">

View File

@ -1199,7 +1199,8 @@ namespace TBF.UI
private void optoHeadsToolStripMenuItem_Click(object sender, EventArgs e)
{
new iPerlCommunicationForm(true).ShowDialog();
//new iPerlCommunicationForm(true).ShowDialog();
new SmartCommunicationForm(true).ShowDialog();
}
private void statusStrip1_DoubleClick(object sender, EventArgs e)

View File

@ -86,8 +86,38 @@ namespace TBF.UI.Process
Bridge.StateMachineTickHandler += delegate(object sndr, UiBridge.StateMachineTickEventArgs args)
{
if (InvokeRequired) { Invoke(new EventHandler<UiBridge.StateMachineTickEventArgs>(OnStateMachineTick), sndr, args); }
else OnStateMachineTick(sndr, args);
try
{
if (IsDisposed || Disposing || !IsHandleCreated)
{
return;
}
if (InvokeRequired)
{
BeginInvoke(new EventHandler<UiBridge.StateMachineTickEventArgs>(OnStateMachineTick), sndr, args);
}
else
{
OnStateMachineTick(sndr, args);
}
}
catch (ObjectDisposedException e)
{
log.DebugFormat("ProcessTabPageCtrl.OnStateMachineTick() skipped because control is disposed: {0}", e.Message);
}
catch (InvalidOperationException e)
{
log.DebugFormat("ProcessTabPageCtrl.OnStateMachineTick() skipped because UI is not available: {0}", e.Message);
}
catch (System.ComponentModel.InvalidAsynchronousStateException e)
{
log.DebugFormat("ProcessTabPageCtrl.OnStateMachineTick() skipped because UI thread is no longer available: {0}", e.Message);
}
catch (Exception e)
{
log.ErrorFormat("ProcessTabPageCtrl.OnStateMachineTick() failed: {0}", e.Message);
}
};
Bridge.TestCompletedHandler += delegate(object sender, TestCompletedEventArgs args)