示例#1
0
        /// <summary>
        /// Determines whether a menu item is dynamic
        /// </summary>
        /// <param name="menuItemId">The menu item identifier.</param>
        /// <returns><c>true</c> if menu item is dynamic, <c>false</c> otherwise.</returns>
        public bool Run(string menuItemId)
        {
            try
            {
                bool result = false;
                var  xml    = XDocument.Parse(AppComController.GetDisplayContent());
                if (xml.Document != null)
                {
                    var displayContent          = xml.Element("DisplayContent");
                    var listPage                = displayContent?.Element("ListPage");
                    var listPageList            = listPage?.Element("List");
                    var menuItemWeAreLookingFor = listPageList?.Elements("ListNavigationItem").Where(e => e.Attribute("id")?.Value == menuItemId);

                    if (menuItemWeAreLookingFor != null && menuItemWeAreLookingFor.Any())
                    {
                        foreach (var menuItem in menuItemWeAreLookingFor)
                        {
                            var isDynamicAttribute = menuItem.Attribute("isDynamic");
                            if (isDynamicAttribute != null)
                            {
                                result = isDynamicAttribute.Value.Equals("true");
                            }
                        }
                    }
                }

                return(result);
            }
            catch (Exception exception)
            {
                Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), exception.Message);
                return(false);
            }
        }
示例#2
0
        /// <summary>
        /// Determines whether an extended header parameter exists in current display content.
        /// </summary>
        /// <param name="parameterId">The parameter identifier.</param>
        /// <returns><c>true</c> if parameter exists, <c>false</c> otherwise.</returns>
        public bool Run(string parameterId)
        {
            try
            {
                bool result = false;
                var  xml    = XDocument.Parse(AppComController.GetDisplayContent());
                if (xml.Document != null)
                {
                    var displayContent = xml.Element("DisplayContent");
                    var listPage       = displayContent?.Element("ListPage");
                    var listPageList   = listPage?.Element("List");

                    var extendedHeaderParams = listPageList?.Elements("ExtendedDeviceHeaderDTM")?.Elements("FloatValueItem").Where(e => e.Attribute("id")?.Value == parameterId);


                    if (extendedHeaderParams != null && extendedHeaderParams.Any())
                    {
                        result = true;
                        Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Parameter " + parameterId + " is available in current display content extended header.");
                    }
                    else
                    {
                        Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Parameter " + parameterId + " is not available in current display content extended header.");
                    }
                }

                return(result);
            }
            catch (Exception exception)
            {
                Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), exception.Message);
                return(false);
            }
        }
