コード例 #1
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="path"></param>
 public ExecSetting(OEM oem)
 {
     this.oem = oem;
     this.wtm = WirelessTestManager.GetInstance();
     this.wtm.WTMRestarted += new WTMRestartedEventHandler(wtm_WTMRestarted);
     this.wtm.WTMClosed    += new WTMRestartedEventHandler(wtm_WTMRestarted);
 }
コード例 #2
0
 /// <summary>
 /// Load the oems for the specified version
 /// </summary>
 /// <returns>ArrayList with the OEM Objects found</returns>
 public ArrayList LoadOEMs()
 {
     try
     {
         oems = new ArrayList();
         string path = WirelessTestManager.GetInstance().GetPath();
         if (path != PATH_NOT_FOUND)
         {
             string[] dirs   = Directory.GetDirectories(path);
             Regex    regexp = new Regex("[^\\\\]{1,}\\\\" + this.Name);
             foreach (string dir in dirs)
             {
                 if (regexp.IsMatch(dir))
                 {
                     OEM oem = new OEM(dir, this);
                     oems.Add(oem);
                 }
             }
         }
         return(oems);
     }
     catch
     {
         return(null);
     }
 }
コード例 #3
0
 /// <summary>
 /// Gets the current instance or creates a new one if no one is there
 /// </summary>
 /// <returns></returns>
 public static WirelessTestManager GetInstance()
 {
     if (instance == null)
     {
         instance = new WirelessTestManager();
     }
     return(instance);
 }
コード例 #4
0
        /// <summary>
        /// Private Contructor, works as singleton
        /// </summary>
        private WirelessTestManager()
        {
            instance = this;
            if (this.IsRunning() != null)
            {
                this.model = GetModelInUse();
            }
            TestPlanUpdaterTimer.Elapsed += new ElapsedEventHandler(TestPlanUpdaterTimer_Elapsed);
            TestPlanUpdaterTimer.Enabled  = true;
            TestPlanUpdaterTimer.Start();

            /*
             * UpdaterThread.Elapsed += new System.Timers.ElapsedEventHandler(UpdaterThread_Elapsed);
             * UpdaterThread.Enabled = true;
             * UpdaterThread.Start();*/
            UpdaterThread = new Thread(Update);
            UpdaterThread.Start();
        }
コード例 #5
0
        /// <summary>
        /// Use the given oem, makes the necessary folder name changes
        /// </summary>
        /// <param name="oemToUse">OEM to use</param>.
        /// <returns>Returns the WTM Version that was closed during the process if any</returns>
        /// <exception cref="Valutech.Agilent.UnableToCloseWTMException">Thrown when the wtm was not able to get closed by the system</exception>
        /// <exception cref="Valutech.Agilent.UnableToArchiveOEMException">Thrown when the oem was not able to get archived</exception>
        /// <exception cref="Valutech.Agilent.UnableToUseOEMException">Thrown when the oem was not able to get used</exception>
        /// <exception cref="Valutech.Agilent.UnableToCreateExecSettingBackupException">Thrown when the ExecSetting backup file could not be created</exception>
        public WTMVersion Archive()
        {
            WTMVersion closedVersion = null;
            //If the oem is not in use currently we need to close the wtm and rename the folders
            WTMVersion runningVersion = WirelessTestManager.GetInstance().IsRunning();

            if (this.InUse)
            {
                //Close the currently running wtm if running
                if (runningVersion != null)
                {
                    if (!runningVersion.Close())
                    {
                        throw new UnableToCloseWTMException(runningVersion);
                    }
                    else
                    {
                        closedVersion = runningVersion;
                    }
                }

                //Archive the oem in use
                if (this != null)
                {
                    if (this.Path != this.ArchivedPath)
                    {
                        try
                        {
                            if (!Directory.Exists(this.ArchivedPath))
                            {
                                Directory.Move(this.Path, this.ArchivedPath);
                                this.setPath(ArchivedPath);
                                if (Archived != null)
                                {
                                    Archived(this);
                                }
                            }
                            else
                            {
                                throw new UnableToArchiveOEMException(this, UnableToArchiveOEMException.ErrorType.ARCHIVED_OEM_ALREADY_EXISTS);
                            }
                        }
                        catch (IOException)
                        {
                            throw new UnableToArchiveOEMException(this, UnableToArchiveOEMException.ErrorType.IO_EXCEPTION);
                        }
                        catch (UnauthorizedAccessException)
                        {
                            throw new UnableToArchiveOEMException(this, UnableToArchiveOEMException.ErrorType.UNAUTHORIZED_ACCESS_EXCEPTION);
                        }
                    }
                }
            }

            //Close the currently running wtm if running
            if (runningVersion != null && this.ExecSetting.NeedsRestart)
            {
                if (!runningVersion.Close())
                {
                    throw new UnableToCloseWTMException(runningVersion);
                }
                else
                {
                    closedVersion = runningVersion;
                }
            }
            return(closedVersion);
        }
コード例 #6
0
        /// <summary>
        /// Use the given oem, makes the necessary folder name changes
        /// </summary>
        /// <param name="oemToUse">OEM to use</param>.
        /// <returns>Returns the WTM Version that was closed during the process if any</returns>
        /// <exception cref="Valutech.Agilent.UnableToCloseWTMException">Thrown when the wtm was not able to get closed by the system</exception>
        /// <exception cref="Valutech.Agilent.UnableToArchiveOEMException">Thrown when the oem was not able to get archived</exception>
        /// <exception cref="Valutech.Agilent.UnableToUseOEMException">Thrown when the oem was not able to get used</exception>
        /// <exception cref="Valutech.Agilent.UnableToCreateExecSettingBackupException">Thrown when the ExecSetting backup file could not be created</exception>
        public WTMVersion Use()
        {
            this.ExecSetting.Load();
            WTMVersion closedVersion = null;
            //If the oem is not in use currently we need to close the wtm and rename the folders
            WTMVersion runningVersion = WirelessTestManager.GetInstance().IsRunning();

            if (!this.InUse)
            {
                //Close the currently running wtm if running
                if (runningVersion != null)
                {
                    if (!runningVersion.Close())
                    {
                        throw new UnableToCloseWTMException(runningVersion);
                    }
                    else
                    {
                        closedVersion = runningVersion;
                    }
                }

                //Utilizar el oem seleccionado
                if (this.Path != this.InUsePath)
                {
                    try
                    {
                        if (!Directory.Exists(this.InUsePath))
                        {
                            Directory.Move(this.Path, this.InUsePath);
                            this.setPath(InUsePath);
                            if (Used != null)
                            {
                                Used(this);
                            }
                        }
                        else
                        {
                            throw new UnableToUseOEMException(this, UnableToUseOEMException.ErrorType.OEM_ALREADY_IN_USE);
                        }
                    }
                    catch (IOException)
                    {
                        throw new UnableToUseOEMException(this, UnableToUseOEMException.ErrorType.IO_EXCEPTION);
                    }
                    catch (UnauthorizedAccessException)
                    {
                        throw new UnableToUseOEMException(this, UnableToUseOEMException.ErrorType.UNAUTHORIZED_ACCESS_EXCEPTION);
                    }
                }
            }

            //Set the location of the new model in the exec settings file of the current oem in use


            //Close the currently running wtm if running
            if (runningVersion != null && this.ExecSetting.NeedsRestart)
            {
                if (!runningVersion.Close())
                {
                    throw new UnableToCloseWTMException(runningVersion);
                }
                else
                {
                    closedVersion = runningVersion;
                }
            }
            return(closedVersion);
        }