Esempio n. 1
0
        public SSP(IPrefSupplier pref, string prefKey, string mode)
        {
            bool result = false;
            List <CommunicationResource> sp = spm.GetSafeSerialPortsMap();

            foreach (CommunicationResource cr in sp)
            {
                if (cr.PortType == ResourceType.BILL_VALIDATOR_SERIAL_PORT &&
                    cr.ProtocolType == DeviceProtocol.PROTOCOL_SSP)
                {
                    port      = cr.PortName;
                    Validator = new SSP_Validator();
                    result    = ConnectToValidator();
                    break;
                }
            }

            if (result)
            {
                result = InitializeBillValidator();
            }

            if (result)
            {
                CreatePollingThread();
            }

            ValFound = result;
        }
Esempio n. 2
0
        public TabTerminal(IPrefSupplier pref, string prefKey, string mode)
        {
            try
            {
                TabioSvc.Tabio mTabioSvc = new Tabio();
                ValFound = Initialize(ref mTabioSvc);

                base.Enable(0);
                Thread.Sleep(800);
                base.Disable();
            }
            catch
            {
                ValFound = false;
            }

            if (ValFound)
            {
                Log.Info("TabTerminal: TabioSvc object was initialized!");
            }
            else
            {
                Log.Info("TabTerminal: Can't initialize TabioSvc!");
            }
        }
        private bool CheckTabTerminalHardware(IPrefSupplier pref, string mode)
        {
            bool result = false;

            try
            {
                if (TabTerminal.TabTerminal.CheckTabBoard())
                {
                    result = true;
                    Type t = Type.GetType("Nbt.Services.Scf.CashIn.Validator.TabTerminal.TabTerminal");
                    if (t != null)
                    {
                        AValidator v = (AValidator)Activator.CreateInstance(t, new object[] { pref, "Validator", mode });
                        if (v != null)
                        {
                            ValFound = v.ValFound;
                            validators.Add(v);
                        }
                    }
                }
            }
            catch
            {
            }

            return(result);
        }
Esempio n. 4
0
        public ID003(IPrefSupplier pref, string prefKey, string mode)
        {
            bool result = false;
            List <CommunicationResource> sp = spm.GetSafeSerialPortsMap();

            foreach (CommunicationResource cr in sp)
            {
                if (cr.PortType == ResourceType.BILL_VALIDATOR_SERIAL_PORT &&
                    cr.ProtocolType == DeviceProtocol.PROTOCOL_ID003)
                {
                    serialPort = new ComPortMT(cr.PortName, 9600, System.IO.Ports.Parity.Even);
                    result     = serialPort.TryOpen();
                    break;
                }
            }

            if (result)
            {
                result = InitializeBillValidator();
            }

            if (result)
            {
                Disable();
                CreatePollingThread();
            }

            ValFound = result;
        }
        public ValidatorComposite(IPrefSupplier pref, string mode)
        {
            string validatorKey = "Validator";
            string validator;

            ValFound = false;
            bool validatorFound = false;


            if (pref != null && pref.Count() > 0)
            {
                if (CheckTabTerminalHardware(pref, mode))
                {
                }
                else
                {
                    for (int i = 1; i < CashInSettings.Default.NumOfValidators; i++)
                    {
                        if ((validator = pref.GetStringEntry(validatorKey + i + "_Type")) != null)
                        {
                            validatorFound = true;
                            try
                            {
                                Type t = Type.GetType(this.GetType().Namespace + '.' + validator);
                                if (t != null)
                                {
                                    AValidator v = (AValidator)Activator.CreateInstance(t, new object[] { pref, validatorKey + i, mode });
                                    if (!ValFound && v != null)
                                    {
                                        ValFound = v.ValFound;
                                    }
                                    validators.Add(v);
                                }
                                else
                                {
                                    Log.Error("Could not create an instance of class:" + this.GetType().Namespace + '.' + validator);
                                }
                            }
                            catch (Exception e)
                            {
                                Log.Error("In ValidatorComposite.", e);
                            }
                        }
                        else if (!validatorFound)
                        {
                            ValFound = true;
                        }
                    }
                }

                foreach (AValidator v in validators)
                {
                    v.CashIn += this.Refresh;
                    v.CashLimitExceededEventHandler += this.OnCashLimitExceeded;
                    Log.Debug("validator:" + v.ToString() + ",credit=" + v.GetCredit() + ",enable=" + v.IsEnabled());
                }
            }
        }
Esempio n. 6
0
        public RM5(IPrefSupplier pref, string prefKey)
        {
            channelValues = new decimal[CHANNEL_COUNT];
            LoadSettings(pref, prefKey);

            Disable();

            pollRM5 = new Thread(new ThreadStart(poll4CoinInput));
            pollRM5.IsBackground = true;
            pollRM5.Start();


            cashInWorkThread = new Thread(new ThreadStart(consumeCoinInput));
            cashInWorkThread.IsBackground = true;
            cashInWorkThread.Start();
            ValFound = true;
        }
Esempio n. 7
0
        public CashInManager(IPrefSupplier prefFile, string mode)
        {
            Log.DebugFormat("CashInManager init....");

            if (prefFile != null)
            {
                foreach (var p in prefFile.GetAllList())
                {
                    Log.DebugFormat("{0} = {1}", p.Key, p.Value);
                }
                validator = new ValidatorComposite(prefFile, mode);
            }
            if (validator != null)
            {
                AceptorsFound = validator.ValFound;
                Initialize();
            }
            //keySystem = new SeriosMK1Keys();
        }
