Exemple #1
0
        /// <summary>
        /// Load the device.
        /// </summary>
        /// <exception cref="IOException">Cannot load device</exception>
        public void Load()
        {
            if (this.DeviceType == DeviceTypes.None)
            {
                return;
            }

            if (this.DeviceType == DeviceTypes.OPOS)
            {
                NetTracer.Information("Peripheral [CashDrawer] - OPOS device loading: {0}", this.DeviceName ?? "<Undefined>");

                oposCashDrawer = new OPOSCashDrawerClass();

                // Open
                oposCashDrawer.Open(this.DeviceName);
                Peripherals.CheckResultCode(this, oposCashDrawer.ResultCode);

                // Claim
                oposCashDrawer.ClaimDevice(Peripherals.ClaimTimeOut);
                Peripherals.CheckResultCode(this, oposCashDrawer.ResultCode);

                // Enable
                oposCashDrawer.DeviceEnabled      = true;
                oposCashDrawer.StatusUpdateEvent += new _IOPOSCashDrawerEvents_StatusUpdateEventEventHandler(posCashDrawer_StatusUpdateEvent);
            }

            IsActive = true;
        }
Exemple #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);
        }