EOL Progress api example

This commit is contained in:
Stoyan Zlatev
2024-09-04 18:19:55 +02:00
parent 20ea29c707
commit d1734a310e
10 changed files with 124 additions and 100 deletions
+2 -2
View File
@@ -33,10 +33,10 @@
// 0x6C, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, // 0x6C, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18,
// LED on // LED on
0x1F, 0x01, 0x08, // 0x1F, 0x01, 0x08,
// Reboot // Reboot
// 0x0E, 0x0, 0x0E, 0x00,
// Provide Pin Auth Level I // Provide Pin Auth Level I
// 0x43, 0x01, 0x14, 0x30, 0x68, 0xD0, // 0x43, 0x01, 0x14, 0x30, 0x68, 0xD0,
+1 -9
View File
@@ -1,12 +1,4 @@
<Window x:Class="Common.UI.WPF.MainWindow" <Window x:Class="Common.UI.WPF.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Common.UI.WPF"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Grid>
</Grid>
</Window> </Window>
@@ -0,0 +1,11 @@
namespace Common.UI.WPF.ViewModels
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
public class MainWindowVM : VM<MainWindowVM>
{
}
}
+1
View File
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<configuration> <configuration>
<appSettings> <appSettings>
<add key="Psno" value="2024"/>
<add key="SIRT.PortName" value="COM6"/> <add key="SIRT.PortName" value="COM6"/>
<add key="SIRT.RWTimeout" value="1000"/> <add key="SIRT.RWTimeout" value="1000"/>
</appSettings> </appSettings>
@@ -2,8 +2,10 @@
{ {
using LaaProduction.Data.Cordonel.ValidationAttributes; using LaaProduction.Data.Cordonel.ValidationAttributes;
using System; using Newtonsoft.Json;
using System;
public class EOLProgressModel public class EOLProgressModel
{ {
/// <summary> /// <summary>
@@ -48,24 +50,28 @@
/// Requirement could be loaded for this device /// Requirement could be loaded for this device
/// </summary> /// </summary>
[NotFailed] [NotFailed]
[JsonConverter(typeof(JsonStatusConverter))]
public EOLStatus RequirementRequestChecked { get; set; } public EOLStatus RequirementRequestChecked { get; set; }
/// <summary> /// <summary>
/// Requirement PcbId equals PcbId of EOLProgress and Cordonel /// Requirement PcbId equals PcbId of EOLProgress and Cordonel
/// </summary> /// </summary>
[NotFailed] [NotFailed]
[JsonConverter(typeof(JsonStatusConverter))]
public EOLStatus RequirementPcbIdChecked { get; set; } public EOLStatus RequirementPcbIdChecked { get; set; }
/// <summary> /// <summary>
/// Requirement order equals Cordonel order /// Requirement order equals Cordonel order
/// </summary> /// </summary>
[NotFailed] [NotFailed]
[JsonConverter(typeof(JsonStatusConverter))]
public EOLStatus RequirementOrderChecked { get; set; } public EOLStatus RequirementOrderChecked { get; set; }
/// <summary> /// <summary>
/// Requirement region equals Cordonel region /// Requirement region equals Cordonel region
/// </summary> /// </summary>
[NotFailed] [NotFailed]
[JsonConverter(typeof(JsonStatusConverter))]
public EOLStatus RequirementRegionChecked { get; set; } public EOLStatus RequirementRegionChecked { get; set; }
/// <summary> /// <summary>
@@ -99,6 +105,7 @@
/// Battery load is in required range /// Battery load is in required range
/// </summary> /// </summary>
[NotFailed] [NotFailed]
[JsonConverter(typeof(JsonStatusConverter))]
public EOLStatus ProductionStatusBatteryLoadChecked { get; set; } public EOLStatus ProductionStatusBatteryLoadChecked { get; set; }
/// <summary> /// <summary>
@@ -111,42 +118,49 @@
/// Remaining life time is in required range /// Remaining life time is in required range
/// </summary> /// </summary>
[NotFailed] [NotFailed]
[JsonConverter(typeof(JsonStatusConverter))]
public EOLStatus ProductionStatusRemainingLifeTimeChecked { get; set; } public EOLStatus ProductionStatusRemainingLifeTimeChecked { get; set; }
/// <summary> /// <summary>
/// Zero flow process executed and parameter set /// Zero flow process executed and parameter set
/// </summary> /// </summary>
[NotFailed] [NotFailed]
[JsonConverter(typeof(JsonStatusConverter))]
public EOLStatus ProductionStatusZeroFlowChecked { get; set; } public EOLStatus ProductionStatusZeroFlowChecked { get; set; }
/// <summary> /// <summary>
/// Calibration process executed and parameter set /// Calibration process executed and parameter set
/// </summary> /// </summary>
[NotFailed] [NotFailed]
[JsonConverter(typeof(JsonStatusConverter))]
public EOLStatus ProductionStatusCalibrationChecked { get; set; } public EOLStatus ProductionStatusCalibrationChecked { get; set; }
/// <summary> /// <summary>
/// Final configuration written with Vako, CSD ... parameters. /// Final configuration written with Vako, CSD ... parameters.
/// </summary> /// </summary>
[NotFailed] [NotFailed]
[JsonConverter(typeof(JsonStatusConverter))]
public EOLStatus ParametrizationDoneChecked { get; set; } public EOLStatus ParametrizationDoneChecked { get; set; }
/// <summary> /// <summary>
/// Parameters saved to non volatile memory. /// Parameters saved to non volatile memory.
/// </summary> /// </summary>
[NotFailed] [NotFailed]
[JsonConverter(typeof(JsonStatusConverter))]
public EOLStatus StoreConfigurationDoneChecked { get; set; } public EOLStatus StoreConfigurationDoneChecked { get; set; }
/// <summary> /// <summary>
/// Reboot executed to clear RAM values and reload values from flash to RAM for check. /// Reboot executed to clear RAM values and reload values from flash to RAM for check.
/// </summary> /// </summary>
[NotFailed] [NotFailed]
[JsonConverter(typeof(JsonStatusConverter))]
public EOLStatus RebootDoneChecked { get; set; } public EOLStatus RebootDoneChecked { get; set; }
/// <summary> /// <summary>
/// Final configuration - read back and compared. /// Final configuration - read back and compared.
/// </summary> /// </summary>
[NotFailed] [NotFailed]
[JsonConverter(typeof(JsonStatusConverter))]
public EOLStatus ParametrizationCompareChecked { get; set; } public EOLStatus ParametrizationCompareChecked { get; set; }
/// <summary> /// <summary>
@@ -165,18 +179,21 @@
/// Final radio system state is as required /// Final radio system state is as required
/// </summary> /// </summary>
[NotFailed] [NotFailed]
[JsonConverter(typeof(JsonStatusConverter))]
public EOLStatus FinalRadioSystemStateCheck { get; set; } public EOLStatus FinalRadioSystemStateCheck { get; set; }
/// <summary> /// <summary>
/// Password file generated and installed. /// Password file generated and installed.
/// </summary> /// </summary>
[NotFailed] [NotFailed]
[JsonConverter(typeof(JsonStatusConverter))]
public EOLStatus PasswordFileInstalledCheck { get; set; } public EOLStatus PasswordFileInstalledCheck { get; set; }
/// <summary> /// <summary>
/// Attachments like pulse adapter checked. /// Attachments like pulse adapter checked.
/// </summary> /// </summary>
[NotFailed] [NotFailed]
[JsonConverter(typeof(JsonStatusConverter))]
public EOLStatus AttachmentsChecked { get; set; } public EOLStatus AttachmentsChecked { get; set; }
/// <summary> /// <summary>
@@ -91,17 +91,17 @@
ParametrizationDoneChecked = reader.GetValue<String>(20), ParametrizationDoneChecked = reader.GetValue<String>(20),
StoreConfigurationDoneChecked = reader.GetValue<String>(21), StoreConfigurationDoneChecked = reader.GetValue<String>(21),
RebootDoneChecked = reader.GetValue<String>(22), RebootDoneChecked = reader.GetValue<String>(22),
ParametrizationCompareChecked = reader.GetValue<String>(21), ParametrizationCompareChecked = reader.GetValue<String>(23),
RadioCheckId = reader.GetValue<Int64?>(23), RadioCheckId = reader.GetValue<Int64?>(24),
FinalRadioSystemState = reader.GetValue<Int64?>(24), FinalRadioSystemState = reader.GetValue<Int64?>(25),
FinalRadioSystemStateCheck = reader.GetValue<String>(25), FinalRadioSystemStateCheck = reader.GetValue<String>(26),
PasswordFileInstalledCheck = reader.GetValue<String>(26), PasswordFileInstalledCheck = reader.GetValue<String>(27),
AttachmentsChecked = reader.GetValue<String>(27), AttachmentsChecked = reader.GetValue<String>(28),
EOLCompleteDate = reader.GetValue<DateTime?>(28), EOLCompleteDate = reader.GetValue<DateTime?>(29),
EOLSoftwareNameAndVersion = reader.GetValue<String>(29), EOLSoftwareNameAndVersion = reader.GetValue<String>(30),
SAPExportDone = reader.GetValue<String>(30), SAPExportDone = reader.GetValue<String>(31),
SentinelCompleted = reader.GetValue<String>(31), SentinelCompleted = reader.GetValue<String>(32),
SentinelCompletedDate = reader.GetValue<DateTime?>(32), SentinelCompletedDate = reader.GetValue<DateTime?>(33),
}); });
} }
@@ -110,34 +110,34 @@
this.sqlConnection this.sqlConnection
.CreateCommand($@" .CreateCommand($@"
UPDATE Cordonel_EOL_Progress UPDATE Cordonel_EOL_Progress
SET StandardRequirementId = ISNULL(StandardRequirementId, @{nameof(model.StandardRequirementId)}) SET StandardRequirementId = @{nameof(model.StandardRequirementId)}
, StandardRequirementVersion = ISNULL(StandardRequirementVersion, @{nameof(model.StandardRequirementVersion)}) , StandardRequirementVersion = @{nameof(model.StandardRequirementVersion)}
, SpecialRequirementId = ISNULL(SpecialRequirementId, @{nameof(model.SpecialRequirementId)}) , SpecialRequirementId = @{nameof(model.SpecialRequirementId)}
, SpecialRequirementVersion = ISNULL(SpecialRequirementVersion, @{nameof(model.SpecialRequirementVersion)}) , SpecialRequirementVersion = @{nameof(model.SpecialRequirementVersion)}
, RequirementRequestChecked = ISNULL(RequirementRequestChecked, @{nameof(model.RequirementRequestChecked)}) , RequirementRequestChecked = @{nameof(model.RequirementRequestChecked)}
, RequirementPcbIdChecked = ISNULL(RequirementPcbIdChecked, @{nameof(model.RequirementPcbIdChecked)}) , RequirementPcbIdChecked = @{nameof(model.RequirementPcbIdChecked)}
, RequirementOrderChecked = ISNULL(RequirementOrderChecked, @{nameof(model.RequirementOrderChecked)}) , RequirementOrderChecked = @{nameof(model.RequirementOrderChecked)}
, RequirementRegionChecked = ISNULL(RequirementRegionChecked, @{nameof(model.RequirementRegionChecked)}) , RequirementRegionChecked = @{nameof(model.RequirementRegionChecked)}
, ProductionStatusLutCrc = ISNULL(ProductionStatusLutCrc, @{nameof(model.ProductionStatusLutCrc)}) , ProductionStatusLutCrc = @{nameof(model.ProductionStatusLutCrc)}
, ProductionStatusFwVersion = ISNULL(ProductionStatusFwVersion, @{nameof(model.ProductionStatusFwVersion)}) , ProductionStatusFwVersion = @{nameof(model.ProductionStatusFwVersion)}
, ProductionStatusMeterSize = ISNULL(ProductionStatusMeterSize, @{nameof(model.ProductionStatusMeterSize)}) , ProductionStatusMeterSize = @{nameof(model.ProductionStatusMeterSize)}
, ProductionStatusDrainedBatteryLoad = ISNULL(ProductionStatusDrainedBatteryLoad, @{nameof(model.ProductionStatusDrainedBatteryLoad)}) , ProductionStatusDrainedBatteryLoad = @{nameof(model.ProductionStatusDrainedBatteryLoad)}
, ProductionStatusBatteryLoadChecked = ISNULL(ProductionStatusBatteryLoadChecked, @{nameof(model.ProductionStatusBatteryLoadChecked)}) , ProductionStatusBatteryLoadChecked = @{nameof(model.ProductionStatusBatteryLoadChecked)}
, ProductionStatusRemainingLifeTime = ISNULL(ProductionStatusRemainingLifeTime, @{nameof(model.ProductionStatusRemainingLifeTime)}) , ProductionStatusRemainingLifeTime = @{nameof(model.ProductionStatusRemainingLifeTime)}
, ProductionStatusRemainingLifeTimeChecked = ISNULL(ProductionStatusRemainingLifeTimeChecked, @{nameof(model.ProductionStatusRemainingLifeTimeChecked)}) , ProductionStatusRemainingLifeTimeChecked = @{nameof(model.ProductionStatusRemainingLifeTimeChecked)}
, ProductionStatusZeroFlowChecked = ISNULL(ProductionStatusZeroFlowChecked, @{nameof(model.ProductionStatusZeroFlowChecked)}) , ProductionStatusZeroFlowChecked = @{nameof(model.ProductionStatusZeroFlowChecked)}
, ProductionStatusCalibrationChecked = ISNULL(ProductionStatusCalibrationChecked, @{nameof(model.ProductionStatusCalibrationChecked)}) , ProductionStatusCalibrationChecked = @{nameof(model.ProductionStatusCalibrationChecked)}
, ParametrizationDoneChecked = ISNULL(ParametrizationDoneChecked, @{nameof(model.ParametrizationDoneChecked)}) , ParametrizationDoneChecked = @{nameof(model.ParametrizationDoneChecked)}
, StoreConfigurationDoneChecked = ISNULL(StoreConfigurationDoneChecked, @{nameof(model.StoreConfigurationDoneChecked)}) , StoreConfigurationDoneChecked = @{nameof(model.StoreConfigurationDoneChecked)}
, RebootDoneChecked = ISNULL(RebootDoneChecked, @{nameof(model.RebootDoneChecked)}) , RebootDoneChecked = @{nameof(model.RebootDoneChecked)}
, ParametrizationCompareChecked = ISNULL(ParametrizationCompareChecked, @{nameof(model.ParametrizationCompareChecked)}) , ParametrizationCompareChecked = @{nameof(model.ParametrizationCompareChecked)}
, RadioCheckId = ISNULL(RadioCheckId, @{nameof(model.RadioCheckId)}) , RadioCheckId = @{nameof(model.RadioCheckId)}
, FinalRadioSystemState = ISNULL(FinalRadioSystemState, @{nameof(model.FinalRadioSystemState)}) , FinalRadioSystemState = @{nameof(model.FinalRadioSystemState)}
, FinalRadioSystemStateCheck = ISNULL(FinalRadioSystemStateCheck, @{nameof(model.FinalRadioSystemStateCheck)}) , FinalRadioSystemStateCheck = @{nameof(model.FinalRadioSystemStateCheck)}
, PasswordFileInstalledCheck = ISNULL(PasswordFileInstalledCheck, @{nameof(model.PasswordFileInstalledCheck)}) , PasswordFileInstalledCheck = @{nameof(model.PasswordFileInstalledCheck)}
, AttachmentsChecked = ISNULL(AttachmentsChecked, @{nameof(model.AttachmentsChecked)}) , AttachmentsChecked = @{nameof(model.AttachmentsChecked)}
, EOLCompleteDate = ISNULL(EOLCompleteDate, @{nameof(model.EOLCompleteDate)}) , EOLCompleteDate = @{nameof(model.EOLCompleteDate)}
, EOLSoftwareNameAndVersion = ISNULL(EOLSoftwareNameAndVersion, @{nameof(model.EOLSoftwareNameAndVersion)}) , EOLSoftwareNameAndVersion = @{nameof(model.EOLSoftwareNameAndVersion)}
WHERE PcbId = @{nameof(model.PcbId)} WHERE PcbId = @{nameof(model.PcbId)}
AND EOLCompleteDate IS NULL") AND EOLCompleteDate IS NULL")
.SetParameter(nameof(model.PcbId), model.PcbId) .SetParameter(nameof(model.PcbId), model.PcbId)
@@ -208,7 +208,7 @@
SET SAPExportDone = 'OK' SET SAPExportDone = 'OK'
, SentinelCompleted = 'OK' , SentinelCompleted = 'OK'
, SentinelCompletedDate = GETDATE() , SentinelCompletedDate = GETDATE()
WHERE PcbId = @{nameof(model.PcbId)}") WHERE PcbId = @{nameof(model.PcbId)}")
.SetParameter(nameof(model.PcbId), model.PcbId) .SetParameter(nameof(model.PcbId), model.PcbId)
.ExecuteNonQuery(); .ExecuteNonQuery();
@@ -38,6 +38,9 @@
<Prefer32Bit>false</Prefer32Bit> <Prefer32Bit>false</Prefer32Bit>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.13.0.3\lib\net40\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="System.IO, Version=2.6.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> <Reference Include="System.IO, Version=2.6.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
@@ -77,6 +80,10 @@
<None Include="packages.config" /> <None Include="packages.config" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Data\LaaProduction.Data.Cordonel\LaaProduction.Data.Cordonel.csproj">
<Project>{03784923-1FD3-4535-80F5-286728DF62AB}</Project>
<Name>LaaProduction.Data.Cordonel</Name>
</ProjectReference>
<ProjectReference Include="..\LaaProduction.Data.SQL\LaaProduction.Data.SQL.csproj"> <ProjectReference Include="..\LaaProduction.Data.SQL\LaaProduction.Data.SQL.csproj">
<Project>{82D34580-23FE-4315-BC51-51D565ABAE23}</Project> <Project>{82D34580-23FE-4315-BC51-51D565ABAE23}</Project>
<Name>LaaProduction.Data.SQL</Name> <Name>LaaProduction.Data.SQL</Name>
@@ -1,61 +1,51 @@
namespace LaaProduction.Console namespace LaaProduction.Console
{ {
using LaaProduction.Data.Cordonel.Models;
using Newtonsoft.Json;
using System; using System;
using System.Net.Http; using System.Net.Http;
using System.Web; using System.Net.Http.Headers;
using System.Threading;
public class Program public class Program
{ {
public static void Main(String[] args) public static void Main(String[] args)
{ {
GetKitronProductionDate(); while (true)
}
private static DateTime GetKitronProductionDate()
{
var requestURIBuilder = new UriBuilder("http://10.49.40.25");
requestURIBuilder.Path = "/MeterProcessState/api/FinalCheck/GetKitronProductionDate";
requestURIBuilder.Query = $"CheckPcbId=241610009";
using (var httpClient = new HttpClient())
{ {
using (var httpRequestMessage = new HttpRequestMessage()) var pcbId = 212120036;
{ var httpclient = new HttpClient();
httpRequestMessage.Method = HttpMethod.Get; httpclient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
httpRequestMessage.RequestUri = requestURIBuilder.Uri;
using (var httpResponseMessage = httpClient.SendAsync(httpRequestMessage).Result) var deleted = httpclient
{ .DeleteAsync($"http://sla12iis01.emea.sensus.net/LaaProductionWeb/api/cordonel/eolprogress/{pcbId}")
var content = httpResponseMessage.Content.ReadAsStringAsync().Result; .Result;
} var deletedContent = deleted.Content.ReadAsStringAsync().Result;
} var deletedModel = JsonConvert.DeserializeObject<EOLProgressModel>(deletedContent);
Thread.Sleep(1000);
var created = httpclient
.GetAsync($"http://sla12iis01.emea.sensus.net/LaaProductionWeb/api/cordonel/eolprogress/{pcbId}")
.Result;
var createdContent = created.Content.ReadAsStringAsync().Result;
var createdModel = JsonConvert.DeserializeObject<EOLProgressModel>(createdContent);
Thread.Sleep(1000);
createdModel.AttachmentsChecked = EOLStatus.OK;
createdModel.EOLSoftwareNameAndVersion = "a";
var postedJson = JsonConvert.SerializeObject(createdModel, Formatting.Indented);
var postedBody = new StringContent(postedJson);
postedBody.Headers.ContentType = new MediaTypeWithQualityHeaderValue("application/json");
var posted = httpclient
.PostAsync($"http://sla12iis01.emea.sensus.net/LaaProductionWeb/api/cordonel/eolprogress", postedBody)
.Result;
var postedContent = posted.Content.ReadAsStringAsync().Result;
var postedModel = JsonConvert.DeserializeObject<EOLProgressModel>(postedContent);
} }
return DateTime.Now;
} }
} }
} }
////////////// 0. Unseal If Sealed
////////////// 1. View System Parameters
////////////// 2. Verify System Parameters
////////////// 3. View & Save Configuration Parameters
/// 4. Reboot Register
/// 5. Set Register Settings
/// 6. Set Configuration Parameters
/// 7. Remove Reading Unit & Resolution
/// 8. Set Leak Alarm
/// 9. Set High Flow Alarm
/// 10. Set Reverse Flow Alarm
/// 11. Clear Metrology Alarms
/// 12. Enable NFC
/// 13. Verify Register Settings
/// 14. Verify System Parameters
/// 15. Verify Configuration Parameters
/// 16. View Alarms State
/// 17. Verify Leak Alarm
/// 18. Verify High Flow Alarm
/// 19. Verify Reverse Flow Alarm
/// 20. Seal Register
@@ -3,4 +3,5 @@
<package id="Microsoft.Bcl" version="1.1.10" targetFramework="net40" /> <package id="Microsoft.Bcl" version="1.1.10" targetFramework="net40" />
<package id="Microsoft.Bcl.Build" version="1.0.21" targetFramework="net40" /> <package id="Microsoft.Bcl.Build" version="1.0.21" targetFramework="net40" />
<package id="Microsoft.Net.Http" version="2.2.29" targetFramework="net40" /> <package id="Microsoft.Net.Http" version="2.2.29" targetFramework="net40" />
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net40" />
</packages> </packages>
@@ -62,8 +62,13 @@
[HttpPost] [HttpPost]
[Route] [Route]
public IHttpActionResult Post([FromBody] EOLProgressModel model) public IHttpActionResult Post(EOLProgressModel model)
{ {
if (model is null)
{
return this.BadRequest("The EOLProgressModel should not be null.");
}
var actualEOLProgressModel = this.dbcontext.EOLProgress.Update(model); var actualEOLProgressModel = this.dbcontext.EOLProgress.Update(model);
return this.Json(actualEOLProgressModel); return this.Json(actualEOLProgressModel);