Exemplo n.º 1
0
        //[TestMethod]
        public async Task TestMethod1Async()
        {
            ComReader comReader = new ComReader("COM1");

            if (comReader.Open())
            {
                IcpDeviceManager icpDeviceManager = new IcpDeviceManager(comReader);
                var devices = await icpDeviceManager.ScanIcpDevicesAsync();

                foreach (var item in devices)
                {
                    Debug.WriteLine($"-- {item.Name}");
                }
            }

            comReader.Close();
        }
Exemplo n.º 2
0
        private void ComDeviceInfoManager_AddedDevicesAsync(object sender, ComDeviceInfoManagerEventArgs e)
        {
            List <string> devices = new List <string>();

            foreach (var item in e.ComDevices)
            {
                ComReader comReader = new ComReader(item.Port);
                if (comReader.Open())
                {
                    IcpDeviceManager IcpDeviceManager = new IcpDeviceManager(comReader);
                    IcpDeviceManagers.Add(IcpDeviceManager);
                }
            }
            ScanIcpDevices(devices).ContinueWith(delegate { AddedDevicesCallback(devices.ToArray()); });
            //ScanIcpDevices(devices).
            //ComDevicesAdded?.Invoke(this, new ComDeviceControllerEventArgs(devices.ToArray()));
        }
Exemplo n.º 3
0
        private async Task ScanIcpDevices(BznModel bznModel)
        {
            ComReader comReader = new ComReader(bznModel.ComDevice.Port);

            if (comReader.Open())
            {
                bznModel.IcpDevices = new ObservableCollection <IcpDeviceModel>(await IcpDeviceManager.ScanIcpDevicesAsync(comReader));
            }
        }