コード例 #1
0
        /// <summary>
        /// Determines if the input matches any registered scanners, and invokes the scanner callback if a match is found.
        /// This method will also invoke the <see cref="InputResultDelegate"/> callback if a scanner is found
        /// </summary>
        /// <param name="input"></param>
        /// <param name="ctx"></param>
        /// <param name="callback"></param>
        public bool ScanInput(string input, IContextObject ctx, InputResultDelegate callback)
        {
            ThrowIfDisposed();

            if (_scanners.Count == 0)
            {
                return(false);
            }

            ScannerData scanner = _scanners.FirstOrDefault(s => s.Pattern.Matches(input));

            if (scanner != null)
            {
                bool remove = false;

                object result = scanner.Callback.Invoke(ctx, input, new LightweightParser(ctx), ref remove);
                callback?.Invoke(InputResult.Scanner, result);

                if (remove)
                {
                    _scanners.Remove(scanner);
                }

                return(true);
            }

            return(false);
        }
コード例 #2
0
 internal void Build() {
   _data = _language.ScannerData;
   _data.LineTerminatorsArray = _grammar.LineTerminators.ToCharArray();
   InitMultilineTerminalsList();
   ProcessNonGrammarTerminals(); 
   BuildTerminalsLookupTable();
 }
コード例 #3
0
 internal void Build()
 {
     _data = _language.ScannerData;
     InitMultilineTerminalsList();
     ProcessNonGrammarTerminals();
     BuildTerminalsLookupTable();
 }
コード例 #4
0
ファイル: LanguageData.cs プロジェクト: TheByte/sones
 public LanguageData(Grammar grammar)
 {
     Grammar = grammar;
       GrammarData = new GrammarData(this);
       ParserData = new ParserData(this);
       ScannerData = new ScannerData(this);
 }
コード例 #5
0
        private void SimulateCustomer(DateTime currentDate, int customerNumber)
        {
            var itemsToPurchase = rng.Next(1, MaxItems + 1);
            var itemsLeft       = itemsToPurchase;

            var itemsPurchased = new List <Product>(itemsToPurchase);

            // Handle each of the specific stat based products
            foreach (var statService in statisticsServices)
            {
                itemsLeft = itemsToPurchase - itemsPurchased.Count;
                if (itemsLeft == 0)
                {
                    break;
                }

                itemsPurchased.AddRange(statService.GetProductsBasedOnStats(itemsLeft));
            }

            //handle everything else
            itemsPurchased.AddRange(groceryStoreInventory.PurchaseRandomProducts(itemsLeft, typesToIgnore));

            foreach (var product in itemsPurchased)
            {
                //Add Scanner data for each item the customer bought
                var scannerData = new ScannerData(product.SKU, currentDate.ToShortDateString(), product.BasePrice * PriceModifier,
                                                  customerNumber, product.ItemsLeft, product.TotalCasesOrdered);

                sqliteHandler.Insert(scannerData);
            }
        }
コード例 #6
0
 internal void Build()
 {
     _data = _language.ScannerData;
     InitMultilineTerminalsList();
     ProcessNonGrammarTerminals();
     BuildTerminalsLookupTable();
 }
コード例 #7
0
ファイル: LanguageData.cs プロジェクト: hozuki/irony-vs
 public LanguageData(Grammar grammar)
 {
     Grammar     = grammar;
     GrammarData = new GrammarData(this);
     ParserData  = new ParserData(this);
     ScannerData = new ScannerData(this);
     ConstructAll();
 }
コード例 #8
0
 // Use this for initialization
 void Start()
 {
     mesh      = new Mesh();
     lidarData = GameObject.Find("Scanner").GetComponent <Scanner>().lidarDataDict;
     numPoints = lidarData.size;
     GetComponent <MeshFilter>().mesh = mesh;
     CreateMesh();
 }
コード例 #9
0
 internal void Build()
 {
     _data = _language.ScannerData;
     _data.LineTerminatorsArray = _grammar.LineTerminators.ToCharArray();
     InitMultilineTerminalsList();
     ProcessNonGrammarTerminals();
     BuildTerminalsLookupTable();
 }
コード例 #10
0
ファイル: ScannerDataBuilder.cs プロジェクト: TheByte/sones
 internal void Build()
 {
     _data = _language.ScannerData;
       _data.LineTerminators = _grammar.LineTerminators.ToCharArray();
       _data.ScannerRecoverySymbols = _grammar.WhitespaceChars + _grammar.Delimiters;
       InitMultilineTerminalsList();
       BuildTerminalsLookupTable();
       InitTokenFilters();
 }
