예제 #1
0
        /// <summary>
        /// Closes any DTM function by its name and validates if the action was successful
        /// </summary>
        /// <param name="functionName">The name of the DTM function</param>
        /// <returns>True if the action was successful</returns>
        public bool Run(string functionName)
        {
            // instanciate all necessary modules
            var selectDeviceFunction = new Functions.Helpers.InterfaceHelpers.DTMFunctions();
            var devScreen            = new Functions.ApplicationArea.Page_DeviceScreen.Page_DeviceScreen_Functions();

            // set module variables
            devScreen.DeviceFunctionName = functionName;

            Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Current task: Close " + functionName + " function tab");

            // check if tab exists
            if (devScreen.IsTabOpen())
            {
                // close desired function tab
                devScreen.CloseFunctionTab();

                // check if tab is really closed
                if (devScreen.IsTabClosed())
                {
                    return(true);
                }
            }

            return(false);
        }
        /// <summary>
        /// The run.
        /// </summary>
        /// <param name="filePath">
        /// The file path.
        /// </param>
        /// <param name="fileName">
        /// The file name.
        /// </param>
        /// <returns>
        /// The <see cref="bool"/>.
        /// </returns>
        public bool Run(string filePath, string fileName)
        {
            // instantiate all necessary modules
            var connectionStatus = new Functions.StatusArea.Statusbar.Statusbar_Functions();
            var execFunction     = new Functions.Helpers.InterfaceHelpers.DTMFunctions();
            var devScreen        = new Functions.ApplicationArea.Page_DeviceScreen.Page_DeviceScreen_Functions();

            string fileLocation;
            string basePath;

            // set all necessary parameters
            devScreen.IsRestoreRequest = false;

            // check if device is online
            if (connectionStatus.IsDeviceConnected())
            {
                Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Device is connected. Saving device data...");

                // click button "program functions"
                devScreen.OpenProgramFunctionsMenu();

                // check if menu is open
                if (devScreen.IsDTMFunctionMenuShown())
                {
                    // select "save device data"
                    devScreen.RunDTMFunction();

                    // wait until process is finished
                    if (connectionStatus.IsActionFinished())
                    {
                        // get event message text
                        string msg = connectionStatus.GetStatusMessage();

                        // check if saving was successful
                        if (msg.Contains("set has been saved"))
                        {
                            // get file path and extract basepath
                            fileLocation = connectionStatus.GetFileLocationFromStatusMessage(msg);
                            basePath     = connectionStatus.GetBasePath(fileLocation);

                            // construct the destination path
                            string finalizedPath = filePath + "\\" + fileName + ".dcdtm";

                            // rename the file
                            execFunction.MoveFile(fileLocation, finalizedPath);

                            // check if renaming was successful
                            if (File.Exists(finalizedPath))
                            {
                                Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "The file was successfully created. File location: " + finalizedPath);
                                return(true);
                            }
                        }
                    }
                }
            }

            return(false);
        }
        /// <summary>
        /// The run.
        /// </summary>
        /// <returns>
        /// The <see cref="bool"/>.
        /// </returns>
        public bool Run()
        {
            // instantiate all modules
            var connectionStatus = new Functions.StatusArea.Statusbar.Statusbar_Functions();
            var devScreen        = new Functions.ApplicationArea.Page_DeviceScreen.Page_DeviceScreen_Functions();

            devScreen.IsAdditionalFunction = false;
            devScreen.DeviceFunctionName   = "OfflineParameterization";

            Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Current task: Connect device (toggle online)");

            // check if device is connected and store value
            bool isConnected = connectionStatus.IsDeviceConnected();

            if (isConnected == false)
            {
                Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Device is in offline state. Checking if device supports offline functionality...");

                // check if device supports offline functionality
                // else return false and user warning
                devScreen.OpenDtmFunctions();

                if (devScreen.IsDTMFunctionMenuShown())
                {
                    if (devScreen.IsOfflineSupported())
                    {
                        // device supports offline functionality
                        Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Device supports offline functionality. Toggling online...");

                        // toggle online
                        devScreen.ToggleOnline();
                        Delay.Milliseconds(2500);

                        if (connectionStatus.IsDeviceConnected())
                        {
                            Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Successfully connected the device");
                            return(true);
                        }

                        Log.Error(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Could not connect to the device");
                        return(false);
                    }

                    // device does not support offline
                    // report a warning and return false
                    Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "The device does not support offline functionality. Cancel connecting the device...");
                    return(false);
                }
            }
            else
            {
                // device is already connected -> do nothing and return
                Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "The device is already in online state");
                return(true);
            }

            return(false);
        }
