/// <summary> /// writes coefficients to device/offline parameterization, waits until "write finished" user notification message is displayed and write button is enabled again /// </summary> /// <returns> /// true: if coefficients were written /// false: if an error occurred /// </returns> public bool Run() { bool isWriting = false; var watch = new Stopwatch(); if (new RunWrite().ViaIcon() == false) { return(false); } isWriting = true; watch.Start(); while (isWriting) { string actualInfo = new UserMessagesElements().UserNotification; string actualInfoLowerCase = actualInfo.ToLower(); bool isSuccess = actualInfoLowerCase.Contains("success"); bool isFinished = new IsWriteFinished().Run(); if (watch.ElapsedMilliseconds > DefaultValues.iTimeoutLong) { if (isFinished == false) { Log.Error(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Button [Write] is not enabled."); } Log.Error(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Writing did not finish within " + DefaultValues.iTimeoutLong + " milliseconds"); return(false); } if (isSuccess) { if (isFinished) { Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Writing finished."); isWriting = false; } } } watch.Stop(); Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Writing coefficients finished after " + watch.ElapsedMilliseconds + " milliseconds. (Timeout: " + DefaultValues.iTimeoutLong + " milliseconds)"); return(true); }
/// <summary> /// Scans the user notification messages in the status area for error messages /// </summary> /// <returns> /// true: if the text contains any of the keywords /// false: if the text does not contain any of the keywords /// </returns> public bool ContainsError() { bool result = false; Element element = new UserMessagesElements().UserMessage; if (element == null) { Log.Error(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "The user messages element cannot be found"); result = true; } else { string actualInfo = element.GetAttributeValueText("Text"); string actualInfoLowerCase = actualInfo.ToLower(); if (actualInfoLowerCase.Contains("error") || actualInfoLowerCase.Contains("fail") || actualInfoLowerCase.Contains("warning") || actualInfoLowerCase.Contains("not successful")) { Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Dip table module reports: \"" + actualInfo + "\""); result = true; } } return(result); }