secondary changes
This commit is contained in:
@@ -90,7 +90,6 @@
|
||||
<Compile Include="Hanlers\StateChangedHandler.cs" />
|
||||
<Compile Include="OmniPlusConnectionsPool.cs" />
|
||||
<Compile Include="OmniPlusDatabase.cs" />
|
||||
<Compile Include="OmniPlusExchange.cs" />
|
||||
<Compile Include="OmniPlusExtensions.cs" />
|
||||
<Compile Include="OmniPlusConstants.cs" />
|
||||
<Compile Include="OmniPlusTest.cs" />
|
||||
|
||||
@@ -5,7 +5,6 @@ using OmniPlus.Features;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@@ -13,39 +12,8 @@ using static OmniPlus.OmniPlusConstants;
|
||||
|
||||
namespace OmniPlus
|
||||
{
|
||||
[Guid("B5979B1D-26D0-46E5-816A-5CF7CABF8899")]
|
||||
[InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
|
||||
public interface IOmniPlusConnectionsEvents
|
||||
public class OmniPlusConnectionsPool
|
||||
{
|
||||
[DispId(1)]
|
||||
void GetV(double value);
|
||||
|
||||
[DispId(2)]
|
||||
void SetQ(double value);
|
||||
|
||||
[DispId(3)]
|
||||
void StateChanged(int column, int succeeded, string header, string value);
|
||||
}
|
||||
|
||||
[Guid("88B0CC86-4C61-4996-A9CA-BD413BEEBCFF")]
|
||||
[InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
|
||||
public interface IOmniPlusConnectionsPool : IDisposable
|
||||
{
|
||||
[DispId(1)]
|
||||
void InitializeInspection(params string[] portNames);
|
||||
|
||||
[DispId(2)]
|
||||
void StartInspection();
|
||||
}
|
||||
|
||||
[ComSourceInterfaces(typeof(IOmniPlusConnectionsEvents))]
|
||||
[ClassInterface(ClassInterfaceType.None)]
|
||||
[Guid("82BBFC66-E75F-4658-87BD-7CA85F213654")]
|
||||
[ProgId("OmniPlus.OmniPlusConnectionsPool")]
|
||||
public class OmniPlusConnectionsPool : IOmniPlusConnectionsPool
|
||||
{
|
||||
public event DoubleEventHandler GetV;
|
||||
public event DoubleEventHandler SetQ;
|
||||
public event OmniPlusStateChanged StateChanged;
|
||||
|
||||
private readonly ConcurrentDictionary<int, OmniPlusConnection> connections;
|
||||
@@ -135,12 +103,6 @@ namespace OmniPlus
|
||||
this.database.LoadOmniPlusType(this.size, this.variant, this.omniType);
|
||||
}
|
||||
|
||||
public void NotifyQ(double q)
|
||||
=> this.SetQ?.Invoke(q);
|
||||
|
||||
public void NotifyV(double v)
|
||||
=> this.GetV?.Invoke(v);
|
||||
|
||||
public void StartInspection()
|
||||
{
|
||||
this.background = new BackgroundWorker();
|
||||
@@ -164,7 +126,7 @@ namespace OmniPlus
|
||||
|
||||
foreach (var point in this.omniType.TestPoints)
|
||||
{
|
||||
this.SetM3(point.VolumeM3H);
|
||||
// TODO: this.SetM3(point.VolumeM3H);
|
||||
|
||||
tasks = new Task[connectionsCount];
|
||||
|
||||
@@ -175,7 +137,7 @@ namespace OmniPlus
|
||||
|
||||
tasks.ContinueWhenAll();
|
||||
|
||||
var volumeMessured = this.GetM3();
|
||||
var volumeMessured = 0.1D; // TODO: this.GetM3();
|
||||
|
||||
foreach (var position in this.connections.Keys)
|
||||
{
|
||||
@@ -400,59 +362,5 @@ namespace OmniPlus
|
||||
|
||||
timer.Stop();
|
||||
}
|
||||
|
||||
private bool SetM3(double volumeM3)
|
||||
{
|
||||
var received = false;
|
||||
var wait = 60000;
|
||||
var sleep = 1000;
|
||||
|
||||
void setm3(double v)
|
||||
{
|
||||
received = v >= 0;
|
||||
}
|
||||
|
||||
this.SetQ += setm3;
|
||||
this.SetQ?.Invoke(volumeM3);
|
||||
|
||||
while (!received && wait >= 0)
|
||||
{
|
||||
Thread.Sleep(sleep);
|
||||
|
||||
wait -= sleep;
|
||||
}
|
||||
|
||||
this.SetQ -= setm3;
|
||||
|
||||
return received;
|
||||
}
|
||||
|
||||
private double GetM3()
|
||||
{
|
||||
var value = default(double);
|
||||
var received = false;
|
||||
var wait = 60000;
|
||||
var sleep = 1000;
|
||||
|
||||
void getm3(double v)
|
||||
{
|
||||
value = v;
|
||||
received = true;
|
||||
}
|
||||
|
||||
this.GetV += getm3;
|
||||
this.GetV?.Invoke(0);
|
||||
|
||||
while (!received && wait >= 0)
|
||||
{
|
||||
Thread.Sleep(sleep);
|
||||
|
||||
wait -= sleep;
|
||||
}
|
||||
|
||||
this.GetV -= getm3;
|
||||
|
||||
return value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
namespace OmniPlus
|
||||
{
|
||||
public delegate void DoubleEventHandler(double value);
|
||||
}
|
||||
Reference in New Issue
Block a user