示例#3
0
        /// <summary>
        ///  Clicks a specified button
        /// </summary>
        /// <param name="buttonId">The button identifier.</param>
        /// <returns><c>true</c> if button clicked, <c>false</c> otherwise.</returns>
        public bool Run(string buttonId)
        {
            bool result = false;

            if (AppComController.Controller != null)
            {
                //var eventHandler = new DisplayContentEventHandler(AppComController.Controller);
                var oldDisplayContent = AppComController.GetDisplayContent();

                AppComController.Controller.SetStringValue(buttonId, "placeholder");

                //if (eventHandler.WaitForNewDisplayContent(15000).Result)
                if (DeviceFunctionLoader.CoDIA.Parameterization.Functions.ApplicationArea.MainView.Validation.WaitForDisplayContentChanged.Run(oldDisplayContent, 15000))
                {
                    Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Recognized display content update. Button clicked.");
                    result = true;
                }
                else
                {
                    Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "No display content update. Button not clicked.");
                }
            }
            else
            {
                Log.Error(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Remote host not connected! Please establish a connection first.");
            }

            return(result);
        }
        /// <summary>
        /// Checks whether a picture is visible (on help page) for a parameter in current display content.
        /// </summary>
        /// <param name="parameterId">The parameter id.</param>
        /// <returns><c>true</c> if picture available, <c>false</c> otherwise.</returns>
        public bool Run(string parameterId)
        {
            try
            {
                bool result = false;
                var  xml    = XDocument.Parse(AppComController.GetDisplayContent());
                if (xml.Document != null)
                {
                    var displayContent           = xml.Element("DisplayContent");
                    var helpPage                 = displayContent?.Element("HelpPage");
                    var helpPageList             = helpPage?.Element("List");
                    var parameterWeAreLookingFor = helpPageList?.Elements().Where(e => e.Attribute("id")?.Value == parameterId);
                    var images = parameterWeAreLookingFor?.Elements("ListColumn").Elements("SVGImage");

                    if (images != null && images.Any())
                    {
                        Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Picture for parameter '" + parameterId + "' is visible.");
                        result = true;
                    }
                    else
                    {
                        Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Picture for parameter '" + parameterId + "' is not available.");
                    }
                }

                return(result);
            }
            catch (Exception exception)
            {
                Log.Error(LogInfo.Namespace(MethodBase.GetCurrentMethod()), exception.Message);
                return(false);
            }
        }
        /// <summary>
        /// Runs the specified item identifier.
        /// </summary>
        /// <param name="itemId">The item identifier.</param>
        /// <param name="source">The source.</param>
        /// <param name="destination">The destination.</param>
        /// <returns><c>true</c> if executed, <c>false</c> otherwise.</returns>
        public bool Run(string itemId, string source, string destination)
        {
            bool result = false;

            if (AppComController.Controller != null)
            {
                //var eventHandler = new DisplayContentEventHandler(AppComController.Controller);
                var oldDisplayContent = AppComController.GetDisplayContent();
                AppComController.Controller.DragAndDrop(itemId, source, destination);

                //if (eventHandler.WaitForNewDisplayContent(15000).Result)
                if (DeviceFunctionLoader.CoDIA.Parameterization.Functions.ApplicationArea.MainView.Validation.WaitForDisplayContentChanged.Run(oldDisplayContent, 15000))
                {
                    Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Recognized display content update. Drag and drop successful.");
                    result = true;
                }
                else
                {
                    Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "No display content update. Drag and drop not successful.");
                }
            }
            else
            {
                Log.Error(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Remote host not connected! Please establish a connection first.");
            }

            return(result);
        }
        /// <summary>
        /// Gets the current state from the status icon within the device header
        /// </summary>
        /// <param name="statusIconId">The status icon identifier.</param>
        /// <returns>Current state</returns>
        public string Run(string statusIconId)
        {
            string result = string.Empty;

            var xml = XDocument.Parse(AppComController.GetDisplayContent());

            if (xml.Document != null)
            {
                var displayContent      = xml.Element("DisplayContent");
                var listPage            = displayContent?.Element("ListPage");
                var listPageList        = listPage?.Element("List");
                var itemWeAreLookingFor = listPageList?.Elements("DeviceHeaderDTM")?.Elements("FloatValueItem").Where(e => e.Attribute("id")?.Value == statusIconId);

                if (itemWeAreLookingFor != null && itemWeAreLookingFor.Any())
                {
                    foreach (var item in itemWeAreLookingFor)
                    {
                        var displayedText = item.Element("FloatValue")?.Attribute("displayedText");
                        if (displayedText != null)
                        {
                            result = displayedText.Value;
                        }
                    }
                }
            }

            return(result);
        }
示例#7
0
        /// <summary>
        /// Determines whether a bread crumb exists in current display content
        /// </summary>
        /// <returns><c>true</c> if bread crumb exists, <c>false</c> otherwise.</returns>
        public bool Run()
        {
            try
            {
                bool result = false;
                var  xml    = XDocument.Parse(AppComController.GetDisplayContent());
                if (xml.Document != null)
                {
                    var displayContent          = xml.Element("DisplayContent");
                    var listPage                = displayContent?.Element("ListPage");
                    var chapters                = listPage?.Element("Chapters");
                    var chaptersWeAreLookingFor = chapters?.Elements("Chapter");

                    if (chaptersWeAreLookingFor != null && chaptersWeAreLookingFor.Any())
                    {
                        Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "A bread crumb exists in current display content.");
                        result = true;
                    }
                    else
                    {
                        Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "No bread crumb available in current display content.");
                    }
                }

                return(result);
            }
            catch (Exception exception)
            {
                Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), exception.Message);
                return(false);
            }
        }