コード例 #11
0
 private static void EnsureBraceMatchFilter(ScannerData data)
 {
     foreach (TokenFilter filter in data.TokenFilters)
     {
         if (filter is BraceMatchFilter)
         {
             return;
         }
     }
     data.TokenFilters.Add(new BraceMatchFilter());
 }
コード例 #12
0
        public override void OnBeingScanned(ScannerData scannerData)
        {
            if (m_isScanned)
            {
                return;
            }

            // being scanned -> become interactable for player to color their scanner
            m_isInteractable = true;
            m_particleSystem.Play();
        }
コード例 #13
0
 private static void InitMultilineTerminalsList(ScannerData data)
 {
     foreach (var terminal in data.GrammarData.Terminals)
     {
         if (terminal.IsSet(TermOptions.IsMultiline))
         {
             data.MultilineTerminals.Add(terminal);
             terminal.MultilineIndex = (byte)(data.MultilineTerminals.Count);
         }
     }
 }
コード例 #14
0
        private static void BuildTerminalsLookupTable(ScannerData data)
        {
            var grammar = data.GrammarData.Grammar;

            data.TerminalsLookup.Clear();
            data.FallbackTerminals.AddRange(grammar.FallbackTerminals);
            foreach (Terminal term in data.GrammarData.Terminals)
            {
                IList <string> prefixes = term.GetFirsts();
                if (prefixes == null || prefixes.Count == 0)
                {
                    if (!data.FallbackTerminals.Contains(term))
                    {
                        data.FallbackTerminals.Add(term);
                    }
                    continue; //foreach term
                }
                //Go through prefixes one-by-one
                foreach (string prefix in prefixes)
                {
                    if (string.IsNullOrEmpty(prefix))
                    {
                        continue;
                    }
                    //Calculate hash key for the prefix
                    char hashKey = prefix[0];
                    if (!grammar.CaseSensitive)
                    {
                        hashKey = char.ToLower(hashKey);
                    }
                    TerminalList currentList;
                    if (!data.TerminalsLookup.TryGetValue(hashKey, out currentList))
                    {
                        //if list does not exist yet, create it
                        currentList = new TerminalList();
                        data.TerminalsLookup[hashKey] = currentList;
                    }
                    //add terminal to the list
                    if (!currentList.Contains(term))
                    {
                        currentList.Add(term);
                    }
                }
            }//foreach term
            //Sort all terminal lists by reverse priority, so that terminal with higher priority comes first in the list
            foreach (TerminalList list in data.TerminalsLookup.Values)
            {
                if (list.Count > 1)
                {
                    list.Sort(Terminal.ByPriorityReverse);
                }
            }
        }//method
コード例 #15
0
        public override void OnBeingScanned(ScannerData scannerData)
        {
            if (m_isScanned)
            {
                return;
            }

            if (ColorMathUtility.ColorMath.ColorDistance01(scannerData.color, targetColor) < 0.2f)
            {
                UpdateState(true);
            }
        }
コード例 #16
0
ファイル: ScannerService.cs プロジェクト: matcodes/OAK
        private void AddScannerData(byte[] data, int startIndex)
        {
            var scannerData = new ScannerData
            {
                X = BitConverter.ToUInt32(data, startIndex + 6),
                Y = BitConverter.ToUInt32(data, startIndex + 2),
                N = BitConverter.ToUInt16(data, startIndex + 0),
            };

            scannerData.Y = (UInt32)(scannerData.Y + this.GetRandom());
            this.Data.Add(scannerData);
        }
コード例 #17
0
        //scans the json string and returns the weighted totals each section under the "sections" key of the json string
        public static List <double> scanSections(string jsonString)
        {
            ScannerData data = parseJsonData(jsonString);

            List <List <point> > sections = data.sections;

            List <Hashtable> section_results = getSectionResults(sections);

            List <double> section_totals = getSectionTotals(section_results, data.weight_percentages);

            return(section_totals);
        }
コード例 #18
0
 public void Insert(ScannerData scannerData)
 {
     command.CommandText = "INSERT INTO scannerData (productPurchased, datePurchased, salePrice, customerNumber, itemsLeft, totalCasesOrdered) " +
                           "VALUES(@productPurchased, @datePurchased, @salePrice, @customerNumber, @itemsLeft, @totalCasesOrdered)";
     command.Parameters.Add(new SQLiteParameter("@productPurchased", scannerData.ProductPurchased));
     command.Parameters.Add(new SQLiteParameter("@datePurchased", scannerData.DatePurchased));
     command.Parameters.Add(new SQLiteParameter("@salePrice", scannerData.SalePrice));
     command.Parameters.Add(new SQLiteParameter("@customerNumber", scannerData.CustomerNumber));
     command.Parameters.Add(new SQLiteParameter("@itemsLeft", scannerData.ItemsLeft));
     command.Parameters.Add(new SQLiteParameter("@totalCasesOrdered", scannerData.TotalCasesOrdered));
     command.ExecuteNonQuery();
     command.Parameters.Clear();
 }
