Beispiel #1
0
        ///  <summary>
        ///  Adds a new attached device.
        ///  </summary>
        ///  <param name="devicePathName"> the device path name to add to the manager. </param>
        private void AddEPdevice(String devicePathName)
        {
            ADS1298device adsDevice = new ADS1298device(this.CLASS_GUID, devicePathName);

            if (adsDevice.InitializeDevice())
            {
                if (adsDevice.ValidateVendorProductID(VENDOR_ID, PRODUCT_ID))
                {
                    _EPdevices.Add(adsDevice);
                    Thread.Sleep(100);
                    EPdevicesVM.Add(new ADS1298deviceVM(adsDevice));
                }
            }
        }
Beispiel #2
0
        /*
        ///  <summary>
        ///  Destructor.
        ///  </summary>
        ~EPdeviceManager()
        {
            ;
        }
        */
        ///  <summary>
        ///  Check if any devices are already connected and create them.
        ///  </summary>
        ///  
        ///  <param name="WPFhandler"> a pointer to the main handler. </param>
        public void Initialize(IntPtr WPFhandler)
        {
            ADS1298device myADSdevice;
            String[] devicePathNames = { };

            // Check if there are any devices for this class connected.
            if (UsbNotifications.FindDevice(CLASS_GUID, ref devicePathNames))
            {
                foreach (String devicePathName in devicePathNames)
                {
                    // Create device and initialize it.
                    myADSdevice = new ADS1298device(this.CLASS_GUID, devicePathName);

                    if (myADSdevice.InitializeDevice())
                    {
                        if (myADSdevice.ValidateVendorProductID(VENDOR_ID, PRODUCT_ID))
                        {
                            _EPdevices.Add(myADSdevice);
                            Thread.Sleep(500);
                            EPdevicesVM.Add(new ADS1298deviceVM(myADSdevice));
                        }
                    }
                }
            }

            // Register for notifications on this device class.
            UsbNotifications.RegisterForDeviceNotifications(WPFhandler, CLASS_GUID, ref UsbNotificationHandle);
        }