finalcheck add

This commit is contained in:
Roland Drabesch
2023-03-06 15:10:37 +01:00
parent f61fe1b99f
commit adecd8c3bd
13 changed files with 153 additions and 113 deletions
@@ -70,7 +70,7 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
Progress = 100;
NewStatus("Zugang verifiziert");
currentProcessState = ProductionProcessState.Done;
//RadioFrequencyMhz
asyncProgrammingParametersTask = new Task<IList<ProgrammingParameters>>(() =>
{
try
@@ -119,6 +119,16 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
overAllResult.Add(_currentGenesis_WriteRegister("GENESISFLOW_SealDisplay",
(new Byte[] { 0x00, 0x00, 0x00, 0x00 }).Reverse().ToArray(), true, true));
// keien frq aber radio parameter
if (!Meter.RadioFrequencyMhz.HasValue && myJsonResponse.Any(a => a.RegisterName.Contains("radio")))
{
throw new ApplicationException("Radio inconsistent between meter and programmingparameters");
}
// eine frequen aber keine radio parameter
if (Meter.RadioFrequencyMhz.HasValue && !myJsonResponse.Any(a => a.RegisterName.Contains("radio")))
{
throw new ApplicationException("Radio inconsistent between meter and programmingparameters");
}
foreach (var item in myJsonResponse.Where(m => m.Source == ProgrammingSource.Vako))
{
@@ -171,20 +181,22 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
overAllResult.Add(wirteRegisterInBetweenCheck("SYSTEM_CalendarSeconds", Convert.ToInt32(ts.TotalSeconds)));
overAllResult.Add(wirteRegisterInBetweenCheck("IRDA_MfgDate", Convert.ToInt32(ts.TotalSeconds)));
overAllResult.Add(_currentGenesis_WriteRegister("LOGGER_TriggerLogFlush",
(new Byte[] { 0x00, 0x00, 0x00, 0x01 }).Reverse().ToArray()));
overAllResult.Add(_currentGenesis_WriteRegister("NFC_EraseRMA",
(new Byte[] { 0x00, 0x00, 0x00, 0x01 }).Reverse().ToArray()));
if (hasRadio)
if (Meter.RadioFrequencyMhz.HasValue)
{
overAllResult.Add(_currentGenesis_WriteRegister("LOGGER_TriggerLogFlush",
(new Byte[] { 0x00, 0x00, 0x00, 0x01 }).Reverse().ToArray()));
overAllResult.Add(_currentGenesis_WriteRegister("PERIODICLOG_ResetCounter",
(new Byte[] { 0x00, 0x00, 0x00, 0x00 }).Reverse().ToArray()));
overAllResult.Add(_currentGenesis_WriteRegister("GENESISFLOW_SealDisplay",
(new Byte[] { 0x00, 0x00, 0x00, 0x01 }).Reverse().ToArray(), true, true));
}
overAllResult.Add(_currentGenesis_WriteRegister("GENESISFLOW_SealDisplay",
(new Byte[] { 0x00, 0x00, 0x00, 0x01 }).Reverse().ToArray(), true, true));
var ret = true;
Int32 done = 0;
@@ -1,4 +1,9 @@
using System;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using ProductionUiCordonel.ProductionProcesses.Enum;
using ProductionUiCordonel.UserControls.FinalTest;
using SIRTCOM;
using System;
using System.Configuration;
using System.Linq;
using System.Net.Http;
@@ -7,11 +12,6 @@ using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Windows.Threading;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using ProductionUiCordonel.ProductionProcesses.Enum;
using ProductionUiCordonel.UserControls.FinalTest;
using SIRTCOM;
using Xylem.Common.CommonCore.Configuration;
using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore;
using Xylem.Common.Hardware.WaterMeter.Genesis.Registers;
@@ -62,12 +62,12 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
{
if (SENSUSRADIO_WakeupInterval != null)
{
var ret = Meter.WriteRegister("SENSUSRADIO_WakeupInterval", SENSUSRADIO_WakeupInterval,true,true);
var ret = Meter.WriteRegister("SENSUSRADIO_WakeupInterval", SENSUSRADIO_WakeupInterval, true, true);
if (!ret)
{
currentProcessState = ProductionProcessState.Error;
}
if (!ret)
{
currentProcessState = ProductionProcessState.Error;
}
}
//clear
}
@@ -78,42 +78,50 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
//readout adress, freq,
//FrequencyIndicator
var freq = RegisterConverter.ConvertTo<UInt32>(Meter.ReadRegister("SENSUSRADIO_FrequencyIndicator"));
RadioAdress = RegisterConverter.ConvertTo<UInt32>(Meter.ReadRegister("SENSUSRADIO_RadioAddress"));
Comport = Convert.ToByte(ConfigurationManager.AppSettings[$"SirtComport{freq}"]);
var enc = Meter.ReadRegister("SENSUSRADIO_EncryptionKey", 16);
EncyptionKey = LocalWebRequest.GetRequest($"{ServiceUrls.GenesisFinalCheckServiceUrl()}GetEncryptionKey?PcbID={Meter.PcbId}", 80000).ToUpper().Trim('\"');
if (!EncyptionKey.Equals(BitConverter.ToString(enc.ToArray()).Replace("-", "")))
if (Meter.RadioFrequencyMhz.HasValue)
{
MessageBox.Show("Funkschlüssel überprüfen!");
var freq = RegisterConverter.ConvertTo<UInt32>(Meter.ReadRegister("SENSUSRADIO_FrequencyIndicator"));
RadioAdress = RegisterConverter.ConvertTo<UInt32>(Meter.ReadRegister("SENSUSRADIO_RadioAddress"));
Comport = Convert.ToByte(ConfigurationManager.AppSettings[$"SirtComport{freq}"]);
var enc = Meter.ReadRegister("SENSUSRADIO_EncryptionKey", 16);
EncyptionKey = LocalWebRequest.GetRequest($"{ServiceUrls.GenesisFinalCheckServiceUrl()}GetEncryptionKey?PcbID={Meter.PcbId}", 80000).ToUpper().Trim('\"');
if (!EncyptionKey.Equals(BitConverter.ToString(enc.ToArray()).Replace("-", "")))
{
MessageBox.Show("Funkschlüssel überprüfen!");
}
EncyptionKey = BitConverter.ToString(enc.ToArray()).Replace("-", "");
//if (freq == 868)
//{
// Comport = 8;
//}
//else
//{
// Comport = 7;
//}
BoxNr = Convert.ToByte(ConfigurationManager.AppSettings["SirtBoxNr"]);
DebugMessage($"Start RadioCheck Comport:{Comport} ,BoxNr:{BoxNr}, freq: {freq}, RadioAddress:{RadioAdress}s\r\n");
Meter.WriteRegister("SENSUSRADIO_IrDAModulePresent", 1, true, true);
SENSUSRADIO_WakeupInterval = Meter.ReadRegister("SENSUSRADIO_WakeupInterval");
Meter.WriteRegister("SENSUSRADIO_WakeupInterval", 0);
GetRssi();
}
EncyptionKey = BitConverter.ToString(enc.ToArray()).Replace("-", "");
//if (freq == 868)
//{
// Comport = 8;
//}
//else
//{
// Comport = 7;
//}
BoxNr = Convert.ToByte(ConfigurationManager.AppSettings["SirtBoxNr"]);
DebugMessage($"Start RadioCheck Comport:{Comport} ,BoxNr:{BoxNr}, freq: {freq}, RadioAddress:{RadioAdress}s\r\n");
Meter.WriteRegister("SENSUSRADIO_IrDAModulePresent", 1, true, true);
SENSUSRADIO_WakeupInterval = Meter.ReadRegister("SENSUSRADIO_WakeupInterval");
Meter.WriteRegister("SENSUSRADIO_WakeupInterval", 0);
GetRssi();
else
{
currentProcessState = ProductionProcessState.Done;
}
}
#region FormerForm
@@ -162,7 +170,7 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
DebugMessage("");
saveData = new SaveData();
SetUi();
@@ -173,10 +181,10 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
//Meter.WriteRegister("SENSUSRADIO_PowerLevelOption", 59, true, true);
//Meter.WriteRegister("SENSUSRADIO_ImpedanceCodeNew", 2992, true, true);
//Meter.WriteRegister("SENSUSRADIO_ImpedanceCodeOption", 2936, true, true);
try
{
await GetRssiMinMaxAsync(BoxNr, Ordernumber);
SetUi();
GetRSSI((Int32)RadioAdress, Comport, EncyptionKey);
@@ -269,10 +277,10 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
RSSI_PAM_Max = 200;
RSSI_SEMI_Min = 100;
RSSI_SEMI_Max = 200;
// RSSI_PAM_Min RSSI_PAM_Max RSSI_SEMI_Min RSSI_SEMI_Max
//145 164 182
// RSSI_PAM_Min RSSI_PAM_Max RSSI_SEMI_Min RSSI_SEMI_Max
//145 164 182
// throw new Exception("Fehler in GetRssiMinMax()", ex);
// throw new Exception("Fehler in GetRssiMinMax()", ex);
}
}
@@ -283,7 +291,7 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
RSSI_SEMI = null;
stm = new Statemashine();
Byte P81_1 = 0;
saveData.RadioAdress = RadioAdress;
@@ -291,7 +299,7 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
stm.initialise((Byte)ByteCOMPort);
Wrapper wrp = new Wrapper();
stm.StartLoggin("C:\\GenesisLog\\log.txt");
// ist wohl nicht nötig da der SIRT richtig konfiguroert ist:
// wrp.ActivateSirt(byte modul1, byte modul2, byte actTimeout, out byte outP12_01, out byte outP12_02);
@@ -350,7 +358,7 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
saveData.RSSI_SEMI = Rssi_Semi_Sirt;
saveData.Result = 1;
if (RSSI_PAM < RSSI_PAM_Min)
{
saveData.Result = 0;
@@ -405,7 +413,9 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
Byte[] SEMI_bytes = new Byte[HexbytesSEMI.Length / 2];
for (Int32 i = 0; i < HexbytesSEMI.Length; i += 2)
{
SEMI_bytes[i / 2] = Convert.ToByte(HexbytesSEMI.Substring(i, 2), 16);
}
// SEMI Status
if (SEMI_bytes[19] == 0)
@@ -445,7 +455,7 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
return content;
}
static async Task<String> GetResponseAsync(String url)
private static async Task<String> GetResponseAsync(String url)
{
httpclient = new HttpClient();
// 20 Sekunden Timeout
@@ -51,10 +51,9 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
Meter.SetLcdText(true, new Byte[] { 0x00, 0x00, 0x00, 0x01 });
Meter.ResetAlarm(GenesisMeter.Alarm.EMPTY_PIPE);//(true, new byte[] { 0x00, 0x00, 0x00, 0x01 });
if (!hasRadio && Meter.RadioFrequencyMhz.HasValue)
{
throw new Exception("Meter radio is incompatible with test");
}
hasRadio = Meter.RadioFrequencyMhz.HasValue;
if (hasRadio)