Author: Matt Gipson Contact: [email protected] Domain: www.livingvalkyrie.com Description: PreProcessor
Inheritance: MonoBehaviour
Esempio n. 1
0
        private static PreProcessor SetUp(List <AbstractPlugin> chain)
        {
            PreProcessor pp = new PreProcessor();

            pp.SetFileProcessingChain(chain);
            return(pp);
        }
Esempio n. 2
0
        /// <summary>
        /// Preprocesses and parses the specified source.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="sourceFileName">Name of the source file.</param>
        /// <param name="macros">The macros defined for the preprocessor.</param>
        /// <param name="includeDirectories">The include directories used by the preprocessor..</param>
        /// <returns>Result of parsing</returns>
        public ParsingResult TryPreProcessAndParse(string source, string sourceFileName, ShaderMacro[] macros = null, params string[] includeDirectories)
        {
            var allIncludeDirectories = new List <string>();

            if (includeDirectories != null)
            {
                allIncludeDirectories.AddRange(includeDirectories);
            }

            var directoryName = Path.GetDirectoryName(sourceFileName);

            if (!string.IsNullOrEmpty(directoryName))
            {
                allIncludeDirectories.Add(directoryName);
            }

            // Run the processor
            string preprocessedSource;

            try
            {
                preprocessedSource = PreProcessor.Run(source, sourceFileName, macros, allIncludeDirectories.ToArray());
            }
            catch (Exception ex)
            {
                var result = new ParsingResult();
                result.Error(MessageCode.ErrorUnexpectedException, new SourceSpan(new SourceLocation(sourceFileName, 0, 1, 1), 1), ex);
                return(result);
            }

            // Parse the source
            return(Parse(preprocessedSource, sourceFileName));
        }
Esempio n. 3
0
        private static async Task <(IMediaInfo, string)> PreProcess(string path)
        {
            var startTime = DateTime.Now;

            var processor = new PreProcessor {
                VideoPath = path, TempFolder = _tempDir
            };

            Console.Write("Reading metadata             ");
            await processor.PopulateMetadata();

            Console.WriteLine($"Done in {Math.Floor((DateTime.Now - startTime).TotalMilliseconds)}ms");
            Console.Write("Preparing to pre-process     ");
            PreProcessor.CleanupTempDir(_tempDir);
            Directory.CreateDirectory(_tempDir);
            Console.WriteLine($"Done in {Math.Floor((DateTime.Now - startTime).TotalMilliseconds)}ms");
            Console.Write("Extracting Audio             ");
            var audioPath = await processor.ExtractAudio();

            Console.WriteLine($"Done in {Math.Round((DateTime.Now - startTime).TotalSeconds, 3)}s");
            Console.Write("Splitting into images        ");
            await processor.SplitVideoIntoImages();

            Console.WriteLine($"Done in {Math.Round((DateTime.Now - startTime).TotalSeconds, 3)}s");

            return(processor.Metadata, audioPath);
        }
