/// <summary> /// The run. /// </summary> /// <returns> /// The <see cref="bool"/>. /// </returns> public bool Run() { Logging.Enter(this, MethodBase.GetCurrentMethod().Name); try { var repo = DeviceCareApplication.Instance; if (repo.MenuArea.MainMenu.MainMenuItems.ButtonHomeInfo.Exists()) { Reporting.Debug("Close Project by pressing home button."); repo.MenuArea.MainMenu.MainMenuItems.ButtonHome.Click(); repo.ApplicationArea.ConnectionSelection.ButtonConnectionAutomaticInfo.WaitForExists(Common.DefaultValues.GeneralTimeout); if (repo.ApplicationArea.ConnectionSelection.ButtonConnectionAutomaticInfo.Exists()) { Reporting.Debug("Project closed. "); return(true); } Reporting.Error("Button Connect automatically is not available."); return(false); } Reporting.Error("Button Home is not available"); return(false); } catch (Exception exception) { Reporting.Error("Button Connect automatically did not become available."); Reporting.Error(exception.Message); return(false); } }
/// <summary> /// The wait until status message becomes available. /// </summary> /// <returns> /// The <see cref="bool"/>. /// </returns> public static bool WaitUntilStatusMessageBecomesAvailable() { Logging.Enter(typeof(ProgressIndicator), MethodBase.GetCurrentMethod().Name); try { DeviceCareApplication repo = DeviceCareApplication.Instance; repo.StatusArea.ProgressIndicatorInfo.WaitForExists(Common.DefaultValues.GeneralTimeout); Reporting.Debug("Progress Indicator is available."); Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); while (stopwatch.ElapsedMilliseconds < Common.DefaultValues.GeneralTimeout) { if (IsStatusMessageAvailable()) { repo.StatusArea.ProgressIndicator.MoveTo(); Reporting.Debug("Status Message is available."); return(true); } } Reporting.Error(string.Format("Status Message is not available after {0} miliseconds.", Common.DefaultValues.GeneralTimeout)); return(false); } catch (Exception exception) { Reporting.Error(exception.Message); return(false); } }
/// <summary> /// The is progress indicator available. /// </summary> /// <returns> /// The <see cref="bool"/>. /// </returns> public static bool WaitUntilProgressIndicatorBecomesNotAvailable() { Logging.Enter(typeof(ProgressIndicator), MethodBase.GetCurrentMethod().Name); try { Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); Reporting.Debug("Wait until Progress Indicator becomes not visible."); while (stopwatch.ElapsedMilliseconds < Common.DefaultValues.GeneralTimeout) { if (!IsProgressIndicatorVisible()) { Reporting.Debug("Progress Indicator is not visible."); return(true); } } Reporting.Error(string.Format("Progress Indicator is still visible after {0} miliseconds.", Common.DefaultValues.GeneralTimeout)); return(false); } catch (Exception exception) { Reporting.Error(exception.Message); return(false); } }
/// <summary> /// The open program functions. /// </summary> /// <returns> /// The <see cref="bool"/>. /// </returns> public static bool OpenMenu() { Logging.Enter(typeof(DtmFunctions), MethodBase.GetCurrentMethod().Name); DeviceCareApplication repo = DeviceCareApplication.Instance; MenuItem menuItem; bool result; Host.Local.TryFindSingle(repo.MenuArea.MainMenu.DTMFunctionsInfo.AbsolutePath, out menuItem); if (menuItem != null && menuItem.Visible) { menuItem.Click(); Reporting.Debug("Menu item DTM Functions found and clicked."); if (Validation.DtmFunctions.IsMenuItemAvailable()) { result = true; } else { result = false; } } else { Reporting.Error("Could not access menu DTM Functions."); result = false; } return(result); }
/// <summary> /// The show progress. /// </summary> /// <returns> /// The <see cref="bool"/>. /// </returns> public static string OpenShowProgress() { Logging.Enter(typeof(ProgramFunctions), MethodBase.GetCurrentMethod().Name); DeviceCareApplication repo = DeviceCareApplication.Instance; if (RunAdditionalFunctions()) { repo.MenuArea.MainMenu.ProgramFunctionsMenuItems.ShowProgressInfo.WaitForExists(Common.DefaultValues.GeneralTimeout); MenuItem showProgress; Host.Local.TryFindSingle(repo.MenuArea.MainMenu.ProgramFunctionsMenuItems.ShowProgressInfo.AbsolutePath, out showProgress); IList <TabPage> tabPagesBefore = Host.Local.Find <TabPage>(repo.ApplicationArea.ModuleSelection.ModuleTabPagesInfo.AbsolutePath); if (showProgress != null && showProgress.Visible) { showProgress.Click(); Reporting.Debug("Menu item Show Progress found and clicked."); IList <TabPage> tabPagesAfter = Host.Local.Find <TabPage>(repo.ApplicationArea.ModuleSelection.ModuleTabPagesInfo.AbsolutePath); foreach (var tabPageAfter in tabPagesAfter) { Text textAfter = tabPageAfter.FindSingle("text"); if (textAfter != null) { string textValueAfter = textAfter.Element.GetAttributeValueText("caption"); if (textValueAfter != null) { foreach (var tabPageBefore in tabPagesBefore) { Text textBefore = tabPageBefore.FindSingle("text"); if (textBefore != null) { string textValueBefore = textBefore.Element.GetAttributeValueText("caption"); if (textValueBefore != null) { if (!textValueBefore.Equals(textValueAfter)) { Reporting.Debug(string.Format("Name of currently opened function is {0}", textValueAfter)); return(textValueAfter); } } } } } } } } } Reporting.Error("Could not access menu item Show Progress."); return(string.Empty); }
/// <summary> /// The run. /// </summary> /// <returns> /// The <see cref="string"/>. /// </returns> public string Run() { Logging.Enter(typeof(GetDtmContainerPath), MethodBase.GetCurrentMethod().Name); try { return(new Functions.ApplicationArea.MainView.Execution.GetDtmContainerPath().Run()); } catch (Exception exception) { Reporting.Error(exception.Message); return(null); } }
/// <summary> /// The run. /// </summary> /// <returns> /// The <see cref="bool"/>. /// </returns> public string Run() { Logging.Enter(typeof(GetHostApplicationLanguage), MethodBase.GetCurrentMethod().Name); Reporting.Debug("Getting DeviceCare language from application config file."); const string EnvironmentVariable = "APPDATA"; string path = Environment.GetEnvironmentVariable(EnvironmentVariable); path = path + "\\..\\Local\\Endress+Hauser\\DeviceCare SFE100\\Shared\\Application.config"; string languageCulture = string.Empty; if (!string.IsNullOrEmpty(path)) { XmlDocument applicationConfiguration = new XmlDocument(); applicationConfiguration.Load(path); XmlNodeList nodes = applicationConfiguration.SelectNodes("/config/settings/culture/name"); if (nodes != null) { foreach (XmlNode node in nodes) { languageCulture = node.InnerText; } } } switch (languageCulture) { case "en-US": return("English"); case "fr-FR": return("French"); case "de-DE": return("German"); case "it-IT": return("Italian"); case "es-ES": return("Spanish"); default: Reporting.Error(string.Format("Language culture {0} is not supported", languageCulture)); return(string.Empty); } }
/// <summary> /// The create automatically. /// </summary> /// <returns> /// The <see cref="bool"/>. /// </returns> public static bool OpenEventLog() { Logging.Enter(typeof(EventLog), MethodBase.GetCurrentMethod().Name); DeviceCareApplication repo = new DeviceCareApplication(); if (!repo.StatusArea.StatusBarInfo.Exists()) { Reporting.Error("Element Status Bar is not available. Event Log cannot be opened."); return(false); } Reporting.Debug("Status Bar is available."); Reporting.Debug("Open Event Log Dialog"); repo.StatusArea.StatusBar.Click(); return(true); }
/// <summary> /// The is menu item available. /// </summary> /// <returns> /// The <see cref="bool"/>. /// </returns> public static bool IsMenuItemAvailable() { Logging.Enter(typeof(DtmFunctions), MethodBase.GetCurrentMethod().Name); try { DeviceCareApplication repo = DeviceCareApplication.Instance; repo.MenuArea.MainMenu.DTMFunctionMenuItems.OnlineParameterizationInfo.WaitForExists(Common.DefaultValues.GeneralTimeout); Reporting.Debug("Menu Items of menu DTM Function are available."); return(true); } catch (Exception exception) { Reporting.Error("Menu Items of menu DTM Function are not available."); Reporting.Error(exception.Message); return(false); } }
/// <summary> /// The create by assistant. /// </summary> /// <returns> /// The <see cref="bool"/>. /// </returns> public static bool CloseEventLog() { Logging.Enter(typeof(EventLog), MethodBase.GetCurrentMethod().Name); DeviceCareApplication repo = DeviceCareApplication.Instance; if (!repo.Dialog.EventLog.CloseInfo.Exists()) { Reporting.Error("Button Close is not available. Event Log cannot be closed."); return(false); } Reporting.Debug("Button Close is available."); Reporting.Debug("Close Event Log Dialog"); repo.Dialog.EventLog.Close.Click(); return(true); }
/// <summary> /// The create automatically. /// </summary> /// <returns> /// The <see cref="bool"/>. /// </returns> public static bool IsEventLogClosed() { try { Logging.Enter(typeof(EventLog), MethodBase.GetCurrentMethod().Name); DeviceCareApplication repo = new DeviceCareApplication(); repo.Dialog.EventLog.CloseInfo.WaitForNotExists(Common.DefaultValues.GeneralTimeout); Reporting.Debug("Event Log Dialog is not available."); return(true); } catch (Exception exception) { Reporting.Error("Event Log Dialog is still available."); Reporting.Error(exception.Message); return(false); } }
/// <summary> /// The open program functions. /// </summary> /// <returns> /// The <see cref="bool"/>. /// </returns> public static bool OpenMenu() { Logging.Enter(typeof(ProgramFunctions), MethodBase.GetCurrentMethod().Name); DeviceCareApplication repo = DeviceCareApplication.Instance; MenuItem menuItem; Host.Local.TryFindSingle(repo.MenuArea.MainMenu.ProgramFunctionsInfo.AbsolutePath, out menuItem); if (menuItem != null && menuItem.Visible) { menuItem.Click(); Reporting.Debug("Menu item Program Functions found and clicked."); return(true); } Reporting.Error("Could not access menu Program Functions."); return(false); }
/// <summary> /// The open program functions. /// </summary> /// <returns> /// The <see cref="bool"/>. /// </returns> public static bool IsMenuAvailable() { Logging.Enter(typeof(AdditionalFunctions), MethodBase.GetCurrentMethod().Name); DeviceCareApplication repo = DeviceCareApplication.Instance; repo.MenuArea.MainMenu.AdditionalFunctionsInfo.WaitForExists(Common.DefaultValues.GeneralTimeout); if (repo.MenuArea.MainMenu.AdditionalFunctionsInfo.Exists()) { if (repo.MenuArea.MainMenu.AdditionalFunctions != null && repo.MenuArea.MainMenu.AdditionalFunctions.Visible) { Reporting.Debug("Menu item Additional Functions is available."); return(true); } } Reporting.Error("Menu item Additional Functions is not available."); return(false); }
/// <summary> /// The restore device data. /// </summary> /// <returns> /// The <see cref="bool"/>. /// </returns> public static bool RunRestoreDeviceData() { Logging.Enter(typeof(ProgramFunctions), MethodBase.GetCurrentMethod().Name); if (OpenMenu()) { DeviceCareApplication repo = DeviceCareApplication.Instance; MenuItem menuItem; Host.Local.TryFindSingle(repo.MenuArea.MainMenu.ProgramFunctionsMenuItems.RestoreDeviceDataInfo.AbsolutePath, out menuItem); if (menuItem != null && menuItem.Visible) { menuItem.MoveTo(); Reporting.Debug("Menu item Restore Device Data found and moved to."); return(true); } } Reporting.Error("Could not access menu item Restore Device Data."); return(false); }
/// <summary> /// The close tab page. /// </summary> /// <param name="functionName"> /// The function name. /// </param> /// <returns> /// The <see cref="bool"/>. /// </returns> private static bool CloseTabPage(string functionName) { Logging.Enter(typeof(DtmFunctions), MethodBase.GetCurrentMethod().Name); DeviceCareApplication repo = DeviceCareApplication.Instance; Button button; string path = repo.ApplicationArea.ModuleSelection.ModuleCloseButtonInfo.AbsolutePath.ToString(); path = path.Replace("MODULENAME", functionName); RxPath ranorexPath = path; Host.Local.TryFindSingle(ranorexPath, out button); if (button != null) { button.Press(); Reporting.Debug(string.Format("Module {0} close button found and pressed.", functionName)); return(true); } Reporting.Error(string.Format("Could not access module {0} close button.", functionName)); return(false); }
/// <summary> /// The select dtm functions. /// </summary> /// <param name="functionName"> /// The function name. /// </param> /// <returns> /// The <see cref="bool"/>. /// </returns> public static bool SelectDtmFunctions(string functionName) { Logging.Enter(typeof(DtmFunctions), MethodBase.GetCurrentMethod().Name); DeviceCareApplication repo = DeviceCareApplication.Instance; TabPage tabPage; string path = repo.ApplicationArea.ModuleSelection.ModuleTabPageInfo.AbsolutePath.ToString(); path = path.Replace("MODULENAME", functionName); RxPath ranorexPath = path; Host.Local.TryFindSingle(ranorexPath, out tabPage); if (tabPage != null) { tabPage.Select(); Reporting.Debug(string.Format("Module {0} found and selected.", functionName)); return(true); } Reporting.Error(string.Format("Could not find module {0} to select.", functionName)); return(false); }
/// <summary> /// The restore device data browse. /// </summary> /// <returns> /// The <see cref="bool"/>. /// </returns> public static bool OpenRestoreDeviceDataBrowse() { Logging.Enter(typeof(ProgramFunctions), MethodBase.GetCurrentMethod().Name); // DeviceCareApplication repo = DeviceCareApplication.Instance; // if (RestoreDeviceData()) // { // repo.MenuArea.MainMenu.ProgramFunctionsMenuItems.RestoreBrowseInfo.WaitForExists(Common.DefaultValues.GeneralTimeout); // MenuItem restoreDeviceDataBrowse; // Host.Local.TryFindSingle(repo.MenuArea.MainMenu.ProgramFunctionsMenuItems.RestoreBrowseInfo.AbsolutePath, out restoreDeviceDataBrowse); // if (restoreDeviceDataBrowse != null && restoreDeviceDataBrowse.Visible) // { // restoreDeviceDataBrowse.Click(); // Reporting.Error("Menu item Device Data Browse found and clicked."); // return true; // } // } // Reporting.Error("Could not access menu item Restore Device Data Browse."); Reporting.Error("Not Implemented Yet"); return(false); }
/// <summary> /// The is online parameterize available. /// </summary> /// <returns> /// The <see cref="bool"/>. /// </returns> public static bool IsOnlineParameterizeAvailable() { Logging.Enter(typeof(DtmFunctions), MethodBase.GetCurrentMethod().Name); DeviceCareApplication repo = DeviceCareApplication.Instance; bool result = Execution.DtmFunctions.OpenMenu(); if (result && repo.MenuArea.MainMenu.DTMFunctionMenuItems.OnlineParameterizationInfo.Exists()) { if (repo.MenuArea.MainMenu.DTMFunctionMenuItems.OnlineParameterization.Enabled) { Reporting.Debug("Menu item Online Parameterize is enabled."); return(true); } Reporting.Debug("Menu item Online Parameterize is not enabled."); return(false); } Reporting.Error("Menu item Online Parameterize is not available."); return(false); }
/// <summary> /// The open dtm function. /// </summary> /// <param name="functionName"> /// The function name. /// </param> /// <returns> /// The <see cref="bool"/>. /// </returns> public static bool OpenDtmFunction(string functionName) { Logging.Enter(typeof(DtmFunctions), MethodBase.GetCurrentMethod().Name); if (OpenMenu()) { DeviceCareApplication repo = DeviceCareApplication.Instance; Text text; string path = repo.MenuArea.MainMenu.DTMFunctionMenuItems.MenuItemInfo.AbsolutePath.ToString(); path = path.Replace("MODULENAME", functionName); RxPath ranorexPath = path; Host.Local.TryFindSingle(ranorexPath, Common.DefaultValues.GeneralTimeout, out text); if (text != null && text.Visible) { text.Click(); Reporting.Debug(string.Format("Menu item {0} found and clicked.", functionName)); return(true); } } Reporting.Error(string.Format("Could not access menu item {0}.", functionName)); return(false); }
/// <summary> /// The run. /// </summary> /// <param name="functionName"> /// The function name. /// </param> /// <returns> /// The <see cref="bool"/>. /// </returns> public bool Run(string functionName) { Logging.Enter(this, MethodBase.GetCurrentMethod().Name); try { Text text = Functions.ApplicationArea.MainView.Helpers.DeviceCareModuleFunctions.IsFunctionOpened(functionName); if (text != null && text.Visible) { text.Click(); return(true); } Reporting.Error("Functions is not opened"); return(false); } catch (Exception exception) { Reporting.Error(string.Format("Could not switch to function {0}", functionName)); Reporting.Error(exception.Message); return(false); } }
/// <summary> /// The is event log table available. /// </summary> /// <returns> /// The <see cref="bool"/>. /// </returns> public static bool IsEventLogTableAvailable() { try { Logging.Enter(typeof(EventLog), MethodBase.GetCurrentMethod().Name); DeviceCareApplication repo = new DeviceCareApplication(); if (repo.Dialog.EventLog.TableInfo.Exists()) { Reporting.Debug("Event Log Table is available."); return(true); } Reporting.Error("Event Log Table is not available."); return(false); } catch (Exception exception) { Reporting.Error("Event Log Table is not available."); Reporting.Error(exception.Message); return(false); } }
/// <summary> /// The run. /// </summary> /// <returns> /// The <see cref="bool"/>. /// </returns> public bool Run() { Logging.Enter(typeof(WriteDataToDevice), MethodBase.GetCurrentMethod().Name); bool methodResult; // check if device is connected if (Functions.StatusArea.StatusBar.Validation.Connection.IsDeviceConnected()) { // check if device supports offline functionality if (Functions.MenuArea.MenuBar.Validation.DtmFunctions.IsOfflineParameterizeAvailable()) { methodResult = Functions.MenuArea.MenuBar.Execution.ProgramFunctions.OpenMenu(); methodResult &= Functions.MenuArea.MenuBar.Execution.ProgramFunctions.RunWriteToDevice(); if (methodResult) { // wait until read is finished // check progress indicator, see create project methodResult &= Functions.StatusArea.StatusBar.Validation.ProgressIndicator.WaitUntilProgressIndicatorBecomesAvailable(); methodResult &= Functions.StatusArea.StatusBar.Validation.ProgressIndicator.WaitUntilProgressIndicatorBecomesNotAvailable(); if (methodResult) { // check event log, see get last message if (Functions.Dialogs.Execution.EventLog.OpenEventLog()) { string lastMessage = Functions.Dialogs.Execution.EventLog.GetLastMessageFromEventLog(); if (lastMessage.Equals(string.Empty)) { Reporting.Error("No message is shown after Write Data To Device"); return(false); } if (Functions.Dialogs.Execution.EventLog.CloseEventLog()) { return(true); } // get device care language string hostApplicationLanguage = new GetHostApplicationLanguage().Run(); string download = string.Empty; string successful = string.Empty; // get language dependent words ResourceSet languages = GUI.StringTranslation.ResourceManager.GetResourceSet(CultureInfo.CurrentUICulture, true, true); foreach (DictionaryEntry language in languages) { if (language.Key.ToString().Contains(hostApplicationLanguage) && language.Key.ToString().Contains("download") && language.Key.ToString().Contains("successful")) { string[] seperator = { "_" }; string[] words = language.Value.ToString().Split(seperator, StringSplitOptions.None); download = words[0]; successful = words[1]; } } if (lastMessage.ToLower().Contains(download) && lastMessage.ToLower().Contains(successful)) { Reporting.Debug("Download finished successful."); Reporting.Debug(lastMessage); return(true); } Reporting.Error("There is no information about an successful download"); return(false); } return(false); } return(false); } return(false); } Reporting.Error("This device does not support an Offline Parameterize. Up / Download is not possible."); return(false); } return(false); }
/// <summary> /// The open dtm function. /// </summary> /// <returns> /// The <see cref="bool"/>. /// </returns> public static bool PrintDeviceReport() { Logging.Enter(typeof(DeviceReport), MethodBase.GetCurrentMethod().Name); Reporting.Error("Not implemented yet"); return(false); }