mirror of
https://github.com/evopro-ag/Sharp7Reactive.git
synced 2025-12-16 19:52:53 +00:00
Fixed InitialTranfer after connected
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
using System.Reactive;
|
using System.Reactive;
|
||||||
using System.Reactive.Disposables;
|
using System.Reactive.Disposables;
|
||||||
using System.Reactive.Linq;
|
using System.Reactive.Linq;
|
||||||
|
using System.Reactive.Threading.Tasks;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Sharp7.Rx.Enums;
|
using Sharp7.Rx.Enums;
|
||||||
using Sharp7.Rx.Interfaces;
|
using Sharp7.Rx.Interfaces;
|
||||||
@@ -23,6 +24,7 @@ namespace Sharp7.Rx.Extensions
|
|||||||
|
|
||||||
if (initialTransfer)
|
if (initialTransfer)
|
||||||
{
|
{
|
||||||
|
await plc.ConnectionState.FirstAsync(state => state == ConnectionState.Connected).ToTask();
|
||||||
var initialValue = await ReadData(plc, readData);
|
var initialValue = await ReadData(plc, readData);
|
||||||
observer.OnNext(initialValue);
|
observer.OnNext(initialValue);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,9 +57,6 @@ namespace Sharp7.Rx
|
|||||||
|
|
||||||
await s7Connector.InitializeAsync();
|
await s7Connector.InitializeAsync();
|
||||||
|
|
||||||
RunNotifications(s7Connector, TimeSpan.FromMilliseconds(100))
|
|
||||||
.AddDisposableTo(Disposables);
|
|
||||||
|
|
||||||
#pragma warning disable 4014
|
#pragma warning disable 4014
|
||||||
Task.Run(async () =>
|
Task.Run(async () =>
|
||||||
{
|
{
|
||||||
@@ -67,13 +64,16 @@ namespace Sharp7.Rx
|
|||||||
{
|
{
|
||||||
await s7Connector.Connect();
|
await s7Connector.Connect();
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
s7Connector.Logger.LogError(e, "Error while connecting to PLC");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
#pragma warning restore 4014
|
#pragma warning restore 4014
|
||||||
|
|
||||||
|
RunNotifications(s7Connector, TimeSpan.FromMilliseconds(100))
|
||||||
|
.AddDisposableTo(Disposables);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user