コード例 #1
0
ファイル: CPayout.cs プロジェクト: kalkansa/stserver
        // This function uses the FLOAT AMOUNT command to set the float amount. The validator will empty
        // notes into the cashbox leaving the requested floating amount in the payout. The minimum payout
        // is also setup so the validator will leave itself the ability to payout the minimum value requested.
        public void SetFloat(int minPayout, int floatAmount, char[] currency, TextBox log = null)
        {
            cmd.CommandData[0] = CCommands.SMARTPayout.SSP_CMD_FLOAT_AMOUNT;
            byte[] b = CHelpers.ConvertInt32ToBytes(minPayout);
            cmd.CommandData[1] = b[0];
            cmd.CommandData[2] = b[1];
            cmd.CommandData[3] = b[2];
            cmd.CommandData[4] = b[3];
            b = CHelpers.ConvertInt32ToBytes(floatAmount);
            cmd.CommandData[5] = b[0];
            cmd.CommandData[6] = b[1];
            cmd.CommandData[7] = b[2];
            cmd.CommandData[8] = b[3];

            // Add currency
            cmd.CommandData[9]  = (byte)currency[0];
            cmd.CommandData[10] = (byte)currency[1];
            cmd.CommandData[11] = (byte)currency[2];

            cmd.CommandData[12] = 0x58; // real float (could use 0x19 for test)

            cmd.CommandDataLength = 13;

            if (!SendCommand(log) || !CheckGenericResponses(log))
            {
                return;
            }

            if (log != null)
            {
                log.AppendText("Floated amount successfully\r\n");
            }
        }
コード例 #2
0
ファイル: CPayout.cs プロジェクト: kalkansa/stserver
        // This function calls the PAYOUT AMOUNT command to payout a specified value. This can be sent
        // with the option byte 0x19 to test whether the payout is possible or 0x58 to actually do the payout.
        public void PayoutAmount(int amount, char[] currency, bool test = false, TextBox log = null)
        {
            cmd.CommandData[0] = CCommands.SMARTPayout.SSP_CMD_PAYOUT_AMOUNT;
            byte[] b = CHelpers.ConvertInt32ToBytes(amount);
            cmd.CommandData[1] = b[0];
            cmd.CommandData[2] = b[1];
            cmd.CommandData[3] = b[2];
            cmd.CommandData[4] = b[3];

            cmd.CommandData[5] = (byte)currency[0];
            cmd.CommandData[6] = (byte)currency[1];
            cmd.CommandData[7] = (byte)currency[2];

            if (!test)
            {
                cmd.CommandData[8] = 0x58; // real payout
            }
            else
            {
                cmd.CommandData[8] = 0x19; // test payout
            }
            cmd.CommandDataLength = 9;
            if (!SendCommand(log) || !CheckGenericResponses(log))
            {
                return;
            }

            if (log != null)
            {
                log.AppendText("Paying out " + CHelpers.FormatToCurrency(amount) + " " +
                               new string(currency) + "\r\n");
            }
        }
コード例 #3
0
ファイル: CNV11.cs プロジェクト: kalkansa/stserver
        // This function uses the GET ROUTING command to determine whether a particular note
        // is recycling.
        void IsNoteRecycling(int note, char[] currency, ref bool b, TextBox log = null)
        {
            cmd.CommandData[0] = CCommands.SSP_CMD_GET_ROUTING;
            byte[] byteArr = CHelpers.ConvertIntToBytes(note);
            cmd.CommandData[1]    = byteArr[0];
            cmd.CommandData[2]    = byteArr[1];
            cmd.CommandData[3]    = byteArr[2];
            cmd.CommandData[4]    = byteArr[3];
            cmd.CommandData[5]    = (byte)currency[0];
            cmd.CommandData[6]    = (byte)currency[1];
            cmd.CommandData[7]    = (byte)currency[2];
            cmd.CommandDataLength = 8;

            if (!SendCommand(log))
            {
                return;
            }
            if (CheckGenericResponses(log))
            {
                if (cmd.ResponseData[1] == 0x00)
                {
                    b = true;
                }
                else
                {
                    b = false;
                }
            }
        }
コード例 #4
0
ファイル: Form1.cs プロジェクト: kalkansa/stserver
        private void ReconnectNV11()
        {
            OutputMessage m = new OutputMessage(AppendToTextBox);

            NV11Connecting = true;
            while (!NV11Running)
            {
                if (textBox1.InvokeRequired)
                {
                    textBox1.Invoke(m, new object[] { "Attempting to reconnect to NV11...\r\n" });
                }
                else
                {
                    textBox1.AppendText("Attempting to reconnect to NV11...\r\n");
                }

                ConnectToNV11(null); // Have to pass null as can't update text box from a different thread without invoking

                CHelpers.Pause(1000);
                if (CHelpers.Shutdown)
                {
                    return;
                }
            }
            if (textBox1.InvokeRequired)
            {
                textBox1.Invoke(m, new object[] { "Reconnected to NV11\r\n" });
            }
            else
            {
                textBox1.AppendText("Reconnected to NV11\r\n");
            }
            NV11.EnableValidator();
            NV11Connecting = false;
        }
コード例 #5
0
        // This function gets the CASHBOX PAYOUT OPERATION DATA from the validator and returns it as a string
        public void GetCashboxPayoutOpData(TextBox log = null)
        {
            // first send the command
            m_cmd.CommandData[0]    = CCommands.Hopper.SSP_CMD_CASHBOX_PAYOUT_OP_DATA;
            m_cmd.CommandDataLength = 1;

            if (!SendCommand(log))
            {
                return;
            }

            // now deal with the response data
            if (CheckGenericResponses(log))
            {
                // number of different coins
                int    n             = m_cmd.ResponseData[1];
                string displayString = "Number of Total Coins: " + n.ToString() + "\r\n\r\n";
                int    i             = 0;
                for (i = 2; i < (9 * n); i += 9)
                {
                    displayString += "Moved " + CHelpers.ConvertBytesToInt16(m_cmd.ResponseData, i) +
                                     " x " + CHelpers.FormatToCurrency(CHelpers.ConvertBytesToInt32(m_cmd.ResponseData, i + 2)) +
                                     " " + (char)m_cmd.ResponseData[i + 6] + (char)m_cmd.ResponseData[i + 7] + (char)m_cmd.ResponseData[i + 8]
                                     + " to cashbox\r\n";
                }
                displayString += CHelpers.ConvertBytesToInt32(m_cmd.ResponseData, i) + " coins not recognised\r\n";

                if (log != null)
                {
                    log.AppendText(displayString);
                }
            }
        }
コード例 #6
0
        // This uses the PAYOUT AMOUNT command to payout a value specified by the param amountToPayout.
        // Protocol 6+ - We can use an option byte to test whether the payout is possible (0x19), and if
        // it is then we can resend with the option byte 0x58 to do the payout.
        public bool PayoutAmount(int amountToPayout, char[] currency, TextBox log = null)
        {
            m_cmd.CommandData[0] = CCommands.Hopper.SSP_CMD_PAYOUT_AMOUNT;

            // Value to payout
            byte[] b = CHelpers.ConvertInt32ToBytes(amountToPayout);
            m_cmd.CommandData[1] = b[0];
            m_cmd.CommandData[2] = b[1];
            m_cmd.CommandData[3] = b[2];
            m_cmd.CommandData[4] = b[3];

            // Country code
            m_cmd.CommandData[5] = (byte)currency[0];
            m_cmd.CommandData[6] = (byte)currency[1];
            m_cmd.CommandData[7] = (byte)currency[2];

            m_cmd.CommandData[8] = 0x58; // payout option (0x19 for test, 0x58 for real)

            m_cmd.CommandDataLength = 9;

            if (!SendCommand(log))
            {
                return(false);
            }

            if (CheckGenericResponses(log))
            {
                return(true);
            }
            return(false);
        }
コード例 #7
0
ファイル: CPayout.cs プロジェクト: kalkansa/stserver
        // This function uses the command GET NOTE AMOUNT to find out the number of
        // a specified type of note stored in the payout. Returns the number of notes stored
        // of that denomination.
        public int CheckNoteLevel(int note, char[] currency, TextBox log = null)
        {
            cmd.CommandData[0] = CCommands.SSP_CMD_GET_NOTE_AMOUNT;
            byte[] b = CHelpers.ConvertIntToBytes(note);
            cmd.CommandData[1] = b[0];
            cmd.CommandData[2] = b[1];
            cmd.CommandData[3] = b[2];
            cmd.CommandData[4] = b[3];

            cmd.CommandData[5]    = (byte)currency[0];
            cmd.CommandData[6]    = (byte)currency[1];
            cmd.CommandData[7]    = (byte)currency[2];
            cmd.CommandDataLength = 8;

            if (!SendCommand(log))
            {
                return(0);
            }
            if (CheckGenericResponses(log))
            {
                int i = (int)cmd.ResponseData[1];
                return(i);
            }
            return(0);
        }
コード例 #8
0
ファイル: Form1.cs プロジェクト: kalkansa/stserver
        // This is a one off function that is called the first time the MainLoop()
        // function runs, it just sets up a few of the UI elements that only need
        // updating once.
        private void SetupFormLayout()
        {
            // need validator class instance
            if (Payout == null)
            {
                MessageBox.Show("Validator class is null.", "ERROR");
                return;
            }

            // Positioning
            int x = 600, y = 40;

            // Add label
            Label lbl = new Label();

            lbl.Location = new Point(x, y - 10);
            lbl.Size     = new Size(80, 30);
            lbl.Text     = "Recycle\nChannels:";
            Controls.Add(lbl);

            for (int i = 1; i <= Payout.NumberOfChannels; i++)
            {
                CheckBox c = new CheckBox();
                c.Location = new Point(x, y + (i * 20));
                c.Name     = i.ToString();
                ChannelData d = new ChannelData();
                Payout.GetDataByChannel(i, ref d);
                c.Text            = CHelpers.FormatToCurrency(d.Value) + " " + new String(d.Currency);
                c.Checked         = d.Recycling;
                c.CheckedChanged += new EventHandler(recycleBox_CheckedChange);
                Controls.Add(c);
            }
        }
