Ejemplo n.º 1
0
        private void LoadVersionAndState()
        {
            //NOT USED ANYMORE
            STATE        currentState    = state;
            VERSION      currentVersion  = version;
            WTM_ACTIVITY currentActivity = activity;
            string       currentTestplan = string.Empty;

            //Check if Wtm is open
            mainHWnd = AppManipulation.FindWindowByClassName("WindowsForms10.Window.8.app3");

            //Set version
            if (mainHWnd != IntPtr.Zero)
            {
                wtmHwnd = AppManipulation.FindWindowByWindowName("E6567C Agilent cdma2000/IS-95/AMPS/1xEV-DO Wireless Test Manager");
                if (wtmHwnd != IntPtr.Zero)
                {
                    version = VERSION.AGILENT_E6567;
                }
                if (wtmHwnd == IntPtr.Zero)
                {
                    wtmHwnd = AppManipulation.FindWindowByWindowName("Agilent E6567D cdma2000/IS-95/AMPS/1xEV-DO/LTE Wireless Test Manager");
                    if (wtmHwnd != IntPtr.Zero)
                    {
                        version = VERSION.AGILENT_E6567;
                    }
                }
                if (wtmHwnd == IntPtr.Zero)
                {
                    wtmHwnd = AppManipulation.FindWindowByWindowName("Agilent E6567E cdma2000/IS-95/AMPS/1xEV-DO/LTE Wireless Test Manager");
                    if (wtmHwnd != IntPtr.Zero)
                    {
                        version = VERSION.AGILENT_E6567;
                    }
                }
                if (wtmHwnd == IntPtr.Zero)
                {
                    wtmHwnd = AppManipulation.FindWindowByWindowName("Agilent E6560C cdma2000/IS-95/AMPS Wireless Test Manager");
                    if (wtmHwnd != IntPtr.Zero)
                    {
                        version = VERSION.AGILENT_E6560;
                    }
                }
                if (wtmHwnd == IntPtr.Zero)
                {
                    wtmHwnd = AppManipulation.FindWindowByWindowName("Agilent E6568C WCDMA/GSM/GPRS/EGPRS Wireless Test Manager");
                    if (wtmHwnd != IntPtr.Zero)
                    {
                        version = VERSION.AGILENT_E6568;
                    }
                }
                if (wtmHwnd == IntPtr.Zero)
                {
                    wtmHwnd = AppManipulation.FindWindowByWindowName("Agilent E6568E WCDMA/GSM/GPRS/EGPRS/LTE Wireless Test Manager");
                    if (wtmHwnd != IntPtr.Zero)
                    {
                        version = VERSION.AGILENT_E6568;
                    }
                }
            }
            else
            {
                wtmHwnd  = AppManipulation.FindWindowByWindowName("PoST- 8924C/E & E8285A CDMA Mobile Tests");
                mainHWnd = wtmHwnd;
                if (wtmHwnd != IntPtr.Zero)
                {
                    version = VERSION.POST_E8285;
                }
            }

            //Set state
            if (mainHWnd != IntPtr.Zero)
            {
                if (wtmHwnd != IntPtr.Zero)
                {
                    state = STATE.OPEN;
                }
                else
                {
                    state = STATE.OPENING;
                }
            }
            else
            {
                state = STATE.CLOSED;
            }

            //Set current wtm activity
            if (mainHWnd != IntPtr.Zero && state == STATE.OPEN && version != VERSION.NONE)
            {
                if (version != VERSION.POST_E8285)
                {
                    try
                    {
                        #region Set the activity for the Wtm versions
                        if (this.gettingStatus)
                        {
                            if (!AppManipulation.IsWindowMinimized(wtmHwnd))
                            {
                                //Get all the handlers for all the Wtm versions
                                int ContainerCount = AppManipulation.FindChildWindowCountByClassName(mainHWnd, "WindowsForms10.Window.8.app3");
                                if (ContainerCount > 0)
                                {
                                    ContainerCount = (ContainerCount > 30) ? 30 : ContainerCount;
                                    activity       = WTM_ACTIVITY.NONE;
                                    string[] captions;
                                    bool     somethingFound = false;
                                    for (int j = ContainerCount - 3; j < ContainerCount; j++)
                                    {
                                        IntPtr statusContainer = AppManipulation.FindChildWindowByClassNameByIndex(mainHWnd, "WindowsForms10.Window.8.app3", j);//27
                                        if (statusContainer != IntPtr.Zero)
                                        {
                                            int count = AppManipulation.FindChildWindowCountByClassName(statusContainer, "WindowsForms10.msctls_statusbar32.app3");//6 o 7

                                            for (int i = 6; i < count; i++)
                                            {
                                                IntPtr statusPtr = AppManipulation.FindChildWindowByClassNameByIndex(statusContainer, "WindowsForms10.msctls_statusbar32.app3", i);
                                                if (statusPtr != IntPtr.Zero)
                                                {
                                                    Valutech.IO.StatusBar status = new Valutech.IO.StatusBar(statusPtr);
                                                    captions = status.Captions;
                                                    if (captions.Length > 1)
                                                    {
                                                        string statusText = captions[1];
                                                        if (statusText != string.Empty)
                                                        {
                                                            somethingFound = true;
                                                            if (activity == WTM_ACTIVITY.NONE)
                                                            {
                                                                if (statusText == "	")
                                                                {
                                                                    activity = WTM_ACTIVITY.FIRST_TIME_START;
                                                                }
                                                                Regex regex = new Regex("Performing CDMAVoiceQuality . . .|Performing GSMMobileInitiatedCall . . .");
                                                                if (regex.IsMatch(statusText))
                                                                {
                                                                    activity = WTM_ACTIVITY.CHECKING_VOICE_QUALITY;
                                                                }
                                                                regex = new Regex("Performing CDMAPage . . .");
                                                                if (regex.IsMatch(statusText))
                                                                {
                                                                    activity = WTM_ACTIVITY.PERFORMING_CDMA_PAGE;
                                                                }
                                                                regex = new Regex("Performing WCDMAOrigination . . .");
                                                                if (regex.IsMatch(statusText))
                                                                {
                                                                    activity = WTM_ACTIVITY.PERFORMING_CDMA_PAGE;
                                                                }
                                                                regex = new Regex("Passed = [0-9]{1,}[ ]{1,}Failed = [0-9]{1,}|Test Plan Aborted");
                                                                if (regex.IsMatch(statusText))
                                                                {
                                                                    activity = WTM_ACTIVITY.TEST_FINISHED;
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                    if (somethingFound && activity == WTM_ACTIVITY.NONE)
                                    {
                                        activity = WTM_ACTIVITY.TESTING;
                                    }
                                }

                                //Get the testplan directly from window
                                int comboboxCount = AppManipulation.FindChildWindowCountByClassName(mainHWnd, "WindowsForms10.COMBOBOX.app3");
                                if (comboboxCount > 0)
                                {
                                    IntPtr comboBoxItem  = IntPtr.Zero;
                                    int    windowsNumber = 15;
                                    while (comboBoxItem == IntPtr.Zero && windowsNumber < 18)
                                    {
                                        comboBoxItem    = AppManipulation.FindChildWindowByClassNameByIndex(mainHWnd, "WindowsForms10.COMBOBOX.app3", windowsNumber);
                                        currentTestplan = AppManipulation.GetText(comboBoxItem);
                                        windowsNumber++;
                                    }
                                }
                            }
                        }
                        else
                        {
                            //AppManipulation.WriteInNotepad("Not getting status");
                        }
                        #endregion
                    }
                    catch { }
                }
                else
                {
                    try
                    {
                        #region Set the activity for the 8285 equipment

                        IntPtr statusContainer = AppManipulation.FindWindowByWindowName("PoST Operator Instructions");
                        if (statusContainer != IntPtr.Zero)
                        {
                            IntPtr statusPtr = AppManipulation.FindChildWindowByClassName(statusContainer, "RichTextWndClass");
                            if (statusPtr != IntPtr.Zero)
                            {
                                string caption = AppManipulation.GetText(statusPtr);
                                if (caption != String.Empty)
                                {
                                    activity = WTM_ACTIVITY.PERFORMING_CDMA_PAGE;
                                    Regex regex = new Regex("Waiting for operator to answer call");
                                    if (regex.IsMatch(caption))
                                    {
                                        activity = WTM_ACTIVITY.WAITING_TO_ANSWER_CALL;
                                    }
                                    regex = new Regex("Speak into the phone");
                                    if (regex.IsMatch(caption))
                                    {
                                        activity = WTM_ACTIVITY.CHECKING_VOICE_QUALITY;
                                    }
                                }
                            }
                        }
                        else
                        {
                            if (currentActivity != WTM_ACTIVITY.WAITING_TO_ANSWER_CALL)
                            {
                                GetBtnHwnds();
                                if (stopBtnHwnd != IntPtr.Zero)
                                {
                                    if (AppManipulation.IsWindowVisible(stopBtnHwnd))
                                    {
                                        activity = WTM_ACTIVITY.TESTING;
                                    }
                                    else
                                    {
                                        activity = WTM_ACTIVITY.TEST_FINISHED;
                                    }
                                }
                            }
                            else
                            {
                                activity = currentActivity;
                            }
                        }

                        #endregion
                    } catch { }
                }
            }
            else
            {
                stopBtnHwnd = IntPtr.Zero;
                runBtnHwnd  = IntPtr.Zero;
            }

            //Send events depending on the change
            if (currentState != state)
            {
                if (StateChanged != null)
                {
                    StateChanged(this, EventArgs.Empty);
                }
            }
            if (currentActivity != activity)
            {
                if (ActivityChanged != null)
                {
                    ActivityChanged(this, EventArgs.Empty);
                }
            }
            if (currentVersion != version)
            {
                if (VersionChanged != null)
                {
                    VersionChanged(this, EventArgs.Empty);
                }
            }
            if (currentTestplan != testplan && currentState == STATE.OPEN && !currentTestplan.Contains("Data terminal ready:") && currentTestplan != string.Empty)
            {
                testplan = currentTestplan;
                if (TestplanChanged != null)
                {
                    TestplanChanged(testplan);
                }
            }
        }
Ejemplo n.º 2
0
        private void LoadVersionAndState()
        {
            STATE        currentState    = state;
            VERSION      currentVersion  = version;
            WTM_ACTIVITY currentActivity = activity;
            string       currentTestplan = testplan;

            //Check if Wtm is open
            mainHWnd = AppManipulation.FindWindowByClassName("WindowsForms10.Window.8.app3");

            //Set version
            if (mainHWnd != IntPtr.Zero)
            {
                string wName = AppManipulation.GetWindowName(mainHWnd);
                wtmHwnd = mainHWnd;
                if (wName.IndexOf("E6560") > -1)
                {
                    version = VERSION.AGILENT_E6560;
                }
                else if (wName.IndexOf("E6567") > -1)
                {
                    version = VERSION.AGILENT_E6567;
                }
                else if (wName.IndexOf("E6568") > -1)
                {
                    version = VERSION.AGILENT_E6568;
                }

                //Get the testplan directly from window
                bool next = false;
                foreach (IntPtr hWnd in AppManipulation.GetChildWindows(mainHWnd))
                {
                    if (next == true)
                    {
                        if (currentState == STATE.OPEN)
                        {
                            this.testplan = AppManipulation.GetText(hWnd);
                        }
                        next = false;
                    }
                    if (AppManipulation.GetText(hWnd).IndexOf("DUT serial number") > -1)
                    {
                        next = true;
                    }
                }
            }
            else
            {
                wtmHwnd  = AppManipulation.FindWindowByWindowName("PoST- 8924C/E & E8285A CDMA Mobile Tests");
                mainHWnd = wtmHwnd;
                if (wtmHwnd != IntPtr.Zero)
                {
                    version = VERSION.POST_E8285;
                }
            }

            //Set state
            if (mainHWnd != IntPtr.Zero)
            {
                if (wtmHwnd != IntPtr.Zero)
                {
                    state = STATE.OPEN;
                }
                else
                {
                    state = STATE.OPENING;
                }
            }
            else
            {
                state = STATE.CLOSED;
            }

            //Set current wtm activity
            if (mainHWnd != IntPtr.Zero && state == STATE.OPEN && version != VERSION.NONE)
            {
                if (version != VERSION.POST_E8285)
                {
                    try
                    {
                        #region Set the activity for the Wtm versions
                        if (this.gettingStatus)
                        {
                            if (!AppManipulation.IsWindowMinimized(wtmHwnd))
                            {
                                //Get all the handlers for all the Wtm versions
                                int ContainerCount = AppManipulation.FindChildWindowCountByClassName(mainHWnd, "WindowsForms10.Window.8.app3");
                                if (ContainerCount > 0)
                                {
                                    ContainerCount = (ContainerCount > 30) ? 30 : ContainerCount;
                                    activity       = WTM_ACTIVITY.NONE;
                                    string[] captions;
                                    bool     somethingFound = false;
                                    for (int j = ContainerCount - 3; j < ContainerCount; j++)
                                    {
                                        IntPtr statusContainer = AppManipulation.FindChildWindowByClassNameByIndex(mainHWnd, "WindowsForms10.Window.8.app3", j);//27
                                        if (statusContainer != IntPtr.Zero)
                                        {
                                            int count = AppManipulation.FindChildWindowCountByClassName(statusContainer, "WindowsForms10.msctls_statusbar32.app3");//6 o 7

                                            for (int i = 6; i < count; i++)
                                            {
                                                IntPtr statusPtr = AppManipulation.FindChildWindowByClassNameByIndex(statusContainer, "WindowsForms10.msctls_statusbar32.app3", i);
                                                if (statusPtr != IntPtr.Zero)
                                                {
                                                    Valutech.IO.StatusBar status = new Valutech.IO.StatusBar(statusPtr);
                                                    captions = status.Captions;
                                                    if (captions.Length > 1)
                                                    {
                                                        string statusText = captions[1];
                                                        if (statusText != string.Empty)
                                                        {
                                                            somethingFound = true;
                                                            if (activity == WTM_ACTIVITY.NONE)
                                                            {
                                                                if (statusText == "	")
                                                                {
                                                                    activity = WTM_ACTIVITY.FIRST_TIME_START;
                                                                }
                                                                Regex regex = new Regex("Performing CDMAVoiceQuality . . .|Performing GSMMobileInitiatedCall . . .");
                                                                if (regex.IsMatch(statusText))
                                                                {
                                                                    activity = WTM_ACTIVITY.CHECKING_VOICE_QUALITY;
                                                                }
                                                                regex = new Regex("Performing CDMAPage . . .");
                                                                if (regex.IsMatch(statusText))
                                                                {
                                                                    activity = WTM_ACTIVITY.PERFORMING_CDMA_PAGE;
                                                                }
                                                                regex = new Regex("Performing WCDMAOrigination . . .");
                                                                if (regex.IsMatch(statusText))
                                                                {
                                                                    activity = WTM_ACTIVITY.PERFORMING_CDMA_PAGE;
                                                                }
                                                                regex = new Regex("Passed = [0-9]{1,}[ ]{1,}Failed = [0-9]{1,}|Test Plan Aborted");
                                                                if (regex.IsMatch(statusText))
                                                                {
                                                                    activity = WTM_ACTIVITY.TEST_FINISHED;
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                    if ((somethingFound && activity == WTM_ACTIVITY.NONE))
                                    {
                                        activity = WTM_ACTIVITY.TESTING;
                                    }
                                }
                            }
                        }
                        else
                        {
                            Console.WriteLine("Not getting status");
                        }
                        #endregion
                    }
                    catch { }
                }
                else
                {
                    try
                    {
                        #region Set the activity for the 8285 equipment

                        IntPtr statusContainer = AppManipulation.FindWindowByWindowName("PoST Operator Instructions");
                        if (statusContainer != IntPtr.Zero)
                        {
                            IntPtr statusPtr = AppManipulation.FindChildWindowByClassName(statusContainer, "RichTextWndClass");
                            if (statusPtr != IntPtr.Zero)
                            {
                                string caption = AppManipulation.GetText(statusPtr);
                                if (caption != String.Empty)
                                {
                                    activity = WTM_ACTIVITY.PERFORMING_CDMA_PAGE;
                                    Regex regex = new Regex("Waiting for operator to answer call");
                                    if (regex.IsMatch(caption))
                                    {
                                        activity = WTM_ACTIVITY.WAITING_TO_ANSWER_CALL;
                                    }
                                    regex = new Regex("Speak into the phone");
                                    if (regex.IsMatch(caption))
                                    {
                                        activity = WTM_ACTIVITY.CHECKING_VOICE_QUALITY;
                                    }
                                }
                            }
                        }
                        else
                        {
                            if (currentActivity != WTM_ACTIVITY.WAITING_TO_ANSWER_CALL)
                            {
                                GetBtnHwnds();
                                if (stopBtnHwnd != IntPtr.Zero)
                                {
                                    if (AppManipulation.IsWindowVisible(stopBtnHwnd))
                                    {
                                        activity = WTM_ACTIVITY.TESTING;
                                    }
                                    else
                                    {
                                        activity = WTM_ACTIVITY.TEST_FINISHED;
                                    }
                                }
                            }
                            else
                            {
                                activity = currentActivity;
                            }
                        }

                        #endregion
                    }
                    catch { }
                }
            }
            else
            {
                stopBtnHwnd         = IntPtr.Zero;
                runBtnHwnd          = IntPtr.Zero;
                dutSerialNumberHwnd = IntPtr.Zero;
            }

            //Send events depending on the change
            if (currentState != state)
            {
                if (StateChanged != null)
                {
                    StateChanged(this, EventArgs.Empty);
                }
                if (state == STATE.OPEN)
                {
                    this.model = GetModelInUse();
                    if (ModelInUseChanged != null)
                    {
                        ModelInUseChanged(this.model);
                    }
                }
            }
            if (currentActivity != activity)
            {
                if (ActivityChanged != null)
                {
                    ActivityChanged(this, EventArgs.Empty);
                }
            }
            if (currentVersion != version)
            {
                if (VersionChanged != null)
                {
                    VersionChanged(this, EventArgs.Empty);
                }
            }
            if (currentTestplan != this.testplan && currentState == STATE.OPEN)
            {
                if (TestplanChanged != null)
                {
                    TestplanChanged(this.testplan);
                }
            }
        }