Esempio n. 4
0
        public static void Complie(string codeFile)
        {
            ParserLanguageSetting.GetInstance(@"C:\Mahesh\Projects\Complier\IDE\KeyMapping.xml");
            Scanner scanner  = null;
            string  fileName = codeFile;
            Parser  parser   = null;

            using (TextReader input = File.OpenText(fileName))
            {
                scanner = new Scanner(input);
            }

            PreProcessor pp = new PreProcessor(@"C:\Mahesh\Projects\Complier\CompilerWriting\PreProcessor.xml");

            pp.RunPreProcessor(scanner.Tokens);

            try
            {
                parser = new Parser(scanner);
                parser.StartParser();
            }
            catch (ParserException ex)
            {
                throw new CompileException(ex.LineNumber, codeFile, ex.Message);
            }
            catch (Exception ex)
            {
                throw new CompileException(parser.GetLastExceptionLine, codeFile, ex.Message);
            }

            AssemblyGen assmGen = new AssemblyGen(parser.Result, Path.GetFileNameWithoutExtension(fileName) + ".exe", @"C:\Mahesh\Projects\Complier\CompilerWriting\bin\Debug\");
        }
Esempio n. 5
0
            public string[] Preprocess(IFileContent filename, Dictionary <string, bool> defs)
            {
                PreProcessor pp = new PreProcessor();

                Logger.VerbosityLevel = VerbosityLevel;


                pp.SetFileProcessingChain(Plugins);

                Definitions definitions;

                if (defs == null)
                {
                    definitions = new Definitions();
                }
                else
                {
                    definitions = new Definitions(defs);
                }

                string[] ret = { "FILE NOT FOUND" };
                try
                {
                    ret = pp.Run(new[] { filename }, new Settings(), definitions);
                }
                catch (ProcessorException ex)
                {
                    DebugHelper.Crash(
                        new TextProcessingException("Could not preprocess file: " + filename.GetFilePath(), ex), true);
                }

                return(ret);
            }
Esempio n. 6
0
        /// <summary>
        /// Preprocesses and parses the specified source.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="sourceFileName">Name of the source file.</param>
        /// <param name="macros">The macros defined for the preprocessor.</param>
        /// <param name="includeDirectories">The include directories used by the preprocessor..</param>
        /// <returns>Result of parsing</returns>
        public ParsingResult TryPreProcessAndParse(string source, string sourceFileName, ShaderMacro[] macros = null, params string[] includeDirectories)
        {
            // Use a default include handler
            var defaultHandler = new DefaultIncludeHandler();

            if (includeDirectories != null)
            {
                defaultHandler.AddDirectories(includeDirectories);
            }

            defaultHandler.AddDirectory(Environment.CurrentDirectory);

            var directoryName = Path.GetDirectoryName(sourceFileName);

            if (!string.IsNullOrEmpty(directoryName))
            {
                defaultHandler.AddDirectory(directoryName);
            }

            // Run the processor
            var preprocessedSource = PreProcessor.Run(source, sourceFileName, macros, defaultHandler);

            // Parse the source
            return(Parse(preprocessedSource, sourceFileName));
        }
Esempio n. 7
0
        /// <summary>
        /// Processes all the queued files with the PreProcessor
        /// </summary>
        /// <param name="pp">The PreProcessor</param>
        /// <param name="settings">The settings used in the computation.</param>
        private void Process(PreProcessor pp, Settings settings)
        {
            //Run/Execute PreProcessor
            for (var index = 0; index < Input.Length; index++)
            {
                var      input = Input[index];
                string[] src   = pp.Run(input.Split(',').Select(x => new FilePathContent(x)).OfType <IFileContent>().ToArray(), settings, _defs);

                if (OutputToConsole)
                {
                    if (Output != null && Output.Length > index)
                    {
                        string outp = Path.GetFullPath(Output[index]);
                        string sr   = src.Unpack("\n");
                        File.WriteAllText(outp, sr);
                    }
                }
                else
                {
                    string outp = Path.GetFullPath(Output[index]);
                    string sr   = src.Unpack("\n");
                    File.WriteAllText(outp, sr);
                }
            }
        }
Esempio n. 8
0
        /// <summary>
        /// loads workload
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button3_Click_1(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog1 = new OpenFileDialog();

            openFileDialog1.InitialDirectory = "c:\\";
            openFileDialog1.Filter           = "All files (*.*)|*.*";
            openFileDialog1.RestoreDirectory = true; if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    Stream myStream;
                    if ((myStream = openFileDialog1.OpenFile()) != null)
                    {
                        using (myStream)
                        {
                            StreamReader reader = new StreamReader(myStream);
                            PreProcessor.ProccessWorkload(reader);
                        }
                        MessageBox.Show("Workload has been loaded.");
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message);
                }
            }
        }
