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
+1 -1
View File
@@ -155,7 +155,7 @@
</site>
<site name="MeterProcessState" id="2">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="D:\Projekte\SENSUS_GitLab\laa_production\Common\Service\MeterProcessState" />
<virtualDirectory path="/" physicalPath="C:\Users\drabesch_ro\Repo\lab\la_operations\laa_production\Common\Service\MeterProcessState" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:56011:localhost" />
@@ -5,7 +5,7 @@
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{D0C8D887-ED52-40AB-A069-90BCE0E801E2}</ProjectGuid>
<OutputType>Library</OutputType>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Xylem.Common.Ui.CordonelPreadjustmentUi</RootNamespace>
<AssemblyName>Xylem.Common.Ui.CordonelPreadjustmentUi</AssemblyName>
@@ -102,6 +102,9 @@
<PropertyGroup />
<PropertyGroup />
<PropertyGroup />
<PropertyGroup>
<NoWin32Manifest>true</NoWin32Manifest>
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.12.0.3\lib\net40\Newtonsoft.Json.dll</HintPath>
@@ -48,5 +48,13 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisPwd
/// List of passwords.
/// </summary>
public List<Byte[]> ListOfPasswords = new List<Byte[]>();
/// <summary>
/// Ident for password server (BSI) can be radioaddress or pcbid
/// </summary>
public String PasswordFileIdent { get; set; }
/// <summary>
/// Ident from password server (BSI)
/// </summary>
public String KeySetId { get; set; }
}
}
@@ -33,6 +33,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisPwd
try
{
//todo: roland umstellen auf localwebrequest
var http = (HttpWebRequest)WebRequest.Create(url + pcbId);
var response = (HttpWebResponse)http.GetResponse();
var responseStream = response.GetResponseStream();
@@ -1 +1 @@
1a3d4919c9c702245832d925951f2b7cb72fc333
5ed75d99ee45ff67821090f1b3dbb001dd9e4fe3
@@ -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));
}
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;
@@ -78,7 +78,10 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
//readout adress, freq,
//FrequencyIndicator
if (Meter.RadioFrequencyMhz.HasValue)
{
var freq = RegisterConverter.ConvertTo<UInt32>(Meter.ReadRegister("SENSUSRADIO_FrequencyIndicator"));
RadioAdress = RegisterConverter.ConvertTo<UInt32>(Meter.ReadRegister("SENSUSRADIO_RadioAddress"));
@@ -115,6 +118,11 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
GetRssi();
}
else
{
currentProcessState = ProductionProcessState.Done;
}
}
#region FormerForm
@@ -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)
@@ -1,4 +1,7 @@
using System;
using Logic.ProductionToProductMapper.Cordonel;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
@@ -7,9 +10,6 @@ using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using System.Web.Http;
using Logic.ProductionToProductMapper.Cordonel;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Xylem.Common.Logic.ProductionOrderCore;
using Xylem.Common.Logic.ProductionOrderCore.KitronTestResults;
using Xylem.Common.Logic.ProductionOrderCore.OrderData;
@@ -398,22 +398,10 @@ namespace Xylem.Common.Service.MeterProcessState.Controllers
var jResults = JsonConvert.DeserializeObject<JToken>(jsonString);
//foreach (var o in jResults["JsonObject"])
//{
// //o.ToString().Contains("StartDT")
// if (o["StartDT"] != null && DateTimeOffset.TryParse(o["StartDT"].ToString(), out ret))
// {
// return ret;
// }
//}
if (DateTimeOffset.TryParse(jResults["JsonObject"]["StartDT"].ToString(), out ret))
{
return ret;
}
}
catch (Exception)
{
@@ -961,7 +949,7 @@ namespace Xylem.Common.Service.MeterProcessState.Controllers
{
sb.AppendLine($" SELECT size.[Dn_InternalId], para.DnParameterId, para.ParameterName, para.ParameterValue ");
sb.AppendLine($" SELECT distinct size.[Dn_InternalId], para.DnParameterId, para.ParameterName, para.ParameterValue ");
sb.AppendLine($" FROM [Auftrag].[dbo].[CordonelMeterSizes] size ");
sb.AppendLine($" inner join [Auftrag].[dbo].[CordonelMeterSizesParameter] para on size.Dn_InternalId = para.[Dn_InternalId] ");
sb.AppendLine($" where size.[Dn_InternalId] = {MeterSize.GetHashCode()} ");
@@ -18,6 +18,7 @@ using Xylem.Common.CommonCore.Exceptions.WaterMeter;
using Xylem.Common.CommonCore.Exceptions.Web;
using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore;
using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile;
using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisPwd;
using Xylem.Common.Logic.ServiceCore;
using Xylem.Common.Logic.SoftwareAccessHelper;
@@ -136,14 +137,22 @@ namespace Xylem.Common.Service.MeterProcessState.Controllers
try
{
var searchKey = "Flash TestFirmware";
var dt = dataAccess.ExecuteQuery($"SELECT top 1 [DS_ID] ,[ID_PCB] ,[ID_TEST] ,[JSON] FROM [MyOraDB]..[DELTACHEF].[GENESIS_PCBMETROLOGYTEST_PD] where [ID_PCB] = '{PcbId}' order by ID_TEST desc");
if (!dt.Select().Any())
{
dt = dataAccess.ExecuteQuery($"SELECT top 1 [DS_ID] ,[ID_PCB] ,[ID_TEST] ,[JSON] FROM [MyOraDB]..[DELTACHEF].[GENESIS_PCBRADIOTEST_PD] where [ID_PCB] = '{PcbId}' order by ID_TEST desc");
searchKey = "Flash Firmware";
}
foreach (var item in dt.Select())
{
var jsonString = item["JSON"].ToString();
var o = JsonConvert.DeserializeObject<JObject>(jsonString);
try
{
var pwString = o["JsonObject"]["Flash TestFirmware"].ToString();
var pwString = o["JsonObject"][searchKey].ToString();
//FE081F0 E5250E5D084FA024 00 04 80 00 70 03 48 9E
//0x 0413F059069BEB24
@@ -180,7 +189,7 @@ namespace Xylem.Common.Service.MeterProcessState.Controllers
}
var logon = from p in o["TestStepResults"]["$values"] select p;
var logonnote = logon.Where(a => a["TestStepName"].ToString() == "Flash TestFirmware").ToList();
var logonnote = logon.Where(a => a["TestStepName"].ToString() == "searchKey").ToList();
var list = logonnote.Children().Where(a => ((JProperty)a).Name == "TestValue").First().Values().First();
@@ -403,18 +412,18 @@ namespace Xylem.Common.Service.MeterProcessState.Controllers
var result = new MeterPasswordContainer();
var result = new MeterPwdDb();
using (var dataAccess = new SqlDataAccess(GlobalConfig.connectionString.Value))
{
var dt = dataAccess.ExecuteQuery(sbQuery.ToString());
foreach (var item in dt.Select())
{
result.orderNumber = (Int32)item["FertigungsauftragNr"];
result.radioAdress = (Int64)item["Adresse"];
result.OrderNumber = (Int32)item["FertigungsauftragNr"];
result.RadioAddress = (Int64)item["Adresse"];
result.Skeleton = (String)item["Skeleton"];
result.Password = (String)item["Password"];
result.PasswordFileIdent = result.radioAdress.HasValue ? result.radioAdress.Value.ToString() : PcbId;
result.PasswordFileIdent = result.RadioAddress.HasValue ? result.RadioAddress.Value.ToString() : PcbId;
if (item["KeySetId"].GetType() != typeof(System.DBNull))
{
result.KeySetId = (String)item["KeySetId"];
@@ -424,7 +433,7 @@ namespace Xylem.Common.Service.MeterProcessState.Controllers
}
}
if (!result.orderNumber.HasValue)
if (!result.OrderNumber.HasValue)
{
return Request.CreateResponse(HttpStatusCode.InternalServerError, new PcbIdNotException(new Guid("160B4C44-6EF7-41DC-A48D-4B4105B4779B")));
}
@@ -439,15 +448,15 @@ namespace Xylem.Common.Service.MeterProcessState.Controllers
{
result.KeySetId = CreateKeySet(Request.Headers.GetValues("X-Node-Token").First(), 7);
//mapp keyset
MapKeySet(Request.Headers.GetValues("X-Node-Token").First(), result.KeySetId, result.orderNumber.Value, result.PasswordFileIdent);
MapKeySet(Request.Headers.GetValues("X-Node-Token").First(), result.KeySetId, result.OrderNumber.Value, result.PasswordFileIdent);
using (var dataAccess = new SqlDataAccess(GlobalConfig.connectionString.Value))
{
var dt = dataAccess.ExecuteQuery(
$"update auftrag.[dbo].[Genesis_PcbPassword] set KeySetId = '{result.KeySetId}', [orderNumber] = {result.orderNumber.Value}, [radioAdress] = {result.PasswordFileIdent} where PcbId = '{PcbId}'; select * from auftrag.[dbo].[Genesis_PcbPassword] where PcbId = '{PcbId}'");
$"update auftrag.[dbo].[Genesis_PcbPassword] set KeySetId = '{result.KeySetId}', [orderNumber] = {result.OrderNumber.Value}, [radioAdress] = {result.PasswordFileIdent} where PcbId = '{PcbId}'; select * from auftrag.[dbo].[Genesis_PcbPassword] where PcbId = '{PcbId}'");
}
}
var passwords = getKeys(Request.Headers.GetValues("X-Node-Token").First(), result.orderNumber.Value.ToString(), result.PasswordFileIdent);
var passwords = getKeys(Request.Headers.GetValues("X-Node-Token").First(), result.OrderNumber.Value.ToString(), result.PasswordFileIdent);
//pw lvl
passwords.Keys.Insert(2, new Key() { Index = 2, KeyKey = result.Skeleton });
@@ -466,11 +475,11 @@ namespace Xylem.Common.Service.MeterProcessState.Controllers
{
rawKey = rawKey.Substring(0, 12);
}
if (result.listOfPasswords.Count <= 7)
if (result.ListOfPasswords.Count <= 7)
{
result.listOfPasswords.Add(Encoding.UTF8.GetBytes(rawKey));
result.ListOfPasswords.Add(Encoding.UTF8.GetBytes(rawKey));
var hash = sha1.ComputeHash(Encoding.UTF8.GetBytes(rawKey));
result.listOfHashes.Add(hash);
result.ListOfHashes.Add(hash);
}
}
}
@@ -385,6 +385,10 @@
<Project>{2C6378C6-6BA1-4CEE-8992-8404D8369A90}</Project>
<Name>GenesisFile</Name>
</ProjectReference>
<ProjectReference Include="..\..\Hardware\WaterMeter\Genesis\GenesisPwd\GenesisPwd.csproj">
<Project>{AC434B18-4D7B-49BA-9AD5-0527C79E8297}</Project>
<Name>GenesisPwd</Name>
</ProjectReference>
<ProjectReference Include="..\..\Hardware\WaterMeter\WaterMeterCore\WaterMeterCore.csproj">
<Project>{8203ABB8-38E5-472E-A742-33F38B7A74A6}</Project>
<Name>WaterMeterCore</Name>
+11 -5
View File
@@ -210,10 +210,14 @@ namespace XylemCommonUiLegacyGenCtl
case BatchState.BatchIsReady:
break;
case BatchState.AddMeters:
_currentState = AddAllMeters_Internal() ? BatchState.PrepareMeters : BatchState.Error;
var tAddMeters = Task<Boolean>.Factory.StartNew(() => { return AddAllMeters_Internal(); });
tAddMeters.ContinueWith(r => { _currentState = r.Result ? BatchState.PrepareMeters : BatchState.Error; });
break;
case BatchState.PrepareMeters:
_currentState = PrepareMeters_Internal() ? BatchState.MetersPrepared : BatchState.Error;
var tPrepareMeters = Task<Boolean>.Factory.StartNew(() => { return PrepareMeters_Internal(); });
tPrepareMeters.ContinueWith(r => { _currentState = r.Result ? BatchState.MetersPrepared : BatchState.Error; });
break;
case BatchState.MetersPrepared:
//Wait For Caller when every thing is setup
@@ -222,15 +226,17 @@ namespace XylemCommonUiLegacyGenCtl
//Wait for caller to start Measurement
break;
case BatchState.StartMesurement:
_currentState = StartMeasurement_Internal() ? BatchState.MeasurementActive : BatchState.Error;
break;
var tStartMesurement = Task<Boolean>.Factory.StartNew(() => { return StartMeasurement_Internal(); });
tStartMesurement.ContinueWith(r => { _currentState = r.Result ? BatchState.MeasurementActive : BatchState.Error; });
break;
case BatchState.MeasurementActive:
// wait for signal that the measurement can be stopped
break;
case BatchState.StopMesurement:
_currentState = StopMeasurement_Internal() ? BatchState.MeasurementCompleted : BatchState.Error;
var tStopMesurement = Task<Boolean>.Factory.StartNew(() => { return StopMeasurement_Internal(); });
tStopMesurement.ContinueWith(r => { _currentState = r.Result ? BatchState.MeasurementCompleted : BatchState.Error; });
break;
case BatchState.MeasurementCompleted:
//Measurement waiting for caller to grab all the results