コード例 #9
0
ファイル: Form1.cs プロジェクト: kalkansa/stserver
        // This function is run in a seperate thread, it allows a reconnection to a validator to happen in the
        // background.
        private void ReconnectValidator()
        {
            OutputMessage m = new OutputMessage(AppendToTextBox); // setup delegate

            while (!validatorRunning)
            {
                if (CHelpers.Shutdown)
                {
                    return;
                }
                // Check for cross-thread access
                if (textBox1.InvokeRequired)
                {
                    textBox1.Invoke(m, new object[] { "Attempting to reconnect to note validator...\r\n" });
                }
                else
                {
                    textBox1.AppendText("Attempting to reconnect to note validator...\r\n");
                }

                // Attempt reconnect (can't pass text box across for output as the class does not
                // deal with threading issues).
                ConnectToNoteValidator();
                CHelpers.Pause(1000);
            }
            if (textBox1.InvokeRequired)
            {
                textBox1.Invoke(m, new object[] { "Reconnected to note validator\r\n" });
            }
            else
            {
                textBox1.AppendText("Reconnected to note validator\r\n");
            }
            Validator.EnableValidator();
        }
コード例 #10
0
ファイル: Form1.cs プロジェクト: kalkansa/stserver
        // This is a one off function that is called the first time the MainLoop()
        // function runs, it just sets up a few of the UI elements that only need
        // updating once.
        private void SetupFormLayout()
        {
            // Basic Validator UI setup

            // Get channel levels in hopper
            tbCoinLevels.Text = Hopper.GetChannelLevelInfo();

            // setup list of recyclable channel tick boxes based on OS type
            System.OperatingSystem osInfo = System.Environment.OSVersion;
            int x = 560, y = 47;

            Label l = new Label();

            l.Location = new Point(x, y);
            l.Size     = new Size(65, 38);
            l.Name     = "lblRecycleCheckBoxes";
            l.Text     = "Recycle\nChannels:";
            Controls.Add(l);

            for (int i = 1; i <= Hopper.NumberOfChannels; i++)
            {
                CheckBox c = new CheckBox();
                c.Location = new Point(x, y + 15 + (i * 20));
                c.Name     = i.ToString();
                c.Text     = CHelpers.FormatToCurrency(Hopper.GetChannelValue(i)) +
                             " " + new String(Hopper.GetChannelCurrency(i));
                c.Checked         = Hopper.IsChannelRecycling(i);
                c.CheckedChanged += new EventHandler(recycleBox_CheckedChange);
                Controls.Add(c);
            }
        }
コード例 #11
0
ファイル: Form1.cs プロジェクト: jjmucci/stserver
        // This is a one off function that is called the first time the MainLoop()
        // function runs, it just sets up a few of the UI elements that only need
        // updating once.
        private void SetupFormLayout()
        {
            // need validator class instance
            if (Hopper == null)
            {
                MessageBox.Show("Validator class is null.", "ERROR");
                return;
            }

            // Positioning
            int x = 555, y = 30;

            Label lbl = new Label();

            lbl.Location = new Point(x, y);
            lbl.Size     = new Size(70, 35);
            lbl.Name     = "lbl";
            lbl.Text     = "Recycle\nChannels:";
            Controls.Add(lbl);

            y += 20;
            for (int i = 1; i <= Hopper.NumberOfChannels; i++)
            {
                CheckBox c = new CheckBox();
                c.Location        = new Point(x, y + (i * 20));
                c.Name            = i.ToString();
                c.Text            = CHelpers.FormatToCurrency(Hopper.GetChannelValue(i)) + " " + new String(Hopper.GetChannelCurrency(i));
                c.Checked         = Hopper.IsChannelRecycling(i);
                c.CheckedChanged += new EventHandler(recycleBox_CheckedChange);
                Controls.Add(c);
            }
        }
コード例 #12
0
ファイル: CPayout.cs プロジェクト: kalkansa/stserver
        // This function uses the GET ROUTING command to see if a specified note is recycling. The
        // caller passes a bool across which is set by the function.
        public void IsNoteRecycling(int noteValue, char[] currency, ref bool response, TextBox log = null)
        {
            // Determine if the note is currently being recycled
            cmd.CommandData[0] = CCommands.SMARTPayout.SSP_CMD_GET_ROUTING;
            byte[] b = CHelpers.ConvertInt32ToBytes(noteValue);
            cmd.CommandData[1] = b[0];
            cmd.CommandData[2] = b[1];
            cmd.CommandData[3] = b[2];
            cmd.CommandData[4] = b[3];

            // Add currency
            cmd.CommandData[5]    = (byte)currency[0];
            cmd.CommandData[6]    = (byte)currency[1];
            cmd.CommandData[7]    = (byte)currency[2];
            cmd.CommandDataLength = 8;

            if (!SendCommand(log) || !CheckGenericResponses(log))
            {
                return;
            }

            // True if it is currently being recycled
            if (cmd.ResponseData[1] == 0x00)
            {
                response = true;
            }
            // False if not
            else if (cmd.ResponseData[1] == 0x01)
            {
                response = false;
            }
        }
コード例 #13
0
ファイル: Form1.cs プロジェクト: kalkansa/stserver
        // These functions are run in a seperate thread to allow the main loop to continue executing.
        private void ReconnectHopper()
        {
            OutputMessage m = new OutputMessage(AppendToTextBox);

            hopperConnecting = true;
            while (!hopperRunning)
            {
                if (textBox1.InvokeRequired)
                {
                    textBox1.Invoke(m, new object[] { "Attempting to reconnect to SMART Hopper...\r\n" });
                }
                else
                {
                    textBox1.AppendText("Attempting to reconnect to SMART Hopper...\r\n");
                }

                ConnectToHopper();
                CHelpers.Pause(1000);
                if (CHelpers.Shutdown)
                {
                    return;
                }
            }
            if (textBox1.InvokeRequired)
            {
                textBox1.Invoke(m, new object[] { "Reconnected to SMART Hopper\r\n" });
            }
            else
            {
                textBox1.AppendText("Reconnected to SMART Hopper\r\n");
            }
            Hopper.EnableValidator();
            hopperConnecting = false;
        }