Esempio n. 9
0
        public string[] Preprocess(IFileContent filename, Dictionary <string, bool> defs)
        {
            PreProcessor pp = new PreProcessor();


            pp.SetFileProcessingChain(Plugins);

            Definitions definitions;

            if (defs == null)
            {
                definitions = new Definitions();
            }
            else
            {
                definitions = new Definitions(defs);
            }

            string[] ret;
            try
            {
                ret = pp.Run(new[] { filename }, new Settings(), definitions);
            }
            catch (ProcessorException ex)
            {
                throw
                    new TextProcessingException("Could not preprocess file: " + filename.GetFilePath(), ex);
            }

            return(ret);
        }
Esempio n. 10
0
        static void Main(string[] args)
        {
            try
               {
                    foreach (var file in args)
                    {
                         if(!File.Exists(file))
                              throw new FileNotFoundException(string.Format("The file {0} could not be found.", file));
                    }

                    stoplist = args[0];
                    trainingData = args[1];
                    trainingLabel = args[2];
                    testingData = args[3];
                    testingLabel = args[4];
               }
               catch (Exception e)
               {

                    Console.WriteLine("There was a problem reading one or more of the input files.");
                    Console.WriteLine("Double check your file paths and try again.");
                    Console.WriteLine(e.Message);
                    exit();
               }

               var preProcessor = new PreProcessor(trainingData, stoplist);
               var trainingFeatures = preProcessor.GenerateAndPrintFeatures(trainingData, trainingLabel, OUTPUT_FILE);

               var classifier = new BayesClassifier(trainingFeatures);
               var testedFeatures = classifier.ClassifyFeatureSet(preProcessor.GetVocabulary.ToList<string>(), testingData);

               Console.WriteLine("It was {0:0.###}% accurate.", classifier.CheckClassificationAccuracy(testedFeatures, testingLabel));
               exit();
        }
Esempio n. 11
0
        private PreProcessor Configure(Ocr ocr)
        {
            ocr.License            = license;
            ocr.TempFolder         = Path.Combine(tempPath, Guid.NewGuid().ToString());
            ocr.Language           = SupportedLanguages.English;
            ocr.EnableDebugOutput  = true;
            ocr.GetAdvancedOCRData = true;
            ocr.LogToFile          = true;
            //ocr.HandleExceptionsInternally = false;

            PreProcessor preProcessor = new PreProcessor();

            preProcessor.Deskew            = true;
            preProcessor.Autorotate        = false;
            preProcessor.KeepOriginalImage = true;

            //Create new binarization object
            Binarization binarize = new Binarization();

            //Enable binarization
            binarize.Binarize = true;

            //Assign it to PreProcessor
            preProcessor.Binarization = binarize;

            return(preProcessor);
            //ocr.Recognize(preProcessor);
        }