示例#8
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="buttonId"></param>
        /// <returns></returns>
        public bool Run(string buttonId)
        {
            try
            {
                bool result = false;
                var  xml    = XDocument.Parse(AppComController.GetDisplayContent());
                if (xml.Document != null)
                {
                    var displayContent        = xml.Element("DisplayContent");
                    var listPage              = displayContent?.Element("ListPage");
                    var listPageWizardButtons = listPage?.Element("WizardButtons");
                    var buttonWeAreLookingFor = listPageWizardButtons?.Elements("WizardButton").Where(e => e.Attribute("id")?.Value == buttonId);

                    if (buttonWeAreLookingFor != null && buttonWeAreLookingFor.Any())
                    {
                        foreach (var button in buttonWeAreLookingFor)
                        {
                            var isSelectableAttribute = button.Attribute("isSelectable");
                            if (isSelectableAttribute != null)
                            {
                                result = isSelectableAttribute.Value.Equals("true");
                            }
                        }
                    }
                }

                return(result);
            }
            catch (Exception exception)
            {
                Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), exception.Message);
                return(false);
            }
        }
        /// <summary>
        /// Waits for a changed display content
        /// </summary>
        /// <param name="oldDisplayContent">Old display content.</param>
        /// <param name="timeoutInMilliseconds">The timeout in milliseconds.</param>
        /// <returns><c>true</c> if changed, <c>false</c> otherwise.</returns>
        public bool Run(string oldDisplayContent, int timeoutInMilliseconds)
        {
            bool result = true;

            string newDisplayContent = AppComController.GetDisplayContent();

            var watch = new Stopwatch();

            watch.Start();
            while (newDisplayContent == oldDisplayContent)
            {
                if (watch.ElapsedMilliseconds > timeoutInMilliseconds)
                {
                    Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "No update of display content recognized.");
                    result = false;
                    break;
                }

                if ((watch.ElapsedMilliseconds / 1000) % 2 == 0)
                {
                    newDisplayContent = AppComController.GetDisplayContent();
                }
            }

            watch.Stop();

            return(result);
        }
        /// <summary>
        /// Validates, whether a specified parameter is visible in current display content.
        /// </summary>
        /// <param name="parameterId">The parameter identifier.</param>
        /// <returns><c>true</c> if parameter is available, <c>false</c> otherwise.</returns>
        public bool Run(string parameterId)
        {
            try
            {
                string isOnScreen = string.Empty;
                bool   result     = false;
                var    xml        = XDocument.Parse(AppComController.GetDisplayContent());
                if (xml.Document != null)
                {
                    IEnumerable <XElement> parameterList = xml.Document.Descendants("ListItem");
                    foreach (XElement parameter in parameterList)
                    {
                        var idAttribute = parameter.Attribute("id");
                        if (idAttribute == null)
                        {
                            Log.Error(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Parameter '" + parameterId + "' id attribute is null.");
                        }
                        else if (idAttribute.Value == parameterId)
                        {
                            var parameterChildren = parameter.Elements();
                            foreach (XElement child in parameterChildren)
                            {
                                var childName = child.Name.LocalName;
                                if (childName == "ListColumn")
                                {
                                    {
                                        var visibilityAttribute = child.Attribute("isOnScreen");
                                        if (visibilityAttribute != null)
                                        {
                                            isOnScreen = visibilityAttribute.Value;
                                        }
                                    }
                                }
                            }

                            if (isOnScreen.Equals("true"))
                            {
                                result = true;
                                Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Parameter '" + parameterId + "' is visible.");
                                break;
                            }
                            else
                            {
                                Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Parameter '" + parameterId + "' is not visible.");
                                break;
                            }
                        }
                    }
                }

                return(result);
            }
            catch (System.Exception exception)
            {
                Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), exception.Message);
                return(false);
            }
        }
