DataEntry.UNI - timeout, autoclose improve
Introduce configurable timeouts for data entry volume reads in `IRegReaderSmart` and its implementations: added optional timeout parameters and updated default values across associated forms and methods. Updated `EntryFormCfg` to support customizable timeout settings.
This commit is contained in:
@@ -51,6 +51,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead
|
||||
|
||||
private const int StartSampleDelaySec = 5;
|
||||
private const int EndSampleDelayCount = 2;
|
||||
private const int DefaultDataEntryVolumeTimeoutMs = 3000;
|
||||
|
||||
private OptoHeadTest _optoHeadTest;
|
||||
|
||||
@@ -1671,26 +1672,26 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead
|
||||
return SerialNr;
|
||||
}
|
||||
|
||||
public Task<double> DataEntry_ReadBeginVolume()
|
||||
public Task<double> DataEntry_ReadBeginVolume(int timeoutMs = DefaultDataEntryVolumeTimeoutMs)
|
||||
{
|
||||
log.Debug("called DataEntry_ReadBeginVolumer()");
|
||||
|
||||
Task<double> readedVolume = DataEntry_BeginVolumeAsync();
|
||||
Task<double> readedVolume = DataEntry_BeginVolumeAsync(timeoutMs);
|
||||
|
||||
return readedVolume;
|
||||
}
|
||||
|
||||
public Task<double> DataEntry_ReadEndVolume()
|
||||
public Task<double> DataEntry_ReadEndVolume(int timeoutMs = DefaultDataEntryVolumeTimeoutMs)
|
||||
{
|
||||
log.Debug("called DataEntry_ReadBeginVolumer()");
|
||||
|
||||
Task<double> readedVolume = DataEntry_EndVolumeAsync();
|
||||
Task<double> readedVolume = DataEntry_EndVolumeAsync(timeoutMs);
|
||||
|
||||
return readedVolume;
|
||||
}
|
||||
|
||||
|
||||
public async Task<double> DataEntry_EndVolumeAsync()
|
||||
public async Task<double> DataEntry_EndVolumeAsync(int timeoutMs = DefaultDataEntryVolumeTimeoutMs)
|
||||
{
|
||||
|
||||
if (optoSerialPort == null || !optoSerialPort.IsOpen)
|
||||
@@ -1708,13 +1709,16 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead
|
||||
log.Debug($"Try get End Volume! COM: {this.OptoComPortNr}");
|
||||
volumeLtr = Double.NaN;
|
||||
|
||||
int counter = 0;
|
||||
while (Double.IsNaN(volumeLtr) && counter < 2)
|
||||
DateTime readDeadline = DateTime.UtcNow.AddMilliseconds(Math.Max(1, timeoutMs));
|
||||
while (Double.IsNaN(volumeLtr))
|
||||
{
|
||||
counter++;
|
||||
int remainingTimeoutMs = (int)(readDeadline - DateTime.UtcNow).TotalMilliseconds;
|
||||
if (remainingTimeoutMs <= 0)
|
||||
break;
|
||||
|
||||
try
|
||||
{
|
||||
string readOptoDataWithTimeout = ReadOptoDataWithTimeout(2000);
|
||||
string readOptoDataWithTimeout = ReadOptoDataWithTimeout(remainingTimeoutMs);
|
||||
if (!string.IsNullOrEmpty(readOptoDataWithTimeout))
|
||||
{
|
||||
try
|
||||
@@ -1766,7 +1770,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead
|
||||
}
|
||||
|
||||
|
||||
public async Task<double> DataEntry_BeginVolumeAsync()
|
||||
public async Task<double> DataEntry_BeginVolumeAsync(int timeoutMs = DefaultDataEntryVolumeTimeoutMs)
|
||||
{
|
||||
if (ConfigStruct == null)
|
||||
{
|
||||
@@ -1782,13 +1786,16 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead
|
||||
Start();
|
||||
|
||||
volumeLtr0 = Double.NaN;
|
||||
int counter = 0;
|
||||
while (Double.IsNaN(volumeLtr0) && counter < 10)
|
||||
DateTime readDeadline = DateTime.UtcNow.AddMilliseconds(Math.Max(1, timeoutMs));
|
||||
while (Double.IsNaN(volumeLtr0))
|
||||
{
|
||||
counter++;
|
||||
int remainingTimeoutMs = (int)(readDeadline - DateTime.UtcNow).TotalMilliseconds;
|
||||
if (remainingTimeoutMs <= 0)
|
||||
break;
|
||||
|
||||
try
|
||||
{
|
||||
string readOptoDataWithTimeout = ReadOptoDataWithTimeout(5000);
|
||||
string readOptoDataWithTimeout = ReadOptoDataWithTimeout(remainingTimeoutMs);
|
||||
if (!string.IsNullOrEmpty(readOptoDataWithTimeout))
|
||||
{
|
||||
try
|
||||
|
||||
Reference in New Issue
Block a user