コード例 #19
0
ファイル: Scanner.cs プロジェクト: androdev4u/XLParser
 public Scanner(Parser parser) {
   Parser = parser; 
   Data = parser.Language.ScannerData;
   _grammar = parser.Language.Grammar;
   //create token streams
   var tokenStream = GetUnfilteredTokens();
   //chain all token filters
   Context.TokenFilters.Clear();
   _grammar.CreateTokenFilters(Data.Language, Context.TokenFilters);
   foreach (TokenFilter filter in Context.TokenFilters) {
     tokenStream = filter.BeginFiltering(Context, tokenStream);
   }
   Context.FilteredTokens = tokenStream.GetEnumerator();
 }
コード例 #20
0
ファイル: Scanner.cs プロジェクト: dseeni/selfDrivingSimTest
    //Instantiate lidar Scanner and calculates the scanArea.
    //Also intantiates the data structure holding the lidar data.
    void createLidarScan()
    {
        laserArray      = new LaserLine[laserChannels];
        laserImpactLocs = new Vector3[laserChannels];
        for (int i = 0; i < laserChannels; i++)
        {
            Vector3 tiltAngle = new Vector3(verticalStartPoint + i * verticalAngularRes, 0);
            laserArray[i] = spawnLaserBeam(tiltAngle);
        }

        scanArea = 360 * rotationFrequency * Time.fixedDeltaTime;  //Fixed rotation speed to match physics updates
        int numOfPoints = (int)(laserChannels * (360 / scanArea)); //Number of points rendered at any given time ste[

        lidarDataDict = new ScannerData(numOfPoints);
        rotation      = new Vector3(0, scanArea, 0);
    }
コード例 #21
0
        private void Refresh_Click(object sender, RoutedEventArgs e)
        {
            ScannerData emptyProd = new ScannerData()
            {
                ArticleName   = "Tom artikel",
                ArticleNumber = "Tom artikel"
            };

            data.Insert(0, emptyProd);

            QueueList.Dispatcher.Invoke(() =>
            {
                QueueList.ItemsSource = null;
                QueueList.ItemsSource = data;
            });
        }
コード例 #22
0
        private void ScannerWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            // the background process is complete. We need to inspect
            // our response to see if an error occurred, a cancel was
            // requested or if we completed successfully.

            scannerData.dialog.Close();

            // check to see if an error occurred in the background process.
            if (e.Cancelled)
            {
                scannerData   = null;
                scannerWorker = null;
                return;
            }

            if (e.Error != null)
            {
                MessageBox.Show(e.Error.Message, "Error");
                scannerData   = null;
                scannerWorker = null;
                return;
            }

            string name  = scannerData.scanner.SuggestName(scannerData.folder);
            string type  = scannerData.scanner.GetName();
            string uname = MakeUniqueName(name);

            try
            {
                Model.FoldersRow folder = model.AddFolder(uname, scannerData.folder, type);
                VisualizeFolder(folder);
                int row = table.TableModel.Rows.Count - 1;
                table.TableModel.Selections.SelectCells(row, 0, row, 2);
                table.EnsureVisible(row, 0);
            }
            catch (Exception ex)
            {
                MessageBox.Show(String.Format("Unable to add new folder: Folder:'{0}'\nType:'{1}'\nUniqueName:'{2}'\nError: {3}", name, type, uname, ex.Message), "Save failed", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            scannerData   = null;
            scannerWorker = null;
        }
コード例 #23
0
ファイル: DBCom.cs プロジェクト: tstaaf/Domino-Queue-Handler
        public ScannerData DBGet(string ScanData)
        {
            using (FbConnection connection = new FbConnection(@"Server=localhost;User=SYSDBA;Password=masterkey;Database=C:\var\db\UTF-8\IKEA.fdb"))
            {
                connection.Open();
                ScannerData queueProduct = new ScannerData();
                using (var transaction = connection.BeginTransaction())
                {
                    using (var command = new FbCommand("SELECT * FROM TBLWARE WHERE BARCODEC = " + ScanData, connection, transaction))
                    {
                        using (var reader = command.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                var values = new object[reader.FieldCount];
                                reader.GetValues(values);

                                queueProduct.ArticleNumber            = values[0].ToString().Replace(" ", "");
                                queueProduct.ArticleName              = values[1].ToString();
                                queueProduct.Supplier                 = values[11].ToString();
                                queueProduct.EAN                      = values[41].ToString().Replace(" ", "");
                                queueProduct.Quantity                 = values[44].ToString();
                                queueProduct.GrossWeight              = values[60].ToString();
                                queueProduct.UnitLoadFootprint1       = values[66].ToString();
                                queueProduct.UnitLoadFootprint2       = values[68].ToString();
                                queueProduct.UnitLoadStackingCapacity = values[69].ToString();
                            }
                            if (queueProduct.EAN == null)
                            {
                                return(null);
                            }
                            else
                            {
                                return(queueProduct);
                            }
                        }
                    }
                }
            }
        }
