public void Configure(BarcodeConfig config)
        {
            var command = new BarcodeCommand();

            config.Configure(command);
            _commander.Execute(command);
        }
        public void GetBarcode(BarcodeConfig config)
        {
            var command = new BarcodeCommand();

            config.Configure(command);
            command.TakeNoAction = false;
            _barcodeMonitor.OnBarcodeReceived(command);
            _commander.Execute(command);
        }
 public void OnBarcodeReceived(BarcodeCommand command)
 {
     command.BarcodeReceived += (sender, e) =>
     {
         if (Enable)
         {
             BarcodeReceivedHandler?.Invoke(this, new BarcodeData(e));
         }
     };
 }
Example #4
0
 public void Configure(BarcodeCommand command)
 {
     command.IncludeDateTime        = BoolToTriState(IncludeDateTime);
     command.IsBarcodeEscaped       = BoolToTriState(EscapeBarcode);
     command.UseAlert               = BoolToTriState(UseAlert);
     command.MaxSynchronousWaitTime = SyncWaitTime;
     command.ScanTime               = ScanTime;
     command.TakeNoAction           = true;
     command.ResetParameters        = true;
 }
Example #5
0
        /// <summary>
        /// Initializes a new instance of the MainViewModel class
        /// </summary>
        /// <param name="displayResponder">Captures all responses from the reader and relays them to the user interface</param>
        /// <param name="commander">Used to setup the responder chain and execute ASCII commands</param>
        /// <param name="settings">The display settings</param>
        public MainViewModel(DisplayResponder displayResponder, IAsciiCommandExecuting commander, IDisplaySettings settings, serviceSocket socket)
        {
            InventoryCommand inventoryResponder;
            BarcodeCommand   barcodeResponder;

            if (displayResponder == null)
            {
                throw new ArgumentNullException("displayResponder");
            }

            if (commander == null)
            {
                throw new ArgumentNullException("commander");
            }

            if (settings == null)
            {
                throw new ArgumentNullException("settings");
            }
            this.socket   = socket;
            this.settings = settings;

            // Create a display responder to capture and display all reader responses
            displayResponder.ReceivedLine += delegate(object sender, AsciiLineEventArgs e)
            {
                this.OnResponseLine(e.Line.FullLine);
            };

            // setup an asynchronous responder for inventory
            inventoryResponder = new InventoryCommand();
            inventoryResponder.TransponderReceived += this.AsynchronousTransponder_Received;

            // setup an asynchronous responder for barcodes
            barcodeResponder = new BarcodeCommand();
            barcodeResponder.BarcodeReceived += this.AsynchronousBarcode_Received;

            // set up the responder chain
            this.commander = commander;
            this.commander.ClearResponders();
            this.commander.AddResponder(new LoggerResponder());
            this.commander.AddResponder(displayResponder);
            this.commander.AddSynchronousResponder();
            this.commander.AddResponder(inventoryResponder.Responder);
            this.commander.AddResponder(barcodeResponder.Responder);

            this.synchronousBarcodeCommand = new BarcodeCommand();
            this.synchronousBarcodeCommand.BarcodeReceived += this.SynchronousBarcode_Received;

            this.synchronousInventoryCommand = new InventoryCommand();
            this.synchronousInventoryCommand.TransponderReceived += this.SynchronousTransponder_Received;
        }
        /// <summary>
        /// 初始化一个<see cref="PrintCommand"/>类型的实例
        /// </summary>
        /// <param name="printPaper">打印纸</param>
        /// <param name="encoding">字符编码</param>
        public PrintCommand(IPrintPaper printPaper, Encoding encoding)
        {
            Writer         = new WriterCommand(encoding);
            BarcodeBuilder = new BarcodeBuilder(encoding);

            FontStyle       = new FontStyleCommand();
            PagerCut        = new PagerCutCommand();
            Drawer          = new DrawerCommand();
            QrCode          = new QRCodeCommand();
            Barcode         = new BarcodeCommand(BarcodeBuilder);
            Style           = new StyleCommand(printPaper, encoding);
            InitializePrint = new InitializePrintCommand();
            PrintStyle      = new PrintStyleCommand();
            Image           = new ImageCommand(printPaper);
            PrintLine       = new PrintLineCommand(printPaper);
        }
 public List <AccountInfo> SearchAccountServices(string barcode)
 {
     using (var command = new BarcodeCommand(_settingService.GetServerIP(),
                                             SettingService.WorkingPort,
                                             _currentUser,
                                             barcode))
     {
         command.Execute();
         if (!command.Success)
         {
             throw new CommandException(command.ErrorMessage);
         }
         else
         {
             return(command.AccountInfos);
         }
     }
 }
        private void NurApi_IOChangeEvent(object sender, NurApi.IOChangeEventArgs e)
        {
            if (e.data.source == 100) // 100 == Accessory device trigger
            {
                if (e.data.dir == 1)
                {
                    // Trigger pressed
                }
                else
                {
                    // Trigger released

                    // Ignore if cancelled by device
                    if (!mIgnoreNextTrigger)
                    {
                        BarcodeCommand.Execute(null);
                    }
                    mIgnoreNextTrigger = false;
                }
            }
        }
 public BarcodeMonitor()
 {
     Enable   = true;
     _command = new BarcodeCommand();
     OnBarcodeReceived(_command);
 }