Beispiel #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);
 }
Beispiel #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);
     }
 }
Beispiel #3
0
 public OEMConfigFile(OEM oem)
     : base(Path.Combine(oem.Path, CONFIG_FILE_NAME))
 {
     if (Exists())
     {
         MigrateToLatestFormat();
     }
     else
     {
         CreateBlank();
     }
 }
Beispiel #4
0
        /// <summary>
        /// Gets the current model in use
        /// </summary>
        /// <returns></returns>
        public Model GetModelInUse()
        {
            Model model = null;

            try
            {
                WTMVersion version = this.IsRunning();
                if (version != null)
                {
                    OEM oem = version.GetOEMInUse();
                    oem.ExecSetting.Load(true);
                    model = oem.GetModelFromPath(oem.ExecSetting.PathLossFile);
                }
            }
            catch
            {
            }
            return(model);
        }
Beispiel #5
0
 /// <summary>
 /// Checks every 5 minutes for any test plan updates
 /// </summary>
 public void PeriodicallyCheckForTestPlanUpdates()
 {
     TestPlanUpdaterTimer.Enabled = false;
     try
     {
         WTMVersion runningVersion = IsRunning();
         if (runningVersion != null)
         {
             OEM oemInUse = runningVersion.GetOEMInUse();
             if (oemInUse != null && oemInUse.TestPlan != String.Empty)
             {
                 CheckForTestPlanUpdates(oemInUse);
             }
         }
     }
     catch (Exception ex)
     {
         Debug.Print("Periodically check for test plan updates exceptions: " + ex.ToString());
     }
     TestPlanUpdaterTimer.Enabled = true;
 }
Beispiel #6
0
        /// <summary>
        /// Makes the directory rename if needed and the changes in the exec settings file if needed
        /// </summary>
        /// <param name="model"></param>
        /// <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 void UseModel(Model model)
        {
            //Use OEM, a wtm close can happen
            OEM inUseOEM = model.OEM.Version.GetOEMInUse();

            if (inUseOEM != null && inUseOEM.Name != model.OEM.Name)
            {
                inUseOEM.Archive();
            }
            model.OEM.Use();
            if (ModelSelected != null)
            {
                ModelSelected(model);
            }

            //Check for the exec settings, the reload just happens if the wtm has been closed
            ExecSetting execSetting = model.OEM.ExecSetting;

            execSetting.Load();
            execSetting.ResetAllSettings();
            execSetting.PathLossFile = model.InUsePath;

            if (execSetting.ChangesNotSaved)
            {
                execSetting.Write();
            }

            WTMVersion runningVersion = IsRunning();

            if (execSetting.NeedsRestart && runningVersion != null)
            {
                Restart();
            }
            else
            {
                model.OEM.Version.Open();
            }
        }
Beispiel #7
0
        /// <summary>
        /// Updates the testplan
        /// </summary>
        /// <param name="oem"></param>
        public void UpdateTestPlan(OEM oem, string version)
        {
            WTMVersion runningVersion = this.IsRunning();

            try
            {
                string      remoteTargetTestPlan = Path.Combine(Path.GetDirectoryName(ONLINE_PLANS_DIRECTORY), Path.GetFileName(oem.TestPlan));
                string      localTargetTestPlan  = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), Path.GetFileName(oem.TestPlan));
                ExecSetting execSetting          = oem.ExecSetting;
                execSetting.Load();
                string database = (execSetting.Database.Length > 3)? Path.Combine(oem.ModelsPath, Path.GetFileName(execSetting.Database)):Path.Combine(oem.ModelsPath, Path.GetFileName(remoteTargetTestPlan));
                File.Copy(remoteTargetTestPlan, localTargetTestPlan, true);
                if (runningVersion != null)
                {
                    this.Close();
                }
                Thread.Sleep(2000);
                File.Copy(localTargetTestPlan, database, true);
                execSetting.Database = database;
                execSetting.Write();
                oem.TestPlanVersion = version;
                if (WTMTestPlanUpdatedSuccessfull != null)
                {
                    WTMTestPlanUpdatedSuccessfull(oem);
                }
            }
            catch (UnauthorizedAccessException ex)
            {
                if (WTMTestPlanUpdateError != null)
                {
                    WTMTestPlanUpdateError(WTMTestPlanUpdateErrorType.UNAUTHORIZED_ACCESS, ex);
                }
            }
            catch (DirectoryNotFoundException ex)
            {
                if (WTMTestPlanUpdateError != null)
                {
                    WTMTestPlanUpdateError(WTMTestPlanUpdateErrorType.DIRECTORY_NOT_FOUND, ex);
                }
            }
            catch (FileNotFoundException ex)
            {
                if (WTMTestPlanUpdateError != null)
                {
                    WTMTestPlanUpdateError(WTMTestPlanUpdateErrorType.FILE_NOT_FOUND, ex);
                }
            }
            catch (IOException ex)
            {
                if (WTMTestPlanUpdateError != null)
                {
                    WTMTestPlanUpdateError(WTMTestPlanUpdateErrorType.IO_EXCEPTION, ex);
                }
            }
            catch (Exception ex)
            {
                if (WTMTestPlanUpdateError != null)
                {
                    WTMTestPlanUpdateError(WTMTestPlanUpdateErrorType.UNKNOWN_ERROR, ex);
                }
            }
            if (runningVersion != null && IsRunning() == null)
            {
                runningVersion.Open();
            }
        }
