Forum Discussion
tristaanogre
14 years agoEsteemed Contributor
The reason being is that TimeNow is a snapshot of the time you captured at the moment you called aqDateTime.Now(). TimeNow is not a reference to the function aqDateTime.Now() but is simply the value returned when that function is called.
Adding a single line (see the line in bold) will do what you ask because it reassigned "TimeNow" each time through the loop to make sure that the time is compared in real time.
You'll also want to change the way you are doing your maxTime assignment.
Adding a single line (see the line in bold) will do what you ask because it reassigned "TimeNow" each time through the loop to make sure that the time is compared in real time.
You'll also want to change the way you are doing your maxTime assignment.
function waitUntilImageIsInStateA(maxTimeInSeconds)
{
var TimeNow = aqDateTime.Now();
var maxTime = aqDateTime.AddSeconds(aqDateTime.Now(), maxTimeInSeconds);
while( maxTime > TimeNow )
{
if (Regions.Compare("Image", Aliases.QObject.lblNavigation, false, false, true, 0, lmNone))
{ Log.Message(":: TEST :: State A Occured after " + aqDateTime.Now() - TimeNow + " seconds.");
return true;
}
TimeNow = aqDateTime.Now();
}
Log.Warning("Timeout occured waiting for Checkpoint");
return false;
}