Sharp7.Rx
Sharp7.Rx
System.Reactive.Linq
System.Reactive.Threading.Tasks
System.Threading.Tasks
var ip = "10.30.3.221"; // Set IP address of S7
var db = 3; // Set to an existing DB
// For rack number and cpu mpi address see
// https://github.com/fbarresi/Sharp7/wiki/Connection#rack-and-slot
var rackNumber = 0;
var cpuMpiAddress = 0;
using var plc = new Sharp7Plc(ip, rackNumber, cpuMpiAddress);
await plc.InitializeConnection();
"Connection established".Dump();
for (int i = 0; i < 10; i++)
{
await plc.SetValue($"DB{db}.Int6", (short)i);
var value = await plc.GetValue($"DB{db}.Int6");
value.Dump();
await Task.Delay(200);
}