示例#11
0
        /// <summary>
        /// Gets the description of a parameter (if available). Empty if not.
        /// </summary>
        /// <param name="parameterId">The parameter identifier.</param>
        /// <returns>System.String.</returns>
        public string Run(string parameterId)
        {
            try
            {
                string   parameterName = string.Empty;
                string[] separator     = { "//" };
                string[] pathParts     = parameterId.Split(separator, StringSplitOptions.None);
                if (pathParts.Length > 0)
                {
                    parameterName = pathParts[pathParts.Length - 1];
                }

                string        result        = string.Empty;
                StringBuilder resultBuilder = new StringBuilder();
                var           xml           = XDocument.Parse(AppComController.GetDisplayContent());
                if (xml.Document != null)
                {
                    var displayContent           = xml.Element("DisplayContent");
                    var helpPage                 = displayContent?.Element("HelpPage");
                    var helpPageList             = helpPage?.Element("List");
                    var parameterWeAreLookingFor = helpPageList?.Elements().Where(e => e.Attribute("id")?.Value == parameterName);

                    if (parameterWeAreLookingFor != null && parameterWeAreLookingFor.Any())
                    {
                        foreach (var parameter in parameterWeAreLookingFor)
                        {
                            var selectionItems = parameter.Elements("ListColumn")?.Elements("SelectionValue")?.Elements("SelectionItem");
                            if (selectionItems.Any())
                            {
                                foreach (var selectionItem in selectionItems)
                                {
                                    var valueAttribute = selectionItem.Attribute("value");
                                    if (valueAttribute != null)
                                    {
                                        resultBuilder.AppendLine(valueAttribute.Value);
                                    }
                                }
                            }
                        }

                        Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Description for parameter '" + parameterId + "' is available.");
                        result = resultBuilder.ToString();
                    }
                    else
                    {
                        Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Description for parameter '" + parameterId + "' is not available.");
                    }
                }

                return(result);
            }
            catch (Exception exception)
            {
                Log.Error(LogInfo.Namespace(MethodBase.GetCurrentMethod()), exception.Message);
                return(string.Empty);
            }
        }
示例#12
0
        /// <summary>
        /// Gets the minimum range from parameter in current display content.
        /// </summary>
        /// <param name="parameterId">The parameter identifier.</param>
        /// <returns>System.String.</returns>
        public string MinimumRange(string parameterId)
        {
            try
            {
                string result = string.Empty;

                string   parameterName = string.Empty;
                string[] separator     = { "//" };
                string[] pathParts     = parameterId.Split(separator, StringSplitOptions.None);
                if (pathParts.Length > 0)
                {
                    parameterName = pathParts[pathParts.Length - 1];
                }

                if (new SelectParameterAbsolute().Run(parameterId))
                {
                    var xml = XDocument.Parse(AppComController.GetDisplayContent());
                    if (xml.Document != null)
                    {
                        var displayContent           = xml.Element("DisplayContent");
                        var listPage                 = displayContent?.Element("ListPage");
                        var listPageList             = listPage?.Element("List");
                        var parameterWeAreLookingFor = listPageList?.Elements("ListItem").Where(e => e.Attribute("id")?.Value == parameterName);

                        if (parameterWeAreLookingFor != null && parameterWeAreLookingFor.Any())
                        {
                            var listColumns = parameterWeAreLookingFor.Elements("ListColumn");
                            var minRanges   = listColumns?.Elements().Where(e => e.Attribute("rangeMin")?.Value != string.Empty);
                            if (minRanges.Any())
                            {
                                foreach (var value in minRanges)
                                {
                                    var rangeMinAttribute = value.Attribute("rangeMin");
                                    if (rangeMinAttribute != null)
                                    {
                                        result = rangeMinAttribute.Value;
                                        break;
                                    }
                                }
                            }
                        }
                        else
                        {
                            Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Parameter '" + parameterId + "' is not available in current display content.");
                        }
                    }
                }

                return(result);
            }
            catch (Exception e)
            {
                Log.Error(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "GetParameterValueRangeMinimumRange threw an exception:" + e.Message);
                return(string.Empty);
            }
        }
        /// <summary>
        /// Gets all enums from a parameter in current display content
        /// </summary>
        /// <param name="parameterId">The parameter identifier.</param>
        /// <returns>List with all enums of a parameter</returns>
        public List <string> Run(string parameterId)
        {
            try
            {
                List <string> resultList = new List <string>();

                string   parameterName = string.Empty;
                string[] separator     = { "//" };
                string[] pathParts     = parameterId.Split(separator, StringSplitOptions.None);
                if (pathParts.Length > 0)
                {
                    parameterName = pathParts[pathParts.Length - 1];
                }

                var xml = XDocument.Parse(AppComController.GetDisplayContent());
                if (xml.Document != null)
                {
                    var displayContent           = xml.Element("DisplayContent");
                    var listPage                 = displayContent?.Element("ListPage");
                    var listPageList             = listPage?.Element("List");
                    var parameterWeAreLookingFor = listPageList?.Elements("ListItem").Where(e => e.Attribute("id")?.Value == parameterName);

                    if (parameterWeAreLookingFor != null && parameterWeAreLookingFor.Any())
                    {
                        var listColumns    = parameterWeAreLookingFor.Elements("ListColumn");
                        var selectionItems = listColumns?.Elements("SelectionValue")?.Elements("SelectionItem");

                        if (selectionItems.Any())
                        {
                            foreach (var selectionItem in selectionItems)
                            {
                                var selectionItemAttribute = selectionItem.Attribute("name");
                                if (selectionItemAttribute != null)
                                {
                                    resultList.Add(selectionItemAttribute.Value);
                                }
                            }
                        }
                    }
                    else
                    {
                        Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Parameter '" + parameterId + "' is not available in current display content.");
                    }
                }

                return(resultList);
            }
            catch (Exception e)
            {
                Log.Error(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "GetParameterEnumItems threw an exception:" + e.Message);
                return(new List <string>());
            }
        }