예제 #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="filePathAndName"></param>
        /// <returns></returns>
        public bool Run(string filePathAndName)
        {
            //instantiate modules
            var connection = new Functions.StatusArea.Statusbar.Statusbar_Functions();
            var create     = new Functions.Helpers.InterfaceHelpers.DeviceReportFunctions();
            var devScreen  = new Functions.ApplicationArea.Page_DeviceScreen.Page_DeviceScreen_Functions();
            var dialog     = new Functions.Helpers.DialogFunctions();

            //check if device is connected
            Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Current task: Print Device Information");

            if (connection.IsDeviceConnected())
            {
                Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Device is connected. Start printing device report...");
                //press button device report
                devScreen.ClickFDTPrintButton();
                // wait until window is open
                if (dialog.WaitForDeviceReportDialog())
                {
                    Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Device Report created. Saving report...");
                    //click button print
                    dialog.ClickPrintButton();

                    //check if print dialog is open
                    if (dialog.IsPrintFormOpen())
                    {
                        //select printer -> E+H FieldCare -> validate -> click print
                        if (dialog.SelectFieldCarePrinter())
                        {
                            //check if save dialog is open
                            if (dialog.IsSaveDialogOpen())
                            {
                                Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Saving report in directory: '" + filePathAndName + "'");
                                //save dialog -> set filename and path
                                bool exists = create.IsFileCreated(filePathAndName);
                                if (exists)
                                {
                                    Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "The file already exists. It will be overwritten...");
                                }
                                //check if text is set -> click save
                                if (dialog.SaveReportWithName(filePathAndName, exists))
                                {
                                    //check if file was created
                                    if (create.IsFileCreated(filePathAndName))
                                    {
                                        Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "The file was created successfully");
                                        return(true);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(false);
        }
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public bool Run()
        {
            //instantiate all modules
            var connectionStatus = new Functions.StatusArea.Statusbar.Statusbar_Functions();
            var execFunction     = new Functions.Helpers.InterfaceHelpers.DTMFunctions();
            var devScreen        = new Functions.ApplicationArea.Page_DeviceScreen.Page_DeviceScreen_Functions();

            devScreen.IsAdditionalFunction = false;
            devScreen.DeviceFunctionName   = "OfflineParameterization";

            Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Current task: Read data from device");
            //check if device is connected
            if (connectionStatus.IsDeviceConnected())
            {
                Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Device is connected. Checking if device supports offline functionality...");

                //check if device supports offline functionality
                //else return false and user warning
                devScreen.ClickFunctionMenu();

                if (devScreen.IsDTMFunctionMenuShown())
                {
                    if (devScreen.IsOfflineSupported())
                    {
                        //device supports offline functionality
                        Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Device supports offline functionality. Uploading device data...");

                        if (devScreen.ReadFromDevice())
                        {
                            Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Reading of the device data was successful");
                        }
                    }
                    else
                    {
                        //device does not support offline
                        //report a warning and return false

                        Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "The device does not support offline functionality. Cancelling the read request.");
                        return(false);
                    }
                }
            }
            return(false);
        }
        /// <summary>
        /// The run.
        /// </summary>
        /// <param name="filePath">
        /// The file path.
        /// </param>
        /// <param name="fileName">
        /// The file name.
        /// </param>
        /// <returns>
        /// The <see cref="bool"/>.
        /// </returns>
        public bool Run(string filePath, string fileName)
        {
            // instantiate all necessary modules
            var execFunction     = new Functions.Helpers.InterfaceHelpers.DTMFunctions();
            var connectionStatus = new Functions.StatusArea.Statusbar.Statusbar_Functions();
            var devScreen        = new Functions.ApplicationArea.Page_DeviceScreen.Page_DeviceScreen_Functions();
            var dialog           = new Functions.Helpers.DialogFunctions();

            // set all necessary parameters
            devScreen.IsRestoreRequest = true;

            Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Current task: Restore device data");

            if (connectionStatus.IsDeviceConnected())
            {
                Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Device is connected. Restoring device data...");

                // click button "program functions"
                devScreen.OpenProgramFunctionsMenu();

                // check if menu is open
                if (devScreen.IsDTMFunctionMenuShown())
                {
                    // select "restore device data" and then "browse"
                    devScreen.RunDTMFunction();

                    // check if browse dialog is open
                    if (dialog.IsBrowseDialogOpen())
                    {
                        // construct the destination path
                        string finalizedPath = filePath + "\\" + fileName + ".dcdtm";

                        // set filepath in the browse dialog
                        dialog.SetFilePath(finalizedPath);

                        // check if path is set
                        if (dialog.IsFilePathSet(finalizedPath))
                        {
                            // select "go" and then "ok"
                            dialog.AckDialog();

                            // check if pop up dialog is open
                            if (dialog.IsPopupOpen())
                            {
                                // select yes in the pop up dialog
                                dialog.AckPopup();

                                // wait for completion and check status area message for success/failure
                                if (devScreen.IsRestoreFinished())
                                {
                                    Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Restoring DTM data was successful");
                                    return(true);
                                }
                            }
                        }
                    }
                }
            }

            return(false);
        }