public TesseractEngine(string datapath, string language, EngineMode engineMode = EngineMode.Default)
        {
            DefaultPageSegMode = PageSegMode.Auto;
            handle = new HandleRef(this, Interop.TessApi.BaseApiCreate());

            Initialise(datapath, language, engineMode);
        }
Ejemplo n.º 2
0
        public TesseractEngine(string datapath, string language, EngineMode engineMode = EngineMode.Default)
        {
            DefaultPageSegMode = PageSegMode.Auto;
            Handle             = TesseractPrimitives.Api.BaseApiCreate();

            Initialise(datapath, language, engineMode);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Выставляем режим работы частотников
        /// </summary>
        /// <param name="mode"></param>
        public static bool SetMode(EngineMode mode)
        {
            switch (mode)
            {
            case EngineMode.Deactivate:
            {
                Mode = mode;

                // сбрасывааем скорость для режима ХОД
                mMotionSpeed.Update(0);
            }
            break;

            case EngineMode.Motion:
                //case EngineMode.Conveyor:
            {
                if (Mode == EngineMode.Deactivate)
                {
                    Mode = mode;
                }
            }
            break;
            }

            return(mode == Mode);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Creates a new instance of <see cref="TesseractEngine"/>.
        /// </summary>
        /// <remarks>
        /// <para>
        /// The <paramref name="datapath"/> parameter should point to the directory that contains the 'tessdata' folder
        /// for example if your tesseract language data is installed in <c>C:\Tesseract\tessdata</c> the value of datapath should
        /// be <c>C:\Tesseract</c>. Note that tesseract will use the value of the <c>TESSDATA_PREFIX</c> environment variable if defined,
        /// effectively ignoring the value of <paramref name="datapath"/> parameter.
        /// </para>
        /// </remarks>
        /// <param name="datapath">The path to the parent directory that contains the 'tessdata' directory, ignored if the <c>TESSDATA_PREFIX</c> environment variable is defined.</param>
        /// <param name="language">The language to load, for example 'eng' for English.</param>
        /// <param name="engineMode">The <see cref="EngineMode"/> value to use when initialising the tesseract engine.</param>
        public TesseractEngine(string datapath, string language, EngineMode engineMode = EngineMode.Default)
        {
            this.DefaultPageSegMode = PageSegMode.Auto;
            this.Handle             = new HandleRef(this, TessApi.Native.BaseApiCreate());

            this.Initialise(datapath, language, engineMode);
        }
Ejemplo n.º 5
0
        public static void Load(EngineMode mode)
        {
            Loader load = new Loader();
            string msg  = "";

            switch (mode)
            {
            case EngineMode.ServerAndClient:
                load.LoadAll(ref msg, new List <MagicalLifeAPI.Universal.IGameLoader>()
                {
                    new TextureLoader(),
                    new MainLoad()
                });
                break;

            case EngineMode.ServerOnly:
                load.LoadAll(ref msg, new List <MagicalLifeAPI.Universal.IGameLoader>()
                {
                    new TextureLoader(),
                    new ProtoTypeLoader(),
                    new MainLoad()
                });
                break;

            default:
                throw new Exception("Unexpected networking mode initiated!");
            }
        }
Ejemplo n.º 6
0
        public TesseractEngine(string dataPath, string language, EngineMode engineMode)
        {
            if (dataPath == null)
            {
                throw new ArgumentNullException(nameof(dataPath));
            }

            if (dataPath == string.Empty)
            {
                throw new ArgumentException("Data path is empty.", nameof(dataPath));
            }

            if (language == null)
            {
                throw new ArgumentNullException(nameof(language));
            }

            dataPath = dataPath.Trim();
            if (dataPath.EndsWith("\\", StringComparison.Ordinal) || dataPath.EndsWith("/", StringComparison.Ordinal))
            {
                dataPath = dataPath.Substring(0, dataPath.Length - 1);
            }

            _handle = new HandleRef(this, Tesseract4.TessBaseAPICreate());
            if (Tesseract4.TessBaseAPIInit2(_handle, dataPath, language, (int)engineMode) == 0)
            {
                return;
            }

            _handle = new HandleRef(this, IntPtr.Zero);
            GC.SuppressFinalize(this);

            throw new TesseractException("Failed to initialise tesseract engine.");
        }
 void ControlAirBreathing()
 {
     if (engineMode == EngineMode.LiftOff && vesselState.speedSurface > startBreathingSpeed)
     {
         engineMode = EngineMode.AirBreathing;
         ApplyEngineMode();
         //Debug.Log("AscentBreathingGT: switching to air breathing mode");
     }
     else if (engineMode == EngineMode.AirBreathing && vesselState.speedSurface > 1.2 * startBreathingSpeed && activeEngine.finalThrust < 0.15 * activeEngine.maxThrust)
     {
         engineMode = EngineMode.ClosedCycle;
         ApplyEngineMode();
         //Debug.Log("AscentBreathingGT: switching to closed cylce mode");
     }
     else if (engineMode == EngineMode.AirBreathing && otherThrottle > 0f && LocalTWR() > minTWRthrottle)
     {
         otherThrottle -= 0.5f;
         ApplyOtherThrottle();
     }
     else if (engineMode == EngineMode.AirBreathing && otherThrottle < 100f && LocalTWR() < minTWRthrottle)
     {
         otherThrottle += 0.5f;
         ApplyOtherThrottle();
     }
 }
Ejemplo n.º 8
0
        private SystemRecycledListener bootstrap(EngineMode mode)
        {
            var listener = new SystemRecycledListener(_messaging);

            copyStorytellerAssemblyIfNecessary();

            _domain = AppDomain.CreateDomain("Storyteller-SpecRunning-Domain", null, _remoteSetup.Setup);


            try
            {
                Type proxyType = typeof(RemoteProxy);
                _proxy = (RemoteProxy)_domain.CreateInstanceAndUnwrap(proxyType.Assembly.FullName, proxyType.FullName);

                _messaging.AddListener(listener);
                _proxy.Start(mode, _project, new RemoteListener(_messaging));
            }
            catch (Exception)
            {
                ConsoleWriter.Write(ConsoleColor.Yellow, "Storyteller was unable to start an AppDomain for the specification project. Check that the project has already been compiled.");

                throw;
            }



            return(listener);
        }
Ejemplo n.º 9
0
        private Engine CreateOcrEngine(BotData data, string lang, EngineMode engineMode)
        {
            if (!Directory.Exists(@".\tessdata"))
            {
                if (data != null)
                {
                    data.Status = BotStatus.ERROR;
                    data.Log(new LogEntry("tessdata not found!", Colors.Red));
                }
                throw new DirectoryNotFoundException("tessdata not found!");
            }

            if (!File.Exists($@".\tessdata\{lang}.traineddata"))
            {
                if (data != null)
                {
                    data.Status = BotStatus.ERROR;
                    data.Log(new LogEntry($"Language '{lang}' not found!", Colors.Red));
                }
                throw new FileNotFoundException($"Language '{lang}' not found!");
            }

            var engine = new Engine(
                new TesseractEngine(@".\tessdata", lang, engineMode),
                lang, engineMode);

            SetVariable(data, engine.Tesseract);

            return(engine);
        }
Ejemplo n.º 10
0
        public static void Load(EngineMode mode)
        {
            Loader load = new Loader();
            string msg  = "";

            switch (mode)
            {
            case EngineMode.ServerAndClient:
                load.LoadAll(ref msg, new List <IGameLoader>()
                {
                    new TextureLoader(),
                    new MainLoad()
                });
                break;

            case EngineMode.ServerOnly:
                SettingsManager.Initialize();

                load.LoadAll(ref msg, new List <IGameLoader>()
                {
                    new ItemLoader(),
                    new TextureLoader(),
                    new ProtoTypeLoader(),
                    new MainLoad()
                });
                break;

            default:
                throw new UnexpectedEnumMemberException();
            }
        }
Ejemplo n.º 11
0
        public TesseractEngine(string datapath, string language, EngineMode engineMode = EngineMode.Default)
        {
            DefaultPageSegMode = PageSegMode.Auto;
            handle             = new HandleRef(this, Interop.TessApi.BaseApiCreate());

            Initialise(datapath, language, engineMode);
        }
Ejemplo n.º 12
0
        /// <summary>
        /// sets engine into <see cref="VelocityMode"/>
        /// </summary>
        /// <returns>bool that indicates, if operation was successful</returns>
        private bool ActivateVelocityMode()
        {
            //if engine is not in VelocityMode, set VelocityMode
            if (_engineMode == EngineMode.Velocity)
            {
                return(false);
            }

            //set VelocityMode for both motors seperately
            _pvm1.ActivateProfileVelocityMode();
            _pvm2.ActivateProfileVelocityMode();

            //PositionProfile is only set, when acceleration and deceleration are not 0
            if (ProfileAcceleration != 0 && ProfileDeceleration != 0)
            {
                _pvm1.SetVelocityProfile(ProfileAcceleration, ProfileDeceleration);
                _pvm2.SetVelocityProfile(ProfileAcceleration, ProfileDeceleration);
            }

            //set state machine to EngineMode.VELOCITY
            _engineMode = EngineMode.Velocity;

            //returns true, if ActivateVelocityMode() was successful
            return(true);
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Опускаем скорость на одну ступеньку
        /// </summary>
        /// <param name="mode"></param>
        public static void SpeedDown(EngineMode mode)
        {
            switch (mode)
            {
            case EngineMode.Motion:
            {
                if (mMotionSpeed.Value > 0)
                {
                    mMotionSpeed.Update(mMotionSpeed.Value - 1);
                }
            }
            break;

                /*
                 * case EngineMode.Conveyor:
                 *  {
                 *      if (mConveyorSpeed.Value > 0)
                 *          mConveyorSpeed.Update(mConveyorSpeed.Value - 1);
                 *  }
                 *  break;
                 */
            }

            mJournal.Debug(string.Format("Снижена скорость: {0}:{1}", mode, mode == EngineMode.Motion ? mMotionSpeed.ValueAsInt : mConveyorSpeed.ValueAsInt), MessageLevel.System);
        }
Ejemplo n.º 14
0
        private void Initialise(string datapath, string language, EngineMode engineMode, IEnumerable <string> configFiles, IDictionary <string, object> initialValues, bool setOnlyNonDebugVariables)
        {
            const string TessDataDirectory = "tessdata";

            Guard.RequireNotNullOrEmpty("language", language);

            // do some minor processing on datapath to fix some common errors (this basically mirrors what tesseract does as of 3.04)
            if (!String.IsNullOrEmpty(datapath))
            {
                // remove any excess whitespace
                datapath = datapath.Trim();

                // remove any trialing '\' or '/' characters
                if (datapath.EndsWith("\\", StringComparison.Ordinal) || datapath.EndsWith("/", StringComparison.Ordinal))
                {
                    datapath = datapath.Substring(0, datapath.Length - 1);
                }
                // remove 'tessdata', if it exists, tesseract will add it when building up the tesseract path
                if (datapath.EndsWith("tessdata", StringComparison.OrdinalIgnoreCase))
                {
                    datapath = datapath.Substring(0, datapath.Length - TessDataDirectory.Length);
                }
            }

            if (Interop.TessApi.BaseApiInit(handle, datapath, language, (int)engineMode, configFiles ?? new List <string>(), initialValues ?? new Dictionary <string, object>(), setOnlyNonDebugVariables) != 0)
            {
                // Special case logic to handle cleaning up as init has already released the handle if it fails.
                handle = new HandleRef(this, IntPtr.Zero);
                GC.SuppressFinalize(this);

                throw new TesseractException(ErrorMessage.Format(1, "Failed to initialise tesseract engine."));
            }
        }
Ejemplo n.º 15
0
        internal AsynchronousContext(
            int threadId,
            EngineMode engineMode,
            Interpreter interpreter,
            string text,
            EngineFlags engineFlags,
            SubstitutionFlags substitutionFlags,
            EventFlags eventFlags,
            ExpressionFlags expressionFlags,
            AsynchronousCallback callback,
            IClientData clientData
            )
        {
            this.threadId = threadId;

            this.engineMode        = engineMode;
            this.interpreter       = interpreter;
            this.text              = text;
            this.engineFlags       = engineFlags;
            this.substitutionFlags = substitutionFlags;
            this.eventFlags        = eventFlags;
            this.expressionFlags   = expressionFlags;
            this.callback          = callback;
            this.clientData        = clientData;
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Creates a new instance of <see cref="TesseractEngine"/> with the specified <paramref name="engineMode"/> and <paramref name="configFiles"/>.
        /// </summary>
        /// <remarks>
        /// <para>
        /// The <paramref name="datapath"/> parameter should point to the directory that contains the 'tessdata' folder
        /// for example if your tesseract language data is installed in <c>C:\Tesseract\tessdata</c> the value of datapath should
        /// be <c>C:\Tesseract</c>. Note that tesseract will use the value of the <c>TESSDATA_PREFIX</c> environment variable if defined,
        /// effectively ignoring the value of <paramref name="datapath"/> parameter.
        /// </para>
        /// </remarks>
        /// <param name="datapath">The path to the parent directory that contains the 'tessdata' directory, ignored if the <c>TESSDATA_PREFIX</c> environment variable is defined.</param>
        /// <param name="language">The language to load, for example 'eng' for English.</param>
        /// <param name="engineMode">The <see cref="EngineMode"/> value to use when initialising the tesseract engine.</param>
        /// <param name="configFiles">
        /// An optional sequence of tesseract configuration files to load, encoded using UTF8 without BOM
        /// with Unix end of line characters you can use an advanced text editor such as Notepad++ to accomplish this.
        /// </param>
        public TesseractEngine(string datapath, string language, EngineMode engineMode, IEnumerable <string> configFiles)
        {
            DefaultPageSegMode = PageSegMode.Auto;
            handle             = new HandleRef(this, Interop.TessApi.Native.BaseApiCreate());

            Initialise(datapath, language, engineMode, configFiles);
        }
Ejemplo n.º 17
0
        ///////////////////////////////////////////////////////////////////////

        public static IScript Create(
            string name,
            string group,
            string description,
            string type,
            string text,
            string fileName,
            int startLine,
            int endLine,
            bool viaSource,
            DateTime timeStamp,
            EngineMode engineMode,
            ScriptFlags scriptFlags,
            EngineFlags engineFlags,
            SubstitutionFlags substitutionFlags,
            EventFlags eventFlags,
            ExpressionFlags expressionFlags,
            IClientData clientData
            )
        {
            return(PrivateCreate(
                       Guid.Empty, name, group, description, type, text, fileName,
                       startLine, endLine, viaSource,
#if XML
                       XmlBlockType.None, timeStamp, null, null,
#endif
                       engineMode, scriptFlags, engineFlags, substitutionFlags,
                       eventFlags, expressionFlags, clientData));
        }
Ejemplo n.º 18
0
        public TesseractTransformer(string dataPath, EngineMode mode)
        {
            Guard.AssertNotNull(dataPath, nameof(dataPath));

            _dataPath = dataPath;
            _mode     = mode;
        }
Ejemplo n.º 19
0
        public Config()
        {
            _blockLength = 10240;
            _engineMode = EngineMode.Parallel;
            _degreeOfParalellism = Environment.ProcessorCount;;

            _bufferSize = _blockLength*10240;
        }
Ejemplo n.º 20
0
        /// <summary>
        /// Creates a new instance of <see cref="TesseractEngine"/> with the specified <paramref name="engineMode"/> and <paramref name="configFiles"/>.
        /// </summary>
        /// <remarks>
        /// <para>
        /// The <paramref name="datapath"/> parameter should point to the directory that contains the 'tessdata' folder
        /// for example if your tesseract language data is installed in <c>C:\Tesseract\tessdata</c> the value of datapath should
        /// be <c>C:\Tesseract</c>. Note that tesseract will use the value of the <c>TESSDATA_PREFIX</c> environment variable if defined,
        /// effectively ignoring the value of <paramref name="datapath"/> parameter.
        /// </para>
        /// </remarks>
        /// <param name="datapath">The path to the parent directory that contains the 'tessdata' directory, ignored if the <c>TESSDATA_PREFIX</c> environment variable is defined.</param>
        /// <param name="language">The language to load, for example 'eng' for English.</param>
        /// <param name="engineMode">The <see cref="EngineMode"/> value to use when initialising the tesseract engine.</param>
        /// <param name="configFiles">
        /// An optional sequence of tesseract configuration files to load, encoded using UTF8 without BOM
        /// with Unix end of line characters you can use an advanced text editor such as Notepad++ to accomplish this.
        /// </param>
        public TesseractEngine(string datapath, string language, EngineMode engineMode, IEnumerable <string> configFiles, IDictionary <string, object> initialOptions, bool setOnlyNonDebugVariables)
        {
            Guard.RequireNotNullOrEmpty("language", language);

            DefaultPageSegMode = PageSegMode.Auto;
            handle             = new HandleRef(this, Interop.TessApi.Native.BaseApiCreate());

            Initialise(datapath, language, engineMode, configFiles, initialOptions, setOnlyNonDebugVariables);
        }
Ejemplo n.º 21
0
        public ProjectInput(EngineMode mode)
        {
            _mode = mode;

#if NET46
            Path = Environment.CurrentDirectory;
#else
            Path = Directory.GetCurrentDirectory();
#endif
        }
Ejemplo n.º 22
0
        public static void Initialize(NetworkSettings networkSettings)
        {
            Local = networkSettings.Mode;

            if (Local == EngineMode.ServerAndClient || Local == EngineMode.ServerOnly)
            {
                TCPServer = new TCPServer();
                TCPServer.Start(networkSettings.Port);
            }
        }
Ejemplo n.º 23
0
        public ProjectInput(EngineMode mode)
        {
            _mode = mode;

#if NET46
            Path = Environment.CurrentDirectory;
#else
            Path = Directory.GetCurrentDirectory();
#endif
        }
Ejemplo n.º 24
0
        private void Initialise(string datapath, string language, EngineMode engineMode)
        {
            if (Interop.TessApi.BaseApiInit(handle, datapath, language, (int)engineMode, IntPtr.Zero, 0, IntPtr.Zero, 0, IntPtr.Zero, 0) != 0)
            {
                // Special case logic to handle cleaning up as init has already released the handle if it fails.
                handle = new HandleRef(this, IntPtr.Zero);
                GC.SuppressFinalize(this);

                throw new TesseractException(ErrorMessage.Format(1, "Failed to initialise tesseract engine."));
            }
        }
Ejemplo n.º 25
0
        private void Initialise(string datapath, string language, EngineMode engineMode)
        {
            if (TesseractPrimitives.Api.BaseApiInit(this, datapath, language, (int)engineMode, IntPtr.Zero, 0, IntPtr.Zero, 0, IntPtr.Zero, 0) != 0)
            {
                // Special case logic to handle cleaning up as init has already released the handle if it fails.
                Handle = IntPtr.Zero;
                GC.SuppressFinalize(this);

                throw new TesseractException("Failed to initialise tesseract engine.");
            }
        }
Ejemplo n.º 26
0
        /// <summary>
        /// Fires up the engine. And then it makes noise.
        /// </summary>
        public static void Start(EngineMode engineMode)
        {
#if DEBUG
            IsDebug = true;
#endif
            AppId = 480;
            Mode  = engineMode;

            LogService.ConfigureLoggers();

            Process      = Process.GetCurrentProcess();
            PlatformId   = PlatformId.Windows;
            PlatformType = PlatformType.Desktop;

            TempPath = Path.Combine(Path.GetTempPath(), "dEngine");
            if (Directory.Exists(TempPath))
            {
                ContentProvider.DeleteDirectory(TempPath);
            }
            // otherwise DeleteDirectory won't get called when stop debugging in VS.
            Directory.CreateDirectory(TempPath);

            Logger.Info("Log opened.");
            Logger.Info($"Command line args: {string.Join(" ", Environment.GetCommandLineArgs().Skip(1))})");
            Logger.Info($"Base directory: {Environment.CurrentDirectory}");

            Logger.Info($"Engine mode: {engineMode}");
            Logger.Info($"Graphics mode: {RenderSettings.GraphicsMode}");

            Logger.Info($"User: {Environment.UserName} on {Environment.MachineName}");
            Logger.Info($"CPU: {DebugSettings.CpuName} ({Environment.ProcessorCount} processors)");
            Logger.Info($"Memory: {((long)new ComputerInfo().TotalPhysicalMemory).ToPrettySize()}");

            CancelTokenSource = new CancellationTokenSource();

            Inst.Init();

            Logger.Info("Starting GraphicsThread...");
            StartThread(nameof(GraphicsThread), GraphicsThread.Start);
            GraphicsThread.Wait();
            Logger.Info("GraphicsThread started.");

            Logger.Info("Starting AudioThread...");
            StartThread(nameof(AudioThread), AudioThread.Start);
            AudioThread.Wait();
            Logger.Info("AudioThread started.");

            Logger.Info("Starting GameThread...");
            StartThread(nameof(GameThread), GameThread.Start);
            GameThread.Wait();
            Logger.Info("GameThread started.");

            AppDomain.CurrentDomain.ProcessExit += (s, e) => Shutdown(0);
        }
Ejemplo n.º 27
0
 internal Engine8(EngineMode mode, Host host, int audioDeviceIndex)
 {
     IsPaused  = false;
     IsLooping = false;
     IsRunning = false;
     _runLock  = new object();
     _useSequencePluginData = false;
     AudioSpeed             = 1f;
     _isLoggingEnabled      = false;
     _isStopping            = false;
     ConstructUsing(mode, host, audioDeviceIndex);
 }
Ejemplo n.º 28
0
 internal Engine8(EngineMode mode, Host host, int audioDeviceIndex)
 {
     IsPaused = false;
     IsLooping = false;
     IsRunning = false;
     _runLock = new object();
     _useSequencePluginData = false;
     AudioSpeed = 1f;
     _isLoggingEnabled = false;
     _isStopping = false;
     ConstructUsing(mode, host, audioDeviceIndex);
 }
Ejemplo n.º 29
0
        public void Start(EngineMode mode, Project project, MarshalByRefObject remoteListener)
        {
            Project.CurrentProject = project;

            EventAggregator.Start((IRemoteListener) remoteListener);

            _project = project;

            Type systemType = null;

            try
            {
                systemType = _project.DetermineSystemType();
                _system = Activator.CreateInstance(systemType).As<ISystem>();
                _services.Add(_system);

                var timeZone = new MachineTimeZoneContext();
                var clock = new Clock();
                var systemTime = new SystemTime(clock, timeZone);
                _specExpiration = new SpecExpiration(systemTime);

                if (mode == EngineMode.Interactive)
                {
                    _engine = buildUserInterfaceEngine();
                }
                else
                {
                    _engine = buildBatchedEngine(project.TracingStyle);
                }

                _engine.Start(project.StopConditions);

            }
            catch (Exception e)
            {
                var message = new SystemRecycled
                {
                    error = e.ToString(),
                    success = false,
                };

                if (systemType != null)
                {
                    message.system_name = systemType.AssemblyQualifiedName;
                }

                EventAggregator.SendMessage(message);
            }

            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
            AppDomain.CurrentDomain.DomainUnload += CurrentDomainOnDomainUnload;
        }
Ejemplo n.º 30
0
        public void Start(EngineMode mode, Project project, MarshalByRefObject remoteListener)
        {
            Project.CurrentProject = project;

            EventAggregator.Start((IRemoteListener)remoteListener);

            _project = project;

            Type systemType = null;

            try
            {
                systemType = _project.DetermineSystemType();
                _system    = Activator.CreateInstance(systemType).As <ISystem>();
                _services.Add(_system);

                var timeZone   = new MachineTimeZoneContext();
                var clock      = new Clock();
                var systemTime = new SystemTime(clock, timeZone);
                _specExpiration = new SpecExpiration(systemTime);

                if (mode == EngineMode.Interactive)
                {
                    _engine = buildUserInterfaceEngine();
                }
                else
                {
                    _engine = buildBatchedEngine(project.TracingStyle);
                }


                _engine.Start(project.StopConditions);
            }
            catch (Exception e)
            {
                var message = new SystemRecycled
                {
                    error   = e.ToString(),
                    success = false,
                };

                if (systemType != null)
                {
                    message.system_name = systemType.AssemblyQualifiedName;
                }

                EventAggregator.SendMessage(message);
            }

            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
            AppDomain.CurrentDomain.DomainUnload       += CurrentDomainOnDomainUnload;
        }
Ejemplo n.º 31
0
        public static void Speed4(EngineMode mode)
        {
            switch (mode)
            {
            case EngineMode.Motion:
            {
                mMotionSpeed.Update(3);
            }
            break;
            }

            mJournal.Debug(string.Format("Установлена скорость: {0}:{1}", mode, mode == EngineMode.Motion ? mMotionSpeed.ValueAsInt : mConveyorSpeed.ValueAsInt), MessageLevel.System);
        }
        public ITesseractEngine Create(string dataPath, string language, EngineMode engineMode)
        {
            if (dataPath == null)
            {
                throw new ArgumentNullException(nameof(dataPath));
            }

            if (language == null)
            {
                throw new ArgumentNullException(nameof(language));
            }

            return(new TesseractEngine(dataPath, language, engineMode));
        }
Ejemplo n.º 33
0
 public EngineOptions(EngineOptions src)
 {
     KOTHFormat = src.KOTHFormat;
     Permutate = src.Permutate;
     SortResults = src.SortResults;
     DumpResults = src.DumpResults;
     StatusLine = src.StatusLine;
     Random = src.Random;
     InitRoundBefore = src.InitRoundBefore;
     Brake = src.Brake;
     EngineMode = src.EngineMode;
     EngineMode = src.EngineMode;
     if (src.ForcedAddresses!=null)
         ForcedAddresses = new List<int>(src.ForcedAddresses);
 }
Ejemplo n.º 34
0
        public Task <SystemRecycled> Start(EngineMode mode)
        {
            _mode = mode;

            var listener = bootstrap(mode);


            return(listener.Task.ContinueWith(x =>
            {
                _watcher = new AppDomainFileChangeWatcher(Recycle);
                _watcher.WatchBinariesAt(_path.AppendPath("bin"));

                LatestSystemRecycled = x.Result;

                return x.Result;
            }));
        }
Ejemplo n.º 35
0
        public OcrEngineMgr(string dataPath, string language, EngineMode mode, int nbInstances)
        {
            config = new EngineConfig()
            {
                DataPath = dataPath,
                Language = language,
                Mode     = mode
            };

            AllowCreateNewEngines = false;
            nbInstances           = Math.Max(1, nbInstances);
            engines = new ConcurrentDictionary <TesseractEngine, bool>();
            for (int i = 0; i < nbInstances; i++)
            {
                CreateEngine();
            }
        }
Ejemplo n.º 36
0
        public TesseractEngine(string dataPath, string language, EngineMode engineMode)
        {
            if (dataPath == null)
            {
                throw new ArgumentNullException(nameof(dataPath));
            }

            if (dataPath == string.Empty)
            {
                throw new ArgumentException("Data path is empty.", nameof(dataPath));
            }

            if (language == null)
            {
                throw new ArgumentNullException(nameof(language));
            }

            dataPath = dataPath.Trim();
            if (dataPath.EndsWith("\\", StringComparison.Ordinal) || dataPath.EndsWith("/", StringComparison.Ordinal))
            {
                dataPath = dataPath.Substring(0, dataPath.Length - 1);
            }

            if (!Directory.Exists(dataPath))
            {
                if (Debugger.IsAttached)
                {
                    dataPath = Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly()?.Location) ?? Directory.GetCurrentDirectory(), dataPath);
                }
                else
                {
                    throw new TesseractException($"Tesseract data path does not exists. Current directory: {Directory.GetCurrentDirectory()}. Supplied data path: {dataPath}.");
                }
            }

            _handle = new HandleRef(this, Tesseract4.TessBaseAPICreate());
            if (Tesseract4.TessBaseAPIInit2(_handle, dataPath, language, (int)engineMode) == 0)
            {
                return;
            }

            _handle = new HandleRef(this, IntPtr.Zero);
            GC.SuppressFinalize(this);

            throw new TesseractException("Failed to initialise tesseract engine.");
        }
Ejemplo n.º 37
0
        /// <summary>
        /// Creates a new instance of <see cref="TesseractEngine"/> with the specified <paramref name="engineMode"/> and <paramref name="configFiles"/>.
        /// </summary>
        /// <remarks>
        /// <para>
        /// The <paramref name="datapath"/> parameter should point to the directory that contains the 'tessdata' folder
        /// for example if your tesseract language data is installed in <c>C:\Tesseract\tessdata</c> the value of datapath should
        /// be <c>C:\Tesseract</c>. Note that tesseract will use the value of the <c>TESSDATA_PREFIX</c> environment variable if defined,
        /// effectively ignoring the value of <paramref name="datapath"/> parameter.
        /// </para>
        /// </remarks>
        /// <param name="datapath">The path to the parent directory that contains the 'tessdata' directory, ignored if the <c>TESSDATA_PREFIX</c> environment variable is defined.</param>
        /// <param name="language">The language to load, for example 'eng' for English.</param>
        /// <param name="engineMode">The <see cref="EngineMode"/> value to use when initialising the tesseract engine.</param>
        /// <param name="configFiles">
        /// An optional sequence of tesseract configuration files to load, encoded using UTF8 without BOM
        /// with Unix end of line characters you can use an advanced text editor such as Notepad++ to accomplish this.
        /// </param>
        public TesseractEngine(string datapath, string language, EngineMode engineMode, IEnumerable<string> configFiles, IDictionary<string, object> initialOptions, bool setOnlyNonDebugVariables)
        {
            Guard.RequireNotNullOrEmpty("language", language);

            DefaultPageSegMode = PageSegMode.Auto;
            handle = new HandleRef(this, Interop.TessApi.Native.BaseApiCreate());

            Initialise(datapath, language, engineMode, configFiles, initialOptions, setOnlyNonDebugVariables);
        }
Ejemplo n.º 38
0
        private void Initialise(string datapath, string language, EngineMode engineMode)
        {
            if (Interop.TessApi.BaseApiInit(handle, datapath, language, (int)engineMode, IntPtr.Zero, 0, IntPtr.Zero, 0, IntPtr.Zero, 0) != 0)
            {
                // Special case logic to handle cleaning up as init has already released the handle if it fails.
                handle = new HandleRef(this, IntPtr.Zero);
                GC.SuppressFinalize(this);

                throw new TesseractException(ErrorMessage.Format(1, "Failed to initialise tesseract engine."));
            }
        }
Ejemplo n.º 39
0
 public EngineModeChangedEventArgs(EngineMode s) {
     Mode = s;
 }
Ejemplo n.º 40
0
 private void ConstructUsing(EngineMode mode, Host host, int audioDeviceIndex)
 {
     Mode = mode;
     _host = host;
     _plugInRouter = Host.Router;
     if (mode == EngineMode.Synchronous) {
         _eventTimer = new Timer(1.0);
         _eventTimer.Elapsed += EventTimerElapsed;
         _fmod = fmod.GetInstance(audioDeviceIndex);
     }
     else {
         _eventTimer = null;
         _fmod = null;
     }
     _engineContext = new EngineContext();
     InstanceList.Add(this);
 }
Ejemplo n.º 41
0
 /// <summary>
 /// Creates a new instance of <see cref="TesseractEngine"/> with the specified <paramref name="engineMode"/> and <paramref name="configFile"/>.
 /// </summary>
 /// <remarks>
 /// <para>
 /// The <paramref name="datapath"/> parameter should point to the directory that contains the 'tessdata' folder
 /// for example if your tesseract language data is installed in <c>C:\Tesseract\tessdata</c> the value of datapath should
 /// be <c>C:\Tesseract</c>. Note that tesseract will use the value of the <c>TESSDATA_PREFIX</c> environment variable if defined,
 /// effectively ignoring the value of <paramref name="datapath"/> parameter.
 /// </para>
 /// <para>
 /// Note: That the config files MUST be encoded without the BOM using unix end of line characters.
 /// </para>
 /// </remarks>
 /// <param name="datapath">The path to the parent directory that contains the 'tessdata' directory, ignored if the <c>TESSDATA_PREFIX</c> environment variable is defined.</param>
 /// <param name="language">The language to load, for example 'eng' for English.</param>
 /// <param name="engineMode">The <see cref="EngineMode"/> value to use when initialising the tesseract engine.</param>
 /// <param name="configFile">
 /// An optional tesseract configuration file that is encoded using UTF8 without BOM
 /// with Unix end of line characters you can use an advanced text editor such as Notepad++ to accomplish this.
 /// </param>
 public TesseractEngine(string datapath, string language, EngineMode engineMode, string configFile)
     : this(datapath, language, engineMode, configFile != null ? new[] { configFile } : new string[0], new Dictionary<string, object>(), false)
 {
 }
Ejemplo n.º 42
0
 /// <summary>
 /// Creates a new instance of <see cref="TesseractEngine"/> with the specified <paramref name="engineMode"/>.
 /// </summary>
 /// <remarks>
 /// <para>
 /// The <paramref name="datapath"/> parameter should point to the directory that contains the 'tessdata' folder
 /// for example if your tesseract language data is installed in <c>C:\Tesseract\tessdata</c> the value of datapath should
 /// be <c>C:\Tesseract</c>. Note that tesseract will use the value of the <c>TESSDATA_PREFIX</c> environment variable if defined,
 /// effectively ignoring the value of <paramref name="datapath"/> parameter.
 /// </para>
 /// </remarks>
 /// <param name="datapath">The path to the parent directory that contains the 'tessdata' directory, ignored if the <c>TESSDATA_PREFIX</c> environment variable is defined.</param>
 /// <param name="language">The language to load, for example 'eng' for English.</param>
 /// <param name="engineMode">The <see cref="EngineMode"/> value to use when initialising the tesseract engine.</param>
 public TesseractEngine(string datapath, string language, EngineMode engineMode)
     : this(datapath, language, engineMode, new string[0], new Dictionary<string, object>(), false)
 {
 }
Ejemplo n.º 43
0
		void Initialise(string datapath, string language, EngineMode engineMode)
		{
			const string TessDataDirectory = "tessdata";
			Guard.RequireNotNullOrEmpty("language", language);
					
			
			// do some minor processing on datapath to fix some common errors (this basically mirrors what tesseract does as of 3.02)
			if(!String.IsNullOrEmpty(datapath)) {
				// remove any trialing '\' or '/' characters
				if(datapath.EndsWith("\\", StringComparison.Ordinal) || datapath.EndsWith("/", StringComparison.Ordinal)) {
					datapath = datapath.Substring(0, datapath.Length-1);
				}
				// remove 'tessdata', if it exists, tesseract will add it when building up the tesseract path
				if(datapath.EndsWith("tessdata", StringComparison.OrdinalIgnoreCase)) {
					datapath = datapath.Substring(0, datapath.Length - TessDataDirectory.Length);
				}
			} 
			
			// log a warning if TESSDATA_PREFIX is set			
			var tessDataPrefix = GetTessDataPrefix();
			if(tessDataPrefix != null) {
				trace.TraceEvent(TraceEventType.Warning, 0, "Detected that the environment variable 'TESSDATA_PREFIX' is set to '{0}', this will be used as the data directory by tesseract.", tessDataPrefix);
			}

            if (Interop.TessApi.Native.BaseApiInit(handle, datapath, language, (int)engineMode, IntPtr.Zero, 0, IntPtr.Zero, 0, IntPtr.Zero, 0) != 0)
            {
				// Special case logic to handle cleaning up as init has already released the handle if it fails.
				handle = new HandleRef(this, IntPtr.Zero);
				GC.SuppressFinalize(this);
				
				throw new TesseractException(ErrorMessage.Format(1, "Failed to initialise tesseract engine."));
			}
		}
        /// <summary>
        /// Creates a new instance of <see cref="TesseractEngine"/> with the specified <paramref name="engineMode"/> and <paramref name="configFiles"/>.
        /// </summary>
        /// <remarks>
        /// <para>
        /// The <paramref name="datapath"/> parameter should point to the directory that contains the 'tessdata' folder
        /// for example if your tesseract language data is installed in <c>C:\Tesseract\tessdata</c> the value of datapath should
        /// be <c>C:\Tesseract</c>. Note that tesseract will use the value of the <c>TESSDATA_PREFIX</c> environment variable if defined,
        /// effectively ignoring the value of <paramref name="datapath"/> parameter.
        /// </para>
        /// </remarks>
        /// <param name="datapath">The path to the parent directory that contains the 'tessdata' directory, ignored if the <c>TESSDATA_PREFIX</c> environment variable is defined.</param>
        /// <param name="language">The language to load, for example 'eng' for English.</param>
        /// <param name="engineMode">The <see cref="EngineMode"/> value to use when initialising the tesseract engine.</param>
        /// <param name="configFiles">
        /// An optional sequence of tesseract configuration files to load, encoded using UTF8 without BOM
        /// with Unix end of line characters you can use an advanced text editor such as Notepad++ to accomplish this.
        /// </param>
        public TesseractEngine(string datapath, string language, EngineMode engineMode, IEnumerable<string> configFiles)
        {
            DefaultPageSegMode = PageSegMode.Auto;
            handle = new HandleRef(this, Interop.TessApi.Native.BaseApiCreate());

            Initialise(datapath, language, engineMode, configFiles);
        }
Ejemplo n.º 45
0
        private void Initialise(string datapath, string language, EngineMode engineMode, IEnumerable<string> configFiles, IDictionary<string, object> initialValues, bool setOnlyNonDebugVariables)
        {
            const string TessDataDirectory = "tessdata";
            Guard.RequireNotNullOrEmpty("language", language);

            // do some minor processing on datapath to fix some common errors (this basically mirrors what tesseract does as of 3.04)
            if (!String.IsNullOrEmpty(datapath)) {
                // remove any excess whitespace
                datapath = datapath.Trim();

                // remove any trialing '\' or '/' characters
                if (datapath.EndsWith("\\", StringComparison.Ordinal) || datapath.EndsWith("/", StringComparison.Ordinal)) {
                    datapath = datapath.Substring(0, datapath.Length - 1);
                }
                // remove 'tessdata', if it exists, tesseract will add it when building up the tesseract path
                if (datapath.EndsWith("tessdata", StringComparison.OrdinalIgnoreCase)) {
                    datapath = datapath.Substring(0, datapath.Length - TessDataDirectory.Length);
                }
            }

            if (Interop.TessApi.BaseApiInit(handle, datapath, language, (int)engineMode, configFiles ?? new List<string>(), initialValues ?? new Dictionary<string, object>(), setOnlyNonDebugVariables) != 0) {
                // Special case logic to handle cleaning up as init has already released the handle if it fails.
                handle = new HandleRef(this, IntPtr.Zero);
                GC.SuppressFinalize(this);

                throw new TesseractException(ErrorMessage.Format(1, "Failed to initialise tesseract engine."));
            }
        }
 /// <summary>
 /// Creates a new instance of <see cref="TesseractEngine"/> with the specified <paramref name="engineMode"/> and <paramref name="configFile"/>.
 /// </summary>
 /// <remarks>
 /// <para>
 /// The <paramref name="datapath"/> parameter should point to the directory that contains the 'tessdata' folder
 /// for example if your tesseract language data is installed in <c>C:\Tesseract\tessdata</c> the value of datapath should
 /// be <c>C:\Tesseract</c>. Note that tesseract will use the value of the <c>TESSDATA_PREFIX</c> environment variable if defined,
 /// effectively ignoring the value of <paramref name="datapath"/> parameter.
 /// </para>
 /// <para>
 /// Note: That the config files MUST be encoded without the BOM using unix end of line characters.
 /// </para>
 /// </remarks>
 /// <param name="datapath">The path to the parent directory that contains the 'tessdata' directory, ignored if the <c>TESSDATA_PREFIX</c> environment variable is defined.</param>
 /// <param name="language">The language to load, for example 'eng' for English.</param>
 /// <param name="engineMode">The <see cref="EngineMode"/> value to use when initialising the tesseract engine.</param>
 /// <param name="configFile">
 /// An optional tesseract configuration file that is encoded using UTF8 without BOM
 /// with Unix end of line characters you can use an advanced text editor such as Notepad++ to accomplish this.
 /// </param>
 public TesseractEngine(string datapath, string language, EngineMode engineMode, string configFile)
     : this(datapath, language, engineMode, configFile != null ? new [] { configFile } : new string[0])
 {
 }
 /// <summary>
 /// Creates a new instance of <see cref="TesseractEngine"/> with the specified <paramref name="engineMode"/>.
 /// </summary>
 /// <remarks>
 /// <para>
 /// The <paramref name="datapath"/> parameter should point to the directory that contains the 'tessdata' folder
 /// for example if your tesseract language data is installed in <c>C:\Tesseract\tessdata</c> the value of datapath should
 /// be <c>C:\Tesseract</c>. Note that tesseract will use the value of the <c>TESSDATA_PREFIX</c> environment variable if defined,
 /// effectively ignoring the value of <paramref name="datapath"/> parameter.
 /// </para>
 /// </remarks>
 /// <param name="datapath">The path to the parent directory that contains the 'tessdata' directory, ignored if the <c>TESSDATA_PREFIX</c> environment variable is defined.</param>
 /// <param name="language">The language to load, for example 'eng' for English.</param>
 /// <param name="engineMode">The <see cref="EngineMode"/> value to use when initialising the tesseract engine.</param>
 public TesseractEngine(string datapath, string language, EngineMode engineMode)
     : this(datapath, language, engineMode, new string[0])
 {
 }
Ejemplo n.º 48
0
        public Engine(string datapath, string language, EngineMode engineMode = EngineMode.Default)
        {
            handle = Interop.TessApi.BaseApiCreate();

            Initialise(datapath, language, engineMode);
        }
Ejemplo n.º 49
0
 /// <summary>
 /// Creates a new instance of <see cref="TesseractEngine"/> with the specified <paramref name="engineMode"/> and <paramref name="configFiles"/>.
 /// </summary>
 /// <remarks>
 /// <para>
 /// The <paramref name="datapath"/> parameter should point to the directory that contains the 'tessdata' folder
 /// for example if your tesseract language data is installed in <c>C:\Tesseract\tessdata</c> the value of datapath should
 /// be <c>C:\Tesseract</c>. Note that tesseract will use the value of the <c>TESSDATA_PREFIX</c> environment variable if defined,
 /// effectively ignoring the value of <paramref name="datapath"/> parameter.
 /// </para>
 /// </remarks>
 /// <param name="datapath">The path to the parent directory that contains the 'tessdata' directory, ignored if the <c>TESSDATA_PREFIX</c> environment variable is defined.</param>
 /// <param name="language">The language to load, for example 'eng' for English.</param>
 /// <param name="engineMode">The <see cref="EngineMode"/> value to use when initialising the tesseract engine.</param>
 /// <param name="configFiles">
 /// An optional sequence of tesseract configuration files to load, encoded using UTF8 without BOM
 /// with Unix end of line characters you can use an advanced text editor such as Notepad++ to accomplish this.
 /// </param>
 public TesseractEngine(string datapath, string language, EngineMode engineMode, IEnumerable<string> configFiles)
     : this(datapath, language, engineMode, configFiles, new Dictionary<string, object>(), false)
 {
 }