Esempio n. 1
0
        private void sendFrame()
        {
            HostDataFrame df = new HostDataFrame();

            df.ChannelsEnabled = new bool[] { AcceptOnes, AcceptFives, AcceptTens, AcceptTwenties, AcceptHundreds };

            // Don't do anything while it's powering up.
            if (!thisState.PowerUp)
            {
                // Accept bills if they're escrowed and bill accepting is turned on.
                if (thisState.Status == StatusState.Escrowed)
                {
                    if (Enabled)
                    {
                        df.ReturnControl = false;
                        df.StackControl  = true;
                    }
                    else
                    {
                        df.ReturnControl = true;
                        df.StackControl  = false;
                    }
                }

                // Dispatch status change events when the status changes.
                if (thisState.Status != lastState.Status)
                {
                    switch (thisState.Status)
                    {
                    case StatusState.None:
                        if (Waiting != null)
                        {
                            Waiting(this);
                        }
                        break;

                    case StatusState.Accepting:
                        if (BillAccepting != null)
                        {
                            BillAccepting(this);
                        }
                        break;

                    case StatusState.Escrowed:
                        if (BillEscrowed != null)
                        {
                            BillEscrowed(this, thisState.Amount);
                        }
                        break;

                    case StatusState.Stacking:
                        if (BillStacking != null)
                        {
                            BillStacking(this, thisState.Amount);
                        }
                        break;

                    case StatusState.Stacked:
                        if (BillStacked != null)
                        {
                            BillStacked(this, thisState.Amount);
                        }
                        break;

                    case StatusState.Returning:
                        if (BillReturning != null)
                        {
                            BillReturning(this);
                        }
                        break;

                    case StatusState.Returned:
                        if (BillReturned != null)
                        {
                            BillReturned(this);
                        }
                        break;

                    case StatusState.Rejecting:
                        if (BillRejecting != null)
                        {
                            BillRejecting(this);
                        }
                        break;

                    case StatusState.Rejected:
                        if (BillRejected != null)
                        {
                            BillRejected(this);
                        }
                        break;
                    }
                }

                // Dispatch event events:
                if (thisState.Failure && !lastState.Failure && Failure != null)
                {
                    Failure(this);
                }
                else if (!thisState.Failure && lastState.Failure && FailureEnded != null)
                {
                    FailureEnded(this);
                }

                if (!thisState.PowerUp && lastState.PowerUp && PoweredUp != null)
                {
                    PoweredUp(this);
                }

                if (thisState.CashboxFull && !lastState.CashboxFull && CashboxFull != null)
                {
                    CashboxFull(this);
                }
                else if (!thisState.CashboxFull && lastState.CashboxFull && CashboxFullEnded != null)
                {
                    CashboxFullEnded(this);
                }

                if (thisState.Cheated && !lastState.Cheated && Cheated != null)
                {
                    Cheated(this);
                }

                if (thisState.NoteJammed && !lastState.NoteJammed && NoteJammed != null)
                {
                    NoteJammed(this);
                }
                else if (!thisState.NoteJammed && lastState.NoteJammed && NoteUnjammed != null)
                {
                    NoteUnjammed(this);
                }

                if (thisState.CashboxPresent && !lastState.CashboxPresent && CashboxPresent != null)
                {
                    CashboxPresent(this);
                }
                else if (!thisState.CashboxPresent && lastState.CashboxPresent && CashboxNotPresent != null)
                {
                    CashboxNotPresent(this);
                }

                if (thisState.InvalidCommand && !lastState.InvalidCommand && InvalidCommand != null)
                {
                    InvalidCommand(this);
                }
            }
            else
            {
                if (!lastState.PowerUp && PowerUp != null)
                {
                    PowerUp(this);
                }
            }

            // Increment the sequence number, or reset it to 0 if it's FFh.
            unchecked
            {
                df.sequenceNumber = (byte)(thisState.SequenceNumber + 1);
            }

            send(df);
        }
        private void sendFrame()
        {
            HostDataFrame df = new HostDataFrame();
            df.ChannelsEnabled = new bool[] { AcceptOnes, AcceptFives, AcceptTens, AcceptTwenties, AcceptHundreds };

            // Don't do anything while it's powering up.
            if (!thisState.PowerUp)
            {
                // Accept bills if they're escrowed and bill accepting is turned on.
                if (thisState.Status == StatusState.Escrowed)
                {
                    if (Enabled)
                    {
                        df.ReturnControl = false;
                        df.StackControl = true;
                    }
                    else
                    {
                        df.ReturnControl = true;
                        df.StackControl = false;
                    }
                }

                // Dispatch status change events when the status changes.
                if (thisState.Status != lastState.Status)
                {
                    switch (thisState.Status)
                    {
                        case StatusState.None:
                            if (Waiting != null)
                            {
                                Waiting(this);
                            }
                            break;
                        case StatusState.Accepting:
                            if (BillAccepting != null)
                            {
                                BillAccepting(this);
                            }
                            break;
                        case StatusState.Escrowed:
                            if (BillEscrowed != null)
                            {
                                BillEscrowed(this, thisState.Amount);
                            }
                            break;
                        case StatusState.Stacking:
                            if (BillStacking != null)
                            {
                                BillStacking(this, thisState.Amount);
                            }
                            break;
                        case StatusState.Stacked:
                            if (BillStacked != null)
                            {
                                BillStacked(this, thisState.Amount);
                            }
                            break;
                        case StatusState.Returning:
                            if (BillReturning != null)
                            {
                                BillReturning(this);
                            }
                            break;
                        case StatusState.Returned:
                            if (BillReturned != null)
                            {
                                BillReturned(this);
                            }
                            break;
                        case StatusState.Rejecting:
                            if (BillRejecting != null)
                            {
                                BillRejecting(this);
                            }
                            break;
                        case StatusState.Rejected:
                            if (BillRejected != null)
                            {
                                BillRejected(this);
                            }
                            break;
                    }
                }

                // Dispatch event events:
                if (thisState.Failure && !lastState.Failure && Failure != null)
                {
                    Failure(this);
                }else if (!thisState.Failure && lastState.Failure && FailureEnded != null)
                {
                    FailureEnded(this);
                }

                if (!thisState.PowerUp && lastState.PowerUp && PoweredUp != null)
                {
                    PoweredUp(this);
                }

                if (thisState.CashboxFull && !lastState.CashboxFull && CashboxFull != null)
                {
                    CashboxFull(this);
                }
                else if (!thisState.CashboxFull && lastState.CashboxFull && CashboxFullEnded != null)
                {
                    CashboxFullEnded(this);
                }

                if (thisState.Cheated && !lastState.Cheated && Cheated != null)
                {
                    Cheated(this);
                }

                if (thisState.NoteJammed && !lastState.NoteJammed && NoteJammed != null)
                {
                    NoteJammed(this);
                }
                else if (!thisState.NoteJammed && lastState.NoteJammed && NoteUnjammed != null)
                {
                    NoteUnjammed(this);
                }

                if (thisState.CashboxPresent && !lastState.CashboxPresent && CashboxPresent != null)
                {
                    CashboxPresent(this);
                }
                else if (!thisState.CashboxPresent && lastState.CashboxPresent && CashboxNotPresent != null)
                {
                    CashboxNotPresent(this);
                }

                if (thisState.InvalidCommand && !lastState.InvalidCommand && InvalidCommand != null)
                {
                    InvalidCommand(this);
                }
            }
            else
            {
                if (!lastState.PowerUp && PowerUp != null)
                {
                    PowerUp(this);
                }
            }

            // Increment the sequence number, or reset it to 0 if it's FFh.
            unchecked
            {
                df.sequenceNumber = (byte)(thisState.SequenceNumber + 1);
            }

            send(df);
        }