示例#14
0
        /// <summary>
        /// Determines whether module is offline
        /// </summary>
        /// <returns><c>true</c> if offline, <c>false</c> otherwise.</returns>
        public bool Run()
        {
            try
            {
                bool result = false;
                var  xml    = XDocument.Parse(AppComController.GetDisplayContent());
                if (xml.Document != null)
                {
                    var displayContent       = xml.Element("DisplayContent");
                    var listPage             = displayContent?.Element("ListPage");
                    var listPageList         = listPage?.Element("List");
                    var deviceHeader         = listPageList?.Element("DeviceHeaderDTM");
                    var paramWeAreLookingFor = deviceHeader?.Elements("FloatValueItem").Where(e => e.Attribute("id")?.Value == "CommunicationInformation.ConnectionState");

                    if (paramWeAreLookingFor != null && paramWeAreLookingFor.Any())
                    {
                        foreach (var item in paramWeAreLookingFor)
                        {
                            var xAttribute = item.Element("FloatValue")?.Attribute("displayedText");
                            if (xAttribute != null)
                            {
                                result = xAttribute.Value.Equals("offline");
                            }
                            else
                            {
                                result = true; // Attribut bei aktueller HMI20 Umsetzung nicht mehr vorhanden
                            }
                        }
                    }
                }

                if (result)
                {
                    Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Module is offline.");
                }
                else
                {
                    Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Module is online");
                }

                return(result);
            }
            catch (Exception exception)
            {
                Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), exception.Message);
                return(false);
            }
        }
        /// <summary>
        /// Determines whether module is ready
        /// </summary>
        /// <returns><c>true</c> if ready, <c>false</c> otherwise.</returns>
        public bool Run()
        {
            try
            {
                bool result = false;
                var  xml    = XDocument.Parse(AppComController.GetDisplayContent());
                if (xml.Document != null)
                {
                    var displayContent        = xml.Element("DisplayContent");
                    var listPage              = displayContent?.Element("ListPage");
                    var listPageList          = listPage?.Element("List");
                    var deviceHeader          = listPageList?.Element("DeviceHeaderDTM");
                    var deviceHeaderParameter = deviceHeader?.Elements("FloatValueItem");
                    var navigationItemsList   = listPageList?.Elements("ListNavigationItem");

                    if ((deviceHeaderParameter != null && deviceHeaderParameter.Any()) && (navigationItemsList != null && navigationItemsList.Any()))
                    {
                        var watch = new Stopwatch();
                        watch.Start();
                        while (watch.ElapsedMilliseconds < 5000)
                        {
                            //do nothing
                        }

                        watch.Stop();

                        result = true;
                    }
                }

                if (result)
                {
                    Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Module is ready.");
                }
                else
                {
                    Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Module is not ready.");
                }

                return(result);
            }
            catch (Exception exception)
            {
                Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), exception.Message);
                return(false);
            }
        }
