From a733da3c78354c7d1140961c79159c4647f27ad7 Mon Sep 17 00:00:00 2001 From: Stoyan Zlatev Date: Wed, 15 Nov 2023 16:40:31 +0100 Subject: [PATCH] secondary changes --- Common/OmniPlus.UI/OmniPlusUI.cs | 12 +-- Common/OmniPlus/OmniPlus.csproj | 1 - Common/OmniPlus/OmniPlusConnectionsPool.cs | 98 +--------------------- Common/OmniPlus/OmniPlusExchange.cs | 4 - 4 files changed, 4 insertions(+), 111 deletions(-) delete mode 100644 Common/OmniPlus/OmniPlusExchange.cs diff --git a/Common/OmniPlus.UI/OmniPlusUI.cs b/Common/OmniPlus.UI/OmniPlusUI.cs index 30af929f..5804d9ea 100644 --- a/Common/OmniPlus.UI/OmniPlusUI.cs +++ b/Common/OmniPlus.UI/OmniPlusUI.cs @@ -24,16 +24,12 @@ namespace OmniPlus.UI private void OmniPlusUI_HandleDestroyed(object _, EventArgs _1) { this.connectionsPool.Dispose(); - - this.connectionsPool.SetQ -= this.ConnectionsPool_SetQ; - this.connectionsPool.GetV -= this.ConnectionsPool_GetV; + this.connectionsPool.StateChanged -= this.ConnectionsPool_StateChanged; } private void OmniPlusUI_HandleCreated(object _, EventArgs _1) { - this.connectionsPool.SetQ += this.ConnectionsPool_SetQ; - this.connectionsPool.GetV += this.ConnectionsPool_GetV; this.connectionsPool.StateChanged += this.ConnectionsPool_StateChanged; this.InitializeBody(); @@ -46,12 +42,6 @@ namespace OmniPlus.UI this.connectionsPool.InitializeInspection(portNames); } - private void ConnectionsPool_GetV(double value) - => this.connectionsPool.NotifyV(value); - - private void ConnectionsPool_SetQ(double value) - => this.connectionsPool.NotifyQ(value); - private void PruefungStartBTN_Click(object _, EventArgs _1) => this.PruefungBackground_DoWork(null, null); diff --git a/Common/OmniPlus/OmniPlus.csproj b/Common/OmniPlus/OmniPlus.csproj index 0918a2d2..68404959 100644 --- a/Common/OmniPlus/OmniPlus.csproj +++ b/Common/OmniPlus/OmniPlus.csproj @@ -90,7 +90,6 @@ - diff --git a/Common/OmniPlus/OmniPlusConnectionsPool.cs b/Common/OmniPlus/OmniPlusConnectionsPool.cs index a55f3514..5825e82b 100644 --- a/Common/OmniPlus/OmniPlusConnectionsPool.cs +++ b/Common/OmniPlus/OmniPlusConnectionsPool.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 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; - } } } diff --git a/Common/OmniPlus/OmniPlusExchange.cs b/Common/OmniPlus/OmniPlusExchange.cs deleted file mode 100644 index 20c748e9..00000000 --- a/Common/OmniPlus/OmniPlusExchange.cs +++ /dev/null @@ -1,4 +0,0 @@ -namespace OmniPlus -{ - public delegate void DoubleEventHandler(double value); -}