Beispiel #1
0
        private void Run()
        {
            var back = objCCNET.RunCommand(CCNETCommand.RESET);

            Print.Log("reset->" + back.Message);
            back = objCCNET.RunCommand(CCNETCommand.SET_SECURITY, new byte[3]);
            Print.Log("security->" + back.Message);

            //币类
            //0d 1,5,10
            //
            back = objCCNET.RunCommand(CCNETCommand.ENABLE_BILL_TYPES, new byte[6] {
                0, 0, 0xff, 0, 0, 0
            });
            Print.Log("enable bill types->" + back.Message);
            while (!stop)
            {
                back = objCCNET.RunCommand(CCNETCommand.Poll);
                var item = back.ReceivedData;
                if (item == null)
                {
                    stop = true;
                    break;
                }
                BVStatus bvs = (BVStatus)item[3];
                Print.Log("data len->" + item.Length);
                switch (bvs)
                {
                case BVStatus.Idling:
                {
                    Print.Log("Idling");
                }
                break;

                case BVStatus.EscrowPosition:
                {
                    Print.Log("EscrowPosition");
                }
                break;

                case BVStatus.BillStacked:
                {        //接收纸币完成
                    BillType bt = (BillType)item[4];
                    Print.Log("接收完成纸币:" + bt);
                    //if (MoneyReceived != null)
                    //{
                    int money = 0;
                    switch (bt)
                    {
                    case BillType.RMB1: money = 1; break;

                    case BillType.RMB5: money = 5; break;

                    case BillType.RMB10: money = 10; break;

                    case BillType.RMB20: money = 20; break;

                    case BillType.RMB50: money = 50; break;

                    case BillType.RMB100: money = 100; break;
                    }
                    Print.Log("money->" + money);
                    //TimeSpan ts = DateTime.Now - LastRecDT;
                    //if (ts.TotalSeconds > 1)
                    //    MoneyReceived(money, bt);
                    //else
                    //{
                    //    Print.Log("一秒内又发生收币事件,丢弃");
                    //}
                    //LastRecDT = DateTime.Now;
                    //}
                    if (OnAcceptMoney != null)
                    {
                        OnAcceptMoney(this, money);
                    }
                }
                break;

                case BVStatus.BillReturned:
                {
                    BillType bt = (BillType)item[4];
                    Print.Log("退出纸币:" + bt);
                }
                break;

                case BVStatus.rejecting:
                {
                    RejectingCode rcode = (RejectingCode)item[4];
                    Print.Log("拒收纸币:" + rcode);
                }
                break;

                case BVStatus.UnitDisabled:
                {
                    Print.Log("验币器禁止");
                }
                break;
                }
                Thread.Sleep(poo_sleep_time);
            }
        }
Beispiel #2
0
        private void Run()
        {
            Answer back = null;

            while (!stop)
            {
                back = objCCNET.RunCommand(CCNETCommand.Poll);
                var item = back.ReceivedData;
                if (item == null)
                {
                    stop = true;
                    break;
                }
                BVStatus bvs = (BVStatus)item[3];
                switch (bvs)
                {
                case BVStatus.Idling:
                {
                    Log.In("Idling->" + back.Message);
                }
                break;

                case BVStatus.EscrowPosition:
                {
                    Log.In("EscrowPosition->" + back.Message);
                }
                break;

                case BVStatus.BillStacked:
                {
                    //接收纸币完成
                    BillType bt = (BillType)item[4];
                    Log.In("接收完成纸币:" + bt);
                    //if (MoneyReceived != null)
                    //{
                    Log.In("data->" + back.Message + " " + item.ToStr());
                    int money = 0;
                    switch (bt)
                    {
                    case BillType.RMB1: money = 20; break;

                    case BillType.RMB5: money = 50; break;

                    case BillType.RMB10: money = 100; break;

                    case BillType.RMB20: money = 200; break;
                    }
                    //TimeSpan ts = DateTime.Now - LastRecDT;
                    //if (ts.TotalSeconds > 1)
                    //    MoneyReceived(money, bt);
                    //else
                    //{
                    //    Log.In("一秒内又发生收币事件,丢弃");
                    //}
                    //LastRecDT = DateTime.Now;
                    //}
                    if (OnAcceptMoney != null)
                    {
                        OnAcceptMoney(this, money);
                    }
                }
                break;

                case BVStatus.BillReturned:
                {
                    BillType bt = (BillType)item[4];
                    Log.In("退出纸币->" + back.Message);
                }
                break;

                case BVStatus.rejecting:
                {
                    RejectingCode rcode = (RejectingCode)item[4];
                    Log.In("拒收纸币:" + rcode + "->" + back.Message);
                }
                break;

                case BVStatus.UnitDisabled:
                {
                    Log.In("验币器禁止" + "->" + back.Message);
                }
                break;
                }
                Thread.Sleep(poo_sleep_time);
            }
        }