From 621537cd9318a8b438a0062955b2d7039bee28c3 Mon Sep 17 00:00:00 2001 From: Thomas Wiedebusch Date: Fri, 9 Sep 2022 18:53:03 +0200 Subject: [PATCH] ReSharper: -WaterMeterCore --- .../Ports/SerialPorts/BaseSerialPort.cs | 5 ++ .../Genesis/GenesisCore/GenesisMeter.cs | 4 +- .../WaterMeterCore/Consts/DisplayCodes.cs | 66 ++++++++++++++++++- .../WaterMeter/WaterMeterCore/MeterBatch.cs | 6 +- .../Ui/GenesisToolBox/FrmStreamingQuality.cs | 2 +- Common/Ui/GenesisToolBox/frmSetup.cs | 5 +- 6 files changed, 76 insertions(+), 12 deletions(-) diff --git a/Common/Hardware/Interfaces/Ports/SerialPorts/BaseSerialPort.cs b/Common/Hardware/Interfaces/Ports/SerialPorts/BaseSerialPort.cs index 4c753763..47445680 100644 --- a/Common/Hardware/Interfaces/Ports/SerialPorts/BaseSerialPort.cs +++ b/Common/Hardware/Interfaces/Ports/SerialPorts/BaseSerialPort.cs @@ -24,6 +24,11 @@ namespace Xylem.Common.Hardware.Interfaces.Ports.SerialPorts /// public virtual event EventHandler OnRawRecordReceived; + /// + /// The port is not assigned. + /// + public const String PortNotAssigned = "NA"; + /// public virtual event EventHandler OnRawRecordSendOut; diff --git a/Common/Hardware/WaterMeter/Genesis/GenesisCore/GenesisMeter.cs b/Common/Hardware/WaterMeter/Genesis/GenesisCore/GenesisMeter.cs index 8bb2c668..95cfce76 100644 --- a/Common/Hardware/WaterMeter/Genesis/GenesisCore/GenesisMeter.cs +++ b/Common/Hardware/WaterMeter/Genesis/GenesisCore/GenesisMeter.cs @@ -662,7 +662,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore /// public void ConnectMeter() { - if (RequestPort != null) + if (RequestPort != null && RequestPort.GetPortName() != BaseSerialPort.PortNotAssigned) { LinkPortToProtocol(RequestPort, RequestProtocol); _logger.Trace($"Slot:{Slot} - RequestPort and RequestProtocol linked"); @@ -670,7 +670,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore RequestProtocol.OnRecordIsDecoded += RequestProtocol_ApplyDecodedRecord; RequestProtocol.OnAuthorizationGrant += RequestProtocol_AuthorizationGrant; } - if (StreamingPort != null) + if (StreamingPort != null && StreamingPort.GetPortName() != BaseSerialPort.PortNotAssigned) { LinkPortToProtocol(StreamingPort, StreamingProtocol); _logger.Trace($"Slot:{Slot} - StreamingPort and StreamingProtocol linked"); diff --git a/Common/Hardware/WaterMeter/WaterMeterCore/Consts/DisplayCodes.cs b/Common/Hardware/WaterMeter/WaterMeterCore/Consts/DisplayCodes.cs index 46880b0f..273989e3 100644 --- a/Common/Hardware/WaterMeter/WaterMeterCore/Consts/DisplayCodes.cs +++ b/Common/Hardware/WaterMeter/WaterMeterCore/Consts/DisplayCodes.cs @@ -1,40 +1,100 @@ namespace Xylem.Common.Hardware.WaterMeter.WaterMeterCore.Consts { + /// + /// Display codes to keep the user informed about the production and processing step. + /// This is useful as the user doesn't need to connect the device to a PC, he can + /// immediately inspect the status of the device. + /// public enum DisplayCodes { - //general + //general information + /// + /// Status not set + /// None = 0x0000, + /// + /// Error state + /// Error = 0xFFFF, - //Production proccess + //Production process //assembly line //Picking + /// + /// Picking in progress + /// PickingStarted = 0x7700, + /// + /// Picking succeeded, next step can be initiated + /// PickingTested = 0x7777, + /// + /// Picking failed + /// PickingFailed = 0xFF77, //Pressure + /// + /// Pressure testing succeeded, next step can be initiated + /// PressureTested = 0x1111, + /// + /// Pressure test failed + /// PressureTestedFailed = 0xFF11, //Marriage + /// + /// Connection between PCBID, Serial Number and Order number done + /// Mounted = 0x2222, - //Testbench + //Test bench + /// + /// Zero flow test succeeded, next step can be initiated + /// ZeroFlow = 0x3333, + /// + /// Zero flow test failed + /// ZeroFlowFailed = 0xFF33, + /// + /// Flow calibration succeeded, next step can be initiated + /// FlowCalibrated = 0x4444, + /// + /// Flow calibration failed + /// FlowCalibrationOurOfRange = 0xFF44, + /// + /// Flow test succeeded, next step can be initiated + /// FlowTested = 0x5555, + /// + /// Flow test failed + /// FlowTestFailed = 0xFF55, //End of line / final test + /// + /// Final test failed, else the display will be switched to operational mode, + /// showing the actual accumulated volume + /// FinalTestFailed = 0xFF66, //FWUpdate + /// + /// FW update is ongoing + /// FwUpdateActive = 0x8888, + /// + /// FW update failed + /// FwUpdateFailed = 0xFF88, + /// + /// FW update succeeded + /// FwUpToDate = 0x9999, } } diff --git a/Common/Hardware/WaterMeter/WaterMeterCore/MeterBatch.cs b/Common/Hardware/WaterMeter/WaterMeterCore/MeterBatch.cs index 32cae414..86ee18e3 100644 --- a/Common/Hardware/WaterMeter/WaterMeterCore/MeterBatch.cs +++ b/Common/Hardware/WaterMeter/WaterMeterCore/MeterBatch.cs @@ -24,14 +24,14 @@ namespace Xylem.Common.Hardware.WaterMeter.WaterMeterCore { private readonly List _meterTypeRegistersCollection = new List(); private readonly ILogger _logger; - private readonly string _sourceLocation; + private readonly String _sourceLocation; /// /// ctor /// - public MeterBatch(String SourceLocation = "") + public MeterBatch(String sourceLocation = "") { - SourceLocation = _sourceLocation; + _sourceLocation = sourceLocation; _logger = NLogHelper.CreateOrGetLogger("MeterBatch"); _logger.Info("Meter batch created"); diff --git a/Common/Ui/GenesisToolBox/FrmStreamingQuality.cs b/Common/Ui/GenesisToolBox/FrmStreamingQuality.cs index 3a5ce0d7..2c3acf6f 100644 --- a/Common/Ui/GenesisToolBox/FrmStreamingQuality.cs +++ b/Common/Ui/GenesisToolBox/FrmStreamingQuality.cs @@ -27,7 +27,7 @@ namespace Xylem.Common.Ui.GenesisToolBox public partial class FrmStreamingQuality : Form { private GenesisMeterStreamingQuality _currentGenesis; - private MeterBatch _meterBatch = new MeterBatch("C:\\Users\\drabesch_ro\\Downloads\\ReleaseV1.1.2.6\\"); + private MeterBatch _meterBatch = new MeterBatch(); private readonly ILogger _logger; private const Int32 SampleRateHz = 16; private Int32 _channels; diff --git a/Common/Ui/GenesisToolBox/frmSetup.cs b/Common/Ui/GenesisToolBox/frmSetup.cs index cd6460b6..b96629e7 100644 --- a/Common/Ui/GenesisToolBox/frmSetup.cs +++ b/Common/Ui/GenesisToolBox/frmSetup.cs @@ -7,7 +7,6 @@ using System.Drawing; using System.IO; using System.IO.Ports; using System.Linq; -using System.Runtime.CompilerServices; using System.Threading; using System.Windows.Forms; using System.Xml.Linq; @@ -281,11 +280,11 @@ namespace Xylem.Common.Ui.GenesisToolBox { if (portList.All(pl => pl != (String)row[StreamingPortString])) { - ret.Rows.Add(row[StreamingPortString].ToString(), "NA"); + ret.Rows.Add(row[StreamingPortString].ToString(), BaseSerialPort.PortNotAssigned); } if (portList.All(pl => pl != (String)row[RequestPortString])) { - ret.Rows.Add(row[RequestPortString].ToString(), "NA"); + ret.Rows.Add(row[RequestPortString].ToString(), BaseSerialPort.PortNotAssigned); } }