Example #1
0
        private void LoadProfile(string newProfilePath)
        {
            Trace("Lumberjack.LoadProfile");
            if (string.IsNullOrEmpty(newProfilePath))
            {
                return;
            }

            this.ui.Invoke(delegate
            {
                try
                {
                    LogProfile newProfile = LogProfile.Load(newProfilePath, this.database);
                    this.logger.SetProfile(newProfile);
                    this.Settings.LastProfilePath = newProfilePath;
                    this.Settings.Save();
                    Trace("Lumberjack.ContinueLoadProfile: setting ignore");
                    this.ignoreProfileSettingsChangeNotifications = true;
                    this.ShowNewProfileSettings();
                    this.ignoreProfileSettingsChangeNotifications = false;
                    Trace("Lumberjack.ContinueLoadProfile: clearing ignore");
                    this.ui.SetSaveButtonState(true);
                    this.currentProfileIsChanged = false;
                    this.SetTitle();
                    this.logger.StartLogging();
                }
                catch (Exception exception)
                {
                    Trace("Exception thrown during ContinueLoadProfile on UI thread");
                    Trace(exception.ToString());
                }
            });
        }
Example #2
0
        /// <summary>
        /// Second half of LoadSelectedProfile
        /// </summary>
        private void ContinueLoadSelectedProfile(IAsyncResult asyncResult)
        {
            Trace("Lumberjack.ContinueLoadSelectedProfile");
            string profilePath = (string)asyncResult.AsyncState;

            this.ui.Invoke(delegate
            {
                Trace("Lumberjack.ContinueLoadSelectedProfile (UI thread)");
                LogProfile profile;
                if (profilePath == null)
                {
                    Trace("Lumberjack.ContinueLoadSelectedProfile: creating trivial profile");
                    profile = LogProfile.CreateInstance();

/*                    foreach (SsmParameter parameter in this.logger.Database.Parameters)
 *                  {
 *                      // Add the RPM parameter and nothing else.
 *                      if (parameter.Id == "P8")
 *                      {
 *                          profile.Add(parameter, parameter.Conversions[0]);
 *                          break;
 *                      }
 *                  }
 */
                }
                else
                {
                    Trace("Lumberjack.ContinueLoadSelectedProfile: loading " + profilePath);
                    profile = LogProfile.Load(profilePath, this.database);
                }

                this.logger.SetProfile(profile);
                this.logger.StartLogging();
                this.Settings.LastProfilePath = profilePath;
                this.Settings.Save();

                this.ignoreProfileSettingsChangeNotifications = true;
                this.ui.ShowNewProfileSettings(this.logger.CurrentProfile);
                this.ui.SelectProfile(this.Settings.LastProfilePath);
                this.ignoreProfileSettingsChangeNotifications = false;

                this.currentProfileIsChanged = false;
                this.ui.SetSaveButtonState(true);
                this.SetTitle();
            });
        }
Example #3
0
        public void LogProfileSaveAndReload()
        {
            ParameterDatabase database = this.InitializeLogger();

            LogProfile expectedProfile = LogProfile.CreateInstance();

            foreach (SsmParameter parameter in database.Parameters)
            {
                expectedProfile.Add(parameter, parameter.Conversions[0]);
                if (expectedProfile.Columns.Count > 3)
                {
                    break;
                }
            }

            this.logger.SetProfile(expectedProfile, database);
            expectedProfile.Save("profile.xml");

            LogProfile emptyProfile = LogProfile.CreateInstance();

            this.logger.SetProfile(emptyProfile, database);

            LogProfile loadedProfile = LogProfile.Load("profile.xml", database);

            this.logger.SetProfile(loadedProfile, database);

            LogProfile actualProfile = this.logger.CurrentProfile;

            foreach (LogColumn column in actualProfile.Columns)
            {
                Assert.IsTrue(expectedProfile.Contains(column.Parameter));
            }

            foreach (LogColumn column in expectedProfile.Columns)
            {
                Assert.IsTrue(actualProfile.Contains(column.Parameter));
            }
        }