diff --git a/Common/.shared/SharedAssemblyInfo.cs b/Common/.shared/SharedAssemblyInfo.cs index 0d00d376..52747df5 100644 --- a/Common/.shared/SharedAssemblyInfo.cs +++ b/Common/.shared/SharedAssemblyInfo.cs @@ -14,5 +14,5 @@ using System.Reflection; //[assembly: AssemblyVersion("1.2.*.0")] -[assembly: AssemblyVersion("2.3.4.*")] -[assembly: AssemblyFileVersion("2.3.4.0")] \ No newline at end of file +[assembly: AssemblyVersion("2.3.5.*")] +[assembly: AssemblyFileVersion("2.3.5.0")] \ No newline at end of file diff --git a/Common/Common.sln.DotSettings b/Common/Common.sln.DotSettings index 588a89aa..4d2ea367 100644 --- a/Common/Common.sln.DotSettings +++ b/Common/Common.sln.DotSettings @@ -47,6 +47,7 @@ True True True + True True True True diff --git a/Common/Common.sln.DotSettings.user b/Common/Common.sln.DotSettings.user index 68fd2006..2ad4797a 100644 --- a/Common/Common.sln.DotSettings.user +++ b/Common/Common.sln.DotSettings.user @@ -27,7 +27,7 @@ True NewVersion True - C:\Users\Thomas\AppData\Local\Temp\JetBrains\ReSharperPlatformVs15\vAny_33007af5\CoverageData\_Common.-1885154465\Snapshot\snapshot.utdcvr + diff --git a/Common/Hardware/WaterMeter/Genesis/GenesisCore/GenesisMeter.cs b/Common/Hardware/WaterMeter/Genesis/GenesisCore/GenesisMeter.cs index 9a78e235..affc74e9 100644 --- a/Common/Hardware/WaterMeter/Genesis/GenesisCore/GenesisMeter.cs +++ b/Common/Hardware/WaterMeter/Genesis/GenesisCore/GenesisMeter.cs @@ -947,10 +947,13 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore /// /// - PcbId unknown returns immediately. /// + /// + /// - Password had been reset to empty string if read from file, corrected! + /// private String GetPassword() { var url = ServiceUrls.GenesisGetPasswordServiceUrl(); - String password; + var password = ""; //without PCB ID it is not possible to login, //but if it is already assigned to this Gensis, don't read it again @@ -966,7 +969,6 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore } } - } url += PcbId; @@ -993,16 +995,14 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore $"URL({url}), Error({ex.Message})"); if (File.Exists(ProgramConfig.OfflineInfoFile)) { - var listOfOfflinePasswords = JsonConvert.DeserializeObject>(File.ReadAllText(ProgramConfig.OfflineInfoFile)); + var listOfOfflinePasswords = JsonConvert.DeserializeObject>( + File.ReadAllText(ProgramConfig.OfflineInfoFile)); password = listOfOfflinePasswords.First(x => x.PcbId == PcbId).Password; if (!string.IsNullOrEmpty(password)) { _logger.Info($"Slot:{Slot} - Got password from password file!"); } } - - password = ""; - } return password; @@ -1053,7 +1053,8 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore /// public Boolean ReLogin() { - if (IsLoggedOn) return true; + if (IsLoggedOn) + return true; return string.IsNullOrEmpty(_password) ? Login() : Login(_password); } @@ -1175,7 +1176,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore /// converted version to string public static String BuildFwVersionString(Int32? version) { - return version == null ? "0.00" : $@"{version / 100}.{version % 100 :D2}"; + return version == null ? "0.00" : $@"{version / 100}.{version % 100:D2}"; } /// @@ -1219,6 +1220,61 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore /// public Byte MetrologyUpgradePermission; + /// + /// Check region and size. + /// After reading the version, all valid registers are going to be selected. + /// + /// + /// - Initial, extracted from + /// + public void CheckRegionSizeLutCrc() + { + //read metrology lookup table CRC + try + { + var lutCrcRaw = ReadRegister(Register.Genesisflow.LookupFileCrc); + if (lutCrcRaw != null) + { + var lutCrc = RegisterConverter.ConvertTo(lutCrcRaw); + LutCrc = $@"0x{lutCrc:X4}"; + } + } + catch (Exception) + { + // ignored + } + + //read meter size + MeterSize = MeterSizeConverter.ConvertMeterSizeEnumToSizeName((MeterSize)RegisterConverter.ConvertTo( + ReadRegister(Register.Genesisflow.MeterSize))); + + //read radio frequency + Region = "NA"; + RadioFrequencyMhz = null; + try + { + var radioFrequencyRaw = ReadRegister(Register.Sensusradio.FrequencyIndicator); + if (radioFrequencyRaw != null ) + { + Region = "EMEA"; + RadioFrequencyMhz = RegisterConverter.ConvertTo(radioFrequencyRaw); + } + } + catch (Exception) + { + // ignored + } + + // check meter size string contains "DN", because if "US" it cannot be an EMEA version + if ((Region.Contains("NA") && MeterSize.Contains("DN")) || + (Region.Contains("EMEA") && MeterSize.Contains("US"))) + { + Region = "?"; + MeterSize = "?"; + LutCrc = "?"; + } + } + /// /// Reading all applications which can be found in the configuration.json and have been stored /// to the meter register dictionary in advance. @@ -1245,6 +1301,9 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore /// - RadioFrequencyMhz introduced as Int32? (null if "NA" region or not installed), /// - LutCrc from String to Int32?. /// + /// + /// - Checked meter size string for "DN", than it cannot be an EMEA version. + /// private void ReadMeterFirmwareAndAssignRegisters() { //avoid overwriting of list if this already exits @@ -1312,29 +1371,12 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore }); } + CheckRegionSizeLutCrc(); + //read metrology upgrade permission MetrologyUpgradePermission = RegisterConverter.ConvertTo( ReadRegister(Register.System.MetrologyUpgradePermission)); - //read metrology lookup table CRC - try - { - var lutCrcRaw = ReadRegister(Register.Genesisflow.LookupFileCrc); - if (lutCrcRaw != null) - { - var lutCrc = RegisterConverter.ConvertTo(lutCrcRaw); - LutCrc = $@"0x{lutCrc:X4}"; - } - } - catch (Exception) - { - // ignored - } - - //read meter size - MeterSize = MeterSizeConverter.ConvertMeterSizeEnumToSizeName((MeterSize)RegisterConverter.ConvertTo( - ReadRegister(Register.Genesisflow.MeterSize))); - //read core revision var coreRegisterRead = RegisterConverter.ConvertTo(ReadRegister(Register.System.CoreRevision, 16)); CoreRevision = null; @@ -1353,24 +1395,6 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore } } - //read radio frequency - Region = "NA"; - RadioFrequencyMhz = null; - try - { - var radioFrequencyRaw = ReadRegister(Register.Sensusradio.FrequencyIndicator); - if (radioFrequencyRaw != null) - { - Region = "EMEA"; - RadioFrequencyMhz = RegisterConverter.ConvertTo(radioFrequencyRaw); - } - } - catch (Exception) - { - // ignored - } - - //log application information to file _logger.Info($"PCB ID: {PcbId}"); _logger.Info($"Date time (UTC): {DateTimeOffset.UtcNow}"); @@ -1394,6 +1418,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore } _logger.Info($"Meter size: {MeterSize}"); + _logger.Info($"Upgrade permission: {MetrologyUpgradePermission:X2}"); //remove unused registers with invalid version var tempConfigRegisters = _configRegister.MeterRegisterDic.ToList(); @@ -1421,13 +1446,14 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore } foreach (var checkMinRegister in Register.GetMinRequiredRegisters()) { - if (!_configRegister.MeterRegisterDic.Any(a => a.Key.GetIdent() == checkMinRegister)) + if (_configRegister.MeterRegisterDic.All(a => a.Key.GetIdent() != checkMinRegister)) { // These registers ar required for essential operation, they have to be added even if the // version in the configuration.json is outdated or they are not defined! try { - var allVersion = tempConfigRegisters.Where(a => a.Key.GetIdent() == checkMinRegister)?.OrderByDescending(s => s.Key.RegisterDetail.Version.Last)?.First(); + var allVersion = tempConfigRegisters.Where(a => a.Key.GetIdent() == checkMinRegister)?.OrderByDescending( + s => s.Key.RegisterDetail.Version.Last)?.First(); if (allVersion.HasValue) { allVersion.Value.Key.RegisterDetail.Version.Last = int.MaxValue; @@ -1439,12 +1465,9 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore _logger.Warn(ex, $"Not able to set minimum list of registers. check json file for {checkMinRegister} "); } - } - } - if (IsDevelopmentUsage) { var registerToPotentialAdd = new List(); @@ -1457,21 +1480,17 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore } if (registerToPotentialAdd.Any()) { - - var registerAddForOldConfigs = registerToPotentialAdd.GroupBy(item => item.GetIdent()) .Select(grp => grp.Aggregate((max, cur) => - (max == null || cur.RegisterDetail.Version.Last > max.RegisterDetail.Version.Last) ? cur : max)); + (max == null || cur.RegisterDetail.Version.Last > max.RegisterDetail.Version.Last) ? + cur : max)); foreach (var registerAddOldConfig in registerAddForOldConfigs) { registerAddOldConfig.IsAvailable = false; _configRegister.MeterRegisterDic.TryAdd(registerAddOldConfig, null); } - // - } - } } @@ -1729,15 +1748,15 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore _logger.Info($"Slot:{Slot} - Old PCB identification was {PcbId}"); - var pcbIdRaw = ReadRegister(Register.Configexchange.PcbSerialNumber, expectedLength); - if (pcbIdRaw != null) - { - PcbId = Encoding.ASCII.GetString(pcbIdRaw).Split('\0')[0]; - _logger.Info($"Slot:{Slot} - Get PCB identification {PcbId}"); - return PcbId; - } + var pcbIdRaw = ReadRegister(Register.Configexchange.PcbSerialNumber, expectedLength); + if (pcbIdRaw != null) + { + PcbId = Encoding.ASCII.GetString(pcbIdRaw).Split('\0')[0]; + _logger.Info($"Slot:{Slot} - Get PCB identification {PcbId}"); + return PcbId; + } - return string.Empty; + return string.Empty; } /// @@ -1816,9 +1835,9 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore { var regDef = _configRegister.GetRegisterDefinitionByName(reg); var data = RegisterConverter.ConvertFrom(value); - _logger.Info( $"Slot:{Slot} - Write register({regDef.RegisterName}), " + + _logger.Info($"Slot:{Slot} - Write register({regDef.RegisterName}), " + $"record({BitConverter.ToString(data.ToArray())})"); - + PreRegisterWrite(regDef, data); var command = data.Length > RegisterDefinition.ChunkSize ? @@ -1897,7 +1916,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore if (IsLoggedOn) { _logger.Debug($"Slot:{Slot} - Authorization is required"); - + if (!string.IsNullOrEmpty(_password)) { IsLoggedOn = false; @@ -1911,7 +1930,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore case RequestAcknowledgeState.Ok: break; - + //try out this case RequestAcknowledgeState.CommandError: case RequestAcknowledgeState.MeterError: @@ -1927,7 +1946,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore /// - Initial /// // ReSharper disable once InconsistentNaming UI1236 is a naming forced by the caller - public Byte[] SendUI1236Command(Byte[] ui1236Frame,Boolean waitForResult = true,Boolean checkRegister = false,UInt16 skipRetryErrorCode = 4) + public Byte[] SendUI1236Command(Byte[] ui1236Frame, Boolean waitForResult = true, Boolean checkRegister = false, UInt16 skipRetryErrorCode = 4) { _logger.Info($"Slot:{Slot} - Sending Ui-1236 frame: {ui1236Frame} "); var sendFifoUi1236 = RequestProtocol.AddRecordToSendFifoUI1236(ui1236Frame); diff --git a/Common/Hardware/WaterMeter/Genesis/GenesisFile/MeterFile.cs b/Common/Hardware/WaterMeter/Genesis/GenesisFile/MeterFile.cs index fffb75f2..78afd9c7 100644 --- a/Common/Hardware/WaterMeter/Genesis/GenesisFile/MeterFile.cs +++ b/Common/Hardware/WaterMeter/Genesis/GenesisFile/MeterFile.cs @@ -29,16 +29,11 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile private readonly GenesisMeter _currentGenesis; private Int32 _filePointer; - //TODO THW test only private const String StrNewFileReadWriteMode = "wb+"; - //wb open file for writing in binary mode, if file exists its contents will be overwritten, - //if file does not exist it will be created //private const String StrNewFileReadWriteMode = "wb"; - private const String StrNewFileReadWriteMode = "w"; - //Open for reading in binary mode. If the file does not exist, FOpen returns NULL //private const String StrOpenFileReadOnlyMode = "rb"; - private const String StrOpenFileReadOnlyMode = "r"; - //Open for both reading and writing in binary mode. If the file does not exist, FOpen returns NULL //private const String StrOpenFileReadWriteMode = "rb+"; + private const String StrNewFileReadWriteMode = "w"; + private const String StrOpenFileReadOnlyMode = "r"; private const String StrOpenFileReadWriteMode = "r+"; /// diff --git a/Common/Hardware/WaterMeter/Genesis/GenesisFile/MeterFwUpdate.cs b/Common/Hardware/WaterMeter/Genesis/GenesisFile/MeterFwUpdate.cs index 57a18ed3..0aa82f1d 100644 --- a/Common/Hardware/WaterMeter/Genesis/GenesisFile/MeterFwUpdate.cs +++ b/Common/Hardware/WaterMeter/Genesis/GenesisFile/MeterFwUpdate.cs @@ -176,6 +176,11 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile /// public Boolean StoreConfigEnable = true; + /// + /// Allow update of genesis flow application + /// + public Boolean UpdateGenesisFlowEnable; + /// /// Enable partial file writes from first failed part to the end /// @@ -245,6 +250,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile /// Ctor /// /// + /// enable update of genesis flow app /// /// - Initial /// @@ -254,13 +260,14 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile /// /// - Check installed application before require access to registers. /// - public MeterFwUpdate(GenesisMeter genesisMeter) + public MeterFwUpdate(GenesisMeter genesisMeter, Boolean updateGenesisFlowEnable = false) { if (genesisMeter == null) { return; } + UpdateGenesisFlowEnable = updateGenesisFlowEnable; AssignGenesis(genesisMeter); if (genesisMeter.MeterAppListVersion.Any(f => f.AppName == "GENESISFLOW" && f.IsInstalled)) @@ -981,6 +988,9 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile /// /// - Try catch block to avoid e.g. METROLOGYASST_PulseMode. /// + /// + /// - Set upgrade permission for metrology to 0xFF if required (will be done by GTB). + /// public Boolean UpdatePreparation() { _actualOperation = Resources.StrFwUpdateStatePrepareUpdate; @@ -1019,6 +1029,10 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile _registersAfterUpdate = new Dictionary(); try { + if (UpdateGenesisFlowEnable) + { + _genesisMeter.WriteRegister(Register.System.MetrologyUpgradePermission, new Byte[] { 0xFF }); + } foreach (var item in _registersBeforeUpdate) { var writeBackValue = _genesisMeter.ReadRegister(item.Key); @@ -1031,6 +1045,8 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile { //nothing to handle } + _genesisMeter.MetrologyUpgradePermission = RegisterConverter.ConvertTo( + _genesisMeter.ReadRegister(Register.System.MetrologyUpgradePermission)); //remove the update stop action StopUpdateProcess = false; @@ -1829,15 +1845,20 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile /// /// - Extended timeout. /// + /// + /// - Set retry counter to 0, + /// - reduce timeout from 5000 to 2000 ms. + /// private Boolean TriggerUpgrade() { Boolean returnValue; //trigger upgrade _actualOperation = Resources.StrFwUpdateStateTriggerUpgrade; + _updateProcedureRetryCtr = 0; var triggerCtr = 0; //set extended timeout for trigger upgrade response delay - _genesisMeter.TransmitProtocol.SetResponseTimeout(5000); + _genesisMeter.TransmitProtocol.SetResponseTimeout(2000); do { returnValue = _genesisMeter.WriteRegister(Register.System.TriggerFwUpgrade, 1); diff --git a/Common/Hardware/WaterMeter/Genesis/GenesisFile/MeterLutUpdate.cs b/Common/Hardware/WaterMeter/Genesis/GenesisFile/MeterLutUpdate.cs index 06cb0ff2..ae549d6f 100644 --- a/Common/Hardware/WaterMeter/Genesis/GenesisFile/MeterLutUpdate.cs +++ b/Common/Hardware/WaterMeter/Genesis/GenesisFile/MeterLutUpdate.cs @@ -434,6 +434,9 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile /// /// - Introduced lock for repeated execution of state machine /// + /// + /// - Started state machine with download of new mettbl. + /// private void LutUpdateStateMachine() { if (_lutBackupUpdateState == _lutUpdateState) @@ -451,7 +454,9 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile case LutUpdateState.StartInitial: _updateProcedureRetryCtr = 0; - _lutUpdateState = LutUpdateState.EraseLutFile; + _lutUpdateState = LutUpdateState.DownloadLutFile; + + //_lutUpdateState = LutUpdateState.EraseLutFile; break; case LutUpdateState.EraseLutFile: @@ -562,6 +567,9 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile /// /// - Initial /// + /// + /// - Used genesis meter lut crc, region and meter size read back procedure. + /// private Boolean FinalizeLutDownload() { var returnValue = true; @@ -616,12 +624,11 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile continue; } - _operationCtr++; - _actualOperation = "Read back LUT CRC from meter"; - var lutCrc = RegisterConverter.ConvertTo( - _genesisMeter.ReadRegister(Register.Genesisflow.LookupFileCrc)); + // read back all values + _genesisMeter.CheckRegionSizeLutCrc(); - if ((lutCrc & LutCrcErrorMask) != 0) + var lutFileCrc = $"0x{LutFile.FileCrc:X4}"; + if (!_genesisMeter.LutCrc.Equals(lutFileCrc)) { const String txt = "Meter LUT CRC could not be set!"; ErrorMessage = txt; @@ -632,14 +639,10 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile } OnProcessUpdate?.Invoke(this, - new ProcessExecEventArgs($"Read back and validated LUT CRC 0x{lutCrc:X4}")); + new ProcessExecEventArgs($"Read back and validated LUT CRC {_genesisMeter.LutCrc}")); - _operationCtr++; - _actualOperation = "Read back meter size from meter"; - var meterSize = (MeterSize)RegisterConverter.ConvertTo( - _genesisMeter.ReadRegister(Register.Genesisflow.MeterSize)); - - if (meterSize != LutFile.MeterSize) + var lutMeterSize = MeterSizeConverter.ConvertMeterSizeEnumToSizeName(LutFile.MeterSize); + if (!_genesisMeter.MeterSize.Equals(lutMeterSize)) { const String txt = "Meter size could not be set!"; ErrorMessage = txt; @@ -651,8 +654,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile ErrorMessage = ""; OnProcessUpdate?.Invoke(this, - new ProcessExecEventArgs("Read back and validated meter size " + - $"{MeterSizeConverter.ConvertMeterSizeEnumToSizeName(meterSize)}")); + new ProcessExecEventArgs($"Read back and validated meter size {lutMeterSize}")); } while (!returnValue && retryCtr++ < RegisterWriteRetries && !StopUpdateProcess); @@ -802,6 +804,9 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile /// /// - Initial /// + /// + /// - Removed list file drive 1 to speed up process. Files will be read back and binary compared! + /// private Boolean DownloadLutFiles() { //counters for actual process information @@ -845,26 +850,26 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile // read all files on drive 1 _operationCtr++; - if (ListMeterFilesDrive1()) - { - foreach (var checkInstalledFile in filesToDownload) - { - if (_meterFilesDrive1.Contains(checkInstalledFile)) - { - ErrorMessage = ""; - var txt = $"{checkInstalledFile} found in meter"; - OnProcessUpdate?.Invoke(this, new ProcessExecEventArgs(txt)); - continue; - } + //if (ListMeterFilesDrive1()) + //{ + // foreach (var checkInstalledFile in filesToDownload) + // { + // if (_meterFilesDrive1.Contains(checkInstalledFile)) + // { + // ErrorMessage = ""; + // var txt = $"{checkInstalledFile} found in meter"; + // OnProcessUpdate?.Invoke(this, new ProcessExecEventArgs(txt)); + // continue; + // } - ErrorMessage = $"LUT file {StrLutMeterFileName} not installed!\n"; - returnValue = false; - } - } - else - { - returnValue = false; - } + // ErrorMessage = $"LUT file {StrLutMeterFileName} not installed!\n"; + // returnValue = false; + // } + //} + //else + //{ + // returnValue = false; + //} if (!returnValue) { diff --git a/Common/Hardware/WaterMeter/WaterMeterCore/WaterMeterRegisters/obj/Debug/WaterMeterRegisters.csproj.CoreCompileInputs.cache b/Common/Hardware/WaterMeter/WaterMeterCore/WaterMeterRegisters/obj/Debug/WaterMeterRegisters.csproj.CoreCompileInputs.cache index f22623aa..d8b5c8f6 100644 --- a/Common/Hardware/WaterMeter/WaterMeterCore/WaterMeterRegisters/obj/Debug/WaterMeterRegisters.csproj.CoreCompileInputs.cache +++ b/Common/Hardware/WaterMeter/WaterMeterCore/WaterMeterRegisters/obj/Debug/WaterMeterRegisters.csproj.CoreCompileInputs.cache @@ -1 +1 @@ -5ed75d99ee45ff67821090f1b3dbb001dd9e4fe3 +1a3d4919c9c702245832d925951f2b7cb72fc333 diff --git a/Common/Metrology/Docu/CordonelCalFactorCalculationCheck.xlsx b/Common/Metrology/Docu/CordonelCalFactorCalculationCheck.xlsx new file mode 100644 index 00000000..22da15ee Binary files /dev/null and b/Common/Metrology/Docu/CordonelCalFactorCalculationCheck.xlsx differ diff --git a/Common/Metrology/Docu/CordonelCalFactorCalculationCheck_JustageVerscheidenWerte.xlsx b/Common/Metrology/Docu/CordonelCalFactorCalculationCheck_JustageVerscheidenWerte.xlsx new file mode 100644 index 00000000..c0de7756 Binary files /dev/null and b/Common/Metrology/Docu/CordonelCalFactorCalculationCheck_JustageVerscheidenWerte.xlsx differ diff --git a/Common/ProductionUiCordonel/App.xaml.cs b/Common/ProductionUiCordonel/App.xaml.cs index e252be06..38724c1a 100644 --- a/Common/ProductionUiCordonel/App.xaml.cs +++ b/Common/ProductionUiCordonel/App.xaml.cs @@ -1,5 +1,5 @@ -using System.Windows; -using System.Windows.Input; +using System; +using System.Windows; namespace ProductionUiCordonel { @@ -8,12 +8,7 @@ namespace ProductionUiCordonel /// public partial class App : Application { - public App() - { - //this.StartupUri = new Uri("MainWindow.xaml"); - //this.StartupUri = new Uri("MultiMode.xaml"); - } - private void Application_Startup(object sender, StartupEventArgs e) + private void Application_Startup(Object sender, StartupEventArgs e) { if (true) diff --git a/Common/ProductionUiCordonel/ApplicationSettings.cs b/Common/ProductionUiCordonel/ApplicationSettings.cs index 20369925..6c285692 100644 --- a/Common/ProductionUiCordonel/ApplicationSettings.cs +++ b/Common/ProductionUiCordonel/ApplicationSettings.cs @@ -1,7 +1,7 @@ -using Newtonsoft.Json; -using System; +using System; using System.Collections.Generic; using System.IO; +using Newtonsoft.Json; namespace ProductionUiCordonel { @@ -14,40 +14,40 @@ namespace ProductionUiCordonel public class Pos { - public double Left { get; set; } - public double Top { get; set; } - public double Height { get; set; } - public double Width { get; set; } + public Double Left { get; set; } + public Double Top { get; set; } + public Double Height { get; set; } + public Double Width { get; set; } } public class MultiFormChilds { public Type ViewModelType { get; set; } - public bool Visisble { get; set; } - public string Name { get; set; } - public int Slot { get; set; } - public string TextPort { get; set; } + public Boolean Visisble { get; set; } + public String Name { get; set; } + public Int32 Slot { get; set; } + public String TextPort { get; set; } public Pos StartPos { get; set; } } - public int Slot { get; set; } + public Int32 Slot { get; set; } - public int? PressureStationId { get; set; } - public bool AutoDetect { get; set; } + public Int32? PressureStationId { get; set; } + public Boolean AutoDetect { get; set; } - public bool AccessToPresuretestTab { get; set; } - public bool AccessToMarrieTab { get; set; } - public bool AccessToFinalcheckTab { get; set; } + public Boolean AccessToPresuretestTab { get; set; } + public Boolean AccessToMarrieTab { get; set; } + public Boolean AccessToFinalcheckTab { get; set; } - public bool AccessToSettingTab { get; set; } - public bool AccessToStatusTab { get; set; } - public bool AccessToPickingTab { get; set; } + public Boolean AccessToSettingTab { get; set; } + public Boolean AccessToStatusTab { get; set; } + public Boolean AccessToPickingTab { get; set; } - public int? SirtComport433 { get; set; } - public int? SirtComport866 { get; set; } - public int? SirtBoxNr { get; set; } + public Int32? SirtComport433 { get; set; } + public Int32? SirtComport866 { get; set; } + public Int32? SirtBoxNr { get; set; } - public int? StationId { get; set; } + public Int32? StationId { get; set; } public List ChildForms { get; set; } diff --git a/Common/ProductionUiCordonel/Data/FinalTestState.cs b/Common/ProductionUiCordonel/Data/FinalTestState.cs new file mode 100644 index 00000000..1981f6d7 --- /dev/null +++ b/Common/ProductionUiCordonel/Data/FinalTestState.cs @@ -0,0 +1,101 @@ +namespace ProductionUiCordonel.Data +{ + /// + /// Genesis meter final test states + /// + public enum FinalTestState + { + /// + /// Idle (nothing to do) + /// + Idle, + /// + /// Start the initial execution + /// + StartInitial, + /// + /// Error handling + /// + Error, + /// + /// Single processing step failed + /// + StepFailed, + /// + /// Repeat last step + /// + RepeatStep, + /// + /// Repeat the entire final test + /// + RepeatFinalTest, + /// + /// Final test failed + /// + FinalTestFailed, + /// + /// Check the actual shipping state + /// + CheckShippingState, + /// + /// Check the attachments + /// + CheckAttachments, + /// + /// Check the order number + /// + CheckOrderNumber, + /// + /// Check the serial number + /// + CheckSerialNumber, + /// + /// Connect to Cordonel + /// + ConnectCordonel, + /// + /// Store all configurations to FLASH memory + /// + StoreAllConfigurations, + /// + /// Reboot the Cordonel to check all parameters being stored to FLASH memory + /// + RebootCordonel, + /// + /// Finalize process + /// + FinalizeProcess, + /// + /// Final parametrization fixed values + /// + FinalParametrizationFix, + /// + /// Final parametrization with VAKO and CSD + /// + FinalParametrizationVakoCsd, + /// + /// Read out all parametrization values + /// + FullReadOutParametrization, + /// + /// Check all settings for against required values + /// + ConfigurationCheck, + /// + /// Acquire, process set the password file + /// + ProcessPasswordFile, + /// + /// Process special configuration + /// + ProcessSpecialConfig, + /// + /// Prepare shipping mode + /// + PrepareShippingMode, + /// + /// Delimiter for list + /// + StateListDelimiter + } +} \ No newline at end of file diff --git a/Common/ProductionUiCordonel/Data/FinalTestStateInfo.cs b/Common/ProductionUiCordonel/Data/FinalTestStateInfo.cs new file mode 100644 index 00000000..bfcbca55 --- /dev/null +++ b/Common/ProductionUiCordonel/Data/FinalTestStateInfo.cs @@ -0,0 +1,52 @@ +using System; +using System.Linq; +using ProductionUiCordonel.Properties; + +namespace ProductionUiCordonel.Data +{ + /// + /// Concatenation of state and string + /// + public static class FinalTestStateInfo + { + /// + /// Build state information + /// + private static readonly FinalTestStateText[] StateInfos; + + /// + /// Ctor + /// + static FinalTestStateInfo() + { + StateInfos = new FinalTestStateText[(Int32)FinalTestState.StateListDelimiter]; + StateInfos[(Int32)FinalTestState.Idle].State = FinalTestState.Idle; + StateInfos[(Int32)FinalTestState.Idle].Message = Resources.StrStateIdle; + + StateInfos[(Int32)FinalTestState.StartInitial].State = FinalTestState.StartInitial; + StateInfos[(Int32)FinalTestState.StartInitial].Message = Resources.StrStateStartInitial; + + } + + /// + /// Get the current information + /// + /// state to search for information text + public static String GetTextFromState(FinalTestState state) + { + return (from stateInfo in StateInfos + where stateInfo.State == state + select stateInfo.Message).FirstOrDefault(); + } + /// + /// Get the state of the text + /// + /// information text to search if state is assigned + public static FinalTestState GetStateFromText(String text) + { + return (from stateInfo in StateInfos + where stateInfo.Message == text + select stateInfo.State).FirstOrDefault(); + } + } +} diff --git a/Common/ProductionUiCordonel/Data/FinalTestStateText.cs b/Common/ProductionUiCordonel/Data/FinalTestStateText.cs new file mode 100644 index 00000000..4bfd80cf --- /dev/null +++ b/Common/ProductionUiCordonel/Data/FinalTestStateText.cs @@ -0,0 +1,19 @@ +using System; + +namespace ProductionUiCordonel.Data +{ + /// + /// Concatenation between final test state and text + /// + public struct FinalTestStateText + { + /// + /// The state of the final test + /// + public FinalTestState State; + /// + /// The message text of the final test state + /// + public String Message; + } +} diff --git a/Common/ProductionUiCordonel/Data/PickingResultData.cs b/Common/ProductionUiCordonel/Data/PickingResultData.cs index 3f6c5f93..a8ca3be1 100644 --- a/Common/ProductionUiCordonel/Data/PickingResultData.cs +++ b/Common/ProductionUiCordonel/Data/PickingResultData.cs @@ -1,8 +1,5 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.Windows.Media; using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore; using Xylem.Common.Hardware.WaterMeter.Genesis.Registers; @@ -10,41 +7,41 @@ namespace ProductionUiCordonel.Data { public class PickingItemCheckReturn { - public bool? Result; - public string Msg; + public Boolean? Result; + public String Msg; } public abstract class PickingResultBaseData : IPickingResultData { - public string Ident { get; set; } + public String Ident { get; set; } - public int Index { get; set; } + public Int32 Index { get; set; } - public string CheckText { get; set; } + public String CheckText { get; set; } - public string CurrentValueText { get; set; } + public String CurrentValueText { get; set; } - public bool? Result { get; set; } + public Boolean? Result { get; set; } - public bool HasError { get; set; } + public Boolean HasError { get; set; } - public System.Windows.Media.Brush ResultColor { get { return getColorFromResult(); } } - public abstract Func Action { get; } + public Brush ResultColor => getColorFromResult(); + public abstract Func Action { get; } - private System.Windows.Media.Brush getColorFromResult() + private Brush getColorFromResult() { - var converter = new System.Windows.Media.BrushConverter(); - var brush = (System.Windows.Media.Brush)converter.ConvertFromString("#000000"); + var converter = new BrushConverter(); + var brush = (Brush)converter.ConvertFromString("#000000"); if (Result.HasValue) // && a.Result.Value )) { if (!Result.Value) { - brush = (System.Windows.Media.Brush)converter.ConvertFromString("#FF8000"); + brush = (Brush)converter.ConvertFromString("#FF8000"); } else { - brush = (System.Windows.Media.Brush)converter.ConvertFromString("#419C14"); + brush = (Brush)converter.ConvertFromString("#419C14"); } } @@ -54,34 +51,34 @@ public abstract class PickingResultBaseData : IPickingResultData } public interface IPickingResultData { - string Ident { get; set; } + String Ident { get; set; } - int Index { get; set; } - string CheckText { get; set; } + Int32 Index { get; set; } + String CheckText { get; set; } - string CurrentValueText { get; set; } + String CurrentValueText { get; set; } - bool? Result { get; set; } + Boolean? Result { get; set; } - bool HasError { get; set; } + Boolean HasError { get; set; } - System.Windows.Media.Brush ResultColor { get; } + Brush ResultColor { get; } Func Action { get; } } public class PickingResultRegisterData : PickingResultBaseData { - public string RegisterIdent { get; set; } + public String RegisterIdent { get; set; } public GenesisMeter ReadMeter { get; set; } - public object CompareObject { get; set; } + public Object CompareObject { get; set; } - public override Func Action { get { return staticReadAndCompareAction(); } } + public override Func Action => staticReadAndCompareAction(); public Func staticReadAndCompareAction() { - return delegate () + return delegate { var retComp = new PickingItemCheckReturn(); retComp.Result = null; @@ -97,7 +94,7 @@ public abstract class PickingResultBaseData : IPickingResultData } else if (CompareObject is Boolean boolCompare) { - retComp.Result = boolCompare.Equals(RegisterConverter.ConvertTo(r)); + retComp.Result = boolCompare.Equals(RegisterConverter.ConvertTo(r)); retComp.Msg = boolCompare.ToString(); } @@ -117,8 +114,7 @@ public abstract class PickingResultBaseData : IPickingResultData } public readonly Func _action; - public override Func Action { get { return _action; } } - + public override Func Action => _action; } } diff --git a/Common/ProductionUiCordonel/Data/PressureResultDataNotifyable.cs b/Common/ProductionUiCordonel/Data/PressureResultDataNotifyable.cs index b0fe1932..d2f7fe2a 100644 --- a/Common/ProductionUiCordonel/Data/PressureResultDataNotifyable.cs +++ b/Common/ProductionUiCordonel/Data/PressureResultDataNotifyable.cs @@ -39,24 +39,24 @@ namespace ProductionUiCordonel.Data } - public string PcbId; + public String PcbId; - private int rev = 0; + private Int32 rev; - public int Rev + public Int32 Rev { - get { return rev; } + get => rev; set { rev = value; InternalPropertyChanged(nameof(Rev)); } } - private bool? passed = false; - public bool? Passed + private Boolean? passed = false; + public Boolean? Passed { - get { return passed; } + get => passed; set { passed = value; @@ -66,10 +66,10 @@ namespace ProductionUiCordonel.Data - private string testerName = "C. Röhl"; + private String testerName = "C. Röhl"; public String TesterName { - get { return testerName; } + get => testerName; set { testerName = value; @@ -77,10 +77,10 @@ namespace ProductionUiCordonel.Data } } - private string testPressure = "6"; + private String testPressure = "6"; public String TestPressure { - get { return testPressure; } + get => testPressure; set { testPressure = value; @@ -89,10 +89,10 @@ namespace ProductionUiCordonel.Data } - private string leakRate = " 0,00001"; + private String leakRate = " 0,00001"; public String LeakRate { - get { return leakRate; } + get => leakRate; set { leakRate = value; @@ -100,10 +100,10 @@ namespace ProductionUiCordonel.Data } } - private string remark = ""; + private String remark = ""; public String Remark { - get { return remark; } + get => remark; set { remark = value; @@ -112,21 +112,22 @@ namespace ProductionUiCordonel.Data } - private ObservableCollection testpoints = new ObservableCollection() { - new PressureTestPoints() { Ident = 1, Input = "2E-07" }, - new PressureTestPoints() { Ident = 2, Input = "2E-07" }, - new PressureTestPoints() { Ident = 3, Input = "2E-07" }, - new PressureTestPoints() { Ident = 4, Input = "2E-07" }, - new PressureTestPoints() { Ident = 5, Input = "2E-07" }, - new PressureTestPoints() { Ident = 6, Input = "2E-07" }, - new PressureTestPoints() { Ident = 7, Input = "2E-07" }, - new PressureTestPoints() { Ident = 8, Input = "2E-07" }, - new PressureTestPoints() { Ident = 9, Input = "2E-07" }, - new PressureTestPoints() { Ident = 10, Input = "2E-07" } + private ObservableCollection testpoints = new ObservableCollection + { + new PressureTestPoints { Ident = 1, Input = "2E-07" }, + new PressureTestPoints { Ident = 2, Input = "2E-07" }, + new PressureTestPoints { Ident = 3, Input = "2E-07" }, + new PressureTestPoints { Ident = 4, Input = "2E-07" }, + new PressureTestPoints { Ident = 5, Input = "2E-07" }, + new PressureTestPoints { Ident = 6, Input = "2E-07" }, + new PressureTestPoints { Ident = 7, Input = "2E-07" }, + new PressureTestPoints { Ident = 8, Input = "2E-07" }, + new PressureTestPoints { Ident = 9, Input = "2E-07" }, + new PressureTestPoints { Ident = 10, Input = "2E-07" } }; public ObservableCollection Testpoints { - get { return testpoints; } + get => testpoints; set { testpoints = value; @@ -134,7 +135,7 @@ namespace ProductionUiCordonel.Data } } - internal void SetAllTestPoints(string input) + internal void SetAllTestPoints(String input) { foreach (var item in Testpoints) { diff --git a/Common/ProductionUiCordonel/Event/StringArgs.cs b/Common/ProductionUiCordonel/Event/StringArgs.cs index fc7afaba..324f7ea1 100644 --- a/Common/ProductionUiCordonel/Event/StringArgs.cs +++ b/Common/ProductionUiCordonel/Event/StringArgs.cs @@ -1,15 +1,11 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace ProductionUiCordonel.Event { public class StringArgs : EventArgs { - public readonly string Content; - public StringArgs(string content) + public readonly String Content; + public StringArgs(String content) { Content = content; } diff --git a/Common/ProductionUiCordonel/FinalTest.xaml b/Common/ProductionUiCordonel/FinalTest.xaml index 9c644d0e..0306640a 100644 --- a/Common/ProductionUiCordonel/FinalTest.xaml +++ b/Common/ProductionUiCordonel/FinalTest.xaml @@ -14,7 +14,7 @@ -