Esempio n. 8
0
        protected override void LoadSettings(IPrefSupplier pref, string prefKey)
        {
            //from prefs
            //int multiplicator = pref.GetIntegerEntry(prefKey + CashInSettings.Default.PrefValidatorMultiplicator) ?? CashInSettings.Default.ValidatorMultiplicator;

            //if (multiplicator == 0)  //0 would cause error
            int multiplicator = 100;

            noOverpay = pref.GetBooleanEntry(prefKey + CashInSettings.Default.PrefValidatorNoOverpay) ?? CashInSettings.Default.ValidatorNoOverpay;

            for (int i = 0; channelValues != null && i < channelValues.Length; i++)
            {
                channelValues[i] = (decimal)((pref.GetDoubleEntry(prefKey + CashInSettings.Default.PrefValidatorChannel + String.Format("{0:##00}", i + 1)) ?? 0) / multiplicator);
                Log.Info("RM5 Channel " + (i + 1) + ": [" + (channelValues[i] == 0 ? "not set" : channelValues[i].ToString()) + "]");
            }

            Log.Info("RM5 No Overpay == " + noOverpay);
            Log.Info("RM5 Multiplicator == " + multiplicator);
        }
Esempio n. 9
0
        public void Init()
        {
            //1) First of all read StationNumber from PrefFile
            PrefFile = new TextFilePref(PrefFileName, PrefFileName, true, false);
            string message = null;

            Log.Debug("Thread:" + System.Threading.Thread.CurrentThread.ManagedThreadId);
            if (PrefFile.Name == "ERROR")
            {
                throw new FileNotFoundException("Preffile loading error");
            }
            if (PrefFile.Name == "DUPLICATE")
            {
                message = "Pref-File corrupt. Station locked. Please check for duplicate lines (also in comments)";
            }

            if (message != null)
            {
                Log.Error(message, new Exception());
            }
        }
Esempio n. 10
0
        protected void ScheduledTask()
        {
            AddLog("ID Card Service started");

            string path      = System.Environment.GetEnvironmentVariable("TERMINAL_CONFIG");
            var    portnames = GetVirtualComPort();

            if (portnames != null && portnames.Count > 0)
            {
                string confFile = path + "PrefFile.txt";

                foreach (var port in portnames)
                {
                    prefFile = new TextFilePref(confFile, confFile, true, false);
                    prefFile.SetStringEntry("IdCardReaderPort", port);

                    AddLog("Reader detected on port: " + port);
                }
            }
            else
            {
                AddLog("Reader not detected");
            }
        }
Esempio n. 11
0
        /// <summary>
        /// reads from Preffile and Settingsfile, if entry not in preffile uses settings and stores value in preffile
        /// IMPORTANT: If one entry in duplicate, the whole pref-file bevomes invalid. This means even duplicate commented lines are not allowed.
        /// e.g.
        /// #PrinterType = 1
        /// #PrinterType = 99
        /// --> error, whole pref-file is invalid, no data can be read from pref-file
        /// </summary>
        /// <param name="curPref">Preference-Object to search</param>
        /// <param name="key">the key to search for</param>
        /// <param name="defaulVal">the default value to return, if no data is found</param>
        /// <returns></returns>
        private static object QueryPref(IPrefSupplier curPref, string key, object defaultVal)
        {
            object val = null;

            //if (val.GetType() != defaulVal.GetType())
            //    return null;
            if (string.IsNullOrEmpty(key))
            {
                return(defaultVal);
            }

            try
            {
                switch (defaultVal.GetType().FullName)
                {
                case "System.Boolean":
                    val = curPref.GetBooleanEntry(key);
                    if (val == null)
                    {
                        val = defaultVal;
                        //							curPref.SetBooleanEntry(key, (bool)val);
                    }
                    else
                    {
                        val = (bool)val;
                    }
                    break;

                case "System.Int32":
                    val = curPref.GetIntegerEntry(key);
                    if (val == null)
                    {
                        val = defaultVal;
                        //							curPref.SetIntegerEntry(key, (int)val);
                    }
                    else
                    {
                        val = (int)val;
                    }
                    break;

                case "System.String":
                    val = curPref.GetStringEntry(key);
                    if (val == null)
                    {
                        val = defaultVal;
                        //							curPref.SetStringEntry(key, (string)val);
                    }
                    break;

                case "System.Double":
                    val = curPref.GetDoubleEntry(key);
                    if (val == null)
                    {
                        val = defaultVal;
                        //							curPref.SetDoubleEntry(key, (double)val);
                    }
                    else
                    {
                        val = (double)val;
                    }
                    break;

                default:
                    break;
                }
            }
            catch (SystemException e)
            {
                //e.g. InvalidCastException or NullReferenceException
                Log.Error("pref read error: key: " + key, e);
                return(defaultVal);
            }

            return(val);
        }
Esempio n. 12
0
        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");
        }
Esempio n. 13
0
 protected virtual void LoadSettings(IPrefSupplier pref, string key)
 {
 }
Esempio n. 14
0
 public NV10(IPrefSupplier pref, string prefKey) : base(pref, prefKey, NVNoteValidator.VALIDATOR_NV10_NAME, CashInSettings.Default.NV10_ChannelCount)
 {
 }
Esempio n. 15
0
        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");
        }