Пример #1
0
        public DeviceAbstract UnpackDevice(DeviceCfg config, Common.Store store)
        {
            DeviceAbstract device = UnpackDeviceSpecific(config.Custom);

            device.Name                     = config.Name;
            device.Description              = config.Description;
            device.BadCommPeriod            = config.BadCommWaitPeriod;
            device.UpdateInActiveTags       = config.InActiveUpdate;
            device.UpdateInActiveTagsPeriod = config.InActiveUpdatePeriod;

            device.ConnectionSource = store.ConnectionsSources.Values.FirstOrDefault(c => c.Name == config.ConnectionSourceCfg.Name);

            return(device);
        }
Пример #2
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);
                }
            }
        }
Пример #3
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;
        }