Beispiel #1
0
        public static void Accept(byte[] buffer, int length, ID003CommandCreater ComDll, SerialPort Port)
        {
            //This method will stack the note once the vend valid message is sent by the unit

            bool vend = false;             //value to check if vend valid has been sent

            byte[] status = new byte[255]; //capturing the status message from the serial port

            ComDll.Stack1(buffer);         //we have detected escrow and now sending the stack command.
            length = (int)buffer[1];
            Port.Write(buffer, 0, length); //writing buffer to com port
            System.Threading.Thread.Sleep(100);

            while (!vend)                     //if no vend valid, keep checking status
            {
                ComDll.StatusRequest(buffer); //checking status
                length = (int)buffer[1];
                Port.Write(buffer, 0, length);
                Port.Read(status, 0, 255); //capturing status from the com port
                System.Threading.Thread.Sleep(100);

                if (status[2] == 0x15)  //we have received vend valid response
                {
                    ComDll.Ack(buffer); //Sending an ACK
                    length = (int)buffer[1];
                    Port.Write(buffer, 0, length);
                    vend = true;
                }
            }
        }
Beispiel #2
0
        private void Poll()
        {
            mut.WaitOne();

            Actions.init(buffer, length, ComDll, Port); //Function to Initialize
            mut.ReleaseMutex();
            while (Active)
            {
                ComDll.StatusRequest(buffer);       //Here Status request command is used. The dll constructs the command into buffer
                length = (int)buffer[1];            //the length is position 1 of the array. The length is casted from byte to int.
                mut.WaitOne();
                Port.Write(buffer, 0, length);      //the buffer it is now written to the com port. offset is 0 and the length is given by length.
                Port.Read(status, 0, 255);          //we now read the response of the Bill Acceptor
                mut.ReleaseMutex();
                System.Threading.Thread.Sleep(100); //Wait for 100ms.

                switch (status[2])
                {
                //here we check the status of the bill acceptor.
                case (byte)Status.PowerUP:

                    _eventAggregator.GetEvent <JCMEvents>().Publish(Status.PowerUP);

                    break;

                case (byte)Status.Idling:
                    _eventAggregator.GetEvent <JCMEvents>().Publish(Status.Idling);
                    break;

                case (byte)Status.Inhibit:
                    _eventAggregator.GetEvent <JCMEvents>().Publish(Status.Inhibit);
                    break;

                case (byte)Status.BillinScrow:    //if there is a bill in escrow do the following.
                    mut.WaitOne();
                    Actions.Accept(buffer, length, ComDll, Port);
                    mut.ReleaseMutex();

                    switch (status[3])
                    {
                    case 0x61:
                        _eventAggregator.GetEvent <Cash_credited>().Publish(1000);
                        inventory.UpdateInventory(InventarioCash.Location.JCM, 1000, InventarioCash.TipoOperacion.sumar, 1);

                        break;

                    case 0x62:
                        _eventAggregator.GetEvent <Cash_credited>().Publish(2000);
                        inventory.UpdateInventory(InventarioCash.Location.JCM, 2000, InventarioCash.TipoOperacion.sumar, 1);
                        break;

                    case 0x63:
                        _eventAggregator.GetEvent <Cash_credited>().Publish(5000);
                        inventory.UpdateInventory(InventarioCash.Location.JCM, 5000, InventarioCash.TipoOperacion.sumar, 1);
                        break;

                    case 0x64:
                        _eventAggregator.GetEvent <Cash_credited>().Publish(10000);
                        inventory.UpdateInventory(InventarioCash.Location.JCM, 10000, InventarioCash.TipoOperacion.sumar, 1);
                        break;

                    case 0x65:
                        inventory.UpdateInventory(InventarioCash.Location.JCM, 20000, InventarioCash.TipoOperacion.sumar, 1);
                        _eventAggregator.GetEvent <Cash_credited>().Publish(20000);
                        break;

                    case 0x66:
                        _eventAggregator.GetEvent <Cash_credited>().Publish(50000);
                        inventory.UpdateInventory(InventarioCash.Location.JCM, 50000, InventarioCash.TipoOperacion.sumar, 1);
                        break;

                    case 0x67:
                        inventory.UpdateInventory(InventarioCash.Location.JCM, 100000, InventarioCash.TipoOperacion.sumar, 1);
                        _eventAggregator.GetEvent <Cash_credited>().Publish(100000);
                        break;
                    }
                    break;

                case (byte)Status.Rejected:
                    _eventAggregator.GetEvent <JCMEvents>().Publish(Status.Rejected);
                    break;

                case (byte)Status.StarckerFull:
                    _eventAggregator.GetEvent <JCMEvents>().Publish(Status.StarckerFull);
                    break;

                case (byte)Status.StackerOpen:
                    _eventAggregator.GetEvent <JCMEvents>().Publish(Status.StackerOpen);
                    break;

                case (byte)Status.JamInAcceptor:
                    _eventAggregator.GetEvent <JCMEvents>().Publish(Status.JamInAcceptor);
                    break;

                case (byte)Status.JamInStacker:
                    _eventAggregator.GetEvent <JCMEvents>().Publish(Status.JamInStacker);
                    break;

                case (byte)Status.Paused:
                    _eventAggregator.GetEvent <JCMEvents>().Publish(Status.Paused);
                    break;

                case (byte)Status.Cheated:
                    _eventAggregator.GetEvent <JCMEvents>().Publish(Status.Cheated);
                    break;

                case (byte)Status.MajorFailure:
                    _eventAggregator.GetEvent <JCMEvents>().Publish(Status.MajorFailure);
                    break;

                case (byte)Status.ComError:
                    _eventAggregator.GetEvent <JCMEvents>().Publish(Status.ComError);
                    break;

                    /*All the other status conditions will be handled here (jams, rejections, returned notes, etc).
                     * Other cases will also include error handling.
                     */
                }

                switch (command)
                {
                case 0xA2:
                    byte[] stat = new byte[255];
                    Port.DiscardInBuffer();
                    ComDll.RecyclerCurrentCountRequest(buffer);
                    length = (int)buffer[1];            //the length is position 1 of the array. The length is casted from byte to int.
                    mut.WaitOne();
                    Port.Write(buffer, 0, length);      //the buffer it is now written to the com port. offset is 0 and the length is given by length.
                    System.Threading.Thread.Sleep(50);  //Wait for 100ms.
                    Port.Read(stat, 0, 255);            //we now read the response of the Bill Acceptor
                    mut.ReleaseMutex();
                    System.Threading.Thread.Sleep(100); //Wait for 100ms.
                    int temp = (int)stat[7];
                    //this.Invoke((MethodInvoker)delegate
                    //{
                    //    rc1.Text = stat[5].ToString();
                    //    rc2.Text = stat[7].ToString();
                    //});
                    command = 0x00;
                    break;
                }
            }
        }