コード例 #24
0
        private void AddProject(string folder)
        {
            // cancel previous worker if running
            if (scannerWorker != null)
            {
                ScannerCancel();
            }

            // create a background worker thread that ReportsProgress & SupportsCancellation
            // hook up the appropriate events.
            scannerWorker = new BackgroundWorker();
            scannerWorker.WorkerReportsProgress      = true;
            scannerWorker.WorkerSupportsCancellation = true;
            scannerWorker.ProgressChanged           += new ProgressChangedEventHandler(ScannerProgressChanged);
            scannerWorker.RunWorkerCompleted        += new RunWorkerCompletedEventHandler(ScannerWorkerCompleted);
            scannerWorker.DoWork          += new DoWorkEventHandler(ScannerDoWork);
            Detector.Current.currentWorker = scannerWorker;
            scannerData = new ScannerData(folder, scannerWorker);
            scannerWorker.RunWorkerAsync();

            scannerData.dialog.ShowDialog();
        }
コード例 #25
0
        }//method

        private static void InitTokenFilters(ScannerData data)
        {
            data.TokenFilters.AddRange(data.GrammarData.Grammar.TokenFilters);
            //check if we need brace match token filter
            bool needBraceMatchFilter = false;

            foreach (var term in data.GrammarData.Terminals)
            {
                if (term.IsSet(TermOptions.IsBrace))
                {
                    needBraceMatchFilter = true;
                    break;
                }
            }
            if (needBraceMatchFilter)
            {
                EnsureBraceMatchFilter(data);
            }
            //initialize filters
            foreach (var filter in data.TokenFilters)
            {
                filter.Init(data.GrammarData);
            }
        }
コード例 #26
0
ファイル: Scanner.cs プロジェクト: TheByte/sones
 public Scanner(ScannerData data)
 {
     _data = data;
       _grammar = _data.Language.Grammar;
 }
コード例 #27
0
ファイル: Configuration.cs プロジェクト: binaryage/xrefresh
        private void AddProject(string folder)
        {
            // cancel previous worker if running
            if (scannerWorker != null)
            {
                ScannerCancel();
            }

            // create a background worker thread that ReportsProgress & SupportsCancellation
            // hook up the appropriate events.
            scannerWorker = new BackgroundWorker();
            scannerWorker.WorkerReportsProgress = true;
            scannerWorker.WorkerSupportsCancellation = true;
            scannerWorker.ProgressChanged += new ProgressChangedEventHandler(ScannerProgressChanged);
            scannerWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(ScannerWorkerCompleted);
            scannerWorker.DoWork += new DoWorkEventHandler(ScannerDoWork);
            Detector.Current.currentWorker = scannerWorker;
            scannerData = new ScannerData(folder, scannerWorker);
            scannerWorker.RunWorkerAsync();

            scannerData.dialog.ShowDialog();
        }
コード例 #28
0
ファイル: SourceStream.cs プロジェクト: pusp/o2platform
 private int _nextNewLinePosition = -1; //private field to cache position of next \n character
 
 public SourceStream(ScannerData scannerData, int tabWidth) {
   _scannerData = scannerData;
   TabWidth = tabWidth;
 }
 public virtual void scannerData(int reqId, int rank, ContractDetails contractDetails, string distance, string benchmark, string projection, string legsStr)
 {
     ScannerData?.Invoke(this, new ScannerDataArgs(reqId, rank, contractDetails, distance, benchmark, projection, legsStr));
 }
