signal r for omni
This commit is contained in:
@@ -100,9 +100,13 @@
|
||||
<Compile Include="Options\OmniControlOptions.cs" />
|
||||
<Compile Include="Options\SerialPortOptions.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="SignalRConnection.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="OmniPlusDatabase.sql" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="app.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
@@ -18,6 +18,7 @@ namespace OmniPlus
|
||||
|
||||
private readonly ConcurrentDictionary<int, OmniPlusConnection> connections;
|
||||
private readonly ConcurrentDictionary<int, OmniPlusMeter> meters;
|
||||
private readonly SignalRConnection signalRConnection;
|
||||
private readonly OmniPlusDatabase database;
|
||||
private readonly OmniPlusType omniType;
|
||||
|
||||
@@ -25,10 +26,11 @@ namespace OmniPlus
|
||||
private string variant;
|
||||
private BackgroundWorker background;
|
||||
|
||||
public OmniPlusConnectionsPool(string dbConnectionString)
|
||||
public OmniPlusConnectionsPool(string dbConnectionString, string signalRURL)
|
||||
{
|
||||
this.connections = new ConcurrentDictionary<int, OmniPlusConnection>();
|
||||
this.meters = new ConcurrentDictionary<int, OmniPlusMeter>();
|
||||
this.signalRConnection = new SignalRConnection(signalRURL);
|
||||
this.database = new OmniPlusDatabase(dbConnectionString);
|
||||
this.omniType = new OmniPlusType();
|
||||
|
||||
@@ -67,6 +69,8 @@ namespace OmniPlus
|
||||
|
||||
public void InitializeInspection(params string[] portNames)
|
||||
{
|
||||
this.signalRConnection.Connect();
|
||||
|
||||
OmniPlusConnection connection;
|
||||
OmniPlusMeter meter;
|
||||
int position = 1;
|
||||
@@ -126,7 +130,8 @@ namespace OmniPlus
|
||||
|
||||
foreach (var point in this.omniType.TestPoints)
|
||||
{
|
||||
// TODO: this.SetM3(point.VolumeM3H);
|
||||
// TODO: 600 = 10min * 60sec - change for production.
|
||||
this.signalRConnection.SetQAndWaitUntilReached(point.VolumeM3H, 600);
|
||||
|
||||
tasks = new Task[connectionsCount];
|
||||
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
namespace OmniPlus
|
||||
{
|
||||
using SignalRClient;
|
||||
using System.Threading;
|
||||
|
||||
public class SignalRConnection
|
||||
{
|
||||
private readonly ExchangeHub exchangeHub;
|
||||
private readonly string url;
|
||||
|
||||
public SignalRConnection(string url)
|
||||
{
|
||||
this.url = url;
|
||||
this.exchangeHub = new ExchangeHub();
|
||||
}
|
||||
|
||||
internal void Connect()
|
||||
=> this.exchangeHub.Connect(this.url);
|
||||
|
||||
public bool SetQAndWaitUntilReached(double value, int seconds)
|
||||
{
|
||||
var reached = false;
|
||||
|
||||
void WaitUntilReached(double _) => reached = true;
|
||||
this.exchangeHub.ExchangeQ += WaitUntilReached;
|
||||
|
||||
this.exchangeHub.SetQ(value);
|
||||
|
||||
while (!reached && seconds >= 0)
|
||||
{
|
||||
Thread.Sleep(1000);
|
||||
|
||||
seconds--;
|
||||
}
|
||||
|
||||
return reached;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-13.0.0.0" newVersion="13.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-2.2.29.0" newVersion="2.2.29.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
</configuration>
|
||||
Reference in New Issue
Block a user