mirror of
https://github.com/evopro-ag/Sharp7Reactive.git
synced 2025-12-16 19:52:53 +00:00
Add multiVarRequestCycleTime parameter
This commit is contained in:
@@ -28,10 +28,30 @@ namespace Sharp7.Rx
|
|||||||
private readonly List<long> performanceCoutner = new List<long>(1000);
|
private readonly List<long> performanceCoutner = new List<long>(1000);
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
public Sharp7Plc(string ipAddress, int rackNumber, int cpuMpiAddress, int port = 102)
|
/// </summary>
|
||||||
|
/// <param name="ipAddress"></param>
|
||||||
|
/// <param name="rackNumber"></param>
|
||||||
|
/// <param name="cpuMpiAddress"></param>
|
||||||
|
/// <param name="port"></param>
|
||||||
|
/// <param name="multiVarRequestCycleTime">
|
||||||
|
/// <para>
|
||||||
|
/// Polling interval used to read multi variable requests from PLC.
|
||||||
|
/// </para>
|
||||||
|
/// <para>
|
||||||
|
/// This is the wait time between two successive reads from PLC and determines the
|
||||||
|
/// time resolution for all variable reads reated with CreateNotification.
|
||||||
|
/// </para>
|
||||||
|
/// <para>
|
||||||
|
/// Default is 100 ms. The minimum supported time is 5 ms.
|
||||||
|
/// </para>
|
||||||
|
/// </param>
|
||||||
|
public Sharp7Plc(string ipAddress, int rackNumber, int cpuMpiAddress, int port = 102, TimeSpan? multiVarRequestCycleTime = null)
|
||||||
{
|
{
|
||||||
plcConnectionSettings = new PlcConnectionSettings() { IpAddress = ipAddress, RackNumber = rackNumber, CpuMpiAddress = cpuMpiAddress, Port = port };
|
plcConnectionSettings = new PlcConnectionSettings() { IpAddress = ipAddress, RackNumber = rackNumber, CpuMpiAddress = cpuMpiAddress, Port = port };
|
||||||
|
|
||||||
|
if (multiVarRequestCycleTime != null && multiVarRequestCycleTime > TimeSpan.FromMilliseconds(5))
|
||||||
|
MultiVarRequestCycleTime = multiVarRequestCycleTime.Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IObservable<ConnectionState> ConnectionState { get; private set; }
|
public IObservable<ConnectionState> ConnectionState { get; private set; }
|
||||||
@@ -58,7 +78,7 @@ namespace Sharp7.Rx
|
|||||||
});
|
});
|
||||||
#pragma warning restore 4014
|
#pragma warning restore 4014
|
||||||
|
|
||||||
RunNotifications(s7Connector, TimeSpan.FromMilliseconds(100))
|
RunNotifications(s7Connector, MultiVarRequestCycleTime)
|
||||||
.AddDisposableTo(Disposables);
|
.AddDisposableTo(Disposables);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -213,7 +233,7 @@ namespace Sharp7.Rx
|
|||||||
return ConnectionState.FirstAsync()
|
return ConnectionState.FirstAsync()
|
||||||
.Select(states => states == Enums.ConnectionState.Connected)
|
.Select(states => states == Enums.ConnectionState.Connected)
|
||||||
.SelectMany(connected => GetAllValues(connected, connector))
|
.SelectMany(connected => GetAllValues(connected, connector))
|
||||||
.RepeatAfterDelay(cycle)
|
.RepeatAfterDelay(MultiVarRequestCycleTime)
|
||||||
.LogAndRetryAfterDelay(Logger, cycle, "Error while getting batch notifications from plc")
|
.LogAndRetryAfterDelay(Logger, cycle, "Error while getting batch notifications from plc")
|
||||||
.Subscribe();
|
.Subscribe();
|
||||||
}
|
}
|
||||||
@@ -259,5 +279,6 @@ namespace Sharp7.Rx
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int MultiVarRequestMaxItems { get; set; } = 16;
|
public int MultiVarRequestMaxItems { get; set; } = 16;
|
||||||
|
public TimeSpan MultiVarRequestCycleTime { get; private set; } = TimeSpan.FromSeconds(0.1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user