mirror of
https://github.com/evopro-ag/Sharp7Reactive.git
synced 2025-12-16 11:42:52 +00:00
Wait for connection before setting up notification
This commit is contained in:
@@ -105,9 +105,13 @@ public class Sharp7Plc : IPlc
|
|||||||
disposableContainer.AddDisposableTo(disp);
|
disposableContainer.AddDisposableTo(disp);
|
||||||
|
|
||||||
var observable =
|
var observable =
|
||||||
// Read variable with GetValue first.
|
ConnectionState
|
||||||
// This will propagate any errors due to reading from invalid addresses.
|
// Wait for connection to be established
|
||||||
Observable.FromAsync(() => GetValue<TValue>(variableName))
|
.FirstAsync(c => c == Enums.ConnectionState.Connected)
|
||||||
|
// Read variable with GetValue first.
|
||||||
|
// This will propagate any errors due to reading from invalid addresses.
|
||||||
|
.SelectMany(_ => GetValue<TValue>(variableName))
|
||||||
|
// Output results from read loop
|
||||||
.Concat(
|
.Concat(
|
||||||
disposableContainer.Observable
|
disposableContainer.Observable
|
||||||
.Select(bytes => ValueConverter.ReadFromBuffer<TValue>(bytes, address))
|
.Select(bytes => ValueConverter.ReadFromBuffer<TValue>(bytes, address))
|
||||||
|
|||||||
Reference in New Issue
Block a user