コード例 #30
0
        //För Excel

        //public void PopulateList(string scanData)
        //{
        //    try
        //    {
        //        data.Add(Excel.CompareXMLWithData(scanData));
        //        QueueList.Dispatcher.Invoke(() =>
        //        {
        //            QueueList.ItemsSource = null;
        //            QueueList.ItemsSource = data;
        //        });
        //    }
        //    catch (Exception e)
        //    {
        //        StatusBar.Dispatcher.Invoke(() =>
        //        {
        //            StatusBar.Content = e.Message;
        //        });
        //    }
        //}

        //För QD-Databas

        public void PopulateList(string scanData)
        {
            DateTimeFormatInfo dfi = DateTimeFormatInfo.CurrentInfo;
            Calendar           cal = dfi.Calendar;

            try
            {
                Application.Current.Dispatcher.Invoke(delegate
                {
                    if (scanData == "\u0018")
                    {
                        ScannerData product = new ScannerData
                        {
                            ArticleNumber = "No Read",
                            ArticleName   = "No Read"
                        };
                        data.Add(product);
                    }
                    else
                    {
                        DBCom db            = new DBCom();
                        ScannerData product = db.DBGet(scanData);

                        if (product == null)
                        {
                            ScannerData notFound = new ScannerData
                            {
                                ArticleNumber = scanData,
                                ArticleName   = "Kunde ej hitta artikel"
                            };
                            data.Add(notFound);
                            StatusBar.Dispatcher.Invoke(() =>
                            {
                                StatusBar.Content = "Kunde ej hitta artikel: " + scanData;
                            });
                        }
                        else
                        {
                            DateTime printDate = datePick.SelectedDate.Value;
                            string weekETI     = cal.GetWeekOfYear(printDate, dfi.CalendarWeekRule, dfi.FirstDayOfWeek).ToString("00");
                            string yearETI     = printDate.ToString("yy");
                            string printETI    = yearETI + weekETI;

                            product.PrintDate = printETI;
                            data.Add(product);
                        }
                    }
                });

                QueueList.Dispatcher.Invoke(() =>
                {
                    QueueList.ItemsSource = null;
                    QueueList.ItemsSource = data;
                });
            }
            catch (Exception e)
            {
                StatusBar.Dispatcher.Invoke(() =>
                {
                    StatusBar.Content = e.Message + scanData;
                });
            }
        }
コード例 #31
0
ファイル: Scanner.cs プロジェクト: Bombadil77/SharpDevelop
 public Scanner(ScannerData data) {
   _data = data;
   _grammar = _data.GrammarData.Grammar;
 }
コード例 #32
0
ファイル: Configuration.cs プロジェクト: binaryage/xrefresh
        private void ScannerWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            // the background process is complete. We need to inspect
            // our response to see if an error occurred, a cancel was
            // requested or if we completed successfully.

            scannerData.dialog.Close();

            // check to see if an error occurred in the background process.
            if (e.Cancelled)
            {
                scannerData = null;
                scannerWorker = null;
                return;
            }

            if (e.Error != null)
            {
                MessageBox.Show(e.Error.Message, "Error");
                scannerData = null;
                scannerWorker = null;
                return;
            }

            string name = scannerData.scanner.SuggestName(scannerData.folder);
            string type = scannerData.scanner.GetName();
            string uname = MakeUniqueName(name);
            try
            {
                Model.FoldersRow folder = model.AddFolder(uname, scannerData.folder, type);
                VisualizeFolder(folder);
                int row = table.TableModel.Rows.Count - 1;
                table.TableModel.Selections.SelectCells(row, 0, row, 2);
                table.EnsureVisible(row, 0);
            }
            catch (Exception ex)
            {
                MessageBox.Show(String.Format("Unable to add new folder: Folder:'{0}'\nType:'{1}'\nUniqueName:'{2}'\nError: {3}", name, type, uname, ex.Message), "Save failed", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            scannerData = null;
            scannerWorker = null;
        }
コード例 #33
0
 public void scannerData(int reqId, int rank, ContractDetails contractDetails, string distance, string benchmark, string projection, string legsStr)
 {
     ScannerData?.Invoke(new ScannerDataMessage(reqId, rank, contractDetails, distance, benchmark, projection, legsStr));
 }
コード例 #34
0
ファイル: IBClient.cs プロジェクト: lulzzz/HedgeHog
 void EWrapper.scannerData(int reqId, int rank, ContractDetails contractDetails, string distance, string benchmark, string projection, string legsStr)
 {
     ScannerData?.Invoke(reqId, rank, contractDetails, distance, benchmark, projection, legsStr);
 }
コード例 #35
0
ファイル: ScannerDataBuilder.cs プロジェクト: TheByte/sones
 private static void EnsureBraceMatchFilter(ScannerData _data)
 {
     foreach (TokenFilter filter in _data.TokenFilters)
     if (filter is BraceMatchFilter) return;
       _data.TokenFilters.Add(new BraceMatchFilter());
 }