Exemple #1
0
        protected virtual void Dispose(bool disposing)
        {
            if (disposing)
            {
                _engine.Dispose();
            }

            Disposed?.Invoke(this, EventArgs.Empty);
        }
Exemple #2
0
#pragma warning disable CA1801 // Review unused parameters
        public static void Initialize(TestContext testContext)
        {
            try
            {
#if NETFX_CORE
                // Load Local Settings
                Settings.Load(@"Properties\TestSettings.json");
#endif
                //if (System.IO.File.Exists("Gala.Dolly.Command.config"))
                //    AppDomain.CurrentDomain.SetData("APP_CONFIG_FILE", "Gala.Dolly.Command.exe.config");

                Settings.Default.DebuggerLogLevel   = DebuggerLogLevel.Diagnostic;
                Settings.Default.DebuggerAlertLevel = DebuggerLogLevel.Message;
                #region Default Settings

                /*
                 * Properties.Settings.Default.ImagingSettings = new ImagingSettings
                 * {
                 *  Timeout = 2000,
                 *  SuppressTimeout = true,
                 *  ColorStatsSettings = new Galatea.AI.Imaging.Configuration.ColorStatsSettings
                 *  {
                 *      StatisticalAnalysisTypes = Galatea.AI.Math.StatsTypes.Mean
                 *  },
                 *  MonochromeBlobFilterSettings = new MonochromeBlobFilterSettings
                 *  {
                 *      ContrastCorrectionFactor = 0,
                 *      AdaptiveSmoothingFactor = 0.25,
                 *      FrameWidth = 10
                 *  },
                 *  BlobPointSettings = new BlobPointSettings
                 *  {
                 *      LineSegmentThreshold = 20,
                 *      LineAngleThreshold = 10,
                 *      CurveAngleThreshold = 27
                 *  },
                 *  TemplateRecognitionSettings = new TemplateRecognitionSettings
                 *  {
                 *      ColorBrightnessThreshold = 5,
                 *      ColorSaturationThreshold = 5,
                 *      ShapeOblongThreshold = 1.75M,
                 *      ShapeOblongRecognitionNormalization = true,
                 *      IdentifyShapeCertaintyMinimum = 65
                 *  }
                 * };
                 */
                #endregion
                Settings.Default.Save();

                // Suppress Timeout
                Settings.Default.ImagingSettings.Timeout = 2000;
                Settings.Default.ImagingSettings.DebugRecognitionSaveImages = true;
                Settings.Default.Save();

                Settings.Default.ImagingSettings.SuppressTimeout = true;

                // Initialize Runtime
                _user = new Galatea.Runtime.Services.User("Test");

                Settings.Default.DebuggerLogLevel = DebuggerLogLevel.Diagnostic;
                DebuggerLogLevelSettings.Initialize(Settings.Default.DebuggerLogLevel, Settings.Default.DebuggerAlertLevel);
                connectionString = Settings.Default.DataAccessManagerConnectionString;

                TestEngine engine   = null;
                IDebugger  debugger = null;
                SerializedDataAccessManager dataAccessManager = null;

                try
                {
                    debugger          = new TestDebugger();
                    dataAccessManager = new SerializedDataAccessManager(connectionString);

                    // Restore Data from backup file
                    FileInfo fi             = new FileInfo(connectionString);
                    string   backupFilename = Path.Combine(fi.DirectoryName, "SerializedData.V1.dat");
                    dataAccessManager.RestoreBackup(backupFilename);

                    // Initialize Engine
                    engine  = new TestEngine(debugger, dataAccessManager);
                    _engine = engine;

                    engine            = null;
                    debugger          = null;
                    dataAccessManager = null;
                }
                finally
                {
                    engine?.Dispose();
                    debugger?.Dispose();
                    dataAccessManager?.Dispose();
                }

                // Suppress Timeout
                Settings.Default.ImagingSettings.SuppressTimeout   = true;
                TestEngine.AI.LanguageModel.IsSpeechModuleInactive = true;

                _engine.User             = _user;
                _engine.StartupComplete += _engine_StartupComplete;
                _engine.Startup();

                _engine.ExecutiveFunctions.ContextRecognition += ExecutiveFunctions_ContextRecognition;
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
                System.Diagnostics.Debug.Write(ex.StackTrace);
                throw;
            }
        }