lstest omni state
This commit is contained in:
@@ -11,9 +11,11 @@
|
||||
{
|
||||
public App()
|
||||
{
|
||||
ServiceProvider
|
||||
.ServiceCollection
|
||||
.AddSingleton(new OmniContext(Appsettings.OmniDB, Appsettings.OutputDirectory));
|
||||
//ServiceProvider
|
||||
// .ServiceCollection
|
||||
// .AddSingleton(new OmniContext(Appsettings.OmniDB, Appsettings.OutputDirectory));
|
||||
|
||||
OmniContext.Create(Appsettings.OmniDB, Appsettings.OutputDirectory);
|
||||
}
|
||||
|
||||
internal static event Action Exiting;
|
||||
|
||||
@@ -60,7 +60,6 @@
|
||||
<DependentUpon>ItemsGrid.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Models\AppLogger.cs" />
|
||||
<Compile Include="Models\ServiceProvider.cs" />
|
||||
<Compile Include="Models\Appsettings.cs" />
|
||||
<Compile Include="Models\CompilerServices.cs" />
|
||||
<Compile Include="ViewModels\DefaultsHeaderRow.cs" />
|
||||
|
||||
@@ -1,101 +0,0 @@
|
||||
namespace InspectionUI.Models
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Linq;
|
||||
|
||||
public interface IServiceCollection
|
||||
{
|
||||
IServiceCollection AddSingleton<T>(T instance);
|
||||
}
|
||||
|
||||
public class ServiceProvider : IServiceProvider, IServiceCollection
|
||||
{
|
||||
private static readonly ServiceProvider serviceProvider = new ServiceProvider();
|
||||
|
||||
private readonly ConcurrentDictionary<Type, object> services;
|
||||
|
||||
private ServiceProvider()
|
||||
{
|
||||
this.services = new ConcurrentDictionary<Type, object>();
|
||||
}
|
||||
|
||||
public IServiceCollection AddSingleton<T>(T instance)
|
||||
{
|
||||
services.AddOrUpdate(typeof(T), instance, (t, i) => instance);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public object GetService(Type serviceType)
|
||||
{
|
||||
return services.GetOrAdd(serviceType, default(object));
|
||||
}
|
||||
|
||||
public static IServiceCollection ServiceCollection
|
||||
{
|
||||
get => serviceProvider;
|
||||
}
|
||||
|
||||
public static T GetService<T>()
|
||||
{
|
||||
var serviceType = typeof(T);
|
||||
var serviceInstance = default(T);
|
||||
|
||||
if (serviceProvider.GetService(serviceType) is T existingInstance)
|
||||
{
|
||||
serviceInstance = existingInstance;
|
||||
}
|
||||
else if (CreateInstance(serviceType) is T newInstance)
|
||||
{
|
||||
serviceInstance = newInstance;
|
||||
}
|
||||
|
||||
return serviceInstance;
|
||||
}
|
||||
|
||||
private static object CreateInstance(Type instanceType)
|
||||
{
|
||||
var instance = default(object);
|
||||
var constructors = instanceType
|
||||
.GetConstructors()
|
||||
.OrderByDescending(x => x.GetParameters().Length);
|
||||
|
||||
foreach (var constructor in constructors)
|
||||
{
|
||||
var parameters = constructor.GetParameters();
|
||||
var parametersLength = parameters.Length;
|
||||
var createParameters = new object[parametersLength];
|
||||
|
||||
for (int i = 0; i < parametersLength; i++)
|
||||
{
|
||||
var parameterType = parameters[i].ParameterType;
|
||||
var parameter = serviceProvider.GetService(parameterType);
|
||||
|
||||
if (parameter is null)
|
||||
{
|
||||
parameter = CreateInstance(parameterType);
|
||||
}
|
||||
|
||||
createParameters[i] = parameter;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
instance = constructor.Invoke(createParameters);
|
||||
|
||||
if (instance != null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e);
|
||||
}
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,8 +13,8 @@
|
||||
this.Add(new ItemsGridHeaderVM());
|
||||
this.Add(new ItemsGridHeaderVM());
|
||||
|
||||
var pruefpunkte = ServiceProvider
|
||||
.GetService<OmniContext>()
|
||||
var pruefpunkte = OmniContext
|
||||
.Current
|
||||
.Auftrag
|
||||
.Pruefpunkte
|
||||
.Count;
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
this.Add(new ItemsGridHeaderVM());
|
||||
this.Add(new ItemsGridHeaderVM { Value = "0.0" });
|
||||
|
||||
var pruefpunkte = ServiceProvider
|
||||
.GetService<OmniContext>()
|
||||
var pruefpunkte = OmniContext
|
||||
.Current
|
||||
.Auftrag
|
||||
.Pruefpunkte;
|
||||
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
this.Add(new ItemsGridHeaderVM { Value = "SerialNr", Width = ItemsGridHeaderVM.Star });
|
||||
this.Add(new ItemsGridHeaderVM { Value = "Crr.F. %", Width = ItemsGridHeaderVM.Auto });
|
||||
|
||||
var pruefpunkte = ServiceProvider
|
||||
.GetService<OmniContext>()
|
||||
var pruefpunkte = OmniContext
|
||||
.Current
|
||||
.Auftrag
|
||||
.Pruefpunkte;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
namespace InspectionUI.ViewModels
|
||||
{
|
||||
using InspectionUI.Models;
|
||||
using OmniPlus;
|
||||
|
||||
using System;
|
||||
using System.Windows.Input;
|
||||
@@ -88,7 +88,7 @@
|
||||
this.EnableButtons(false);
|
||||
|
||||
this.Errors = default(string);
|
||||
this.MetersPool = ServiceProvider.GetService<MetersPoolVM>();
|
||||
this.MetersPool = new MetersPoolVM(OmniContext.Current);
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(this.SuchNr))
|
||||
{
|
||||
@@ -108,7 +108,7 @@
|
||||
this.StartNewTask(() =>
|
||||
{
|
||||
this.Errors = "Connecting meters ...";
|
||||
this.MetersPool.LoadMeters();
|
||||
this.MetersPool.LoadMetersAsync();
|
||||
})
|
||||
.ContinueWith(_ =>
|
||||
{
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
namespace InspectionUI.ViewModels
|
||||
{
|
||||
using InspectionUI.Models;
|
||||
|
||||
using OmniPlus;
|
||||
|
||||
using System;
|
||||
@@ -25,8 +23,8 @@
|
||||
this.Add(new ItemsGridCellVM());
|
||||
this.Add(new ItemsGridCellVM());
|
||||
|
||||
var pruefpunkte = ServiceProvider
|
||||
.GetService<OmniContext>()
|
||||
var pruefpunkte = OmniContext
|
||||
.Current
|
||||
.Auftrag
|
||||
.Pruefpunkte
|
||||
.Count;
|
||||
@@ -72,94 +70,145 @@
|
||||
base.Dispose();
|
||||
}
|
||||
|
||||
public Task SaveMeterStateAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
return this.StartNewTask(this.meter.SaveMeterState, cancellationToken);
|
||||
}
|
||||
|
||||
public Task LoadTestRunAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
return this.StartNewTask(this.meter.LoadTestRun, cancellationToken);
|
||||
void LoadTestRun(object state)
|
||||
{
|
||||
if (state is MeterVM meterVM)
|
||||
{
|
||||
if (!meterVM.meter.IsConnected)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
meterVM.meter.LoadTestRun();
|
||||
}
|
||||
}
|
||||
|
||||
return this.StartNewTask(LoadTestRun, this, cancellationToken);
|
||||
}
|
||||
|
||||
public Task InitializeInspectionAsync(bool keepCorrection, CancellationToken cancellationToken)
|
||||
{
|
||||
this.uinr = 0;
|
||||
|
||||
void InitializeInspection()
|
||||
if (keepCorrection)
|
||||
{
|
||||
this.meter.InitializeForInspection(keepCorrection);
|
||||
|
||||
this.Set(this.meter.TestRun.CrrfBefore, "{0:0.0}", 3);
|
||||
cancellationToken.Register(this.meter.FinishInspection);
|
||||
}
|
||||
|
||||
return this.StartNewTask(InitializeInspection, cancellationToken);
|
||||
void InitializeInspection(object state)
|
||||
{
|
||||
if (state is MeterVM meterVM)
|
||||
{
|
||||
meterVM.uinr = 0;
|
||||
|
||||
var meter = meterVM.meter;
|
||||
|
||||
if (!meter.IsConnected)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
meter.InitializeForInspection(keepCorrection);
|
||||
meterVM.Set(meter.TestRun.CrrfBefore, "{0:0.0}", 3);
|
||||
}
|
||||
}
|
||||
|
||||
return this.StartNewTask(InitializeInspection, this, cancellationToken);
|
||||
}
|
||||
|
||||
public Task StartCalibrationAsync(OmniPruefpunkt pp, CancellationToken cancellationToken)
|
||||
{
|
||||
this.uinr++;
|
||||
|
||||
void StartCalibration()
|
||||
void StartCalibration(object state)
|
||||
{
|
||||
this.meter.StartCalibration((ushort)pp.Rotations, (ushort)pp.Duration);
|
||||
if (state is MeterVM meterVM)
|
||||
{
|
||||
meterVM.uinr++;
|
||||
|
||||
this.ShowRestTime(pp.Duration, this.uinr * 3 + 1);
|
||||
var _pp = pp;
|
||||
var meter = meterVM.meter;
|
||||
|
||||
if (!meter.IsConnected)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
meter.StartCalibration((ushort)_pp.Rotations, (ushort)_pp.Duration);
|
||||
meterVM.ShowRestTime(_pp.Duration, meterVM.uinr * 3 + 1);
|
||||
}
|
||||
}
|
||||
|
||||
return this.StartNewTask(StartCalibration, cancellationToken);
|
||||
return this.StartNewTask(StartCalibration, this, cancellationToken);
|
||||
}
|
||||
|
||||
public Task StopCalibrationAsync(OmniPruefpunkt pp, double refm3s, CancellationToken cancellationToken)
|
||||
{
|
||||
void StopCalibration()
|
||||
void StopCalibration(object state)
|
||||
{
|
||||
var response = this.meter.StopCalibration(pp, refm3s);
|
||||
var index = this.uinr * 3 + 1;
|
||||
if (state is MeterVM meterVM)
|
||||
{
|
||||
var _pp = pp;
|
||||
var meter = meterVM.meter;
|
||||
|
||||
this.Set(response.Item2, "{0}", index);
|
||||
this.Set(response.Item1, "{0:0.0000000000}", index + 1);
|
||||
this.Set(response.Item3, "{0:0.00}", index + 2);
|
||||
if (!meter.IsConnected)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var response = meter.StopCalibration(_pp, refm3s);
|
||||
var index = meterVM.uinr * 3 + 1;
|
||||
|
||||
meterVM.Set(response.Item2, "{0}", index);
|
||||
meterVM.Set(response.Item1, "{0:0.0000000}", index + 1);
|
||||
meterVM.Set(response.Item3, "{0:0.00}", index + 2);
|
||||
}
|
||||
}
|
||||
|
||||
return this.StartNewTask(StopCalibration, cancellationToken);
|
||||
return this.StartNewTask(StopCalibration, this, cancellationToken);
|
||||
}
|
||||
|
||||
public Task FinishInspectionAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
void FinishInspection()
|
||||
void FinishInspection(object state)
|
||||
{
|
||||
this.meter.FinishInspection();
|
||||
|
||||
var crrf = this.meter.TestRun.CrrfAfter;
|
||||
var foreground = this.meter.TestRun.Succeeded == true
|
||||
? Brushes.Green
|
||||
: Brushes.Red;
|
||||
|
||||
this.Set(x => x.Foreground = foreground, this.LastIndex);
|
||||
|
||||
this.Set(crrf, "{0:0.0}", this.LastIndex);
|
||||
|
||||
this.uinr = 1;
|
||||
|
||||
foreach (var testedPP in this.meter.TestRun.TestedPoints)
|
||||
if (state is MeterVM meterVM)
|
||||
{
|
||||
var index = this.uinr * 3 + 1 + 2;
|
||||
var meter = meterVM.meter;
|
||||
|
||||
this.Set(testedPP.Acc, "{0:0.00}", index);
|
||||
this.Set(x =>
|
||||
if (!meter.IsConnected)
|
||||
{
|
||||
foreground = testedPP.Succeeded == true
|
||||
? Brushes.Green
|
||||
: Brushes.Red;
|
||||
x.Foreground = foreground;
|
||||
}, index);
|
||||
return;
|
||||
}
|
||||
|
||||
this.uinr++;
|
||||
meter.FinishInspection();
|
||||
|
||||
var crrf = meter.TestRun.CrrfAfter;
|
||||
var foreground = meter.TestRun.Succeeded == true
|
||||
? Brushes.Green
|
||||
: Brushes.Red;
|
||||
|
||||
meterVM.Set(x => x.Foreground = foreground, meterVM.LastIndex);
|
||||
meterVM.Set(crrf, "{0:0.0}", meterVM.LastIndex);
|
||||
meterVM.uinr = 1;
|
||||
|
||||
foreach (var testedPP in meter.TestRun.TestedPoints)
|
||||
{
|
||||
var index = meterVM.uinr * 3 + 1 + 2;
|
||||
|
||||
meterVM.Set(testedPP.Acc, "{0:0.00}", index);
|
||||
meterVM.Set(x =>
|
||||
{
|
||||
foreground = testedPP.Succeeded == true
|
||||
? Brushes.Green
|
||||
: Brushes.Red;
|
||||
x.Foreground = foreground;
|
||||
}, index);
|
||||
|
||||
meterVM.uinr++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return this.StartNewTask(FinishInspection, cancellationToken);
|
||||
return this.StartNewTask(FinishInspection, this, cancellationToken);
|
||||
}
|
||||
|
||||
private void ShowRestTime(int duration, int index)
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
private CancellationTokenSource cancellationTokenSource;
|
||||
private ReferenceMeterVM referenceMeter;
|
||||
|
||||
public MetersPoolVM(OmniContext omniContext) : base()
|
||||
public MetersPoolVM() : base()
|
||||
{
|
||||
this.omniContext = omniContext;
|
||||
this.omniContext = OmniContext.Current;
|
||||
}
|
||||
|
||||
public void CancelInspection()
|
||||
@@ -34,28 +34,25 @@
|
||||
|
||||
}
|
||||
|
||||
public void LoadMeters()
|
||||
public void LoadMetersAsync()
|
||||
{
|
||||
this.referenceMeter = ServiceProvider.GetService<ReferenceMeterVM>();
|
||||
this.referenceMeter = new ReferenceMeterVM(OmniContext.Current);
|
||||
|
||||
this.Add(this.referenceMeter);
|
||||
this.omniContext.LoadMeters(Appsettings.COMPorts, Appsettings.PSNR);
|
||||
|
||||
this.omniContext
|
||||
.LoadMetersAsync(Appsettings.COMPorts, Appsettings.PSNR)
|
||||
.ContinueWith(_ =>
|
||||
{
|
||||
foreach (var meter in this.omniContext.Meters)
|
||||
{
|
||||
this.Add(new MeterVM(meter));
|
||||
}
|
||||
foreach (var meter in this.omniContext.Meters)
|
||||
{
|
||||
this.Add(new MeterVM(meter));
|
||||
}
|
||||
|
||||
this.NotifyPropertyChanged();
|
||||
});
|
||||
this.NotifyPropertyChanged();
|
||||
}
|
||||
|
||||
public void RunInspection(bool keepCorrection = false, bool addCorrection = false)
|
||||
public void RunInspection(bool keepCorrection = false)
|
||||
{
|
||||
// show reference meter seconds
|
||||
this.cancellationTokenSource = new CancellationTokenSource();
|
||||
|
||||
var cancellationToken = this.cancellationTokenSource.Token;
|
||||
var tasks = new List<Task>();
|
||||
var meters = this
|
||||
@@ -70,13 +67,6 @@
|
||||
|
||||
this.ContinueWhenAll(tasks);
|
||||
|
||||
foreach (var meterVM in meters)
|
||||
{
|
||||
tasks.Add(meterVM.SaveMeterStateAsync(cancellationToken));
|
||||
}
|
||||
|
||||
this.ContinueWhenAll(tasks);
|
||||
|
||||
foreach (var meterVM in meters)
|
||||
{
|
||||
tasks.Add(meterVM.InitializeInspectionAsync(keepCorrection, cancellationToken));
|
||||
@@ -162,9 +152,9 @@
|
||||
{
|
||||
this.DispatcherInvoke(() =>
|
||||
{
|
||||
this.Add(ServiceProvider.GetService<HeadersRowVM>());
|
||||
this.Add(ServiceProvider.GetService<DefaultsHeaderRow>());
|
||||
this.Add(ServiceProvider.GetService<DefaultsRowVM>());
|
||||
this.Add(new HeadersRowVM());
|
||||
this.Add(new DefaultsHeaderRow());
|
||||
this.Add(new DefaultsRowVM());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,10 +18,10 @@
|
||||
private int ppnr;
|
||||
private bool cancel;
|
||||
|
||||
public ReferenceMeterVM(OmniContext omniContext, ExchangeConnection signarR) : base()
|
||||
public ReferenceMeterVM(OmniContext omniContext) : base()
|
||||
{
|
||||
this.omniContext = omniContext;
|
||||
this.signarR = signarR;
|
||||
this.signarR = new ExchangeConnection();
|
||||
this.signarR.StateChanged += this.SignarR_StateChanged;
|
||||
this.signarR.Connect(Appsettings.HubURL);
|
||||
this.ppnr = 1;
|
||||
@@ -193,14 +193,14 @@
|
||||
waitHandle.Wait(timeout * interval);
|
||||
waitHandle.Reset();
|
||||
|
||||
OmniPlusFormulas.OutDebugM3S(ref referenceV);
|
||||
// OmniPlusFormulas.OutDebugM3S(ref referenceV);
|
||||
|
||||
this.signarR.StopReferenceMessurement -= ReceiveFlow;
|
||||
timer.Elapsed -= TimerElapsed;
|
||||
|
||||
waitHandle.Wait(1000);
|
||||
|
||||
this.Set(referenceV, "{0:0.0000000000}", this.ppnr + 1);
|
||||
this.Set(referenceV, "{0:0.0000000}", this.ppnr + 1);
|
||||
this.Set(referenceV == 0 ? 0 : 100, "{0:0.00}", this.ppnr + 2);
|
||||
|
||||
return referenceV;
|
||||
|
||||
@@ -99,6 +99,20 @@
|
||||
}, cancellationToken);
|
||||
}
|
||||
|
||||
protected Task StartNewTask(Action<object> action, object state, CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return Task
|
||||
.Factory
|
||||
.StartNew(action, state, cancellationToken)
|
||||
.ContinueWith(task =>
|
||||
{
|
||||
if (task.Exception != null)
|
||||
{
|
||||
AppLogger.Log(task.Exception);
|
||||
}
|
||||
}, cancellationToken);
|
||||
}
|
||||
|
||||
protected class Command : ICommand
|
||||
{
|
||||
private readonly Action executable;
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
const int PULSES_PER_ROTATION = 8;
|
||||
|
||||
var fractionPart = (double)fraction / FRACTION_FACTOR;
|
||||
var mlPlain = intPart + fractionPart;
|
||||
var mlPulse = intPart + fractionPart;
|
||||
var mlr = mlPulse * PULSES_PER_ROTATION;
|
||||
|
||||
@@ -114,15 +113,14 @@
|
||||
|
||||
public static double MeterFlowM3S(double rotations, double mlr, double duration)
|
||||
{
|
||||
var seconds = duration * (1D / (short.MaxValue + 1));
|
||||
var m3s = rotations * mlr / seconds / 1000D / 1000D * 100;
|
||||
var m3s = rotations * mlr / duration / 1000D / 1000D * 100;
|
||||
|
||||
if (double.IsNaN(m3s) || double.IsInfinity(m3s))
|
||||
{
|
||||
return default(double);
|
||||
}
|
||||
|
||||
return rotations * mlr / seconds / 1000D / 1000D * 100;
|
||||
return m3s;
|
||||
}
|
||||
|
||||
public static double MeterFlowM3S(this OmniPlusTestPoint point, OmniPlusTest test)
|
||||
@@ -186,13 +184,5 @@
|
||||
|
||||
return crrf;
|
||||
}
|
||||
|
||||
public static void OutDebugM3S(ref double value)
|
||||
{
|
||||
//if (true)
|
||||
//{
|
||||
// value = new Random().Next(95, 100) / 1005D;
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
public class OmniContext : IDisposable
|
||||
@@ -11,16 +12,21 @@
|
||||
private readonly ConcurrentDictionary<int, OmniMeter> meters;
|
||||
private readonly OmniDatabase database;
|
||||
private readonly string outputDirectory;
|
||||
|
||||
|
||||
private int slotNr;
|
||||
|
||||
public static void Create(String omniDB, String outputDirectory)
|
||||
{
|
||||
Current = new OmniContext(omniDB, outputDirectory);
|
||||
}
|
||||
|
||||
private int runId;
|
||||
|
||||
public OmniContext(string connectionString, string outputDirectory)
|
||||
private OmniContext(string connectionString, string outputDirectory)
|
||||
{
|
||||
this.outputDirectory = outputDirectory;
|
||||
this.database = new OmniDatabase(connectionString, outputDirectory);
|
||||
this.meters = new ConcurrentDictionary<int, OmniMeter>();
|
||||
|
||||
Current = this;
|
||||
}
|
||||
|
||||
public OmniAuftrag Auftrag { get; set; }
|
||||
@@ -77,36 +83,36 @@
|
||||
this.runId = this.database.GetNextRunId();
|
||||
}
|
||||
|
||||
public Task LoadMetersAsync(string portNames, string psnr)
|
||||
public void LoadMeters(string portNames, string psnr)
|
||||
{
|
||||
this.Dispose();
|
||||
|
||||
this.slotNr = 1;
|
||||
|
||||
var tasks = new List<Task>();
|
||||
var slotNr = 1;
|
||||
|
||||
foreach (var portName in portNames.Split(new[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries))
|
||||
{
|
||||
var meter = new OmniMeter(psnr, slotNr, portName, this.outputDirectory);
|
||||
tasks
|
||||
.Add(Task.Factory
|
||||
.StartNew(state =>
|
||||
{
|
||||
if (state is OmniContext context)
|
||||
{
|
||||
var meter = new OmniMeter(psnr, context.slotNr, portName, context.outputDirectory);
|
||||
|
||||
this.meters.AddOrUpdate(slotNr, meter, (_, _1) => meter);
|
||||
meter.ConnectIrda();
|
||||
|
||||
tasks.Add(Task.Factory.StartNew(() => meter.ConnectIrda()));
|
||||
context.meters.AddOrUpdate(slotNr, meter, (_, _1) => meter);
|
||||
}
|
||||
}, this, CancellationToken.None));
|
||||
|
||||
slotNr++;
|
||||
}
|
||||
|
||||
return Task.Factory.ContinueWhenAll(tasks.ToArray(), _tasks =>
|
||||
{
|
||||
foreach (var task in _tasks)
|
||||
{
|
||||
if (task.Exception != null)
|
||||
{
|
||||
// TODO: Add logging.
|
||||
}
|
||||
}
|
||||
|
||||
tasks.Clear();
|
||||
});
|
||||
Task.Factory
|
||||
.ContinueWhenAll(tasks.ToArray(), _ => { })
|
||||
.Wait();
|
||||
}
|
||||
|
||||
internal int UpdateTestRun(IDictionary<string, object> parameters, int id, byte slotNr)
|
||||
@@ -114,6 +120,6 @@
|
||||
return this.database.UpdateTestRun(parameters, id, slotNr);
|
||||
}
|
||||
|
||||
internal static OmniContext Current { get; private set; }
|
||||
public static OmniContext Current { get; private set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,6 +45,8 @@
|
||||
|
||||
public OmniPruefgang TestRun { get; private set; }
|
||||
|
||||
public Boolean IsConnected { get; set; }
|
||||
|
||||
public void ConnectIrda()
|
||||
{
|
||||
if (this.connection is null)
|
||||
@@ -64,6 +66,15 @@
|
||||
if (buildInfo.Status == Status.Completed)
|
||||
{
|
||||
this.MeterNr = buildInfo.Value;
|
||||
|
||||
if (string.IsNullOrWhiteSpace(this.MeterNr))
|
||||
{
|
||||
this.MeterNr = new string('.', 12);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.IsConnected = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -87,6 +98,11 @@
|
||||
this.WriteToLog();
|
||||
}
|
||||
|
||||
public void SaveCorrection()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void InitializeForInspection(bool keepCorrection = false)
|
||||
{
|
||||
var systemParameters = this.connection.ViewSystemParameters();
|
||||
@@ -231,11 +247,16 @@
|
||||
var response = this.connection.ViewChamberCalibration();
|
||||
var rotations = response.Rotations;
|
||||
var duration = response.DurationSec;
|
||||
|
||||
this.NotifyStateChanged(rotations);
|
||||
this.NotifyStateChanged(duration);
|
||||
|
||||
var rs = $"{rotations}/{duration:0.0}";
|
||||
var mlr = OmniPlusFormulas.MilliliterPerRotation(this.defaults.IntPart, (ushort)this.defaults.Fraction, this.defaults.Factor);
|
||||
var m3s = OmniPlusFormulas.MeterFlowM3S(rotations, mlr, duration);
|
||||
|
||||
OmniPlusFormulas.OutDebugM3S(ref m3s);
|
||||
|
||||
this.NotifyStateChanged(mlr);
|
||||
this.NotifyStateChanged(m3s);
|
||||
|
||||
var acc = OmniPlusFormulas.AccuracyPercentage(m3s, refm3s);
|
||||
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
namespace Xylem.Common.Ui.GenesisToolBox.Ctls
|
||||
{
|
||||
partial class RegisterForm
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||
this.Text = "RegisterForm";
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Xylem.Common.Ui.GenesisToolBox.Ctls
|
||||
{
|
||||
public partial class RegisterForm : Form
|
||||
{
|
||||
public RegisterForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -216,6 +216,12 @@
|
||||
<Compile Include="Ctls\LoginForm.Designer.cs">
|
||||
<DependentUpon>LoginForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Ctls\RegisterForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Ctls\RegisterForm.Designer.cs">
|
||||
<DependentUpon>RegisterForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Ctls\TextProgressBar.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
@@ -442,7 +448,7 @@
|
||||
<Compile Include="Infrastructure\ParseExtensions.cs" />
|
||||
<Compile Include="Infrastructure\RefTempRange.cs" />
|
||||
<Compile Include="Infrastructure\Software.cs" />
|
||||
<Compile Include="Infrastructure\SoftwareUser.cs" />
|
||||
<Compile Include="Infrastructure\LDAPUser.cs" />
|
||||
<Compile Include="Infrastructure\SoftwareVersion.cs" />
|
||||
<Compile Include="Infrastructure\SoftwareFunctions.cs" />
|
||||
<Compile Include="Infrastructure\TemperatureSource.cs" />
|
||||
|
||||
Reference in New Issue
Block a user