示例#16
0
        /// <summary>
        /// Validates, whether a specified menu item exists in current display content.
        /// </summary>
        /// <param name="menuItemId">The menu item identifier.</param>
        /// <returns><c>true</c> if parameter is available, <c>false</c> otherwise.</returns>
        public bool Run(string menuItemId)
        {
            string displayContent = AppComController.GetDisplayContent();
            var    result         = false;

            if (displayContent.Contains(menuItemId))
            {
                result = true;
                Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Menu item '" + menuItemId + "' is available in current display content.");
            }
            else
            {
                Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Menu item '" + menuItemId + "' is not available in current display content.");
            }

            return(result);
        }
        /// <summary>
        /// Determines whether a specific wizard button (next, previous, cancel) is available in current display content
        /// </summary>
        /// <param name="buttonId">The button identifier.</param>
        /// <returns><c>true</c> if button is available, <c>false</c> otherwise.</returns>
        public bool Run(string buttonId)
        {
            var result = false;

            if (AppComController.GetDisplayContent().Contains(buttonId))
            {
                Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Button '" + buttonId + "' is available.");
                result = true;
            }
            else
            {
                Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Button '" + buttonId + "' is not available.");
            }


            return(result);
        }
        /// <summary>
        /// Validates, whether a specified parameter exists in current display content.
        /// </summary>
        /// <param name="parameterId">The parameter identifier.</param>
        /// <returns><c>true</c> if parameter is available, <c>false</c> otherwise.</returns>
        public bool Run(string parameterId)
        {
            string displayContent = AppComController.GetDisplayContent();
            var    result         = false;

            if (displayContent.Contains(parameterId))
            {
                result = true;
                Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Parameter '" + parameterId + "' is available.");
            }
            else
            {
                Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Parameter '" + parameterId + "' is not available.");
            }

            return(result);
        }
示例#19
0
        /// <summary>
        /// Determines whether a wizard sequence is active. (Are wizard navigation buttons on screen?)
        /// </summary>
        /// <returns><c>true</c> if wizard sequence is active, <c>false</c> otherwise.</returns>
        public bool Run()
        {
            var result = false;

            if (AppComController.GetDisplayContent().Contains("WizardButton id="))
            {
                Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "A wizard is active.");
                result = true;
            }
            else
            {
                Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "No wizard active.");
            }


            return(result);
        }
        /// <summary>
        /// Validates, whether extended device header exists in current display content.
        /// </summary>
        /// <returns><c>true</c> if parameter is available, <c>false</c> otherwise.</returns>
        public bool Run()
        {
            string displayContent = AppComController.GetDisplayContent();
            var    result         = false;

            if (displayContent.Contains(@"<ExtendedDeviceHeader"))
            {
                Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Extended device header is available.");
                result = true;
            }
            else
            {
                Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Extended header is not available.");
            }

            return(result);
        }
示例#21
0
        /// <summary>
        /// Determines whether a bread crumb exists in current display content
        /// </summary>
        /// <returns><c>true</c> if bread crumb exists, <c>false</c> otherwise.</returns>
        public bool Run(string breadCrumbId)
        {
            try
            {
                bool result = false;
                var  xml    = XDocument.Parse(AppComController.GetDisplayContent());
                if (xml.Document != null)
                {
                    var displayContent         = xml.Element("DisplayContent");
                    var listPage               = displayContent?.Element("ListPage");
                    var chapters               = listPage?.Element("Chapters");
                    var chapterWeAreLookingFor = chapters?.Elements("Chapter").Where(e => e.Attribute("id")?.Value == breadCrumbId);

                    if (chapterWeAreLookingFor != null && chapterWeAreLookingFor.Any())
                    {
                        foreach (var chapter in chapterWeAreLookingFor)
                        {
                            var attribute = chapter.Attribute("isOnScreen");
                            if (attribute != null)
                            {
                                result = attribute.Value.Equals("true");
                            }
                        }
                    }

                    if (result)
                    {
                        Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Bread crumb " + breadCrumbId + " is visible in current display content.");
                    }
                    else
                    {
                        Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Bread crumb " + breadCrumbId + " is not visible in current display content.");
                    }
                }

                return(result);
            }
            catch (Exception exception)
            {
                Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), exception.Message);
                return(false);
            }
        }