コード例 #14
0
ファイル: frmPayoutByDenom.cs プロジェクト: kalkansa/stserver
        private void PayoutBtn_Click(object sender, EventArgs e)
        {
            bool payoutRequired = false;

            byte[] data           = new byte[9 * Hopper.NumberOfChannels]; // create to size of maximum possible
            byte   length         = 0;
            int    dataIndex      = 0;
            byte   denomsToPayout = 0;

            // For each denomination
            for (int i = 0; i < Hopper.NumberOfChannels; i++)
            {
                try
                {
                    // Check if there is input in the box
                    if (AmountToPayout[i].Text != "" && AmountToPayout[i].Text != "0")
                    {
                        // If textbox isn't blank then this denom is being paid out
                        denomsToPayout++;
                        length        += 9;    // 9 bytes per denom to payout (2 amount, 4 value, 3 currency)
                        payoutRequired = true; // need to do a payout as there is now > 0 denoms

                        // Number of this denomination to payout
                        UInt16 numToPayout = UInt16.Parse(AmountToPayout[i].Text);
                        byte[] b           = CHelpers.ConvertInt16ToBytes((short)numToPayout);
                        data[dataIndex++] = b[0];
                        data[dataIndex++] = b[1];

                        // Value of this denomination
                        ChannelData d = Hopper.UnitDataList[i];
                        b = CHelpers.ConvertInt32ToBytes(d.Value);
                        data[dataIndex++] = b[0];
                        data[dataIndex++] = b[1];
                        data[dataIndex++] = b[2];
                        data[dataIndex++] = b[3];

                        // Currency of this denomination
                        data[dataIndex++] = (Byte)d.Currency[0];
                        data[dataIndex++] = (Byte)d.Currency[1];
                        data[dataIndex++] = (Byte)d.Currency[2];
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                    payoutRequired = false; // don't payout on exception
                }
            }

            if (payoutRequired)
            {
                // Send payout command and shut this form
                Hopper.PayoutByDenomination(denomsToPayout, data, length, Output);
                base.Dispose();
            }
        }
コード例 #15
0
        // Set a channel to route to storage, this sends the SET ROUTING command.
        public void RouteChannelToStorage(int channelNumber, TextBox log = null)
        {
            // setup command
            m_cmd.CommandData[0] = CCommands.Hopper.SSP_CMD_SET_ROUTING;
            m_cmd.CommandData[1] = 0x00; // storage

            // coin to route

            // Get value of coin (4 byte protocol 6)
            byte[] b = CHelpers.ConvertInt32ToBytes(GetChannelValue(channelNumber));
            m_cmd.CommandData[2] = b[0];
            m_cmd.CommandData[3] = b[1];
            m_cmd.CommandData[4] = b[2];
            m_cmd.CommandData[5] = b[3];

            // Add country code, locate from dataset
            foreach (ChannelData d in m_UnitDataList)
            {
                if (d.Channel == channelNumber)
                {
                    m_cmd.CommandData[6] = (byte)d.Currency[0];
                    m_cmd.CommandData[7] = (byte)d.Currency[1];
                    m_cmd.CommandData[8] = (byte)d.Currency[2];
                    break;
                }
            }

            m_cmd.CommandDataLength = 9;

            // send command
            if (!SendCommand(log))
            {
                return;
            }

            if (CheckGenericResponses(log))
            {
                // update list
                foreach (ChannelData d in m_UnitDataList)
                {
                    if (d.Channel == channelNumber)
                    {
                        d.Recycling = true;
                        break;
                    }
                }

                if (log != null)
                {
                    log.AppendText("Successfully routed coin on channel " + channelNumber.ToString() + " to storage\r\n");
                }
            }
        }
コード例 #16
0
        // This uses the SET COIN AMOUNT command to increase a channel level by passing over the channel and the amount to increment by
        public void SetCoinLevelsByChannel(int channel, short amount, TextBox log = null)
        {
            m_cmd.CommandData[0] = CCommands.Hopper.SSP_CMD_SET_COIN_AMOUNT;
            // Level to set
            byte[] b = CHelpers.ConvertInt16ToBytes(amount);
            m_cmd.CommandData[1] = b[0];
            m_cmd.CommandData[2] = b[1];

            // Coin(channel) to set
            b = CHelpers.ConvertInt32ToBytes(GetChannelValue(channel));
            m_cmd.CommandData[3] = b[0];
            m_cmd.CommandData[4] = b[1];
            m_cmd.CommandData[5] = b[2];
            m_cmd.CommandData[6] = b[3];

            // Add country code, locate from dataset
            foreach (ChannelData d in m_UnitDataList)
            {
                if (d.Channel == channel)
                {
                    m_cmd.CommandData[7] = (byte)d.Currency[0];
                    m_cmd.CommandData[8] = (byte)d.Currency[1];
                    m_cmd.CommandData[9] = (byte)d.Currency[2];
                    break;
                }
            }

            m_cmd.CommandDataLength = 10;

            if (!SendCommand(log))
            {
                return;
            }
            if (CheckGenericResponses(log))
            {
                // Update the level
                foreach (ChannelData d in m_UnitDataList)
                {
                    if (d.Channel == channel)
                    {
                        d.Level += amount;
                        break;
                    }
                }

                if (log != null)
                {
                    log.AppendText("Changed coin value " + CHelpers.FormatToCurrency(GetChannelValue(channel)).ToString() +
                                   "'s level to " + amount.ToString() + "\r\n");
                }
            }
        }
コード例 #17
0
ファイル: CPayout.cs プロジェクト: kalkansa/stserver
        // The set routing command changes the way the validator deals with a note, either it can send the note straight to the cashbox
        // or it can store the note for payout. This is specified in the second byte (0x00 to store for payout, 0x01 for cashbox). The
        // bytes after this represent the 4 bit value of the note.
        // This function allows the note to be specified as an int in the param note, the stack bool is true for cashbox, false for storage.
        public void ChangeNoteRoute(int note, char[] currency, bool stack, TextBox log = null)
        {
            cmd.CommandData[0] = CCommands.SMARTPayout.SSP_CMD_SET_ROUTING;

            // if this note is being changed to stack (cashbox)
            if (stack)
            {
                cmd.CommandData[1] = 0x01;
            }
            // note being stored (payout)
            else
            {
                cmd.CommandData[1] = 0x00;
            }

            // get the note as a byte array
            byte[] b = BitConverter.GetBytes(note);
            cmd.CommandData[2] = b[0];
            cmd.CommandData[3] = b[1];
            cmd.CommandData[4] = b[2];
            cmd.CommandData[5] = b[3];

            // send country code (protocol 6+)
            cmd.CommandData[6] = (byte)currency[0];
            cmd.CommandData[7] = (byte)currency[1];
            cmd.CommandData[8] = (byte)currency[2];

            cmd.CommandDataLength = 9;

            if (!SendCommand(log) || !CheckGenericResponses(log))
            {
                return;
            }

            if (log != null)
            {
                string s = new string(currency);
                if (stack)
                {
                    s += " to cashbox)\r\n";
                }
                else
                {
                    s += " to storage)\r\n";
                }

                log.AppendText("Note routing successful (" + CHelpers.FormatToCurrency(note) + " " + s);
            }
        }
コード例 #18
0
ファイル: CNV11.cs プロジェクト: kalkansa/stserver
 // The get note positions command instructs the validator to return in the second byte the number of
 // notes stored and then in the following bytes, the values/channel (see SetValueReportingType()) of the stored
 // notes. The length of the response will vary based on the number of stored notes.
 public void CheckForStoredNotes(TextBox log = null)
 {
     cmd.CommandData[0]    = CCommands.SSP_CMD_GET_NOTE_POSITIONS;
     cmd.CommandDataLength = 1;
     if (!SendCommand(log))
     {
         return;
     }
     if (CheckGenericResponses(log))
     {
         int counter = 0;
         Array.Clear(m_NotePositionValues, 0, m_NotePositionValues.Length);
         // Work backwards for a more accurate display (LIFO)
         for (int i = (cmd.ResponseData[1] * 4) + 1; i >= 2; i -= 4, counter++)
         {
             m_NotePositionValues[counter] = CHelpers.ConvertBytesToInt32(cmd.ResponseData, i - 3);
         }
     }
 }
コード例 #19
0
        // This function uses the GET ROUTING command to see if a specified coin is recycling. The
        // caller passes a bool across which is set by the function.
        public void IsCoinRecycling(int coinValue, char[] currency, ref bool response, TextBox log = null)
        {
            // First determine if the coin is currently being recycled
            m_cmd.CommandData[0] = CCommands.Hopper.SSP_CMD_GET_ROUTING;
            byte[] b = CHelpers.ConvertInt32ToBytes(coinValue);
            m_cmd.CommandData[1] = b[0];
            m_cmd.CommandData[2] = b[1];
            m_cmd.CommandData[3] = b[2];
            m_cmd.CommandData[4] = b[3];

            // Add currency
            m_cmd.CommandData[5]    = (byte)currency[0];
            m_cmd.CommandData[6]    = (byte)currency[1];
            m_cmd.CommandData[7]    = (byte)currency[2];
            m_cmd.CommandDataLength = 8;

            if (!SendCommand(log))
            {
                return;
            }
            if (CheckGenericResponses(log))
            {
                // True if it is currently being recycled
                if (m_cmd.ResponseData[1] == 0x00)
                {
                    response = true;
                    if (log != null)
                    {
                        log.AppendText(CHelpers.FormatToCurrency(coinValue) + " is recycling\r\n");
                    }
                }
                // False if not
                else if (m_cmd.ResponseData[1] == 0x01)
                {
                    response = false;
                    if (log != null)
                    {
                        log.AppendText(CHelpers.FormatToCurrency(coinValue) + " is not recycling\r\n");
                    }
                }
            }
        }
コード例 #20
0
ファイル: Form1.cs プロジェクト: kalkansa/stserver
        // This is a one off function that is called the first time the MainLoop()
        // function runs, it just sets up a few of the UI elements that only need
        // updating once.
        private void SetupFormLayout()
        {
            // Note float UI setup

            // Find number and value of channels in NV11 and update combo box
            cbRecycleChannelNV11.Items.Add("No recycling");
            foreach (ChannelData d in NV11.UnitDataList)
            {
                cbRecycleChannelNV11.Items.Add(d.Value / 100 + " " + new String(d.Currency));
            }
            cbRecycleChannelNV11.SelectedIndex = 0;

            // Get channel levels in hopper
            tbCoinLevels.Text = Hopper.GetChannelLevelInfo();

            // setup list of recyclable channel tick boxes
            int x = 0, y = 0;

            x = 465;
            y = 30;

            Label lbl = new Label();

            lbl.Location = new Point(x, y);
            lbl.Size     = new Size(70, 35);
            lbl.Name     = "lbl";
            lbl.Text     = "Recycle\nChannels:";
            Controls.Add(lbl);

            y += 20;
            for (int i = 1; i <= Hopper.NumberOfChannels; i++)
            {
                CheckBox c = new CheckBox();
                c.Location        = new Point(x, y + (i * 20));
                c.Name            = i.ToString();
                c.Text            = CHelpers.FormatToCurrency(Hopper.GetChannelValue(i)) + " " + new String(Hopper.GetChannelCurrency(i));
                c.Checked         = Hopper.IsChannelRecycling(i);
                c.CheckedChanged += new EventHandler(recycleBox_CheckedChange);
                Controls.Add(c);
            }
        }
コード例 #21
0
        // This uses the GET COIN AMOUNT command to query the validator on a specified coin it has stored, it returns
        // the level as an int.
        public short CheckCoinLevel(int coinValue, char[] currency, TextBox log = null)
        {
            m_cmd.CommandData[0] = CCommands.Hopper.SSP_CMD_GET_COIN_AMOUNT;
            byte[] b = CHelpers.ConvertInt32ToBytes(coinValue);
            m_cmd.CommandData[1]    = b[0];
            m_cmd.CommandData[2]    = b[1];
            m_cmd.CommandData[3]    = b[2];
            m_cmd.CommandData[4]    = b[3];
            m_cmd.CommandData[5]    = (byte)currency[0];
            m_cmd.CommandData[6]    = (byte)currency[1];
            m_cmd.CommandData[7]    = (byte)currency[2];
            m_cmd.CommandDataLength = 8;

            if (!SendCommand(log) || !CheckGenericResponses(log))
            {
                return(0);
            }
            short ret = CHelpers.ConvertBytesToInt16(m_cmd.ResponseData, 1);

            return(ret);
        }
コード例 #22
0
        // This function uses the FLOAT AMOUNT command to set the float amount. The Hopper will empty
        // coins into the cashbox leaving the requested floating amount in the payout. The minimum payout
        // is also setup so the validator will leave itself the ability to payout the minimum value requested.
        public bool SetFloat(short minPayout, int floatAmount, char[] currency, TextBox log = null)
        {
            m_cmd.CommandData[0] = CCommands.Hopper.SSP_CMD_FLOAT_AMOUNT;

            // Min payout
            byte[] b = CHelpers.ConvertInt16ToBytes(minPayout);
            m_cmd.CommandData[1] = b[0];
            m_cmd.CommandData[2] = b[1];

            // Amount to payout
            b = CHelpers.ConvertInt32ToBytes(floatAmount);
            m_cmd.CommandData[3] = b[0];
            m_cmd.CommandData[4] = b[1];
            m_cmd.CommandData[5] = b[2];
            m_cmd.CommandData[6] = b[3];

            // Country code
            m_cmd.CommandData[7] = (byte)currency[0];
            m_cmd.CommandData[8] = (byte)currency[1];
            m_cmd.CommandData[9] = (byte)currency[2];

            m_cmd.CommandData[10] = 0x58; // real float

            m_cmd.CommandDataLength = 11;

            if (!SendCommand(log))
            {
                return(false);
            }

            if (CheckGenericResponses(log))
            {
                if (log != null)
                {
                    log.AppendText("Set float successfully\r\n");
                }
                return(true);
            }
            return(false);
        }
コード例 #23
0
        // This uses the SET COIN AMOUNT command to increase a channel level by passing over the coin value and the amount to increment by
        public void SetCoinLevelsByCoin(int coin, char[] currency, short amount, TextBox log = null)
        {
            m_cmd.CommandData[0] = CCommands.Hopper.SSP_CMD_SET_COIN_AMOUNT;
            byte[] b = CHelpers.ConvertInt16ToBytes(amount);
            m_cmd.CommandData[1] = b[0];
            m_cmd.CommandData[2] = b[1];
            b = CHelpers.ConvertInt32ToBytes(coin);
            m_cmd.CommandData[3]    = b[0];
            m_cmd.CommandData[4]    = b[1];
            m_cmd.CommandData[5]    = b[2];
            m_cmd.CommandData[6]    = b[3];
            m_cmd.CommandData[7]    = (byte)currency[0];
            m_cmd.CommandData[8]    = (byte)currency[1];
            m_cmd.CommandData[9]    = (byte)currency[2];
            m_cmd.CommandDataLength = 10;

            if (!SendCommand(log))
            {
                return;
            }
            if (CheckGenericResponses(log))
            {
                // Update the level
                foreach (ChannelData d in m_UnitDataList)
                {
                    if (d.Value == coin)
                    {
                        d.Level += amount;
                        break;
                    }
                }

                if (log != null)
                {
                    log.AppendText("Increased coin value " + CHelpers.FormatToCurrency(coin).ToString() + "'s level by " + amount.ToString() + "\r\n");
                }
            }
        }
コード例 #24
0
ファイル: CPayout.cs プロジェクト: kalkansa/stserver
        // The poll function is called repeatedly to poll to validator for information, it returns as
        // a response in the command structure what events are currently happening.
        public bool DoPoll(TextBox log)
        {
            byte i;

            //send poll
            cmd.CommandData[0]    = CCommands.Generic.SSP_CMD_POLL;
            cmd.CommandDataLength = 1;

            if (!SendCommand(log))
            {
                return(false);
            }
            if (cmd.ResponseData[0] == 0xFA)
            {
                return(false);
            }

            // store response locally so data can't get corrupted by other use of the cmd variable
            byte[] response = new byte[255];
            cmd.ResponseData.CopyTo(response, 0);
            byte responseLength = cmd.ResponseDataLength;

            //parse poll response
            ChannelData data = new ChannelData();

            for (i = 1; i < responseLength; ++i)
            {
                switch (response[i])
                {
                // This response indicates that the unit was reset and this is the first time a poll
                // has been called since the reset.
                case CCommands.SMARTPayout.SSP_POLL_RESET:
                    log.AppendText("Unit reset\r\n");
                    UpdateData();
                    break;

                // This response indicates the unit is disabled.
                case CCommands.SMARTPayout.SSP_POLL_DISABLED:
                    log.AppendText("Unit disabled...\r\n");
                    break;

                // A note is currently being read by the validator sensors. The second byte of this response
                // is zero until the note's type has been determined, it then changes to the channel of the
                // scanned note.
                case CCommands.SMARTPayout.SSP_POLL_NOTE_READ:
                    if (cmd.ResponseData[i + 1] > 0)
                    {
                        GetDataByChannel(response[i + 1], ref data);
                        log.AppendText("Note in escrow, amount: " + CHelpers.FormatToCurrency(data.Value) + "\r\n");
                    }
                    else
                    {
                        log.AppendText("Reading note\r\n");
                    }
                    i++;
                    break;

                // A credit event has been detected, this is when the validator has accepted a note as legal currency.
                case CCommands.SMARTPayout.SSP_POLL_CREDIT:
                    GetDataByChannel(response[i + 1], ref data);
                    log.AppendText("Credit " + CHelpers.FormatToCurrency(data.Value) + "\r\n");
                    UpdateData();
                    i++;
                    break;

                // A note is being rejected from the validator. This will carry on polling while the note is in transit.
                case CCommands.SMARTPayout.SSP_POLL_REJECTING:
                    log.AppendText("Rejecting note\r\n");
                    break;

                // A note has been rejected from the validator, the note will be resting in the bezel. This response only
                // appears once.
                case CCommands.SMARTPayout.SSP_POLL_REJECTED:
                    log.AppendText("Note rejected\r\n");
                    QueryRejection(log);
                    break;

                // A note is in transit to the cashbox.
                case CCommands.SMARTPayout.SSP_POLL_STACKING:
                    log.AppendText("Stacking note\r\n");
                    break;

                // The payout device is 'floating' a specified amount of notes. It will transfer some to the cashbox and
                // leave the specified amount in the payout device.
                case CCommands.SMARTPayout.SSP_POLL_FLOATING:
                    log.AppendText("Floating notes\r\n");
                    // Now the index needs to be moved on to skip over the data provided by this response so it
                    // is not parsed as a normal poll response.
                    // In this response, the data includes the number of countries being floated (1 byte), then a 4 byte value
                    // and 3 byte currency code for each country.
                    i += (byte)((response[i + 1] * 7) + 1);
                    break;

                // A note has reached the cashbox.
                case CCommands.SMARTPayout.SSP_POLL_STACKED:
                    log.AppendText("Note stacked\r\n");
                    break;

                // The float operation has been completed.
                case CCommands.SMARTPayout.SSP_POLL_FLOATED:
                    log.AppendText("Completed floating\r\n");
                    UpdateData();
                    EnableValidator();
                    i += (byte)((response[i + 1] * 7) + 1);
                    break;

                // A note has been stored in the payout device to be paid out instead of going into the cashbox.
                case CCommands.SMARTPayout.SSP_POLL_NOTE_STORED:
                    log.AppendText("Note stored\r\n");
                    UpdateData();
                    break;

                // A safe jam has been detected. This is where the user has inserted a note and the note
                // is jammed somewhere that the user cannot reach.
                case CCommands.SMARTPayout.SSP_POLL_SAFE_JAM:
                    log.AppendText("Safe jam\r\n");
                    break;

                // An unsafe jam has been detected. This is where a user has inserted a note and the note
                // is jammed somewhere that the user can potentially recover the note from.
                case CCommands.SMARTPayout.SSP_POLL_UNSAFE_JAM:
                    log.AppendText("Unsafe jam\r\n");
                    break;

                // An error has been detected by the payout unit.
                case CCommands.SMARTPayout.SSP_POLL_PAYOUT_ERROR:     // Note: Will be reported only when Protocol version >= 7
                    log.AppendText("Detected error with payout device\r\n");
                    i += (byte)((response[i + 1] * 7) + 2);
                    break;

                // A fraud attempt has been detected.
                case CCommands.SMARTPayout.SSP_POLL_FRAUD_ATTEMPT:
                    log.AppendText("Fraud attempt\r\n");
                    i += (byte)((response[i + 1] * 7) + 1);
                    break;

                // The stacker (cashbox) is full.
                case CCommands.SMARTPayout.SSP_POLL_STACKER_FULL:
                    log.AppendText("Stacker full\r\n");
                    break;

                // A note was detected somewhere inside the validator on startup and was rejected from the front of the
                // unit.
                case CCommands.SMARTPayout.SSP_POLL_NOTE_CLEARED_FROM_FRONT:
                    log.AppendText("Note cleared from front of validator\r\n");
                    i++;
                    break;

                // A note was detected somewhere inside the validator on startup and was cleared into the cashbox.
                case CCommands.SMARTPayout.SSP_POLL_NOTE_CLEARED_TO_CASHBOX:
                    log.AppendText("Note cleared to cashbox\r\n");
                    i++;
                    break;

                // A note has been detected in the validator on startup and moved to the payout device
                case CCommands.SMARTPayout.SSP_POLL_NOTE_PAID_INTO_STORE_ON_POWERUP:
                    log.AppendText("Note paid into payout device on startup\r\n");
                    i += 7;
                    break;

                // A note has been detected in the validator on startup and moved to the cashbox
                case CCommands.SMARTPayout.SSP_POLL_NOTE_PAID_INTO_STACKER_ON_POWERUP:
                    log.AppendText("Note paid into cashbox on startup\r\n");
                    i += 7;
                    break;

                // The cashbox has been removed from the unit. This will continue to poll until the cashbox is replaced.
                case CCommands.SMARTPayout.SSP_POLL_CASHBOX_REMOVED:
                    log.AppendText("Cashbox removed\r\n");
                    break;

                // The cashbox has been replaced, this will only display on a poll once.
                case CCommands.SMARTPayout.SSP_POLL_CASHBOX_REPLACED:
                    log.AppendText("Cashbox replaced\r\n");
                    break;

                // The validator is in the process of paying out a note, this will continue to poll until the note has
                // been fully dispensed and removed from the front of the validator by the user.
                case CCommands.SMARTPayout.SSP_POLL_NOTE_DISPENSING:
                    log.AppendText("Dispensing note(s)\r\n");
                    i += (byte)((response[i + 1] * 7) + 1);
                    break;

                // The note has been dispensed and removed from the bezel by the user.
                case CCommands.SMARTPayout.SSP_POLL_NOTE_DISPENSED:
                    log.AppendText("Dispensed note(s)\r\n");
                    UpdateData();
                    EnableValidator();
                    i += (byte)((response[i + 1] * 7) + 1);
                    break;

                // The payout device is in the process of emptying all its stored notes to the cashbox. This
                // will continue to poll until the device is empty.
                case CCommands.SMARTPayout.SSP_POLL_EMPTYING:
                    log.AppendText("Emptying\r\n");
                    break;

                // This single poll response indicates that the payout device has finished emptying.
                case CCommands.SMARTPayout.SSP_POLL_EMPTIED:
                    log.AppendText("Emptied\r\n");
                    UpdateData();
                    EnableValidator();
                    break;

                // The payout device is in the process of SMART emptying all its stored notes to the cashbox, keeping
                // a count of the notes emptied. This will continue to poll until the device is empty.
                case CCommands.SMARTPayout.SSP_POLL_SMART_EMPTYING:
                    log.AppendText("SMART Emptying...\r\n");
                    i += (byte)((response[i + 1] * 7) + 1);
                    break;

                // The payout device has finished SMART emptying, the information of what was emptied can now be displayed
                // using the CASHBOX PAYOUT OPERATION DATA command.
                case CCommands.SMARTPayout.SSP_POLL_SMART_EMPTIED:
                    log.AppendText("SMART Emptied, getting info...\r\n");
                    UpdateData();
                    GetCashboxPayoutOpData(log);
                    EnableValidator();
                    i += (byte)((response[i + 1] * 7) + 1);
                    break;

                // The payout device has encountered a jam. This will not clear until the jam has been removed and the unit
                // reset.
                case CCommands.SMARTPayout.SSP_POLL_JAMMED:
                    log.AppendText("Unit jammed...\r\n");
                    i += (byte)((response[i + 1] * 7) + 1);
                    break;

                // This is reported when the payout has been halted by a host command. This will report the value of
                // currency dispensed upto the point it was halted.
                case CCommands.SMARTPayout.SSP_POLL_HALTED:
                    log.AppendText("Halted...\r\n");
                    i += (byte)((response[i + 1] * 7) + 1);
                    break;

                // This is reported when the payout was powered down during a payout operation. It reports the original amount
                // requested and the amount paid out up to this point for each currency.
                case CCommands.SMARTPayout.SSP_POLL_INCOMPLETE_PAYOUT:
                    log.AppendText("Incomplete payout\r\n");
                    i += (byte)((response[i + 1] * 11) + 1);
                    break;

                // This is reported when the payout was powered down during a float operation. It reports the original amount
                // requested and the amount paid out up to this point for each currency.
                case CCommands.SMARTPayout.SSP_POLL_INCOMPLETE_FLOAT:
                    log.AppendText("Incomplete float\r\n");
                    i += (byte)((response[i + 1] * 11) + 1);
                    break;

                // A note has been transferred from the payout unit to the stacker.
                case CCommands.SMARTPayout.SSP_POLL_NOTE_TRANSFERRED_TO_STACKER:
                    log.AppendText("Note transferred to stacker\r\n");
                    i += 7;
                    break;

                // A note is resting in the bezel waiting to be removed by the user.
                case CCommands.SMARTPayout.SSP_POLL_NOTE_HELD_IN_BEZEL:
                    log.AppendText("Note in bezel...\r\n");
                    i += 7;
                    break;

                // The payout has gone out of service, the host can attempt to re-enable the payout by sending the enable payout
                // command.
                case CCommands.SMARTPayout.SSP_POLL_PAYOUT_OUT_OF_SERVICE:
                    log.AppendText("Payout out of service...\r\n");
                    break;

                // The unit has timed out while searching for a note to payout. It reports the value dispensed before the timeout
                // event.
                case CCommands.SMARTPayout.SSP_POLL_TIMEOUT:
                    log.AppendText("Timed out searching for a note\r\n");
                    i += (byte)((response[i + 1] * 7) + 1);
                    break;

                default:
                    log.AppendText("Unsupported poll response received: " + (int)cmd.ResponseData[i] + "\r\n");
                    break;
                }
            }
            return(true);
        }
コード例 #25
0
ファイル: Form1.cs プロジェクト: kalkansa/stserver
        // This is a one off function that is called the first time the MainLoop()
        // function runs, it just sets up a few of the UI elements that only need
        // updating once.
        private void SetupFormLayout()
        {
            // Get channel levels in hopper
            tbCoinLevels.Text = Hopper.GetChannelLevelInfo();

            // setup list of recyclable channel tick boxes based on OS type
            System.OperatingSystem osInfo = System.Environment.OSVersion;
            int x1 = 0, y1 = 0, x2 = 0, y2 = 0;

            // XP, 2000, Server 2003
            if (osInfo.Platform == PlatformID.Win32NT && osInfo.Version.Major == 5)
            {
                x1 = this.Location.X + 455;
                y1 = this.Location.Y + 10;
                x2 = this.Location.X + 780;
                y2 = this.Location.Y + 10;
            }
            // Vista, 7
            else if (osInfo.Platform == PlatformID.Win32NT && osInfo.Version.Major == 6)
            {
                x1 = this.Location.X + 458;
                y1 = this.Location.Y + 12;
                x2 = this.Location.X + 780;
                y2 = this.Location.Y + 12;
            }

            GroupBox g1 = new GroupBox();

            g1.Size     = new Size(100, 380);
            g1.Location = new Point(x1, y1);
            g1.Text     = "Hopper Recycling";

            GroupBox g2 = new GroupBox();

            g2.Size     = new Size(100, 380);
            g2.Location = new Point(x2, y2);
            g2.Text     = "Payout Recycling";

            // Hopper checkboxes
            for (int i = 1; i <= Hopper.NumberOfChannels; i++)
            {
                CheckBox c = new CheckBox();
                c.Location        = new Point(5, 20 + (i * 20));
                c.Name            = i.ToString();
                c.Text            = CHelpers.FormatToCurrency(Hopper.GetChannelValue(i)) + " " + new String(Hopper.GetChannelCurrency(i));
                c.Checked         = Hopper.IsChannelRecycling(i);
                c.CheckedChanged += new EventHandler(recycleBoxHopper_CheckedChange);
                g1.Controls.Add(c);
            }

            // Payout checkboxes
            for (int i = 1; i <= Payout.NumberOfChannels; i++)
            {
                CheckBox c = new CheckBox();
                c.Location = new Point(5, 20 + (i * 20));
                c.Name     = i.ToString();
                ChannelData d = new ChannelData();
                Payout.GetDataByChannel(i, ref d);
                c.Text            = CHelpers.FormatToCurrency(d.Value) + " " + new String(d.Currency);
                c.Checked         = d.Recycling;
                c.CheckedChanged += new EventHandler(recycleBoxPayout_CheckedChange);
                g2.Controls.Add(c);
            }

            Controls.Add(g1);
            Controls.Add(g2);
        }
コード例 #26
0
        // The poll function is called repeatedly to poll to validator for information, it returns as
        // a response in the command structure what events are currently happening.
        public bool DoPoll(TextBox log)
        {
            byte i;

            //send poll
            cmd.CommandData[0]    = CCommands.Generic.SSP_CMD_POLL;
            cmd.CommandDataLength = 1;

            if (!SendCommand(log))
            {
                return(false);
            }

            // Check unit hasn't lost key (could be due to power loss or reset)
            if (cmd.ResponseData[0] == 0xFA)
            {
                return(false);
            }

            // Store poll response to avoid corruption if the cmd structure is accessed whilst polling
            cmd.ResponseData.CopyTo(m_CurrentPollResponse, 0);
            m_CurrentPollResponseLength = cmd.ResponseDataLength;

            //parse poll m_CurrentPollResponse
            int noteVal = 0;

            for (i = 1; i < m_CurrentPollResponseLength; i++)
            {
                switch (m_CurrentPollResponse[i])
                {
                // This m_CurrentPollResponse indicates that the unit was reset and this is the first time a poll
                // has been called since the reset.
                case CCommands.NV11.SSP_POLL_RESET:
                    log.AppendText("Unit reset\r\n");
                    UpdateData();
                    break;

                // A note is currently being read by the validator sensors. The second byte of this response
                // is zero until the note's type has been determined, it then changes to the channel of the
                // scanned note.
                case CCommands.NV11.SSP_POLL_NOTE_READ:
                    if (m_CurrentPollResponse[i + 1] > 0)
                    {
                        noteVal = GetChannelValue(m_CurrentPollResponse[i + 1]);
                        log.AppendText("Note in escrow, amount: " + CHelpers.FormatToCurrency(noteVal) + "\r\n");
                    }
                    else
                    {
                        log.AppendText("Reading note\r\n");
                    }
                    i++;
                    break;

                // A credit event has been detected, this is when the validator has accepted a note as legal currency.
                case CCommands.NV11.SSP_POLL_CREDIT:
                    noteVal = GetChannelValue(m_CurrentPollResponse[i + 1]);
                    log.AppendText("Credit " + CHelpers.FormatToCurrency(noteVal) + "\r\n");
                    NotesAccepted++;
                    UpdateData();
                    i++;
                    break;

                // A note is being rejected from the validator. This will carry on polling while the note is in transit.
                case CCommands.NV11.SSP_POLL_REJECTING:
                    break;

                // A note has been rejected from the validator. This response only appears once.
                case CCommands.NV11.SSP_POLL_REJECTED:
                    log.AppendText("Note rejected\r\n");
                    QueryRejection(log);
                    UpdateData();
                    break;

                // A note is in transit to the cashbox.
                case CCommands.NV11.SSP_POLL_STACKING:
                    log.AppendText("Stacking note\r\n");
                    break;

                // A note has reached the cashbox.
                case CCommands.NV11.SSP_POLL_STACKED:
                    log.AppendText("Note stacked\r\n");
                    break;

                // A safe jam has been detected. This is where the user has inserted a note and the note
                // is jammed somewhere that the user cannot reach.
                case CCommands.NV11.SSP_POLL_SAFE_JAM:
                    log.AppendText("Safe jam\r\n");
                    break;

                // An unsafe jam has been detected. This is where a user has inserted a note and the note
                // is jammed somewhere that the user can potentially recover the note from.
                case CCommands.NV11.SSP_POLL_UNSAFE_JAM:
                    log.AppendText("Unsafe jam\r\n");
                    break;

                // The validator is disabled, it will not execute any commands or do any actions until enabled.
                case CCommands.NV11.SSP_POLL_DISABLED:
                    log.AppendText("Unit disabled...\r\n");
                    break;

                // A fraud attempt has been detected. The second byte indicates the channel of the note that a fraud
                // has been attempted on.
                case CCommands.NV11.SSP_POLL_FRAUD_ATTEMPT:
                    log.AppendText("Fraud attempt, note type: " + GetChannelValue(m_CurrentPollResponse[i + 1]) + "\r\n");
                    i++;
                    break;

                // The stacker (cashbox) is full.
                case CCommands.NV11.SSP_POLL_STACKER_FULL:
                    log.AppendText("Stacker full\r\n");
                    break;

                // A note was detected somewhere inside the validator on startup and was rejected from the front of the
                // unit.
                case CCommands.NV11.SSP_POLL_NOTE_CLEARED_FROM_FRONT:
                    log.AppendText(GetChannelValue(m_CurrentPollResponse[i + 1]) + " note cleared from front at reset." + "\r\n");
                    i++;
                    break;

                // A note was detected somewhere inside the validator on startup and was cleared into the cashbox.
                case CCommands.NV11.SSP_POLL_NOTE_CLEARED_TO_CASHBOX:
                    log.AppendText(GetChannelValue(m_CurrentPollResponse[i + 1]) + " note cleared to stacker at reset." + "\r\n");
                    i++;
                    break;

                // The cashbox has been removed from the unit. This will continue to poll until the cashbox is replaced.
                case CCommands.NV11.SSP_POLL_CASHBOX_REMOVED:
                    log.AppendText("Cashbox removed\r\n");
                    break;

                // The cashbox has been replaced, this will only display on a poll once.
                case CCommands.NV11.SSP_POLL_CASHBOX_REPLACED:
                    log.AppendText("Cashbox replaced\r\n");
                    break;

                // A note has been stored in the payout device to be paid out instead of going into the cashbox.
                case CCommands.NV11.SSP_POLL_NOTE_STORED:
                    log.AppendText("Note stored\r\n");
                    i += (byte)((m_CurrentPollResponse[i + 1] * 7) + 1);
                    UpdateData();
                    break;

                // The validator is in the process of paying out a note, this will continue to poll until the note has
                // been fully dispensed and removed from the front of the validator by the user.
                case CCommands.NV11.SSP_POLL_NOTE_DISPENSING:
                    log.AppendText("Dispensing note\r\n");
                    i += (byte)((m_CurrentPollResponse[i + 1] * 7) + 1);
                    break;

                // The note has been dispensed and removed from the bezel by the user.
                case CCommands.NV11.SSP_POLL_NOTE_DISPENSED:
                    for (int j = 0; j < m_CurrentPollResponse[i + 1]; j += 7)
                    {
                        log.AppendText("Dispensed " + (CHelpers.ConvertBytesToInt32(m_CurrentPollResponse, j + i + 2) / 100).ToString() +
                                       " " + (char)m_CurrentPollResponse[j + i + 6] + (char)m_CurrentPollResponse[j + i + 7] +
                                       (char)m_CurrentPollResponse[j + i + 8] + "\r\n");
                    }
                    i += (byte)((m_CurrentPollResponse[i + 1] * 7) + 1);
                    NotesDispensed++;
                    UpdateData();
                    EnableValidator(log);
                    break;

                // A note has been transferred from the payout storage to the cashbox
                case CCommands.NV11.SSP_POLL_NOTE_TRANSFERRED_TO_STACKER:
                    log.AppendText("Note stacked\r\n");
                    UpdateData();
                    EnableValidator(log);
                    break;

                // This single poll response indicates that the payout device has finished emptying.
                case CCommands.NV11.SSP_POLL_EMPTIED:
                    log.AppendText("Device emptied\r\n");
                    UpdateData();
                    EnableValidator(log);
                    break;

                // This response indicates a note is being dispensed and is resting in the bezel waiting to be removed
                // before the validator can continue
                case CCommands.NV11.SSP_POLL_NOTE_HELD_IN_BEZEL:
                    for (int j = 0; j < m_CurrentPollResponse[i + 1]; j += 7)
                    {
                        log.AppendText((CHelpers.ConvertBytesToInt32(m_CurrentPollResponse, j + i + 2) / 100).ToString() +
                                       " " + (char)m_CurrentPollResponse[j + i + 6] + (char)m_CurrentPollResponse[j + i + 7] +
                                       (char)m_CurrentPollResponse[j + i + 8] + " held in bezel...\r\n");
                    }
                    i += (byte)((m_CurrentPollResponse[i + 1] * 7) + 1);
                    break;

                default:
                    break;
                }
            }
            return(true);
        }
コード例 #27
0
ファイル: CValidator.cs プロジェクト: kalkansa/stserver
        // The poll function is called repeatedly to poll to validator for information, it returns as
        // a response in the command structure what events are currently happening.
        public bool DoPoll(TextBox log)
        {
            byte i;

            //send poll
            cmd.CommandData[0]    = CCommands.SSP_CMD_POLL;
            cmd.CommandDataLength = 1;

            if (!SendCommand(log))
            {
                return(false);
            }

            //parse poll response
            int noteVal = 0;

            for (i = 1; i < cmd.ResponseDataLength; i++)
            {
                switch (cmd.ResponseData[i])
                {
                // This response indicates that the unit was reset and this is the first time a poll
                // has been called since the reset.
                case CCommands.SSP_POLL_RESET:
                    log.AppendText("Unit reset\r\n");
                    break;

                // A note is currently being read by the validator sensors. The second byte of this response
                // is zero until the note's type has been determined, it then changes to the channel of the
                // scanned note.
                case CCommands.SSP_POLL_NOTE_READ:
                    if (cmd.ResponseData[i + 1] > 0)
                    {
                        noteVal = GetChannelValue(cmd.ResponseData[i + 1]);
                        log.AppendText("Note in escrow, amount: " + CHelpers.FormatToCurrency(noteVal) + "\r\n");
                    }
                    else
                    {
                        log.AppendText("Reading note...\r\n");
                    }
                    i++;
                    break;

                // A credit event has been detected, this is when the validator has accepted a note as legal currency.
                case CCommands.SSP_POLL_CREDIT:
                    noteVal = GetChannelValue(cmd.ResponseData[i + 1]);
                    log.AppendText("Credit " + CHelpers.FormatToCurrency(noteVal) + "\r\n");
                    m_NumStackedNotes++;
                    i++;
                    break;

                // A note is being rejected from the validator. This will carry on polling while the note is in transit.
                case CCommands.SSP_POLL_REJECTING:
                    log.AppendText("Rejecting note...\r\n");
                    break;

                // A note has been rejected from the validator, the note will be resting in the bezel. This response only
                // appears once.
                case CCommands.SSP_POLL_REJECTED:
                    log.AppendText("Note rejected\r\n");
                    QueryRejection(log);
                    break;

                // A note is in transit to the cashbox.
                case CCommands.SSP_POLL_STACKING:
                    log.AppendText("Stacking note...\r\n");
                    break;

                // A note has reached the cashbox.
                case CCommands.SSP_POLL_STACKED:
                    log.AppendText("Note stacked\r\n");
                    break;

                // A safe jam has been detected. This is where the user has inserted a note and the note
                // is jammed somewhere that the user cannot reach.
                case CCommands.SSP_POLL_SAFE_JAM:
                    log.AppendText("Safe jam\r\n");
                    break;

                // An unsafe jam has been detected. This is where a user has inserted a note and the note
                // is jammed somewhere that the user can potentially recover the note from.
                case CCommands.SSP_POLL_UNSAFE_JAM:
                    log.AppendText("Unsafe jam\r\n");
                    break;

                // The validator is disabled, it will not execute any commands or do any actions until enabled.
                case CCommands.SSP_POLL_DISABLED:
                    break;

                // A fraud attempt has been detected. The second byte indicates the channel of the note that a fraud
                // has been attempted on.
                case CCommands.SSP_POLL_FRAUD_ATTEMPT:
                    log.AppendText("Fraud attempt, note type: " + GetChannelValue(cmd.ResponseData[i + 1]) + "\r\n");
                    i++;
                    break;

                // The stacker (cashbox) is full.
                case CCommands.SSP_POLL_STACKER_FULL:
                    log.AppendText("Stacker full\r\n");
                    break;

                // A note was detected somewhere inside the validator on startup and was rejected from the front of the
                // unit.
                case CCommands.SSP_POLL_NOTE_CLEARED_FROM_FRONT:
                    log.AppendText(GetChannelValue(cmd.ResponseData[i + 1]) + " note cleared from front at reset." + "\r\n");
                    i++;
                    break;

                // A note was detected somewhere inside the validator on startup and was cleared into the cashbox.
                case CCommands.SSP_POLL_NOTE_CLEARED_TO_CASHBOX:
                    log.AppendText(GetChannelValue(cmd.ResponseData[i + 1]) + " note cleared to stacker at reset." + "\r\n");
                    i++;
                    break;

                // The cashbox has been removed from the unit. This will continue to poll until the cashbox is replaced.
                case CCommands.SSP_POLL_CASHBOX_REMOVED:
                    log.AppendText("Cashbox removed...\r\n");
                    break;

                // The cashbox has been replaced, this will only display on a poll once.
                case CCommands.SSP_POLL_CASHBOX_REPLACED:
                    log.AppendText("Cashbox replaced\r\n");
                    break;

                // A bar code ticket has been detected and validated. The ticket is in escrow, continuing to poll will accept
                // the ticket, sending a reject command will reject the ticket.
                case CCommands.SSP_POLL_BAR_CODE_VALIDATED:
                    log.AppendText("Bar code ticket validated\r\n");
                    break;

                // A bar code ticket has been accepted (equivalent to note credit).
                case CCommands.SSP_POLL_BAR_CODE_ACK:
                    log.AppendText("Bar code ticket accepted\r\n");
                    break;

                // The validator has detected its note path is open. The unit is disabled while the note path is open.
                // Only available in protocol versions 6 and above.
                case CCommands.SSP_POLL_NOTE_PATH_OPEN:
                    log.AppendText("Note path open\r\n");
                    break;

                // All channels on the validator have been inhibited so the validator is disabled. Only available on protocol
                // versions 7 and above.
                case CCommands.SSP_POLL_CHANNEL_DISABLE:
                    log.AppendText("All channels inhibited, unit disabled\r\n");
                    break;

                default:
                    log.AppendText("Unrecognised poll response detected " + (int)cmd.ResponseData[i] + "\r\n");
                    break;
                }
            }
            return(true);
        }
コード例 #28
0
        // This function uses the setup request command to get all the information about the validator.
        public void SetupRequest(TextBox log = null)
        {
            // send setup request
            cmd.CommandData[0]    = CCommands.Generic.SSP_CMD_SETUP_REQUEST;
            cmd.CommandDataLength = 1;

            if (!SendCommand(log))
            {
                return;
            }

            // display setup request
            string displayString = "Validator Type: ";
            int    index         = 1;

            // unit type (table 0-1)
            m_UnitType = (char)cmd.ResponseData[index++];
            switch (m_UnitType)
            {
            case (char)0x00: displayString += "Validator"; break;

            case (char)0x03: displayString += "SMART Hopper"; break;

            case (char)0x06: displayString += "SMART Payout"; break;

            case (char)0x07: displayString += "NV11"; break;

            default: displayString += "Unknown Type"; break;
            }

            displayString += "\r\nFirmware: ";

            // firmware (table 2-5)
            while (index <= 5)
            {
                displayString += (char)cmd.ResponseData[index++];
                if (index == 4)
                {
                    displayString += ".";
                }
            }

            // country code (table 6-8)
            // this is legacy code, in protocol version 6+ each channel has a seperate currency
            index = 9; // to skip country code

            // value multiplier (table 9-11)
            // also legacy code, a real value multiplier appears later in the response
            index = 12; // to skip value multiplier

            displayString += "\r\nNumber of Channels: ";
            int numChannels = cmd.ResponseData[index++];

            m_NumberOfChannels = numChannels;

            displayString += numChannels + "\r\n";
            // channel values (table 13 to 13+n)
            // the channel values located here in the table are legacy, protocol 6+ provides a set of expanded
            // channel values.
            index = 13 + m_NumberOfChannels; // Skip channel values

            // channel security (table 13+n to 13+(n*2))
            // channel security values are also legacy code
            index = 13 + (m_NumberOfChannels * 2); // Skip channel security

            displayString += "Real Value Multiplier: ";

            // real value multiplier (table 13+(n*2) to 15+(n*2))
            // (big endian)
            m_ValueMultiplier  = cmd.ResponseData[index + 2];
            m_ValueMultiplier += cmd.ResponseData[index + 1] << 8;
            m_ValueMultiplier += cmd.ResponseData[index] << 16;
            displayString     += m_ValueMultiplier + "\r\nProtocol Version: ";
            index             += 3;

            // protocol version (table 16+(n*2))
            index = 16 + (m_NumberOfChannels * 2);
            int protocol = cmd.ResponseData[index++];

            displayString += protocol + "\r\n";

            // protocol 6+ only

            // channel currency country code (table 17+(n*2) to 17+(n*5))
            index = 17 + (m_NumberOfChannels * 2);
            int sectionEnd = 17 + (m_NumberOfChannels * 5);
            int count      = 0;

            byte[] channelCurrencyTemp = new byte[3 * m_NumberOfChannels];
            while (index < sectionEnd)
            {
                displayString += "Channel " + ((count / 3) + 1) + ", currency: ";
                channelCurrencyTemp[count] = cmd.ResponseData[index++];
                displayString += (char)channelCurrencyTemp[count++];
                channelCurrencyTemp[count] = cmd.ResponseData[index++];
                displayString += (char)channelCurrencyTemp[count++];
                channelCurrencyTemp[count] = cmd.ResponseData[index++];
                displayString += (char)channelCurrencyTemp[count++];
                displayString += "\r\n";
            }

            // expanded channel values (table 17+(n*5) to 17+(n*9))
            index          = sectionEnd;
            displayString += "Expanded channel values:\r\n";
            sectionEnd     = 17 + (m_NumberOfChannels * 9);
            int n = 0;

            count = 0;
            int[] channelValuesTemp = new int[m_NumberOfChannels];
            while (index < sectionEnd)
            {
                n = CHelpers.ConvertBytesToInt32(cmd.ResponseData, index);
                channelValuesTemp[count] = n;
                index         += 4;
                displayString += "Channel " + ++count + ", value = " + n + "\r\n";
            }

            // Create list entry for each channel
            m_UnitDataList.Clear(); // clear old table
            for (byte i = 0; i < m_NumberOfChannels; i++)
            {
                ChannelData d = new ChannelData();
                d.Channel = i;
                d.Channel++; // Offset from array index by 1
                d.Value       = channelValuesTemp[i] * Multiplier;
                d.Currency[0] = (char)channelCurrencyTemp[0 + (i * 3)];
                d.Currency[1] = (char)channelCurrencyTemp[1 + (i * 3)];
                d.Currency[2] = (char)channelCurrencyTemp[2 + (i * 3)];
                d.Level       = 0;     // Can't store notes
                d.Recycling   = false; // Can't recycle notes

                m_UnitDataList.Add(d);
            }

            // Sort the list of data by the value.
            m_UnitDataList.Sort(delegate(ChannelData d1, ChannelData d2) { return(d1.Value.CompareTo(d2.Value)); });

            if (log != null)
            {
                log.AppendText(displayString);
            }
        }
コード例 #29
0
        // The poll function is called repeatedly to poll to validator for information, it returns as
        // a response in the command structure what events are currently happening.
        public bool DoPoll(TextBox log)
        {
            byte i;

            //send poll
            cmd.CommandData[0]    = CCommands.Generic.SSP_CMD_POLL;
            cmd.CommandDataLength = 1;

            if (!SendCommand(log))
            {
                return(false);
            }

            // if 0xFA received the key has been lost, possibly by power down so return false
            if (cmd.ResponseData[0] == 0xFA)
            {
                return(false);
            }

            // Store poll response
            cmd.ResponseData.CopyTo(m_CurrentPollResponse, 0);
            m_CurrentPollResponseLength = cmd.ResponseDataLength;

            //parse poll response
            int noteVal = 0;

            for (i = 1; i < m_CurrentPollResponseLength; i++)
            {
                switch (m_CurrentPollResponse[i])
                {
                // This response indicates that the unit was reset and this is the first time a poll
                // has been called since the reset.
                case CCommands.Validator.SSP_POLL_RESET:
                    log.AppendText("Validator reset\r\n");
                    break;

                // A note is currently being read by the validator sensors. The second byte of this response
                // is zero until the note's type has been determined, it then changes to the channel of the
                // scanned note.
                case CCommands.Validator.SSP_POLL_NOTE_READ:
                    if (m_CurrentPollResponse[i + 1] > 0)
                    {
                        noteVal = GetChannelValue(m_CurrentPollResponse[i + 1]);
                        log.AppendText("Note in escrow, amount: " + CHelpers.FormatToCurrency(noteVal) + "\r\n");
                    }
                    else
                    {
                        log.AppendText("Reading note...\r\n");
                    }
                    i++;
                    break;

                // A credit event has been detected, this is when the validator has accepted a note as legal currency.
                case CCommands.Validator.SSP_POLL_CREDIT:
                    noteVal = GetChannelValue(m_CurrentPollResponse[i + 1]);
                    log.AppendText("Credit " + CHelpers.FormatToCurrency(noteVal) + "\r\n");
                    m_NumStackedNotes++;
                    i++;
                    break;

                // A note is being rejected from the validator. This will carry on polling while the note is in transit.
                case CCommands.Validator.SSP_POLL_REJECTING:
                    log.AppendText("Rejecting note...\r\n");
                    break;

                // A note has been rejected from the validator, the note will be resting in the bezel. This response only
                // appears once.
                case CCommands.Validator.SSP_POLL_REJECTED:
                    log.AppendText("Note rejected\r\n");
                    QueryRejection(log);
                    break;

                // A note is in transit to the cashbox.
                case CCommands.Validator.SSP_POLL_STACKING:
                    log.AppendText("Stacking note...\r\n");
                    break;

                // A note has reached the cashbox.
                case CCommands.Validator.SSP_POLL_STACKED:
                    log.AppendText("Note stacked\r\n");
                    break;

                // A safe jam has been detected. This is where the user has inserted a note and the note
                // is jammed somewhere that the user cannot reach.
                case CCommands.Validator.SSP_POLL_SAFE_JAM:
                    log.AppendText("Safe jam\r\n");
                    break;

                // An unsafe jam has been detected. This is where a user has inserted a note and the note
                // is jammed somewhere that the user can potentially recover the note from.
                case CCommands.Validator.SSP_POLL_UNSAFE_JAM:
                    log.AppendText("Unsafe jam\r\n");
                    break;

                // The validator is disabled, it will not execute any commands or do any actions until enabled.
                case CCommands.Validator.SSP_POLL_DISABLED:
                    break;

                // A fraud attempt has been detected. The second byte indicates the channel of the note that a fraud
                // has been attempted on.
                case CCommands.Validator.SSP_POLL_FRAUD_ATTEMPT:
                    log.AppendText("Fraud attempt, note type: " + GetChannelValue(m_CurrentPollResponse[i + 1]) + "\r\n");
                    i++;
                    break;

                // The stacker (cashbox) is full.
                case CCommands.Validator.SSP_POLL_STACKER_FULL:
                    log.AppendText("Stacker full\r\n");
                    break;

                // A note was detected somewhere inside the validator on startup and was rejected from the front of the
                // unit.
                case CCommands.Validator.SSP_POLL_NOTE_CLEARED_FROM_FRONT:
                    log.AppendText(GetChannelValue(m_CurrentPollResponse[i + 1]) + " note cleared from front at reset." + "\r\n");
                    i++;
                    break;

                // A note was detected somewhere inside the validator on startup and was cleared into the cashbox.
                case CCommands.Validator.SSP_POLL_NOTE_CLEARED_TO_CASHBOX:
                    log.AppendText(GetChannelValue(m_CurrentPollResponse[i + 1]) + " note cleared to stacker at reset." + "\r\n");
                    i++;
                    break;

                // The cashbox has been removed from the unit. This will continue to poll until the cashbox is replaced.
                case CCommands.Validator.SSP_POLL_CASHBOX_REMOVED:
                    log.AppendText("Cashbox removed...\r\n");
                    break;

                // The cashbox has been replaced, this will only display on a poll once.
                case CCommands.Validator.SSP_POLL_CASHBOX_REPLACED:
                    log.AppendText("Cashbox replaced\r\n");
                    break;

                default:
                    break;
                }
            }
            return(true);
        }
コード例 #30
0
        // This function is called repeatedly to poll the validator about what events are happening. It
        // can optionally output these events to a textbox.
        public bool DoPoll(TextBox log)
        {
            byte i;

            //send poll
            m_cmd.CommandData[0]    = CCommands.Generic.SSP_CMD_POLL;
            m_cmd.CommandDataLength = 1;

            if (!SendCommand(log))
            {
                return(false);
            }

            // Check unit hasn't lost key (could be due to power loss or reset)
            if (m_cmd.ResponseData[0] == 0xFA)
            {
                return(false);
            }

            // isolate poll response to allow reuse of the SSP_COMMAND structure
            m_CurrentPollResponseLength = m_cmd.ResponseDataLength;
            m_cmd.ResponseData.CopyTo(m_CurrentPollResponse, 0);

            //parse poll response
            int    coin     = 0;
            string currency = "";

            for (i = 1; i < m_CurrentPollResponseLength; i++)
            {
                switch (m_CurrentPollResponse[i])
                {
                // This response indicates that the unit was reset and this is the first time a poll
                // has been called since the reset.
                case CCommands.Hopper.SSP_POLL_RESET:
                    UpdateData();
                    break;

                // This response is given when the unit is disabled.
                case CCommands.Hopper.SSP_POLL_DISABLED:
                    log.AppendText("Unit disabled...\r\n");
                    break;

                // The unit is in the process of paying out a coin or series of coins, this will continue to poll
                // until the coins have been fully dispensed
                case CCommands.Hopper.SSP_POLL_DISPENSING:
                    log.AppendText("Dispensing coin(s)...\r\n");
                    // Now the index needs to be moved on to skip over the data provided by this response so it
                    // is not parsed as a normal poll response.
                    // In this response, the data includes the number of countries being dispensed (1 byte), then a 4 byte value
                    // and 3 byte currency code for each country.
                    i += (byte)((m_CurrentPollResponse[i + 1] * 7) + 1);
                    break;

                // This is polled when a unit has finished a dispense operation. The following 4 bytes give the
                // value of the coin(s) dispensed.
                case CCommands.Hopper.SSP_POLL_DISPENSED:
                    for (int j = 0; j < m_CurrentPollResponse[i + 1] * 7; j += 7)
                    {
                        coin = CHelpers.ConvertBytesToInt32(m_cmd.ResponseData, i + j + 2);     // get coin data from response
                        // get currency from response
                        currency  = "";
                        currency += (char)m_CurrentPollResponse[i + j + 6];
                        currency += (char)m_CurrentPollResponse[i + j + 7];
                        currency += (char)m_CurrentPollResponse[i + j + 8];
                        log.AppendText(CHelpers.FormatToCurrency(coin) + " " + currency + " coin(s) dispensed\r\n");
                    }

                    UpdateData();
                    EnableValidator();
                    i += (byte)((m_CurrentPollResponse[i + 1] * 7) + 1);
                    break;

                // The coins being recycled inside the unit are running low.
                case CCommands.Hopper.SSP_POLL_COINS_LOW:
                    log.AppendText("Coins low\r\n");
                    break;

                // There are no coins left in the unit.
                case CCommands.Hopper.SSP_POLL_EMPTY:
                    log.AppendText("Unit empty\r\n");
                    break;

                // The mechanism inside the unit is jammed.
                case CCommands.Hopper.SSP_POLL_JAMMED:
                    log.AppendText("Jammed\r\n");
                    i += (byte)((m_CurrentPollResponse[i + 1] * 7) + 1);
                    break;

                // A dispense, SMART empty or float operation has been halted.
                case CCommands.Hopper.SSP_POLL_HALTED:
                    i += (byte)((m_CurrentPollResponse[i + 1] * 7) + 1);
                    break;

                // The device is 'floating' a specified amount of coins. It will transfer some to the cashbox and
                // leave the specified amount in the device.
                case CCommands.Hopper.SSP_POLL_FLOATING:
                    i += (byte)((m_CurrentPollResponse[i + 1] * 7) + 1);
                    break;

                // The float operation has completed.
                case CCommands.Hopper.SSP_POLL_FLOATED:
                    UpdateData();
                    EnableValidator();
                    i += (byte)((m_CurrentPollResponse[i + 1] * 7) + 1);
                    break;

                // This poll appears when the SMART Hopper has been searching for a coin but cannot find it within
                // the timeout period.
                case CCommands.Hopper.SSP_POLL_TIME_OUT:
                    log.AppendText("Search for suitable coins failed\r\n");
                    i += (byte)((m_CurrentPollResponse[i + 1] * 7) + 1);
                    break;

                // A payout was interrupted in some way. The amount paid out does not match what was requested. The value
                // of the dispensed and requested amount is contained in the response.
                case CCommands.Hopper.SSP_POLL_INCOMPLETE_PAYOUT:
                    log.AppendText("Incomplete payout detected...\r\n");
                    i += (byte)((m_CurrentPollResponse[i + 1] * 11) + 1);
                    break;

                // A float was interrupted in some way. The amount floated does not match what was requested. The value
                // of the dispensed and requested amount is contained in the response.
                case CCommands.Hopper.SSP_POLL_INCOMPLETE_FLOAT:
                    log.AppendText("Incomplete float detected...\r\n");
                    i += (byte)((m_CurrentPollResponse[i + 1] * 11) + 1);
                    break;

                // This poll appears when coins have been dropped to the cashbox whilst making a payout. The value of
                // coins and the currency is reported in the response.
                case CCommands.Hopper.SSP_POLL_CASHBOX_PAID:
                    log.AppendText("Cashbox paid\r\n");
                    i += (byte)((m_CurrentPollResponse[i + 1] * 7) + 1);
                    break;

                // A credit event has been detected, this is when the coin mech has accepted a coin as legal currency.
                case CCommands.Hopper.SSP_POLL_COIN_CREDIT:
                    coin      = CHelpers.ConvertBytesToInt16(m_cmd.ResponseData, i + 1);
                    currency  = "";
                    currency += (char)m_CurrentPollResponse[i + 5];
                    currency += (char)m_CurrentPollResponse[i + 6];
                    currency += (char)m_CurrentPollResponse[i + 7];
                    log.AppendText(CHelpers.FormatToCurrency(coin) + " " + currency + " credited\r\n");
                    UpdateData();
                    i += 7;
                    break;

                // The coin mech has become jammed.
                case CCommands.Hopper.SSP_POLL_COIN_MECH_JAMMED:
                    log.AppendText("Coin mech jammed\r\n");
                    break;

                // The return button on the coin mech has been pressed.
                case CCommands.Hopper.SSP_POLL_COIN_MECH_RETURN_PRESSED:
                    log.AppendText("Return button pressed\r\n");
                    break;

                // The unit is in the process of dumping all the coins stored inside it into the cashbox.
                case CCommands.Hopper.SSP_POLL_EMPTYING:
                    log.AppendText("Emptying...\r\n");
                    break;

                // The unit has finished dumping coins to the cashbox.
                case CCommands.Hopper.SSP_POLL_EMPTIED:
                    log.AppendText("Emptied\r\n");
                    UpdateData();
                    EnableValidator();
                    break;

                // A fraud attempt has been detected.
                case CCommands.Hopper.SSP_POLL_FRAUD_ATTEMPT:
                    log.AppendText("Fraud attempted\r\n");
                    i += (byte)((m_CurrentPollResponse[i + 1] * 7) + 1);
                    break;

                // The unit is in the process of dumping all the coins stored inside it into the cashbox.
                // This poll means that the unit is keeping track of what it empties.
                case CCommands.Hopper.SSP_POLL_SMART_EMPTYING:
                    log.AppendText("SMART emptying...\r\n");
                    i += (byte)((m_CurrentPollResponse[i + 1] * 7) + 1);
                    break;

                // The unit has finished SMART emptying. The info on what has been dumped can be obtained
                // by sending the CASHBOX PAYOUT OPERATION DATA command.
                case CCommands.Hopper.SSP_POLL_SMART_EMPTIED:
                    GetCashboxPayoutOpData(log);
                    UpdateData();
                    EnableValidator();
                    log.AppendText("SMART emptied\r\n");
                    i += (byte)((m_CurrentPollResponse[i + 1] * 7) + 1);
                    break;

                // A coin has had its routing changed to either cashbox or recycling.
                case CCommands.Hopper.SSP_POLL_COIN_ROUTED:
                    log.AppendText("Routed coin\r\n");
                    UpdateData();
                    break;

                default:
                    log.AppendText("Unsupported poll response received: " + (int)m_CurrentPollResponse[i] + "\r\n");
                    break;
                }
            }
            return(true);
        }