From 5897c685eb7353b75e83d0fb16a7e1eae2a9afc7 Mon Sep 17 00:00:00 2001 From: Roland Drabesch Date: Fri, 29 Aug 2025 14:05:15 +0200 Subject: [PATCH] Ami API --- Common/.shared/NlogConfig.xml | 22 +-- Common/.shared/SharedAssemblyInfo.cs | 2 +- .../.vs/Common/config/applicationhost.config | 8 ++ Common/.vs/config/applicationhost.config | 2 +- Common/CommonConsole/PAM03.cs | 2 +- .../Genesis/GenesisCore/GenesisMeter.cs | 25 ++++ .../ProductionUiCordonel/App.config | 6 +- .../EolProcesses/CheckRadio.cs | 135 ++++++++++-------- .../Controllers/FinalCheckController.cs | 2 + .../Controllers/PushControler.cs | 95 +++++++++++- .../MeterProcessState.csproj.user | 2 +- 11 files changed, 221 insertions(+), 80 deletions(-) diff --git a/Common/.shared/NlogConfig.xml b/Common/.shared/NlogConfig.xml index fbf263fd..4679a451 100644 --- a/Common/.shared/NlogConfig.xml +++ b/Common/.shared/NlogConfig.xml @@ -7,7 +7,7 @@ - + - + - + - - + + - + - + - + - + - + - + diff --git a/Common/.shared/SharedAssemblyInfo.cs b/Common/.shared/SharedAssemblyInfo.cs index cdfd0046..e9f0e34f 100644 --- a/Common/.shared/SharedAssemblyInfo.cs +++ b/Common/.shared/SharedAssemblyInfo.cs @@ -13,4 +13,4 @@ using System.Reflection; // //[assembly: AssemblyVersion("1.2.*.0")] -[assembly: AssemblyVersion("2.8.0.*")] +[assembly: AssemblyVersion("2.8.2.*")] diff --git a/Common/.vs/Common/config/applicationhost.config b/Common/.vs/Common/config/applicationhost.config index 4b78051e..a9fd77c3 100644 --- a/Common/.vs/Common/config/applicationhost.config +++ b/Common/.vs/Common/config/applicationhost.config @@ -160,6 +160,14 @@ + + + + + + + + diff --git a/Common/.vs/config/applicationhost.config b/Common/.vs/config/applicationhost.config index a894c3cf..1c31d6be 100644 --- a/Common/.vs/config/applicationhost.config +++ b/Common/.vs/config/applicationhost.config @@ -155,7 +155,7 @@ - + diff --git a/Common/CommonConsole/PAM03.cs b/Common/CommonConsole/PAM03.cs index 92aacfbc..0963f597 100644 --- a/Common/CommonConsole/PAM03.cs +++ b/Common/CommonConsole/PAM03.cs @@ -58,7 +58,7 @@ int ResetAlarms(byte alarmMask) { - task.Data = new ResetAlarms(0xFF).Append(auth); + task.Data = new ResetAlarms(alarmMask).Append(auth); task.SetPending(); sirt.Start(task); task.Wait(); diff --git a/Common/Hardware/WaterMeter/Genesis/GenesisCore/GenesisMeter.cs b/Common/Hardware/WaterMeter/Genesis/GenesisCore/GenesisMeter.cs index 27b70911..7ae0ab1f 100644 --- a/Common/Hardware/WaterMeter/Genesis/GenesisCore/GenesisMeter.cs +++ b/Common/Hardware/WaterMeter/Genesis/GenesisCore/GenesisMeter.cs @@ -2092,6 +2092,31 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore WriteRegister(Register.Customer.TriggerAlarmCancel, Alarm.ALL); + + + if (GetRegistersDic().Any(a => a.Key.RegisterName == "PersistenceGroup1")) + { + var x = ReadRegister("SENSUSRADIO_PersistenceGroup1"); + WriteRegister("SENSUSRADIO_PersistenceGroup1", new byte[] { 0x00,0xff,0x00,0xff }); + } + + if (GetRegistersDic().Any(a => a.Key.RegisterName == "PersistenceGroup2")) + { + WriteRegister("SENSUSRADIO_PersistenceGroup2", new byte[] { 0x00, 0xff, 0x00, 0xff }); + } + if (GetRegistersDic().Any(a => a.Key.RegisterName == "PersistenceGroup3")) + { + WriteRegister("SENSUSRADIO_PersistenceGroup3", new byte[] { 0x00, 0xff, 0x00, 0xff }); + } + if (GetRegistersDic().Any(a => a.Key.RegisterName == "PersistenceGroup4")) + { + WriteRegister("SENSUSRADIO_PersistenceGroup4", new byte[] { 0x00, 0xff, 0x00, 0xff }); + } + if (GetRegistersDic().Any(a => a.Key.RegisterName == "PersistenceGroup5")) + { + WriteRegister("SENSUSRADIO_PersistenceGroup5", new byte[] { 0x00, 0xff, 0x00, 0xff }); + } + WriteRegister("CUSTOMER_AlarmEnableMask", beforeCancelAlarmEnableMask); WriteRegister("CUSTOMER_AlarmBroadcastMask", beforeCancelAlarmBroadcastMask); diff --git a/Common/Production/ProductionUiCordonel/App.config b/Common/Production/ProductionUiCordonel/App.config index 78a66942..706ad1e1 100644 --- a/Common/Production/ProductionUiCordonel/App.config +++ b/Common/Production/ProductionUiCordonel/App.config @@ -37,7 +37,11 @@ - + + + + + diff --git a/Common/Production/ProductionUiCordonel/ProductionProcesses/EolProcesses/CheckRadio.cs b/Common/Production/ProductionUiCordonel/ProductionProcesses/EolProcesses/CheckRadio.cs index ffb221c8..5871ab9e 100644 --- a/Common/Production/ProductionUiCordonel/ProductionProcesses/EolProcesses/CheckRadio.cs +++ b/Common/Production/ProductionUiCordonel/ProductionProcesses/EolProcesses/CheckRadio.cs @@ -109,6 +109,11 @@ namespace Xylem.Common.Production.ProductionUiCordonel.ProductionProcesses.EolPr /// private Byte _sirtComport; + /// + /// Comport number of SIRT + /// + private Byte _sirtSecondComport; + /// /// Radio address Cordonel /// @@ -273,6 +278,7 @@ namespace Xylem.Common.Production.ProductionUiCordonel.ProductionProcesses.EolPr ActualProcessProgress++; _sirtComport = Convert.ToByte(ConfigurationManager.AppSettings[$"SirtComport{freq}"]); + //_sirtSecondComport = Convert.ToByte(ConfigurationManager.AppSettings[$"SirtComportAlarm{freq}"]); _sirtBoxNr = Convert.ToByte(ConfigurationManager.AppSettings["SirtBoxNr"]); var ucRadio = (UcRadioCheck)UserControl; ucRadio.SetHeadline($"{Resources.StrStateRadioCheck} BOX: {_sirtBoxNr}"); @@ -329,77 +335,80 @@ namespace Xylem.Common.Production.ProductionUiCordonel.ProductionProcesses.EolPr } SuccessMsgDispatcher(Resources.StrSuccessMsgRadioInCustomerMode); - - _stateMachine?.Stop(); - _stateMachine = null; - //Radio rest alarms - //readout wakeup, interval - //start process - //wait for proccess exitcode - var WakupRestore = RegisterConverter.ByteArrayToValue(Meter.ReadRegister("SENSUSRADIO_WakeupInterval")); - var TxIntervalRestore = RegisterConverter.ByteArrayToValue(Meter.ReadRegister("SENSUSRADIO_TxInterval")); - var LatRestore = RegisterConverter.ByteArrayToValue(Meter.ReadRegister("SENSUSRADIO_LatInterval")); - WriteRegisterLogAndProcessCtr(new ProgrammingParameters("SENSUSRADIO_WakeupInterval", - new Byte[] { 0x00 }, ProgrammingSource.ProgramInternal)); - WriteRegisterLogAndProcessCtr(new ProgrammingParameters("SENSUSRADIO_TxInterval", - new Byte[] { 0x01 }, ProgrammingSource.ProgramInternal)); - - WriteRegisterLogAndProcessCtr(new ProgrammingParameters("SENSUSRADIO_LatInterval", RegisterConverter.ValueToByteArray(3), ProgrammingSource.ProgramInternal)); - - - Meter.Logout(); - - var process = new Process + // Initialize the SIRT + if (!SirtInit()) { - EnableRaisingEvents = true, - StartInfo = new ProcessStartInfo - { - Arguments = $"COM{_sirtComport} {_radioAddressCordonel} {_radioEncryptionKey}", - FileName = @"\\sla12file\auftrag\ProductionUiCordonel\CommonConsole\CommonConsole.exe", - CreateNoWindow = true, - UseShellExecute = false, - RedirectStandardError = true, - RedirectStandardOutput = true - } - }; + return SetTestFailed(Resources.StrErrorMsgSirt); + } - void logData(string data, bool error) - { - if (!string.IsNullOrWhiteSpace(data)) - { - if (error) - { - ErrorMsgDispatcher(data.Trim()); - } - else - { - SuccessMsgDispatcher(data.Trim()); - } + ////Radio rest alarms + ////readout wakeup, interval + ////start process + ////wait for proccess exitcode + //var WakupRestore = RegisterConverter.ByteArrayToValue(Meter.ReadRegister("SENSUSRADIO_WakeupInterval")); + //var TxIntervalRestore = RegisterConverter.ByteArrayToValue(Meter.ReadRegister("SENSUSRADIO_TxInterval")); + //var LatRestore = RegisterConverter.ByteArrayToValue(Meter.ReadRegister("SENSUSRADIO_LatInterval")); + //WriteRegisterLogAndProcessCtr(new ProgrammingParameters("SENSUSRADIO_WakeupInterval", + //new Byte[] { 0x00 }, ProgrammingSource.ProgramInternal)); + //WriteRegisterLogAndProcessCtr(new ProgrammingParameters("SENSUSRADIO_TxInterval", + //new Byte[] { 0x01 }, ProgrammingSource.ProgramInternal)); + + //WriteRegisterLogAndProcessCtr(new ProgrammingParameters("SENSUSRADIO_LatInterval", RegisterConverter.ValueToByteArray(3), ProgrammingSource.ProgramInternal)); + + + //Meter.Logout(); + + //var process = new Process + //{ + // EnableRaisingEvents = true, + // StartInfo = new ProcessStartInfo + // { + // Arguments = $"COM{_sirtSecondComport} {_radioAddressCordonel} {_radioEncryptionKey}", + // FileName = @"\\sla12file\auftrag\ProductionUiCordonel\CommonConsoleV2\CommonConsole.exe", + // CreateNoWindow = true, + // UseShellExecute = false, + // RedirectStandardError = true, + // RedirectStandardOutput = true + // } + //}; + + //void logData(string data, bool error) + //{ + // if (!string.IsNullOrWhiteSpace(data)) + // { + // if (error) + // { + // ErrorMsgDispatcher(data.Trim()); + // } + // else + // { + // SuccessMsgDispatcher(data.Trim()); + // } - } - } + // } + //} - process.ErrorDataReceived += (_, args) => logData(args.Data, true); - process.OutputDataReceived += (_, args) => logData(args.Data, false); + //process.ErrorDataReceived += (_, args) => logData(args.Data, true); + //process.OutputDataReceived += (_, args) => logData(args.Data, false); - process.Start(); - process.BeginOutputReadLine(); - process.BeginErrorReadLine(); - process.WaitForExit(80_000); - if (process.ExitCode != 0) - { - ErrorMsgDispatcher($"AlarmReset failed ExitCode{process.ExitCode}"); - return SetTestFailed($"AlarmReset failed ExitCode{process.ExitCode}"); - } - //restore + //process.Start(); + //process.BeginOutputReadLine(); + //process.BeginErrorReadLine(); + //process.WaitForExit(80_000); + //if (process.ExitCode != 0) + //{ + // ErrorMsgDispatcher($"AlarmReset failed ExitCode{process.ExitCode}"); + // return SetTestFailed($"AlarmReset failed ExitCode{process.ExitCode}"); + //} + ////restore - // reset system state back to shipping mode + //// reset system state back to shipping mode - Meter.Login(); - WriteRegisterLogAndProcessCtr(new ProgrammingParameters("SENSUSRADIO_WakeupInterval", RegisterConverter.ValueToByteArray(WakupRestore) , ProgrammingSource.ProgramInternal)); - WriteRegisterLogAndProcessCtr(new ProgrammingParameters("SENSUSRADIO_TxInterval", RegisterConverter.ValueToByteArray(TxIntervalRestore), ProgrammingSource.ProgramInternal)); - WriteRegisterLogAndProcessCtr(new ProgrammingParameters("SENSUSRADIO_LatInterval", RegisterConverter.ValueToByteArray(LatRestore), ProgrammingSource.ProgramInternal)); + //Meter.Login(); + //WriteRegisterLogAndProcessCtr(new ProgrammingParameters("SENSUSRADIO_WakeupInterval", RegisterConverter.ValueToByteArray(WakupRestore) , ProgrammingSource.ProgramInternal)); + //WriteRegisterLogAndProcessCtr(new ProgrammingParameters("SENSUSRADIO_TxInterval", RegisterConverter.ValueToByteArray(TxIntervalRestore), ProgrammingSource.ProgramInternal)); + //WriteRegisterLogAndProcessCtr(new ProgrammingParameters("SENSUSRADIO_LatInterval", RegisterConverter.ValueToByteArray(LatRestore), ProgrammingSource.ProgramInternal)); diff --git a/Common/Service/MeterProcessState/Controllers/FinalCheckController.cs b/Common/Service/MeterProcessState/Controllers/FinalCheckController.cs index 8fdb63a0..b17c08e3 100644 --- a/Common/Service/MeterProcessState/Controllers/FinalCheckController.cs +++ b/Common/Service/MeterProcessState/Controllers/FinalCheckController.cs @@ -1274,6 +1274,8 @@ namespace Xylem.Common.Service.MeterProcessState.Controllers + + [HttpGet] [Route("CalibrationResults/{pcbId}")] public IHttpActionResult CalibrationResults(String pcbId) diff --git a/Common/Service/MeterProcessState/Controllers/PushControler.cs b/Common/Service/MeterProcessState/Controllers/PushControler.cs index f7b98f2a..b0f56ceb 100644 --- a/Common/Service/MeterProcessState/Controllers/PushControler.cs +++ b/Common/Service/MeterProcessState/Controllers/PushControler.cs @@ -1,5 +1,7 @@ -using System; +using LaaPackages.Features.Cordonel.Models; +using System; using System.Collections.Generic; +using System.Data; using System.Net; using System.Net.Http; using System.Net.Http.Headers; @@ -38,7 +40,98 @@ namespace Xylem.Common.Service.MeterProcessState.Controllers } } + public class retItem { + public int OrderNr; + public int pos; + public int Pcb; + public DateTimeOffset kitronDate; + + public int SerienNr { get; internal set; } + } + + + [Route("GetOrderProductionDates")] + public async Task GetOrderProductionDates(int? Order = null, int? Pos = null, int? PcbId = null) + { + try + { + + return Request.CreateResponse(HttpStatusCode.OK, await Task.Run(() => + { + var ret = new List(); + + using (var dataacces = new SqlDataAccess(GlobalConfig.connectionString.Value)) + { + + var listOfPcb = new List(); + + var sbq = new StringBuilder(); + sbq.AppendLine("select distinct AuftragNr, PositionNr, aps.SerienNr, map.MapPcbIdToSerialNumber_PcbId " + + "from Auftrag.dbo.AuftragPositionSerienNr aps " + + "inner join Auftrag.dbo.MapPcbIdToSerialNumber map " + + "on aps.SerienNr = map.MapPcbIdToSerialNumber_SerialNumber " + + "" + + "where Wiederholungen = -1 "); + if (PcbId.HasValue) + { + sbq.AppendLine($" and map.MapPcbIdToSerialNumber_PcbId = {PcbId.Value}"); + } + else if(Order.HasValue) + { + sbq.AppendLine($" and aps.AuftragNr = {Order.Value}"); + if (Pos.HasValue) + { + sbq.AppendLine($" and aps.PositionNr = {Pos.Value}"); + } + + } + else + { + return ret; + } + var OrderRow = dataacces.ExecuteQuery(sbq.ToString()); + + foreach (DataRow item in OrderRow.Rows) + { + var retC = new retItem(); + retC.OrderNr = (Int32)item["AuftragNr"]; + retC.pos = (Int32)item["PositionNr"]; + retC.SerienNr = (Int32)item["SerienNr"]; + retC.Pcb = (Int32)item["MapPcbIdToSerialNumber_PcbId"]; + + var dtPrdDate = dataacces.ExecuteQuery($"sELECT * FROM OPENQUERY(MyOraDB, ' SELECT JSON FROM DELTACHEF.GENESIS_PCBFUNCTIONALTEST_PD WHERE ID_PCB = ''{retC.Pcb}'' order by ID_TEST desc ');"); + if (dtPrdDate.Rows.Count >= 1) + { + var St = dtPrdDate.Rows[0]["JSON"].ToString(); + var startInex = St.IndexOf("\"StartDT\":\"") + "\"StartDT\":\"".Length; + var datestring = St.Substring(startInex, "29.07.2022 06:47:27".Length); + var olastProdDate = new DateTime(); + DateTime.TryParse(datestring, out olastProdDate); + retC.kitronDate = olastProdDate; + } + else + { + retC.kitronDate = DateTime.MinValue; + } + ret.Add(retC); + + } + } + return ret; + })); + + } + catch (Exception ex) + { + return Request.CreateResponse(HttpStatusCode.InternalServerError, ex.ToString() + "
" + ex.InnerException.ToString()); + } + } + + + + + diff --git a/Common/Service/MeterProcessState/MeterProcessState.csproj.user b/Common/Service/MeterProcessState/MeterProcessState.csproj.user index 76826d37..9f8fc787 100644 --- a/Common/Service/MeterProcessState/MeterProcessState.csproj.user +++ b/Common/Service/MeterProcessState/MeterProcessState.csproj.user @@ -45,7 +45,7 @@ True 56011 / - http://localhost:56011/ + http://localhost:56015/ False False