示例#22
0
        /// <summary>
        /// Gets the value of a header parameter exists in current display content.
        /// </summary>
        /// <param name="parameterId">The parameter identifier.</param>
        /// <returns>The parameter value.</returns>
        public string Run(string parameterId)
        {
            try
            {
                var result = string.Empty;
                var xml    = XDocument.Parse(AppComController.GetDisplayContent());
                if (xml.Document != null)
                {
                    var displayContent       = xml.Element("DisplayContent");
                    var listPage             = displayContent?.Element("ListPage");
                    var listPageList         = listPage?.Element("List");
                    var standardHeaderParams = listPageList?.Elements("DeviceHeaderDTM")?.Elements("FloatValueItem").Where(e => e.Attribute("id")?.Value == parameterId);

                    if (standardHeaderParams != null && standardHeaderParams.Any())
                    {
                        foreach (var param in standardHeaderParams)
                        {
                            var floatValue = param.Element("FloatValue");
                            if (floatValue != null)
                            {
                                var displayedText = floatValue.Attribute("displayedText");
                                if (displayedText != null)
                                {
                                    result = displayedText.Value;
                                }
                            }
                        }
                    }
                    else
                    {
                        Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Parameter " + parameterId + " is not available in current display content.");
                    }
                }

                return(result);
            }
            catch (Exception exception)
            {
                Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), exception.Message);
                return(string.Empty);
            }
        }
        /// <summary>
        /// Waits for display content change after changing a parameter
        /// </summary>
        /// <param name="timeoutInMilliseconds">The timeout in milliseconds.</param>
        /// <param name="nodePath">The node path.</param>
        /// <param name="value"></param>
        /// <returns><c>true</c> if content changed, <c>false</c> otherwise.</returns>
        public bool Run(int timeoutInMilliseconds, string nodePath, string value)
        {
            try
            {
                bool result = true;

                var xml = XDocument.Parse(AppComController.GetDisplayContent());
                if (xml.Document != null)
                {
                    var watch = new Stopwatch();
                    watch.Start();
                    while (!this.IsSet(xml, nodePath, value))
                    {
                        if (watch.ElapsedMilliseconds > timeoutInMilliseconds)
                        {
                            Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "No update of display content recognized.");
                            result = false;
                            break;
                        }

                        if ((watch.ElapsedMilliseconds / 1000) % 2 == 0)
                        {
                            xml = XDocument.Parse(AppComController.GetDisplayContent());
                        }
                    }

                    watch.Stop();
                }
                else
                {
                    result = false;
                }

                return(result);
            }
            catch (Exception e)
            {
                Log.Error(LogInfo.Namespace(MethodBase.GetCurrentMethod()), e.Message);
                return(false);
            }
        }
