コード例 #1
0
ファイル: CCTCoin.cs プロジェクト: RemSoftDev/SportBetting
        public CCTCoin(IPrefSupplier pref, string prefKey, string mode)
        {
            ValFound = false;
            Log.Debug("Creating CCTalk-CoinAcceptor...");
            _pref           = pref;
            _prefKey        = prefKey;
            _defaultAddress = 2;
            CHANNEL_COUNT   = 16;
            _encrytionKey   = new byte[6];
            enableLock      = new Object();
            bool flag = false;

            _channelValues = new decimal[CHANNEL_COUNT];

            create_spacial_coin_class = CheckIfCashDevicesUseDiffPorts();
            int adr = Convert.ToInt32(pref.GetIntegerEntry(prefKey + CashInSettings.Default.PrefValidatorAddress));

            if (adr == 0)
            {
                _address = _defaultAddress;
            }
            else
            {
                _address = (byte)adr;
            }


            if (create_spacial_coin_class)
            {
                CCTCommunicationA.SetMode(mode);


                if (CCTCommunicationA.Instance.CheckAcceptorPresent("Coin Acceptor", _address, ref _useCRCChecksum, _encrytionKey))
                {
                    flag = true;
                }
                else if (CCTCommunicationA.Instance.FindAcceptor("Coin Acceptor", ref _address, ref _useCRCChecksum, _encrytionKey))
                {
                    pref.SetIntegerEntry(prefKey + CashInSettings.Default.PrefValidatorAddress, Convert.ToInt32(_address));
                    flag = true;
                }
            }
            else
            {
                CCTCommunication.SetMode(mode);


                if (CCTCommunication.Instance.CheckAcceptorPresent("Coin Acceptor", _address, ref _useCRCChecksum, _encrytionKey))
                {
                    flag = true;
                }
                else if (CCTCommunication.Instance.FindAcceptor("Coin Acceptor", ref _address, ref _useCRCChecksum, _encrytionKey))
                {
                    pref.SetIntegerEntry(prefKey + CashInSettings.Default.PrefValidatorAddress, Convert.ToInt32(_address));
                    flag = true;
                }
            }
            if (flag)
            {
                ResetCoinAccseptor();
                base.Disable();
                GetChannelValues();
                _pollAcceptor = new Thread(new ThreadStart(readData));
                _pollAcceptor.Start();
                ValFound = true;
                return;
            }
            Log.Debug("No CCTalk CoinAcceptor found on address:" + _address);
            // throw new ApplicationException("no CCTalk-CoinAcceptor found");
        }
コード例 #2
0
ファイル: CCTNote.cs プロジェクト: RemSoftDev/SportBetting
        public CCTNote(IPrefSupplier pref, string prefKey, string mode)
        {
            ValFound = false;
            Log.Debug("Creating CCTalk-NoteAcceptor...");
            _pref           = pref;
            _prefKey        = prefKey;
            _defaultAddress = 40;
            _encrytionKey   = new byte[6];
            _encrypted      = true;
            _channelCount   = 16;
            enableLock      = new Object();
            string s          = "123456";
            string defaultKey = "123456";
            bool   flag       = false;
            // timeOut = 1000 * 60 * 5;
            ASCIIEncoding asciiencoding = new ASCIIEncoding();

            _channelValues = new decimal[_channelCount];
            CCTCommunication.SetMode(mode);

            int adr = Convert.ToInt32(pref.GetIntegerEntry(prefKey + CashInSettings.Default.PrefValidatorAddress));

            if (adr == 0)
            {
                _address = _defaultAddress;
            }
            else
            {
                _address = (byte)adr;
            }

            s = Convert.ToString(pref.GetIntegerEntry(prefKey + CashInSettings.Default.PrefValidatorEncryptionKey));

            if (s != null && s.Length <= 0)
            {
                s = defaultKey;
            }

            if (s.Length != 6)
            {
                Log.Debug("No Encryption set. Try to find Noteacceptor.");
                _encrypted = false;
                if (CCTCommunication.Instance.CheckAcceptorPresent("Bill Validator", _address, ref _useCRCChecksum, _encrytionKey))
                {
                    flag = true;
                }
                else if (CCTCommunication.Instance.FindAcceptor("Bill Validator", ref _address, ref _useCRCChecksum, _encrytionKey))
                {
                    pref.SetIntegerEntry(prefKey + CashInSettings.Default.PrefValidatorAddress, Convert.ToInt32(_address));
                    flag = true;
                }
            }
            else
            {
                Log.Debug("Encryptionkey set to:" + s + ". Try to find Noteacceptor.");
                _encrypted    = true;
                _encrytionKey = asciiencoding.GetBytes(s);
                for (int i1 = 0; i1 < _encrytionKey.Length; i1++)
                {
                    _encrytionKey[i1] = (byte)(_encrytionKey[i1] - 48);
                }
                CCTCommunication.Instance.secArray = _encrytionKey;
                //if (CCTCommunication.Instance.CheckAcceptorPresentEncrypted("Bill Validator", _address, ref _encrypted, ref _useCRCChecksum))
                if (CCTCommunication.Instance.CheckAcceptorPresentEncrypted("Bill Validator", _address, ref _encrypted, ref _useCRCChecksum, _encrytionKey))
                {
                    flag = true;
                }
                else
                {
                    _address = _defaultAddress;
                    if (CCTCommunication.Instance.FindAcceptor("Bill Validator", ref _address, ref _useCRCChecksum, _encrytionKey))
                    {
                        pref.SetIntegerEntry(prefKey + CashInSettings.Default.PrefValidatorAddress, Convert.ToInt32(_address));
                        flag = true;
                    }
                    if (CCTCommunication.Instance.CheckAcceptorPresentEncrypted("Bill Validator", _address, ref _encrypted, ref _useCRCChecksum, _encrytionKey))
                    {
                        pref.SetIntegerEntry(prefKey + CashInSettings.Default.PrefValidatorAddress, Convert.ToInt32(_address));
                        flag = true;
                    }
                }
            }

            if (flag)
            {
                base.Disable();
#if BETCENTER
#else
                if (!CheckCurrencyDataSet("EUR05"))
                {
                    _datasetIsValid = false;
                    Log.Error("DATASET is FALSE", new Exception(""));
                    //return;
                }
 #endif
                SetBillOperationMode();

                /* int useAcceptorValues = Convert.ToInt32(pref.GetIntegerEntry(prefKey + CashInSettings.Default.UseAcceptorValues));
                 * if (useAcceptorValues == 1)
                 *   GetChannelValues();
                 * else
                 *   loadChannelSettings();*/
                GetChannelValues();
                _pollAcceptor = new Thread(new ThreadStart(readData));
                _pollAcceptor.Start();
                base.Enable(0);
                Thread.Sleep(800);
                base.Disable();
                ValFound = true;
                return;
            }
            Log.Error("No CCTalk Noteacceptor found on address:" + _address, new Exception());
            // throw new ApplicationException("No CCTalk-NoteAcceptor found");
        }