Beispiel #8
0
        /// <summary>
        /// Checks for updates on the test plan
        /// </summary>
        /// <param name="oem"></param>
        public void CheckForTestPlanUpdates(OEM oem)
        {
            try
            {
                Process thisProc = Process.GetCurrentProcess();
                if (thisProc.ProcessName != "devenv")
                {
                    string localTestPlanLocation = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), Path.GetFileName(ONLINE_PLANS_DIRECTORY));

                    if (!File.Exists(localTestPlanLocation))
                    {
                        File.Copy(ONLINE_PLANS_DIRECTORY, localTestPlanLocation, true);
                    }
                    if (!FileVersionHandler.CompareVersions(localTestPlanLocation, ONLINE_PLANS_DIRECTORY))
                    {
                        File.Copy(ONLINE_PLANS_DIRECTORY, localTestPlanLocation, true);
                    }

                    PlansDirectory plansDirectory = PlansDirectory.GetInstance();
                    plansDirectory.UpdateDataFromFile(localTestPlanLocation);
                    ArrayList plans = plansDirectory.Plans;
                    foreach (Plan plan in plans)
                    {
                        if (plan.FileName == oem.TestPlan)
                        {
                            if (plan.Version != oem.TestPlanVersion)
                            {
                                UpdateTestPlan(oem, plan.Version);
                                if (WTMTestPlanUpdateCheckSuccessfull != null)
                                {
                                    WTMTestPlanUpdateCheckSuccessfull(oem);
                                }
                            }
                        }
                    }
                }
            }
            catch (FileNotFoundException ex)
            {
                if (WTMTestPlanCheckForUpdatesError != null)
                {
                    WTMTestPlanCheckForUpdatesError(WTMTestPlanCheckForUpdatesErrorType.FILE_NOT_FOUND, ex);
                }
            }
            catch (UnauthorizedAccessException ex)
            {
                if (WTMTestPlanCheckForUpdatesError != null)
                {
                    WTMTestPlanCheckForUpdatesError(WTMTestPlanCheckForUpdatesErrorType.UNAUTHORIZED_ACCESS, ex);
                }
            }
            catch (DirectoryNotFoundException ex)
            {
                if (WTMTestPlanCheckForUpdatesError != null)
                {
                    WTMTestPlanCheckForUpdatesError(WTMTestPlanCheckForUpdatesErrorType.DIRECTORY_NOT_FOUND, ex);
                }
            }
            catch (IOException ex)
            {
                if (WTMTestPlanCheckForUpdatesError != null)
                {
                    WTMTestPlanCheckForUpdatesError(WTMTestPlanCheckForUpdatesErrorType.IO_EXCEPTION, ex);
                }
            }
            catch (Exception ex)
            {
                if (WTMTestPlanCheckForUpdatesError != null)
                {
                    WTMTestPlanCheckForUpdatesError(WTMTestPlanCheckForUpdatesErrorType.UNKNOWN_ERROR, ex);
                }
            }
        }
Beispiel #9
0
 public UnableToArchiveOEMException(OEM oem, ErrorType error)
     : base()
 {
     this.OEM   = oem;
     this.Error = error;
 }
Beispiel #10
0
 public Model(string path, OEM oem)
 {
     this.path = path;
     this.oem  = oem;
 }