omni context Current as internal

test runs MeterNr deleted
setup for debuging
This commit is contained in:
Stoyan Zlatev
2024-02-06 09:24:12 +01:00
parent 02943ebcbc
commit 56476e5b5c
18 changed files with 74 additions and 324 deletions
@@ -25,7 +25,6 @@
private HubConnection connection;
private IHubProxy proxy;
private string outputFile;
public ExchangeConnection()
=> this.disposables = new List<IDisposable>();
@@ -36,9 +36,6 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Data" />
@@ -1,5 +1,7 @@
namespace InspectionUI.ViewModels
{
using InspectionUI.Models;
using OmniPlus;
public class DefaultsHeaderRow : ItemsGridRowVM
@@ -11,9 +13,13 @@
this.Add(new ItemsGridHeaderVM());
this.Add(new ItemsGridHeaderVM());
var auftrag = OmniContext.Current.Auftrag;
var pruefpunkte = ServiceProvider
.GetService<OmniContext>()
.Auftrag
.Pruefpunkte
.Count;
foreach (var pp in auftrag.Pruefpunkte)
for (int i = 0; i < pruefpunkte; i++)
{
this.Add(new ItemsGridHeaderVM { Value = $"r/s" });
this.Add(new ItemsGridHeaderVM { Value = $"m³/h" });
@@ -1,5 +1,7 @@
namespace InspectionUI.ViewModels
{
using InspectionUI.Models;
using OmniPlus;
public class DefaultsRowVM : ItemsGridRowVM
@@ -11,9 +13,12 @@
this.Add(new ItemsGridHeaderVM());
this.Add(new ItemsGridHeaderVM { Value = "0.0" });
var auftrag = OmniContext.Current.Auftrag;
var pruefpunkte = ServiceProvider
.GetService<OmniContext>()
.Auftrag
.Pruefpunkte;
foreach (var pp in auftrag.Pruefpunkte)
foreach (var pp in pruefpunkte)
{
this.Add(new ItemsGridHeaderVM { Value = $"{pp.Rotations}/{pp.Duration:0.0}" });
this.Add(new ItemsGridHeaderVM { Value = $"{pp.FlowM3H:0.000}" });
@@ -1,5 +1,7 @@
namespace InspectionUI.ViewModels
{
using InspectionUI.Models;
using OmniPlus;
public class HeadersRowVM : ItemsGridRowVM
@@ -11,9 +13,12 @@
this.Add(new ItemsGridHeaderVM { Value = "SerialNr", Width = ItemsGridHeaderVM.Star });
this.Add(new ItemsGridHeaderVM { Value = "Crr.F. %", Width = ItemsGridHeaderVM.Auto });
var auftrag = OmniContext.Current.Auftrag;
var pruefpunkte = ServiceProvider
.GetService<OmniContext>()
.Auftrag
.Pruefpunkte;
foreach (var pp in auftrag.Pruefpunkte)
foreach (var pp in pruefpunkte)
{
this.Add(new ItemsGridHeaderVM
{
@@ -1,5 +1,7 @@
namespace InspectionUI.ViewModels
{
using InspectionUI.Models;
using OmniPlus;
using System;
@@ -23,9 +25,13 @@
this.Add(new ItemsGridCellVM());
this.Add(new ItemsGridCellVM());
var auftrag = OmniContext.Current.Auftrag;
var pruefpunkte = ServiceProvider
.GetService<OmniContext>()
.Auftrag
.Pruefpunkte
.Count;
foreach (var _ in auftrag.Pruefpunkte)
for (int i = 0; i < pruefpunkte; i++)
{
this.Add(new ItemsGridCellVM());
this.Add(new ItemsGridCellVM());
@@ -84,8 +84,7 @@
this.ContinueWhenAll(tasks);
var pruefpunkte = OmniContext
.Current
var pruefpunkte = this.omniContext
.Auftrag
.Pruefpunkte;
@@ -41,7 +41,7 @@
private void StartFlow(OmniPruefpunkt pp)
{
var interval = 1000;
var timeout = 500;
var timeout = 5;// 00;
var volume = default(double);
var waitHandle = new ManualResetEventSlim();
var timer = new System.Timers.Timer
@@ -95,7 +95,7 @@
private void StartRZ(OmniPruefpunkt pp)
{
var interval = 1000;
var timeout = 60;
var timeout = 6;// 0;
var seconds = default(double);
var waitHandle = new ManualResetEventSlim();
var timer = new System.Timers.Timer
@@ -149,7 +149,7 @@
internal double GetFlow()
{
var interval = 1000;
var timeout = 60;
var timeout = 6;// 0;
var referenceV = 0D;
var waitHandle = new ManualResetEventSlim();
var timer = new System.Timers.Timer
@@ -189,10 +189,10 @@
public static void OutDebugM3S(ref double value)
{
//if (true)
//{
// value = new Random().Next(95, 100) / 1005D;
//}
if (true)
{
value = new Random().Next(95, 100) / 1005D;
}
}
}
}
+2 -5
View File
@@ -4,7 +4,6 @@
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Threading;
using System.Threading.Tasks;
public class OmniContext : IDisposable
@@ -12,9 +11,7 @@
private readonly ConcurrentDictionary<int, OmniMeter> meters;
private readonly OmniDatabase database;
private readonly string outputDirectory;
private CancellationTokenSource cancellationTokenSource;
private CancellationToken cancellationToken;
private int runId;
public OmniContext(string connectionString, string outputDirectory)
@@ -117,6 +114,6 @@
return this.database.UpdateTestRun(parameters, id, slotNr);
}
public static OmniContext Current { get; private set; }
internal static OmniContext Current { get; private set; }
}
}
+8 -9
View File
@@ -217,26 +217,26 @@
};
}
public OmniPruefgang AddTestRun(int id, string psnr, int slotnr, string meterNr)
public OmniPruefgang AddTestRun(int id, string psnr, int slotnr, string buildInfo)
{
return this.sqlConnection
.CreateCommand($@"
INSERT
INTO [OmniTestRuns] ([Id], [PsNr], [SlotNr], [MeterNr])
INTO [OmniTestRuns] ([Id], [PsNr], [SlotNr], [BuildInfo])
OUTPUT [inserted].[Id]
, [inserted].[SlotNr]
, [inserted].[MeterNr]
, [inserted].[BuildInfo]
, [inserted].[AddDate]
VALUES (@{nameof(id)}, @{nameof(psnr)}, @{nameof(slotnr)}, @{nameof(meterNr)})")
VALUES (@{nameof(id)}, @{nameof(psnr)}, @{nameof(slotnr)}, @{nameof(buildInfo)})")
.SetParameter(nameof(id), id)
.SetParameter(nameof(psnr), psnr)
.SetParameter(nameof(slotnr), slotnr)
.SetParameter(nameof(meterNr), meterNr)
.SetParameter(nameof(buildInfo), buildInfo)
.FirstOrDefault(reader => new OmniPruefgang
{
Id = reader.GetInt(),
SlotNr = reader.GetTinyint(),
MeterNr = reader.GetString(),
BuildInfo = reader.GetString(),
AddDate = reader.GetDate()
});
}
@@ -309,7 +309,8 @@
public OmniParameter TypParameter { get; internal set; }
public ICollection<OmniPruefpunkt> Pruefpunkte { get; internal set; }
public ICollection<OmniPruefpunkt> Pruefpunkte { get; internal set; }
= new List<OmniPruefpunkt>();
internal void GiveAllTestPointsNr()
{
@@ -372,8 +373,6 @@
public byte SlotNr { get; set; }
public string MeterNr { get; set; }
public DateTime AddDate { get; set; }
public string BuildInfo { get; set; }
+22 -8
View File
@@ -69,6 +69,8 @@
{
this.MeterNr = NA;
}
this.WriteToLog();
}
public void Dispose()
@@ -82,10 +84,7 @@
this.connection = null;
while (this.states.TryDequeue(out var state))
{
File.AppendAllText(this.outputFile, $"{state}{Environment.NewLine}");
}
this.WriteToLog();
}
public void InitializeForInspection(bool keepCorrection = false)
@@ -129,11 +128,15 @@
this.TestRun.CrrfBefore = this.connection.ViewFactoryCorrection();
this.TestRun.SaveChanges();
this.WriteToLog();
}
public void LoadTestRun()
{
this.TestRun = OmniContext.Current.AddTestRun(this.PSNR, this.SlotNr, this.MeterNr);
this.WriteToLog();
}
public void SaveMeterState()
@@ -212,11 +215,15 @@
}
OmniContext.Current.Add(this.MeterNr, meterState.ToString());
this.WriteToLog();
}
public void StartCalibration(ushort rotations, ushort duration)
{
var response = connection.StartChamberCalibration(rotations, duration);
this.WriteToLog();
}
public Tuple<double, string, double> StopCalibration(OmniPruefpunkt pp, double refm3s)
@@ -234,6 +241,8 @@
this.TestRun.AddTestPoint(pp.PPNR, pp.TestPointId, pp.GalPerMin, rotations, duration, m3s, refm3s, acc);
this.WriteToLog();
return new Tuple<double, string, double>(m3s, rs, acc);
}
@@ -307,10 +316,7 @@
this.connection.FactorySeal(true);
}
while (this.states.TryDequeue(out var state))
{
File.AppendAllText(this.outputFile, $"{state}{Environment.NewLine}");
}
this.WriteToLog();
}
public void NotifyStateChanged(object state)
@@ -326,5 +332,13 @@
return outputFile;
}
private void WriteToLog()
{
while (this.states.TryDequeue(out var state))
{
File.AppendAllText(this.outputFile, $"{state}{Environment.NewLine}");
}
}
}
}
@@ -81,7 +81,6 @@ CREATE TABLE [OmniTestRuns] (
[Id] INT NOT NULL,
[PsNr] VARCHAR(10) NOT NULL,
[SlotNr] TINYINT NOT NULL,
[MeterNr] VARCHAR(32) NOT NULL,
[AddDate] DATETIME NOT NULL DEFAULT(GETDATE()),
[BuildInfo] VARCHAR(15) NULL,