示例#1
0
        /// <summary>
        /// Open the cash drawer.
        /// </summary>
        public void OpenDrawer()
        {
            if (FiscalPrinter.FiscalPrinter.Instance.FiscalPrinterEnabled())
            {
                FiscalPrinter.FiscalPrinter.Instance.OpenDrawer();
                return;
            }

            if (IsActive)
            {
                NetTracer.Information("Peripheral [CashDrawer] - Open drawer");

                switch (this.DeviceType)
                {
                case DeviceTypes.OPOS:
                    oposCashDrawer.OpenDrawer();
                    break;

                case DeviceTypes.Windows:
                    using (SerialPort port = new SerialPort(this.DeviceName, 9600, Parity.None, 8, StopBits.One))
                    {
                        port.Open();
                        port.Write(OPEN_DRAWER_SEQUENCE);
                    }
                    break;

                case DeviceTypes.Manual:
                    // NoOp
                    break;
                }
            }
        }
示例#2
0
        public string openCashBox()
        {
            string posNum  = string.Empty;
            string posType = string.Empty;

            try
            {
                //nec的机子,此方法不会真正调钱箱方法,只是会用返回的posNum。真正真正调钱箱方法在IsNec的判断里面
                OpenCashBox.OpenCashBox.openCashBox(out posNum, out posType);
                LogTools.Info(string.Format("调OpenCashBox.openCashBox的结果:posNum:{0},posType:{1}。", posNum, posType));
            }
            catch (Exception ex)
            {
                LogTools.Info("调弹钱箱异常:" + ex.ToString());
            }
            if (IsNec == 1)
            {
                try
                {
                    int num = this.cashDrawer1.Open(cashBox_name);
                    if (num != 0)
                    {
                        cashDrawer1.Close();
                        num = cashDrawer1.Open(cashBox_name);
                        if (num != 0)
                        {
                            throw new Exception("[Pos 2001] 钱箱驱动Open失败!返回码:" + num.ToString());
                        }
                    }
                    int claimResult = cashDrawer1.ClaimDevice(1000);
                    if (claimResult != 0)
                    {
                        throw new Exception("[Pos 2002] 钱箱声明失败!返回码:" + claimResult.ToString());
                    }
                    cashDrawer1.DeviceEnabled = true;
                    cashDrawer1.OpenDrawer();
                    cashDrawer1.DeviceEnabled = false;
                }
                catch (Exception ex)
                {
                    LogTools.Debug("开钱箱异常:" + ex.ToString());
                }
                finally
                {
                    cashDrawer1.ReleaseDevice();
                    cashDrawer1.Close();
                }
            }
            return(posNum);
        }