Add GenesisCorrections implementation for smart meter calibration and worker thread management.
This commit is contained in:
parent
74bcbaf12d
commit
c79688dc0c
@ -8,13 +8,13 @@ using System.Xml.Serialization;
|
||||
using Common;
|
||||
using Config.Entities;
|
||||
using TBF.Rig.Generic;
|
||||
|
||||
using TBF.Rig.RegisterReaders.CommonRR.IPerl;
|
||||
|
||||
|
||||
namespace TBF.Rig.TestMethods.GenesisFullCommunication
|
||||
{
|
||||
[XmlRoot("TestMethodCfg")] // Add this attribute to match the XML root
|
||||
public class TestMethodCfg : ComponentCfgBase, IComponentCfg
|
||||
public class TestMethodCfg : ComponentCfgBase, ITestMethodCfg/*IComponentCfg*/
|
||||
{
|
||||
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(TestMethodCfg) })[0];
|
||||
public override XmlSerializer GetSerializer() { return Serializer; }
|
||||
|
||||
@ -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;
|
||||
@ -158,6 +160,14 @@ namespace TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication
|
||||
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");
|
||||
}
|
||||
catch (Exception e)
|
||||
@ -190,6 +200,14 @@ namespace TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication
|
||||
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");
|
||||
}
|
||||
catch (Exception e)
|
||||
@ -224,6 +242,12 @@ namespace TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication
|
||||
continue;
|
||||
}
|
||||
|
||||
if (smartHead is GenesisSmartReader genSmartReader)
|
||||
{
|
||||
typeReaders.Add(genSmartReader.ClassName);
|
||||
continue;
|
||||
}
|
||||
|
||||
throw new Exception("Unknown smart head type");
|
||||
}
|
||||
catch (Exception e)
|
||||
@ -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))
|
||||
{
|
||||
@ -513,7 +544,7 @@ namespace TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication
|
||||
WaterMetersCount = iperlHeads.Count;
|
||||
ShuffleTextBoxes(WaterMetersCount, ProcessData.LineSize);
|
||||
|
||||
Correction.PrepareForTestsActivities(WaterMetersCount);
|
||||
Correction?.PrepareForTestsActivities(WaterMetersCount);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -552,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);
|
||||
}
|
||||
|
||||
|
||||
@ -594,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();
|
||||
@ -704,7 +735,7 @@ namespace TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication
|
||||
{
|
||||
meterTypeComboBox.Visible = false;
|
||||
}
|
||||
Correction.Load(labels,counters,messages,checkBoxes,ckbIndex,ckbState, iperlHeads,textBoxesCount,checkBoxesEditMode );
|
||||
Correction?.Load(labels,counters,messages,checkBoxes,ckbIndex,ckbState, iperlHeads,textBoxesCount,checkBoxesEditMode );
|
||||
|
||||
///
|
||||
/// Set location and checkbox states to values stored in local settings
|
||||
@ -719,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;
|
||||
}
|
||||
@ -728,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 !!!
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -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" />
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user