ReSharper: -CordonelAssemblyLine

This commit is contained in:
Thomas Wiedebusch
2022-10-12 11:39:48 +02:00
parent b30d580ad5
commit 561b46a580
10 changed files with 3126 additions and 483 deletions
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,21 @@
using System;
namespace Logic.ProductionToProductMapper.Cordonel
{
public class RegisterHisory
{
public RegisterHisory(String pcbId, Byte[] address, Byte[] value, DateTimeOffset date)
{
PcbId = pcbId;
Address = address;
Value = value;
Date = date;
}
public String PcbId { get; set; }
public Byte[] Address { get; set; }
public Byte[] Value { get; set; }
public DateTimeOffset Date { get; set; }
}
}
@@ -0,0 +1,22 @@
using Logic.ProductionToProductMapper.Cordonel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Logic.ProductionToProductMapper.Files.Lut
{
public class CordonelMetrologyLut
{
public int FileId { get; set; }
public string FileName { get; set; }
public MeterSize MeterSize { get; set; }
public string Region { get; set; }
public int CRC { get; set; }
public bool ForProduction { get; set; }
public List<byte> Content { get; set; }
}
}
@@ -0,0 +1,3 @@
namespace Service.Core
{
}
File diff suppressed because it is too large Load Diff
Binary file not shown.
@@ -0,0 +1,46 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
namespace XylemCommonUiLegacyGenCtl
{
[ClassInterface(ClassInterfaceType.AutoDual)]
[Guid("FDD23F12-5AE6-4D23-BF34-9C46EA61F02E")]
[ComVisible(true)]
public class PopEventArgs : EventArgs
{
public bool Show { set; get; }
}
[ClassInterface(ClassInterfaceType.AutoDual)]
[Guid("AE0875F7-D30D-4113-AE28-E0CBD0372544")]
[ComVisible(true)]
public class StateChangeEventArgs : EventArgs
{
public bool IsRunning { set; get; }
public bool HasErrors { set; get; }
}
public delegate void OnStateChange(Object sender, StateChangeEventArgs e);
public delegate void OnPop(Object sender, PopEventArgs e);
[InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
[Guid("A1095409-2795-42C7-B6B6-800B4F76CA60")]
public interface IEasyMeterRdy
{
[DispId(1)]
void OneStateChange();
[DispId(2)]
void OnPop(Object sender, PopEventArgs e);
}
}
+238
View File
@@ -0,0 +1,238 @@
namespace XylemCommonUiLegacyGenCtl
{
partial class ctlEasyMeterRdy
{
/// <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.components = new System.ComponentModel.Container();
this.lblLogin = new System.Windows.Forms.Label();
this.lblLed = new System.Windows.Forms.Label();
this.lblDataOverall = new System.Windows.Forms.Label();
this.lblDataDisplay = new System.Windows.Forms.Label();
this.lblDataP1 = new System.Windows.Forms.Label();
this.lblDataP2 = new System.Windows.Forms.Label();
this.lblDataP3 = new System.Windows.Forms.Label();
this.tmrBusy = new System.Windows.Forms.Timer(this.components);
this.lblFlowTest = new System.Windows.Forms.Label();
this.lblPreadjustment = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.lblPcbId = new System.Windows.Forms.Label();
this.button1 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// lblLogin
//
this.lblLogin.AutoSize = true;
this.lblLogin.BackColor = System.Drawing.Color.LightGray;
this.lblLogin.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.lblLogin.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lblLogin.Location = new System.Drawing.Point(165, 1);
this.lblLogin.Name = "lblLogin";
this.lblLogin.Size = new System.Drawing.Size(55, 22);
this.lblLogin.TabIndex = 6;
this.lblLogin.Text = "Login";
//
// lblLed
//
this.lblLed.AutoSize = true;
this.lblLed.BackColor = System.Drawing.Color.LightGray;
this.lblLed.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.lblLed.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lblLed.Location = new System.Drawing.Point(219, 1);
this.lblLed.Name = "lblLed";
this.lblLed.Size = new System.Drawing.Size(46, 22);
this.lblLed.TabIndex = 7;
this.lblLed.Text = "LED";
//
// lblDataOverall
//
this.lblDataOverall.AutoSize = true;
this.lblDataOverall.BackColor = System.Drawing.Color.LightGray;
this.lblDataOverall.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.lblDataOverall.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lblDataOverall.Location = new System.Drawing.Point(264, 1);
this.lblDataOverall.Name = "lblDataOverall";
this.lblDataOverall.Size = new System.Drawing.Size(87, 22);
this.lblDataOverall.TabIndex = 8;
this.lblDataOverall.Text = "Messwert";
//
// lblDataDisplay
//
this.lblDataDisplay.AutoSize = true;
this.lblDataDisplay.BackColor = System.Drawing.Color.LightGray;
this.lblDataDisplay.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.lblDataDisplay.Font = new System.Drawing.Font("Microsoft Sans Serif", 8F, System.Drawing.FontStyle.Bold);
this.lblDataDisplay.Location = new System.Drawing.Point(350, 1);
this.lblDataDisplay.Name = "lblDataDisplay";
this.lblDataDisplay.Size = new System.Drawing.Size(66, 15);
this.lblDataDisplay.TabIndex = 9;
this.lblDataDisplay.Text = " Display ";
this.lblDataDisplay.Click += new System.EventHandler(this.lblDataDisplay_Click);
//
// lblDataP1
//
this.lblDataP1.AutoSize = true;
this.lblDataP1.BackColor = System.Drawing.Color.LightGray;
this.lblDataP1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.lblDataP1.Font = new System.Drawing.Font("Microsoft Sans Serif", 6F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lblDataP1.Location = new System.Drawing.Point(350, 15);
this.lblDataP1.Name = "lblDataP1";
this.lblDataP1.Size = new System.Drawing.Size(21, 11);
this.lblDataP1.TabIndex = 10;
this.lblDataP1.Text = " P1";
//
// lblDataP2
//
this.lblDataP2.AutoSize = true;
this.lblDataP2.BackColor = System.Drawing.Color.LightGray;
this.lblDataP2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.lblDataP2.Font = new System.Drawing.Font("Microsoft Sans Serif", 6F, System.Drawing.FontStyle.Bold);
this.lblDataP2.Location = new System.Drawing.Point(371, 15);
this.lblDataP2.Name = "lblDataP2";
this.lblDataP2.Size = new System.Drawing.Size(24, 11);
this.lblDataP2.TabIndex = 11;
this.lblDataP2.Text = " P2 ";
//
// lblDataP3
//
this.lblDataP3.AutoSize = true;
this.lblDataP3.BackColor = System.Drawing.Color.LightGray;
this.lblDataP3.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.lblDataP3.Font = new System.Drawing.Font("Microsoft Sans Serif", 6F, System.Drawing.FontStyle.Bold);
this.lblDataP3.Location = new System.Drawing.Point(395, 15);
this.lblDataP3.Name = "lblDataP3";
this.lblDataP3.Size = new System.Drawing.Size(21, 11);
this.lblDataP3.TabIndex = 12;
this.lblDataP3.Text = "P3 ";
//
// tmrBusy
//
this.tmrBusy.Enabled = true;
this.tmrBusy.Interval = 1000;
this.tmrBusy.Tick += new System.EventHandler(this.tmrBusy_Tick);
//
// lblFlowTest
//
this.lblFlowTest.AutoSize = true;
this.lblFlowTest.BackColor = System.Drawing.Color.LightGray;
this.lblFlowTest.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.lblFlowTest.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold);
this.lblFlowTest.Location = new System.Drawing.Point(142, 1);
this.lblFlowTest.Name = "lblFlowTest";
this.lblFlowTest.Size = new System.Drawing.Size(24, 22);
this.lblFlowTest.TabIndex = 14;
this.lblFlowTest.Text = "H";
//
// lblPreadjustment
//
this.lblPreadjustment.AutoSize = true;
this.lblPreadjustment.BackColor = System.Drawing.Color.LightGray;
this.lblPreadjustment.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.lblPreadjustment.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold);
this.lblPreadjustment.Location = new System.Drawing.Point(120, 1);
this.lblPreadjustment.Name = "lblPreadjustment";
this.lblPreadjustment.Size = new System.Drawing.Size(23, 22);
this.lblPreadjustment.TabIndex = 15;
this.lblPreadjustment.Text = "V";
//
// label1
//
this.label1.AutoSize = true;
this.label1.BackColor = System.Drawing.Color.LightGray;
this.label1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold);
this.label1.Location = new System.Drawing.Point(3, 4);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(23, 22);
this.label1.TabIndex = 22;
this.label1.Text = "S";
//
// lblPcbId
//
this.lblPcbId.AutoSize = true;
this.lblPcbId.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lblPcbId.Location = new System.Drawing.Point(29, 5);
this.lblPcbId.Name = "lblPcbId";
this.lblPcbId.Size = new System.Drawing.Size(79, 15);
this.lblPcbId.TabIndex = 21;
this.lblPcbId.Text = "000000000";
//
// button1
//
this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.button1.Font = new System.Drawing.Font("Arial", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.button1.Location = new System.Drawing.Point(422, -2);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(28, 33);
this.button1.TabIndex = 23;
this.button1.Text = "►";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// ctlEasyMeterRdy
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.Controls.Add(this.button1);
this.Controls.Add(this.label1);
this.Controls.Add(this.lblPcbId);
this.Controls.Add(this.lblPreadjustment);
this.Controls.Add(this.lblFlowTest);
this.Controls.Add(this.lblDataP3);
this.Controls.Add(this.lblDataP2);
this.Controls.Add(this.lblDataP1);
this.Controls.Add(this.lblDataDisplay);
this.Controls.Add(this.lblDataOverall);
this.Controls.Add(this.lblLed);
this.Controls.Add(this.lblLogin);
this.Name = "ctlEasyMeterRdy";
this.Size = new System.Drawing.Size(452, 30);
this.Load += new System.EventHandler(this.ctlMeterReady_Load);
this.MouseEnter += new System.EventHandler(this.ctlEasyMeterRdy_MouseEnter);
this.MouseLeave += new System.EventHandler(this.ctlEasyMeterRdy_MouseLeave);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label lblLogin;
private System.Windows.Forms.Label lblLed;
private System.Windows.Forms.Label lblDataOverall;
private System.Windows.Forms.Label lblDataDisplay;
private System.Windows.Forms.Label lblDataP1;
private System.Windows.Forms.Label lblDataP2;
private System.Windows.Forms.Label lblDataP3;
private System.Windows.Forms.Timer tmrBusy;
private System.Windows.Forms.Label lblFlowTest;
private System.Windows.Forms.Label lblPreadjustment;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label lblPcbId;
private System.Windows.Forms.Button button1;
}
}
@@ -0,0 +1,719 @@
using Logic.ProductionToProductMapper.Cordonel;
using Newtonsoft.Json;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Runtime.InteropServices;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using Xylem.Common.CommonCore.Configuration;
using Xylem.Common.Hardware.WaterMeter.Genesis.DataPackages.EventArguments;
using Xylem.Common.Hardware.WaterMeter.Genesis.DataPackages.MeasurementRecords;
using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore;
using Xylem.Common.Hardware.WaterMeter.Genesis.Registers;
using Xylem.Common.Hardware.WaterMeter.WaterMeterCore;
using Xylem.Common.Logic.SoftwareAccessHelper;
using XylemCommonUiLegacyGenCtl.DataPackage;
using XylemCommonUiLegacyGenCtl.Enums;
namespace XylemCommonUiLegacyGenCtl
{
[Guid("532F05D1-3317-4f00-B5D9-6CBB208B6B58")]
[ComSourceInterfaces(typeof(IEasyMeterRdy))]
[ComVisible(true)]
public partial class ctlEasyMeterRdy : UserControl, IEasyMeterRdy
{
public event OnPop Expand;
public event OnStateChange StateChange;
public event EventHandler OnStateChanged;
private MeterReadyResults FlowState = MeterReadyResults.NotStarted;
private MeterReadyResults Path1State = MeterReadyResults.NotStarted;
private MeterReadyResults Path2State = MeterReadyResults.NotStarted;
private MeterReadyResults Path3State = MeterReadyResults.NotStarted;
private ConcurrentBag<FlowTestRecord> FlowRecords;
private ConcurrentBag<CalibrationRecord> PathRecords;
private Task MainTask;
private enum TaskState
{
//allGrey
Init,
SetSlot,
SetPcbId,
LoginInProgress,
LoginDone,
LedInProgress,
LedDone,
MessurementInProgress,
MessurementDone,
MessurementDoneWithHint,
LoginFailed,
LedFailed,
MessurementFailed,
Fatal,
}
private bool isBusy;
private TaskState currentState = TaskState.Init;
public string PcbId = "-";
private GenesisMeter meter;
public string OrderNumber { get; set; }
public string RadioAdress { get; set; }
public string CustomerSerialNr { get; set; }
public string CalibrationRun { get; set; }
public int LastTestBechState { get; set; }
public MeterSize Metersize { get; set; } = MeterSize.NAN;
public ctlEasyMeterRdy(int v)
{
SetSlot(v);
InitializeComponent();
button1.Text = "►";
this.Width = 140;
var vis = false;
lblPreadjustment.Visible = vis;
lblFlowTest.Visible = vis;
lblLogin.Visible = vis;
lblLed.Visible = vis;
lblDataOverall.Visible = vis;
lblDataDisplay.Visible = vis;
lblDataP1.Visible = vis;
lblDataP2.Visible = vis;
lblDataP3.Visible = vis;
}
private void changeCurrentSlotState(TaskState NewState)
{
if (NewState != currentState)
{
currentState = NewState;
OnStateChanged?.Invoke(currentState, EventArgs.Empty);
}
if (NewState >= TaskState.SetPcbId)
{
Invoke(new Action(() =>
{
setUi(PcbId, NewState, FlowState, Path1State, Path2State, Path3State);
}));
}
}
private Color NonColor = Color.LightGray;
private Color CurrentColor = Color.FromArgb(0xff, 0xf5, 0x9d);
private Color alterColor = Color.FromArgb(0xff, 0xf9, 0xc4);
private Color ErrorColor = Color.FromArgb(0xef, 0x53, 0x50);
private Color DoneColor = Color.FromArgb(0x81, 0xc7, 0x84);
private void setUi(string pcbId, TaskState newState, MeterReadyResults flowState, MeterReadyResults path1State, MeterReadyResults path2State, MeterReadyResults path3State)
{
lblPcbId.Text = pcbId;
lblLogin.BackColor = NonColor;
lblLed.BackColor = NonColor;
lblDataOverall.BackColor = NonColor;
lblDataDisplay.BackColor = NonColor;
lblDataP1.BackColor = NonColor;
lblDataP2.BackColor = NonColor;
lblDataP3.BackColor = NonColor;
if (newState == TaskState.LoginInProgress)
{
lblLogin.BackColor = CurrentColor;
return;
}
if (newState == TaskState.Fatal || newState == TaskState.LoginFailed)
{
lblLogin.BackColor = ErrorColor;
return;
}
lblDataDisplay.BackColor = MeterStateToColor(flowState);
lblDataP1.BackColor = MeterStateToColor(path1State);
lblDataP2.BackColor = MeterStateToColor(path2State);
lblDataP3.BackColor = MeterStateToColor(path3State);
if (newState >= TaskState.LoginDone)
{
lblLogin.BackColor = DoneColor;
if (newState == TaskState.LedInProgress)
{
lblLed.BackColor = CurrentColor;
return;
}
if (newState == TaskState.Fatal || newState == TaskState.LedFailed)
{
lblLed.BackColor = ErrorColor;
return;
}
if (newState >= TaskState.LedDone)
{
lblLed.BackColor = DoneColor;
if (newState == TaskState.MessurementInProgress)
{
lblDataOverall.BackColor = CurrentColor;
return;
}
if (newState == TaskState.Fatal || newState == TaskState.MessurementFailed)
{
lblDataOverall.BackColor = ErrorColor;
return;
}
if (newState == TaskState.MessurementDone || newState == TaskState.MessurementDoneWithHint)
{
lblDataOverall.BackColor = DoneColor;
}
}
}
}
internal void SetSlot(int key)
{
changeCurrentSlotState(TaskState.SetSlot);
meterSlot = key;
overallMeterBatch = new MeterBatch();
}
private Color MeterStateToColor(MeterReadyResults state)
{
switch (state)
{
case MeterReadyResults.NotStarted:
return NonColor;
case MeterReadyResults.NoRecords:
return ErrorColor;
case MeterReadyResults.OnlyInvalidRecords:
return ErrorColor;
case MeterReadyResults.MixedInvalidRecords:
return Color.Orange;
case MeterReadyResults.OnlyValidRecords:
return DoneColor;
}
return ErrorColor;
}
private void setMeterInfo(string SerialNumber, bool? Preadjustment, bool? FlowTest)
{
Invoke(new Action(() =>
{
setMeterInfoUi(SerialNumber, Preadjustment, FlowTest);
}));
}
private void setMeterInfoUi(string SerialNumber, bool? Preadjustment, bool? FlowTest)
{
if (Preadjustment.HasValue)
{
if (Preadjustment.Value)
{
lblPreadjustment.BackColor = DoneColor;
}
else
{
lblPreadjustment.BackColor = ErrorColor;
}
}
else
{
lblPreadjustment.BackColor = NonColor;
}
if (FlowTest.HasValue)
{
if (FlowTest.Value)
{
lblFlowTest.BackColor = DoneColor;
}
else
{
lblFlowTest.BackColor = ErrorColor;
}
}
else
{
lblFlowTest.BackColor = NonColor;
}
}
internal void StartGetMeterInfos(string PcbId)
{
var t = new Task(() =>
{
var at = 0;
if (int.TryParse(PcbId, out at))
{
var responseJson = LocalWebRequest.GetRequest($"{ServiceUrls.MeterInfoForTestBench()}{PcbId}");
var a = JsonConvert.DeserializeObject<string[]>(responseJson);
var SerialNumber = a[0];
if (!String.IsNullOrEmpty(SerialNumber))
{
OrderNumber = a[1];
RadioAdress = a[2];
CustomerSerialNr = a[3];
CalibrationRun = a[4];
LastTestBechState = 0;
bool? HyState = null;
bool? preState = null;
if (!string.IsNullOrEmpty(a[5]))
{
var tmp = 0;
int.TryParse(a[5], out tmp);
LastTestBechState = tmp;
}
if (!string.IsNullOrEmpty(a[6]))
{
var tmp = 0;
int.TryParse(a[6], out tmp);
Metersize = MeterSizeConverter.ConvertToMeter(tmp);
}
if (LastTestBechState <= 20)
{
HyState = null;
}
else if (LastTestBechState <= 30)
{
HyState = true;
}
else
{
HyState = false;
}
if (!string.IsNullOrEmpty(CalibrationRun))
{
preState = true;
}
setMeterInfo(SerialNumber, preState, HyState);
}
}
else
{
setMeterInfo("-", false, false);
}
});
t.Start();
}
private CancellationTokenSource CancellationTokenSource = new CancellationTokenSource();
public void Start(bool forceDisplayClear = false)
{
if (!isBusy)
{
var t = new Task(() =>
{
var ctlCancellationToken = CancellationTokenSource.Token;
try
{
var settingsToUse = new DefaultSettings();
meter = new GenesisMeter();
meter.SetupFromConfigFile(meterSlot, false, true, true);
overallMeterBatch.AddMeter(meter);
changeCurrentSlotState(TaskState.SetPcbId);
}
catch (Exception)
{
changeCurrentSlotState(TaskState.Fatal);
}
isBusy = true;
changeCurrentSlotState(TaskState.SetPcbId);
setMeterInfo("-", null, null);
if (ctlCancellationToken.IsCancellationRequested)
{
return;
}
try
{
if (currentState != TaskState.Fatal)
{
FlowState = MeterReadyResults.NotStarted;
Path1State = MeterReadyResults.NotStarted;
Path2State = MeterReadyResults.NotStarted;
Path3State = MeterReadyResults.NotStarted;
if (string.IsNullOrEmpty(meter.PcbId))
{
PcbId = meter.GetPcbId();
}
else
{
PcbId = meter.PcbId;
}
if (ctlCancellationToken.IsCancellationRequested)
{
return;
}
StartGetMeterInfos(PcbId);
changeCurrentSlotState(TaskState.LoginInProgress);
if (ctlCancellationToken.IsCancellationRequested)
{
return;
}
if (!string.IsNullOrEmpty(meter.PcbId) && meter.Login())
{
changeCurrentSlotState(TaskState.LoginDone);
if (ctlCancellationToken.IsCancellationRequested)
{
return;
}
if (forceDisplayClear)
{
meter.WriteRegister(Register.Genesisflow.TriggerIdle, 0, true, true);
}
meter.InitMeasurement();
FlowRecords = new ConcurrentBag<FlowTestRecord>();
PathRecords = new ConcurrentBag<CalibrationRecord>();
meter.StreamingProtocol.OnRecordIsDecoded += StreamingProtocol_OnRecordIsDecoded;
meter.SyncStreamingBuffer(Xylem.Common.CommonCore.Consts.SyncMarkRecord.DecodeEveryPackage);
changeCurrentSlotState(TaskState.LedInProgress);
var nrOfChecksLeft = 50;//50 * 100ms = 5 Sekunden
var startChnl = 1;
while (nrOfChecksLeft > 0)
{
if (ctlCancellationToken.IsCancellationRequested)
{
return;
}
if (currentState == TaskState.LedInProgress)
{
if (PathRecords.Any() || FlowRecords.Any())
{
changeCurrentSlotState(TaskState.MessurementInProgress);
nrOfChecksLeft = 100;
}
}
else
{
//check every path
if (FlowRecords.Any() && FlowState != MeterReadyResults.MixedInvalidRecords)
{
if (FlowRecords.All(a => a.IsValid))
{
FlowState = MeterReadyResults.OnlyValidRecords;
}
else if (FlowRecords.All(a => !a.IsValid))
{
FlowState = MeterReadyResults.OnlyInvalidRecords;
}
else
{
FlowState = MeterReadyResults.MixedInvalidRecords;
}
}
else
{
FlowState = MeterReadyResults.NoRecords;
}
if (PathRecords.Any())
{
Path1State = NewMethod(Path1State, PathRecords.Where(c => c.Channel == 1).ToList());
Path2State = NewMethod(Path2State, PathRecords.Where(c => c.Channel == 2).ToList());
Path3State = NewMethod(Path3State, PathRecords.Where(c => c.Channel == 3).ToList());
}
}
nrOfChecksLeft = nrOfChecksLeft - 1;
Thread.Sleep(100);
}
if (currentState == TaskState.LedInProgress)
{
changeCurrentSlotState(TaskState.LedFailed);
}
else
{
var aggregate = new List<MeterReadyResults>();
aggregate.Add(FlowState);
aggregate.Add(Path1State);
aggregate.Add(Path2State);
aggregate.Add(Path3State);
if (aggregate.All(a => a == MeterReadyResults.OnlyValidRecords))
{
changeCurrentSlotState(TaskState.MessurementDone);
}
else if (aggregate.Any(a => a == MeterReadyResults.OnlyInvalidRecords))
{
changeCurrentSlotState(TaskState.MessurementFailed);
}
else
{
changeCurrentSlotState(TaskState.MessurementDoneWithHint);
}
}
}
else
{
changeCurrentSlotState(TaskState.LoginFailed);
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message + ex.StackTrace, "Error on check meter is ready");
}
finally
{
isBusy = false;
overallMeterBatch.RemoveMeter(meter);
meter?.Dispose();
}
});
t.Start();
}
}
internal MeterTestSettings GetMeterTestSettings()
{
var ret = new MeterTestSettings();
ret.Slot = meterSlot;
return ret;
}
private MeterReadyResults NewMethod(MeterReadyResults oldstate, List<CalibrationRecord> records)
{
if (records.Any())
{
if (records.All(a => a.Validation == 0))
{
return MeterReadyResults.OnlyValidRecords;
}
else if (records.All(a => a.Validation != 0))
{
return MeterReadyResults.OnlyInvalidRecords;
}
else
{
return MeterReadyResults.MixedInvalidRecords;
}
}
else
{
return MeterReadyResults.NoRecords;
}
}
private void StreamingProtocol_OnRecordIsDecoded(object sender, BaseDataEventArgs e)
{
try
{
if (e is CalibDataEventArgs)
{
PathRecords.Add(((CalibDataEventArgs)e).CalibChl);
}
if (e is FlowDataEventArgs)
{
FlowRecords.Add(((FlowDataEventArgs)e).NewData);
}
}
catch (Exception ex)
{
}
}
public new void Dispose()
{
CancellationTokenSource?.Cancel();
if (meter != null)
{
meter.Dispose();
}
base.Dispose();
}
private bool Light = false;
private MeterBatch overallMeterBatch;
private int meterSlot;
private void tmrBusy_Tick(object sender, EventArgs e)
{
if (isBusy)
{
List<Label> lblList = new List<Label>()
{
lblLogin,
lblLed,
lblDataOverall,
lblDataDisplay,
lblDataP1,
lblDataP2,
lblDataP3
};
if (Light)
{
lblList.Where(a => a.BackColor == CurrentColor).ToList().ForEach(a => a.BackColor = alterColor);
Light = false;
}
else
{
lblList.Where(a => a.BackColor == alterColor).ToList().ForEach(a => a.BackColor = CurrentColor);
Light = true;
}
}
}
private void numericUpDown1_ValueChanged(object sender, EventArgs e)
{
}
private void label4_Click(object sender, EventArgs e)
{
}
private void ctlMeterReady_Load(object sender, EventArgs e)
{
}
private void lblSerialNr_Click(object sender, EventArgs e)
{
Start();
}
private void lblSlot_Click(object sender, EventArgs e)
{
Start();
}
private void lblPcbId_Click(object sender, EventArgs e)
{
Start();
}
private void lblDataDisplay_Click(object sender, EventArgs e)
{
Start(true);
}
private void lblPcbId_MouseLeave(object sender, EventArgs e)
{
}
private void ctlEasyMeterRdy_MouseLeave(object sender, EventArgs e)
{
// Expand?.Invoke(sender, new PopEventArgs() { Show = false });
}
public void OneStateChange()
{
throw new NotImplementedException();
}
public void OnPop(object sender, PopEventArgs e)
{
throw new NotImplementedException();
}
private void ctlEasyMeterRdy_MouseEnter(object sender, EventArgs e)
{
//
}
private void button1_Click(object sender, EventArgs e)
{
var vis = false;
//"◄►"
if (button1.Text == "►")
{
this.Width = 450;
Expand?.Invoke(sender, new PopEventArgs() { Show = true });
button1.Text = "◄";
vis = true;
}
else
{
this.Width = 140;
Expand?.Invoke(sender, new PopEventArgs() { Show = false });
button1.Text = "►";
this.Width = 140;
vis = false;
}
lblPreadjustment.Visible = vis;
lblFlowTest.Visible = vis;
lblLogin.Visible = vis;
lblLed.Visible = vis;
lblDataOverall.Visible = vis;
lblDataDisplay.Visible = vis;
lblDataP1.Visible = vis;
lblDataP2.Visible = vis;
lblDataP3.Visible = vis;
}
}
}
@@ -0,0 +1,123 @@
<?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>
<metadata name="tmrBusy.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>58, 16</value>
</metadata>
</root>