mirror of
https://github.com/evopro-ag/Sharp7Reactive.git
synced 2025-12-15 11:22: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);
|
||||
|
||||
var observable =
|
||||
// Read variable with GetValue first.
|
||||
// This will propagate any errors due to reading from invalid addresses.
|
||||
Observable.FromAsync(() => GetValue<TValue>(variableName))
|
||||
ConnectionState
|
||||
// Wait for connection to be established
|
||||
.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(
|
||||
disposableContainer.Observable
|
||||
.Select(bytes => ValueConverter.ReadFromBuffer<TValue>(bytes, address))
|
||||
|
||||
Reference in New Issue
Block a user