Esempio n. 12
0
 static void Main(string[] args)
 {
     try
     {
         if (args.Length < 2)
         {
             Console.WriteLine("bas2prg");
             Console.WriteLine("A commandline CBM Basic compiler.");
             Console.WriteLine("By Six/Style 2016-2018");
             Console.WriteLine("usage: bas2prg basfile.bas prgfile.prg");
             Console.WriteLine();
         }
         else
         {
             //var basic = new BASIC();
             var pp               = new PreProcessor();
             var basfile          = File.ReadAllLines(args[0]).ToList();
             var compilerSettings = new CompilerSettings();
             var p     = pp.PreProcess(basfile, ref compilerSettings);
             var bytes = (true) ? SixBASICTokenizer.Tokenize(p, ref compilerSettings) : Tokenizer.Tokenize(p, ref compilerSettings);
             File.WriteAllBytes(args[1], bytes);
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
     }
 }
        /*
         * This is the main function to generate gcode files for the
         * already sliced model
         */
        public static GCodeFile Generate(SliceFile sf, MachineConfig pi)
        {
            String        gcode;
            StringBuilder sb    = new StringBuilder();
            PreProcessor  pp    = PreparePreprocessor(sf, pi);
            double        zdist = 0.0;
            // double feedrate = pi.ZMaxFeedrate; // 10mm/min
            double liftfeed    = sf.m_config.liftfeedrate;
            double retractfeed = sf.m_config.liftretractrate;
            double zdir        = 1.0; // assume a bottom up machine
            int    numbottom   = sf.m_config.numfirstlayers;

            if (sf.m_config.direction == SliceBuildConfig.eBuildDirection.Top_Down)
            {
                zdir = -1.0;// top down machine, reverse the z direction
            }
            pp.SetVar("$ZDir", zdir);

            // append the build parameters as reference
            sb.Append(sf.m_config.ToString());
            sb.Append(";Number of Slices        =  " + sf.NumSlices.ToString() + "\r\n");

            sb.Append(pi.ToString());//add the machine build parameters string

            // append the header
            sb.Append(pp.Process(sf.m_config.HeaderCode));

            zdist = sf.m_config.ZThick;

            String firstlayerdelay = ";<Delay> " + sf.m_config.firstlayertime_ms + " \r\n";
            String layerdelay      = ";<Delay> " + sf.m_config.layertime_ms + " \r\n";
            String blankdelay      = ";<Delay> " + sf.m_config.blanktime_ms + " \r\n";

            String preSliceGCode = pp.Process(sf.m_config.PreSliceCode);
            String LiftGCode     = pp.Process(sf.m_config.LiftCode);

            for (int c = 0; c < sf.NumSlices; c++)
            {
                sb.Append(preSliceGCode);//add in the pre-slice code
                // this is the marker the BuildManager uses to display the correct slice
                sb.Append(";<Slice> " + c + " \r\n");
                // add a pause for the UV resin to be set using this image
                if (c < numbottom)// check for the bottom layers
                {
                    sb.Append(firstlayerdelay);
                }
                else
                {
                    sb.Append(layerdelay);
                }
                sb.Append(";<Slice> Blank \r\n"); // show the blank layer
                sb.Append(LiftGCode);             // append the pre-lift codes
            }
            //append the footer
            sb.Append(pp.Process(sf.m_config.FooterCode));
            gcode = sb.ToString();
            GCodeFile gc = new GCodeFile(gcode);

            return(gc);
        }
Esempio n. 14
0
        private StringInput RunPreProcessorOn(ICompilerInput input)
        {
            PreProcessor processor;
            TextReader   reader;
            StringInput  input2;
            PreProcessor processor1 = processor = new PreProcessor(this.Parameters.Defines.Keys);
            int          num1       = (int)(processor.PreserveLines = true);
            PreProcessor processor2 = processor;
            IDisposable  disposable = (reader = input.Open()) as IDisposable;

            try
            {
                StringWriter writer = new StringWriter();
                processor2.Process(reader, writer);
                input2 = new StringInput(input.Name, writer.ToString());
            }
            finally
            {
                if (disposable != null)
                {
                    disposable.Dispose();
                    disposable = null;
                }
            }
            return(input2);
        }
Esempio n. 15
0
        public override void InitPlugin(TabPage pluginScreenSpace, Label pluginStatusText)
        {
            _settingsLoaded    = false;
            ParentTabPage      = pluginScreenSpace;
            StatusLabel        = pluginStatusText;
            ParentTabPage.Text = "Fox TTS";

            try
            {
                Controller = new MainController();
                Settings   = new SettingsHolder();

                Settings.AttachToAct(this);

                SettingsTab = new FoxTTSTabControl();
                SettingsTab.AttachToAct(this);

                PreProcessor.AttachToAct(this);
                UpdateChecker.AttachToAct(this);
                SoundPlayer.AttachToAct(this);
                TtsInjector.AttachToAct(this);

                Controller.TTSEngineChanged += ControllerOnTtsEngineChanged;

                Settings.PostAttachToAct(this);
                SettingsTab.PostAttachToAct(this);
                PreProcessor.PostAttachToAct(this);
                UpdateChecker.PostAttachToAct(this);
                SoundPlayer.PostAttachToAct(this);
                TtsInjector.PostAttachToAct(this);

                Settings.Load();
                _settingsLoaded = true;

                DoLocalization();

                Settings.NotifySettingsLoaded();

                TtsInjector.StartWorkingThread(this);

                StatusLabel.Text = "Init Success. >w<";
            }
            catch (SettingsNotLoadException ex)
            {
                StatusLabel.Text = "Init Failed: " + ex;
            }
            catch (Exception ex)
            {
                StatusLabel.Text = "Init Failed: " + ex;
                if (_settingsLoaded)
                {
                    MessageBox.Show($"Init failed!\nCaused by:\n{ex}");
                }
                else
                {
                    MessageBox.Show($"Init failed before settings are loaded. Settings won't be saved until next successfully initialization to prevent settings lost!\nCaused by:\n{ex}");
                }
            }
        }
Esempio n. 16
0
 public static EventProcessorCache CreateEventProcessorCache()
 {
     var eventProcessorCache = new EventProcessorCache();
     var preProcessor = new PreProcessor(eventProcessorCache, new EventAccessor(new EventPropertyLocator()));
     preProcessor.RegisterForPreProcessing<ClientMovedEvent>();
     preProcessor.Process();
     return eventProcessorCache;
 }
Esempio n. 17
0
        public void Comments_are_filtered_correctly(string input, int count)
        {
            var stream = Streamify(input);
            var tokens = _lexer.Scan(stream);

            tokens = PreProcessor.FilterComments(tokens);
            Assert.AreEqual(count, tokens.Length);
        }
Esempio n. 18
0
    private List <HSPAction> groundActions(List <HSPOperator> _operations, List <OBase> _objects)
    {
        List <HSPAction> actions = new List <HSPAction>();

        processor = PreProcessor.Instance;
        actions   = processor.groundActions(_operations, getObjectPredicates(_objects));
        return(actions);
    }
Esempio n. 19
0
        public static string[] SetUpAndCompile(List <AbstractPlugin> chain, Settings settings, IDefinitions definitions,
                                               params string[] fileNames)
        {
            PreProcessor pp = SetUp(chain);

            return(pp.Run(fileNames.Select(x => new FilePathContent(x)).OfType <IFileContent>().ToArray(), settings,
                          definitions));
        }
Esempio n. 20
0
        public static string Preprocess(string shaderSource, string filename, ShaderMacro[] macros)
        {
            // Preprocess
            // First, perform token concatenation (not supported by D3DX)
            // Check for either TOKEN ## or ## TOKEN
            var preprocessedSource = ConcatenateTokens(shaderSource, macros);

            return(PreProcessor.Run(preprocessedSource, filename, macros));
        }
Esempio n. 21
0
        public static EventProcessorCache CreateEventProcessorCache()
        {
            var eventProcessorCache = new EventProcessorCache();
            var preProcessor        = new PreProcessor(eventProcessorCache, new EventAccessor(new EventPropertyLocator()));

            preProcessor.RegisterForPreProcessing <ClientMovedEvent>();
            preProcessor.Process();
            return(eventProcessorCache);
        }
Esempio n. 22
0
        public static ISourceScript[] SetUpAndProcess(List <AbstractPlugin> chain, Settings settings,
                                                      IDefinitions definitions, params string[] fileNames)
        {
            PreProcessor pp = SetUp(chain);

            return(pp.ProcessFiles(
                       fileNames.Select(x => new FilePathContent(Path.GetFullPath(x))).OfType <IFileContent>().ToArray(),
                       settings, definitions));
        }
Esempio n. 23
0
		public TableScripts(Configuration configuration, string table, bool autoIndexForeignKeys)
		{
			_configuration = configuration;
			_table = table;

			// ensure that this configuration object has been pre-processed
			var preProcessor = new PreProcessor(true, autoIndexForeignKeys);
			preProcessor.Process(_configuration);
		}
Esempio n. 24
0
 public void ExtPP_PreProcessor_FilterRun_Test()
 {
     string[] files = Directory.GetFiles(Path.Combine(ResourceFolder, "filter/tests/"), "*.fl");
     foreach (string file in files)
     {
         PreProcessor pp = new PreProcessor();
         pp.SetFileProcessingChain(Plugins);
         pp.Run(new[] { file }, new Definitions());
     }
 }
Esempio n. 25
0
 public void Speak(string text, dynamic playDevice, bool isSync = false, float?volume = null)
 {
     try
     {
         var processed = PreProcessor.Process(text);
         TtsEngine?.Speak(processed, playDevice, isSync, volume);
     }
     catch (Exception ex)
     {
         Controller.NotifyLogMessageAppend(false, ex.ToString());
     }
 }
Esempio n. 26
0
 public void Speak(string text)
 {
     Logger.Info($"Speak {text}");
     try
     {
         var processed = PreProcessor.Process(text);
         TtsEngine?.Speak(processed);
     }
     catch (Exception ex)
     {
         Logger.Error($"Failed to speak \"{text}\"", ex);
     }
 }
Esempio n. 27
0
        public ExecutionEngine()
        {
            preProccessor             = new PreProcessor(sys);
            SystemState.internalState = sys;
            StackFrame t = new StackFrame("INT", new Dictionary <string, NetLogoObject>(), null);

            OperatorFunctions.ResetSystemState();
            sys.exeStack.Push(t);
            sys.globals.Add("ticks", new Number()
            {
                val = 0
            });
        }
Esempio n. 28
0
 public static void FilterRunTest()
 {
     Directory.SetCurrentDirectory(ResourceFolder);
     string[] files = Directory.GetFiles("filter/tests/", "*.fl");
     foreach (var file in files)
     {
         string dir = Directory.GetCurrentDirectory();
         Directory.SetCurrentDirectory(ResourceFolder);
         PreProcessor pp = new PreProcessor();
         pp.SetFileProcessingChain(Plugins);
         pp.Run(new[] { file }, new Definitions());
     }
 }
Esempio n. 29
0
        public void StartTrain(DataTable trainX, DataTable trainY, DataTable testX, DataTable testY)
        {
            if (PreProcessor == null)
            {
                throw new Exception("you need a PreProcessor!");
            }

            StartTrain(
                PreProcessor.PreProcessX(trainX),
                PreProcessor.PreProcessY(trainY),
                PreProcessor.PreProcessX(testX),
                PreProcessor.PreProcessY(testY));
        }
Esempio n. 30
0
        private IList <Comment> CollectCommentsFor(SourceFile sourceFile, IEnumerable <string> definedSymbols)
        {
            var comments = new List <Comment>();
            var p        = new PreProcessor();

            p.PreserveLines = true;
            foreach (var symbol in definedSymbols)
            {
                p.Define(symbol);
            }

            var result = p.Process(sourceFile.Contents);

            var lexer = UnityScriptParser.UnityScriptLexerFor(new StringReader(result), sourceFile.FileName, 4);

            lexer.PreserveComments = true;

            var    token = lexer.nextToken();
            IToken last  = null;

            while (token != null && token.Type != UnityScriptLexer.EOF)
            {
                try
                {
                    if (token.Type == UnityScriptLexer.SL_COMMENT || token.Type == UnityScriptLexer.ML_COMMENT)
                    {
                        comments.Add(new Comment(token, token.Type == UnityScriptLexer.SL_COMMENT ? CommentKind.SingleLine : CommentKind.MultipleLine, last));
                    }
                    else
                    {
                        last = token;
                    }
                }
                catch (TokenStreamRecognitionException tre)
                {
                    //TODO: Collect errors from this phase so we can at least show them to user ?
                }
                finally
                {
                    try
                    {
                        token = lexer.nextToken();
                    }
                    catch (TokenStreamRecognitionException tre)
                    {
                    }
                }
            }

            return(comments);
        }
        /*
         * GCode Process for building 3d DVP UV objects
         *
         * <Build Start>
         * <Slicing Comments> comments containing the slicing and building parameters
         * <Header Code> start.gcode - commands from this
         * file are inserted, they contain whatever intiailization sequences are need to initialize the machine
         * at this point, the build tray is in position to start printing a layer
         * <Layer Start>
         * Display the correct image slice for the current layer
         * Delay for <Layertime> to expose the UV resin
         * <Layer End>
         *
         *
         */

        // here we prepare the gcode preprocessor and fill all nessesary variables
        protected static PreProcessor PreparePreprocessor(SliceFile sf, MachineConfig pi)
        {
            PreProcessor pp = new PreProcessor();

            pp.SetVar("$LayerThickness", sf.m_config.ZThick);
            pp.SetVar("$ZLiftDist", sf.m_config.liftdistance);
            pp.SetVar("$ZLiftRate", sf.m_config.liftfeedrate);
            pp.SetVar("$ZRetractRate", sf.m_config.liftretractrate);
            pp.SetVar("$SlideTiltVal", sf.m_config.slidetiltval);
            pp.SetVar("$BlankTime", sf.m_config.blanktime_ms);
            pp.SetVar("$LayerTime", sf.m_config.layertime_ms);
            pp.SetVar("$FirstLayerTime", sf.m_config.firstlayertime_ms);
            return(pp);
        }
Esempio n. 32
0
        public void IncludeCircular()
        {
            PreProcessor          pp = new PreProcessor();
            List <AbstractPlugin> lp = new List <AbstractPlugin>()
            {
                new IncludePlugin(),
            };

            pp.SetFileProcessingChain(lp);
            var ret = pp.Process(new[] { "includecircular.cl" }, new Settings(), new Definitions());

            Assert.AreEqual(
                ret.Length,
                3);
        }
        /*
         * GCode Process for building 3d DVP UV objects
         *
         * <Build Start>
         * <Slicing Comments> comments containing the slicing and building parameters
         * <Header Code> start.gcode - commands from this
         * file are inserted, they contain whatever intiailization sequences are need to initialize the machine
         * at this point, the build tray is in position to start printing a layer
         * <Layer Start>
         * Display the correct image slice for the current layer
         * Delay for <Layertime> to expose the UV resin
         * <Layer End>
         *
         *
         */

        // here we prepare the gcode preprocessor and fill all nessesary variables
        protected static PreProcessor PreparePreprocessor(SliceFile sf, MachineConfig pi)
        {
            PreProcessor pp = new PreProcessor();

            pp.SetVar("$LayerThickness", sf.m_config.ZThick);            // the thickenss of the layer in mm
            pp.SetVar("$ZLiftDist", sf.m_config.liftdistance);           // how far we're lifting
            pp.SetVar("$ZLiftRate", sf.m_config.liftfeedrate);           // the rate at which we're lifting
            pp.SetVar("$ZRetractRate", sf.m_config.liftretractrate);     // how fast we'r retracting
            pp.SetVar("$SlideTiltVal", sf.m_config.slidetiltval);        // any used slide / tilt value on the x axis
            pp.SetVar("$BlankTime", sf.m_config.blanktime_ms);           // how long to show the blank in ms
            pp.SetVar("$LayerTime", sf.m_config.layertime_ms);           // total delay for a layer for gcode commands to complete - not including expusre time
            pp.SetVar("$FirstLayerTime", sf.m_config.firstlayertime_ms); // time to expose the first layers in ms
            pp.SetVar("$NumFirstLayers", sf.m_config.numfirstlayers);    // number of first layers
            return(pp);
        }
Esempio n. 34
0
		private static void WriteOutput(TextWriter writer, DdlWriterCommandLine cmdLine)
		{
			try
			{
				// load the persistent store defined by the current set of binaries
				var store = (PersistentStore)PersistentStoreRegistry.GetDefaultStore();

				// get config

				// run pre-processors
				var preProcessor = new PreProcessor(cmdLine.CreateIndexes, cmdLine.AutoIndexForeignKeys);
				preProcessor.Process(store);


				// if this is an upgrade, load the baseline model file
				RelationalModelInfo baselineModel = null;
				if (!string.IsNullOrEmpty(cmdLine.BaselineModelFile))
				{
					var serializer = new RelationalModelSerializer();
					baselineModel = serializer.ReadModel(File.OpenText(cmdLine.BaselineModelFile));
				}

				switch (cmdLine.Format)
				{
					case DdlWriterCommandLine.FormatOptions.sql:

						// create script writer and set properties based on command line 
						var scriptWriter = new ScriptWriter(store)
											{
												Options = new RelationalSchemaOptions
															{
																EnumOption = cmdLine.EnumOption,
																SuppressForeignKeys = !cmdLine.CreateForeignKeys,
																SuppressUniqueConstraints = !cmdLine.CreateUniqueKeys,
																NamespaceFilter = new RelationalSchemaOptions.NamespaceFilterOption(cmdLine.Namespace)
															},
												QualifyNames = cmdLine.QualifyNames,
												BaselineModel = baselineModel
											};

						// decide whether to write a creation or upgrade script, depending on if a baseline was supplied
						if (baselineModel == null)
							scriptWriter.WriteCreateScript(writer);
						else
							scriptWriter.WriteUpgradeScript(writer);

						break;

					case DdlWriterCommandLine.FormatOptions.xml:

						// we don't currently support outputting upgrades in XML format
						if (baselineModel != null)
							throw new NotSupportedException("Upgrade is not compatible with XML output format.");

						var serializer = new RelationalModelSerializer();
						var relationalModelInfo = new RelationalModelInfo(store, new RelationalSchemaOptions.NamespaceFilterOption(cmdLine.Namespace));
						serializer.WriteModel(relationalModelInfo, writer);
						break;

					default:
						throw new NotSupportedException(string.Format("{0} is not a valid output format.", cmdLine.Format));
				}
			}
			catch (Exception e)
			{
				Log(e, LogLevel.Error);
			}
		}
Esempio n. 35
0
        private string processImage(string imageInput, string outputFilePath)
        {
            var debugMessage = new StringBuilder();
            try
            {
                debugMessage.Append("Process Image output file path " + outputFilePath);
                var ocr = new Ocr();
                var preProcessor = new PreProcessor();

                debugMessage.Append("Objects created");

                preProcessor.Deskew = true;
                preProcessor.Autorotate = false;
                preProcessor.RemoveLines = true;
                preProcessor.Binarize = 96;
                preProcessor.Morph = "c2.2";

                ocr.License =
               "MD1BZHZhbmNlZDsxPWtlZXJ0aSAtIGt2a2lydGh5QGdtYWlsLmNvbTsyPTUyNDY4Njg5OTE5MTMwMjg5NTI7Mz1rZWVydGkgLSBrdmtpcnRoeUBnbWFpbC5jb207ND05OTk7NT1UcnVlOzUuMT1GYWxzZTs3PTYzNTE4ODYwODAwMDAwMDAwMDs4PTQxRDA3NEFFODJFQjI3QjM3RDdGMTUzQ0REQjVEQkNFNEVGRjdGREU5MEIwOTg1MjkwQ0JDREFCQTM3MEFBNzU7OT0xLjQxLjAuMA";
                
                ocr.ResourceFolder = @"C:\Aquaforest\OCRSDK\bin";
                ocr.EnableConsoleOutput = true;
                ocr.EnableTextOutput = true;

                //ocr.ReadBMPSource(@"C:\Users\KotaruV\Documents\Visual Studio 2012\Projects\Playground\OCRConsoleApp\OCRConsoleApp\images\3.jpg");
                //ocr.ReadTIFFSource(imageInput);
                ocr.ReadBMPSource(imageInput);

                debugMessage.Append("Read from bmp source. ");
                ocr.Recognize(preProcessor);
                debugMessage.Append("Recognize executed. ");
                
                ocr.SaveTextOutput(outputFilePath, true);
                var ocrText = getOcrTextFromFile(outputFilePath);
                debugMessage.Append("Saved text output. ");
                ocr.DeleteTemporaryFiles();
                debugMessage.Append("Deleted temporary files. ");
                return ocrText;
            }
            finally
            {
                System.Diagnostics.EventLog.WriteEntry("Application", debugMessage.ToString(), System.Diagnostics.EventLogEntryType.Error);
            }

        }