Skip to content

Commit

Permalink
Update LinqPad samples
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter-B- committed Jul 30, 2024
1 parent af2df01 commit 61e04c7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Sharp7.Rx/linqpad-samples/Create Notification.linq
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ await plc.InitializeConnection();
// create an IObservable
var observable = plc.CreateNotification<short>($"DB{db}.Int6", Sharp7.Rx.Enums.TransmissionMode.OnChange);

observable.Dump();
_ = observable.Dump();

for (int i = 0; i < 10; i++)
{
Expand Down
10 changes: 6 additions & 4 deletions Sharp7.Rx/linqpad-samples/Establish connection.linq
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@ using var plc = new Sharp7Plc(ip, rackNumber, cpuMpiAddress);
// Initialize connection
await plc.InitializeConnection();

// wait for connection to be established
await plc.ConnectionState
.FirstAsync(c => c == Sharp7.Rx.Enums.ConnectionState.Connected)
.ToTask();
// // Alternative: Trigger connection and wait for ConnectionState == Connected
// plc.TriggerConnection();
// // wait for connection to be established
//await plc.ConnectionState
// .FirstAsync(c => c == Sharp7.Rx.Enums.ConnectionState.Connected)
// .ToTask();

"Connection established".Dump();

Expand Down
6 changes: 3 additions & 3 deletions Sharp7.Rx/linqpad-samples/Multiple notifications.linq
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ var cpuMpiAddress = 0;

using var plc = new Sharp7Plc(ip, rackNumber, cpuMpiAddress);

plc.ConnectionState.Dump();
_ = plc.ConnectionState.Dump();

await plc.InitializeConnection();

// create an IObservable
plc.CreateNotification<short>($"DB{db}.Int6", Sharp7.Rx.Enums.TransmissionMode.OnChange).Dump("Int 6");
plc.CreateNotification<float>($"DB{db}.Real10", Sharp7.Rx.Enums.TransmissionMode.OnChange).Dump("Real 10");
_ = plc.CreateNotification<short>($"DB{db}.Int6", Sharp7.Rx.Enums.TransmissionMode.OnChange).Dump("Int 6");
_ = plc.CreateNotification<float>($"DB{db}.Real10", Sharp7.Rx.Enums.TransmissionMode.OnChange).Dump("Real 10");



Expand Down

0 comments on commit 61e04c7

Please sign in to comment.