示例#24
0
        /// <summary>
        /// Checks whether a help text for a parameter is available in current display content.
        /// </summary>
        /// <param name="parameterId">The parameter id.</param>
        /// <returns><c>true</c> if help available, <c>false</c> otherwise.</returns>
        public bool Run(string parameterId)
        {
            try
            {
                string   parameterName = string.Empty;
                string[] separator     = { "//" };
                string[] pathParts     = parameterId.Split(separator, StringSplitOptions.None);
                if (pathParts.Length > 0)
                {
                    parameterName = pathParts[pathParts.Length - 1];
                }

                bool result = false;
                var  xml    = XDocument.Parse(AppComController.GetDisplayContent());
                if (xml.Document != null)
                {
                    var displayContent           = xml.Element("DisplayContent");
                    var helpPage                 = displayContent?.Element("HelpPage");
                    var helpPageList             = helpPage?.Element("List");
                    var parameterWeAreLookingFor = helpPageList?.Elements().Where(e => e.Attribute("id")?.Value == parameterName);

                    if (parameterWeAreLookingFor != null && parameterWeAreLookingFor.Any())
                    {
                        Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Description for parameter '" + parameterId + "' is available.");
                        result = true;
                    }
                    else
                    {
                        Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Description for parameter '" + parameterId + "' is not available.");
                    }
                }

                return(result);
            }
            catch (System.Exception exception)
            {
                Log.Error(LogInfo.Namespace(MethodBase.GetCurrentMethod()), exception.Message);
                return(false);
            }
        }
        /// <summary>
        /// Validates, whether device header is visible in current display content.
        /// </summary>
        /// <returns><c>true</c> if parameter is available, <c>false</c> otherwise.</returns>
        public bool Run()
        {
            try
            {
                var result = false;
                var xml    = XDocument.Parse(AppComController.GetDisplayContent());
                if (xml.Document != null)
                {
                    var displayContent        = xml.Element("DisplayContent");
                    var helpPage              = displayContent?.Element("ListPage");
                    var helpPageList          = helpPage?.Element("List");
                    var deviceHeader          = helpPageList?.Element("DeviceHeaderDTM");
                    var deviceHeaderAttribute = deviceHeader?.Attribute("isOnScreen");

                    if (deviceHeaderAttribute == null)
                    {
                        Log.Error(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Device header attribute is null.");
                    }
                    else if (deviceHeaderAttribute.Value.Equals("true"))
                    {
                        Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Device Header is visible.");
                        result = true;
                    }
                    else
                    {
                        Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Device Header is not visible.");
                    }
                }

                return(result);
            }
            catch (System.Exception e)
            {
                Log.Error(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "IsHeaderVisible.Run threw an exception:" + e.Message);
                return(false);
            }
        }
示例#26
0
        /// <summary>
        /// Searches for the specified parameter and returns its value
        /// </summary>
        /// <param name="pathToParameter">
        /// The path to the parameter
        /// </param>
        /// <returns>
        /// The value of the parameter
        /// </returns>
        public string Run(string pathToParameter)
        {
            try
            {
                string   parameterId = string.Empty;
                string   result      = string.Empty;
                string[] separator   = { "//" };
                string[] pathParts   = pathToParameter.Split(separator, StringSplitOptions.None);
                if (pathParts.Length > 0)
                {
                    parameterId = pathParts[pathParts.Length - 1];
                }

                if (new SelectParameterAbsolute().Run(pathToParameter))
                {
                    var xml = XDocument.Parse(AppComController.GetDisplayContent());
                    if (xml.Document != null)
                    {
                        IEnumerable <XElement> parameterList = xml.Document.Descendants("ListItem");
                        foreach (XElement parameter in parameterList)
                        {
                            var idAttribute = parameter.Attribute("id");
                            if (idAttribute == null)
                            {
                                Log.Error(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Parameter '" + parameterId + "' id attribute is null.");
                            }
                            else if (idAttribute.Value == parameterId)
                            {
                                var parameterChildren = parameter.Elements();
                                foreach (XElement child in parameterChildren)
                                {
                                    var childName = child.Name.LocalName;
                                    if (childName == "ListColumn")
                                    {
                                        var actualValues = child.Elements();
                                        foreach (var actualValue in actualValues)
                                        {
                                            if (actualValue.Name.LocalName.Contains("Value"))
                                            {
                                                var displayedText = actualValue.Attribute("displayedText");
                                                if (displayedText != null)
                                                {
                                                    result = displayedText.Value;
                                                }

                                                break;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        Log.Error(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Display content xml is null.");
                    }
                }


                return(result);
            }
            catch (System.Exception exception)
            {
                Log.Error(LogInfo.Namespace(MethodBase.GetCurrentMethod()), exception.Message);
                return(string.Empty);
            }
        }
示例#27
0
 /// <summary>
 /// Connects the testing interface
 /// </summary>
 /// <param name="remoteHost">The remote host.</param>
 /// <param name="remotePort">The remote port.</param>
 /// <param name="pushMessageServerHost">The push message server host.</param>
 /// <param name="pushMessageServerPort">The push message server port.</param>
 /// <returns><c>true</c> if connected, <c>false</c> otherwise.</returns>
 private bool Run(string remoteHost, ushort remotePort, string pushMessageServerHost, ushort pushMessageServerPort)
 {
     return(AppComController.Connect(remoteHost, remotePort, pushMessageServerHost, pushMessageServerPort));
 }
 /// <summary>
 /// Runs this instance.
 /// </summary>
 /// <returns><c>true</c> if disconnected, <c>false</c> otherwise.</returns>
 public bool Run()
 {
     return(AppComController.Disconnect());
 }