Exemple #1
0
        public AbstractReaders(string readersName)
        {
            ReadersName = readersName;
            DeviceCfg     deviceCfg     = new DeviceCfg();
            DeviceCfgItem deviceCfgItem = deviceCfg.FindReaderItem(readersName);

            if (deviceCfgItem != null)
            {
                PortType portType  = (PortType)Enum.Parse(typeof(PortType), deviceCfgItem.PortType);
                PortType portType2 = portType;
                if (portType2 == PortType.TcpServer)
                {
                    CommPort = new TcpServerPort(deviceCfgItem.ConnStr);
                }
            }
        }
Exemple #2
0
        public Reader(string readerName)
            : base(readerName)
        {
            isRs485    = false;
            RS485Items = null;
            DeviceCfg     deviceCfg     = new DeviceCfg();
            DeviceCfgItem deviceCfgItem = deviceCfg.FindReaderItem(ReaderName);

            if (deviceCfgItem != null)
            {
                switch ((PortType)Enum.Parse(typeof(PortType), deviceCfgItem.PortType))
                {
                case PortType.TcpClient:
                    base.CommPort = new TcpClientPort(deviceCfgItem.ConnStr);
                    break;

                case PortType.RS232:
                    base.CommPort = new Rs232Port(deviceCfgItem.ConnStr);
                    break;

                case PortType.RS485:
                {
                    isRs485    = true;
                    RS485Items = new RS485Item[deviceCfgItem.AddressList.Length];
                    int    num         = 0;
                    byte[] addressList = deviceCfgItem.AddressList;
                    foreach (byte address in addressList)
                    {
                        RS485Items[num].Address = address;
                        RS485Items[num].pReader = this;
                        num++;
                    }
                    base.CommPort = new Rs485Port(deviceCfgItem.ConnStr, deviceCfgItem.AddressList);
                    break;
                }
                }
            }
            AbstractReader.OnApiException += Reader_OnApiException;
            base.OnReaderMessageReceived  += Reader_OnMessageNotificationReceived;
        }