Пример #1
0
        public bool DoPoll(ref string log)
        {
            cmd.CommandData[0]     = 7;
            cmd.CommandDataLength  = 1;
            cmd.ResponseDataLength = 0;
            if (!SendCommand(ref log))
            {
                return(false);
            }
            int num = 0;

            ReStartNeed = 0;
            if (IsEnable)
            {
                TimeOutComs++;
            }
            if (cmd.ResponseDataLength == 1 && cmd.ResponseData[0] == 250)
            {
                TimeOutComs = 1000;
            }
            for (byte b = 1; b < cmd.ResponseDataLength; b = (byte)(b + 1))
            {
                TimeOutComs = 0;
                switch (cmd.ResponseData[b])
                {
                case 241:
                    log += "Unit reset\r\n";
                    break;

                case 239:
                    if (cmd.ResponseData[b + 1] > 0)
                    {
                        num = GetChannelValue(cmd.ResponseData[b + 1]);
                        log = log + "Note in escrow, amount: " + CHelpers.FormatToCurrency(num) + "\r\n";
                    }
                    else
                    {
                        log += "Reading note...\r\n";
                    }
                    b = (byte)(b + 1);
                    break;

                case 238:
                    num      = GetChannelValue(cmd.ResponseData[b + 1]);
                    log      = log + "Credit " + CHelpers.FormatToCurrency(num) + "\r\n";
                    Creditos = num;
                    m_NumStackedNotes++;
                    b = (byte)(b + 1);
                    break;

                case 237:
                    log += "Rejecting note...\r\n";
                    break;

                case 236:
                    log += "Note rejected\r\n";
                    QueryRejection(ref log);
                    break;

                case 204:
                    log += "Stacking note...\r\n";
                    break;

                case 235:
                    log += "Note stacked\r\n";
                    break;

                case 234:
                    log += "Safe jam\r\n";
                    break;

                case 233:
                    log += "Unsafe jam\r\n";
                    break;

                case 232:
                    TimeOutComs = 1000;
                    break;

                case 230:
                {
                    object obj = log;
                    log = obj + "Fraud attempt, note type: " + GetChannelValue(cmd.ResponseData[b + 1]) + "\r\n";
                    b   = (byte)(b + 1);
                    break;
                }

                case 231:
                    log += "Stacker full\r\n";
                    break;

                case 225:
                    log = log + GetChannelValue(cmd.ResponseData[b + 1]) + " note cleared from front at reset.\r\n";
                    b   = (byte)(b + 1);
                    break;

                case 226:
                    log = log + GetChannelValue(cmd.ResponseData[b + 1]) + " note cleared to stacker at reset.\r\n";
                    b   = (byte)(b + 1);
                    break;

                case 227:
                    log += "Cashbox removed...\r\n";
                    break;

                case 228:
                    log += "Cashbox replaced\r\n";
                    break;

                case 229:
                    log += "Bar code ticket validated\r\n";
                    break;

                case 209:
                    log += "Bar code ticket accepted\r\n";
                    break;

                case 224:
                    log += "Note path open\r\n";
                    break;

                case 181:
                    log += "All channels inhibited, unit disabled\r\n";
                    break;

                default:
                {
                    object obj = log;
                    log = obj + "Unrecognised poll response detected " + (int)cmd.ResponseData[b] + "\r\n";
                    break;
                }
                }
            }
            return(true);
        }
Пример #2
0
        public void SetupRequest(ref string log)
        {
            cmd.CommandData[0]    = 5;
            cmd.CommandDataLength = 1;
            if (!SendCommand(ref log))
            {
                return;
            }
            string str = "Unit Type: ";
            int    num = 1;

            m_UnitType = (char)cmd.ResponseData[num++];
            switch (m_UnitType)
            {
            case '\0':
                str += "Validator";
                break;

            case '\u0003':
                str += "SMART Hopper";
                break;

            case '\u0006':
                str += "SMART Payout";
                break;

            case '\a':
                str += "NV11";
                break;

            default:
                str += "Unknown Type";
                break;
            }
            str += "\r\nFirmware: ";
            while (num <= 5)
            {
                str += (char)cmd.ResponseData[num++];
                if (num == 4)
                {
                    str += ".";
                }
            }
            num  = 9;
            num  = 12;
            str += "\r\nNumber of Channels: ";
            str  = str + (m_NumberOfChannels = cmd.ResponseData[num++]) + "\r\n";
            num  = 13 + m_NumberOfChannels;
            int[] array = new int[m_NumberOfChannels];
            for (int i = 0; i < m_NumberOfChannels; i++)
            {
                array[i] = cmd.ResponseData[13 + m_NumberOfChannels + i];
            }
            num  = 13 + m_NumberOfChannels * 2;
            str += "Real Value Multiplier: ";
            m_ValueMultiplier  = cmd.ResponseData[num + 2];
            m_ValueMultiplier += cmd.ResponseData[num + 1] << 8;
            m_ValueMultiplier += cmd.ResponseData[num] << 16;
            str  = str + m_ValueMultiplier + "\r\nProtocol Version: ";
            num += 3;
            num  = 16 + m_NumberOfChannels * 2;
            int num2 = cmd.ResponseData[num++];

            str = str + num2 + "\r\n";
            num = 17 + m_NumberOfChannels * 2;
            int num3 = 17 + m_NumberOfChannels * 5;
            int num4 = 0;

            byte[] array2 = new byte[3 * m_NumberOfChannels];
            while (num < num3)
            {
                object obj = str;
                str          = obj + "Channel " + (num4 / 3 + 1) + ", currency: ";
                array2[num4] = cmd.ResponseData[num++];
                str         += (char)array2[num4++];
                array2[num4] = cmd.ResponseData[num++];
                str         += (char)array2[num4++];
                array2[num4] = cmd.ResponseData[num++];
                str         += (char)array2[num4++];
                str         += "\r\n";
            }
            num  = num3;
            str += "Expanded channel values:\r\n";
            num3 = 17 + m_NumberOfChannels * 9;
            int num5 = 0;

            num4 = 0;
            int[] array3 = new int[m_NumberOfChannels];
            while (num < num3)
            {
                num5 = (array3[num4] = CHelpers.ConvertBytesToInt32(cmd.ResponseData, num));
                num += 4;
                object obj = str;
                str = obj + "Channel " + ++num4 + ", value = " + num5 + "\r\n";
            }
            m_UnitDataList.Clear();
            for (byte b = 0; b < m_NumberOfChannels; b = (byte)(b + 1))
            {
                ChannelData channelData = new ChannelData();
                channelData.Channel = b;
                channelData.Channel++;
                channelData.Value       = array3[b] * Multiplier;
                channelData.Currency[0] = (char)array2[b * 3];
                channelData.Currency[1] = (char)array2[1 + b * 3];
                channelData.Currency[2] = (char)array2[2 + b * 3];
                channelData.Level       = 0;
                channelData.Recycling   = false;
                channelData.Enabled     = ((array[b] != 4) ? true : false);
                channelData.Inhibit     = false;
                m_UnitDataList.Add(channelData);
            }
            m_UnitDataList.Sort((ChannelData d1, ChannelData d2) => d1.Value.CompareTo(d2.Value));
            if (log != null)
            {
                log += str;
            }
        }