Beispiel #1
0
        public void DeviceInit()
        {
            DevicePluginName = "DeviceCfg";

            // Device Discovery
            connected = false;

            // Create Device info object
            DeviceInformation = new DeviceInformation();

            try
            {
                // Initialize Device
                device = HidDevices.Enumerate(Device_IDTech.IDTechVendorID).FirstOrDefault();

                if (device != null)
                {
                    // Get Capabilities
                    Debug.WriteLine("");
                    Debug.WriteLine("device capabilities ----------------------------------------------------------------");
                    Debug.WriteLine("  Usage                          : " + Convert.ToString(device.Capabilities.Usage, 16));
                    Debug.WriteLine("  Usage Page                     : " + Convert.ToString(device.Capabilities.UsagePage, 16));
                    Debug.WriteLine("  Input Report Byte Length       : " + device.Capabilities.InputReportByteLength);
                    Debug.WriteLine("  Output Report Byte Length      : " + device.Capabilities.OutputReportByteLength);
                    Debug.WriteLine("  Feature Report Byte Length     : " + device.Capabilities.FeatureReportByteLength);
                    Debug.WriteLine("  Number of Link Collection Nodes: " + device.Capabilities.NumberLinkCollectionNodes);
                    Debug.WriteLine("  Number of Input Button Caps    : " + device.Capabilities.NumberInputButtonCaps);
                    Debug.WriteLine("  Number of Input Value Caps     : " + device.Capabilities.NumberInputValueCaps);
                    Debug.WriteLine("  Number of Input Data Indices   : " + device.Capabilities.NumberInputDataIndices);
                    Debug.WriteLine("  Number of Output Button Caps   : " + device.Capabilities.NumberOutputButtonCaps);
                    Debug.WriteLine("  Number of Output Value Caps    : " + device.Capabilities.NumberOutputValueCaps);
                    Debug.WriteLine("  Number of Output Data Indices  : " + device.Capabilities.NumberOutputDataIndices);
                    Debug.WriteLine("  Number of Feature Button Caps  : " + device.Capabilities.NumberFeatureButtonCaps);
                    Debug.WriteLine("  Number of Feature Value Caps   : " + device.Capabilities.NumberFeatureValueCaps);
                    Debug.WriteLine("  Number of Feature Data Indices : " + device.Capabilities.NumberFeatureDataIndices);

                    // Using the device notifier to detect device removed event
                    device.Removed        += DeviceRemovedHandler;
                    Device.OnNotification += OnNotification;

                    Device.Init(SerialPortService.GetAvailablePorts(), ref DeviceInformation.deviceMode);

                    // Notify Main Form
                    SetDeviceMode(DeviceInformation.deviceMode);

                    if (DeviceInformation.emvConfigSupported)
                    {
                        // Initialize Universal SDK
                        IDT_Device.setCallback(MessageCallBack);
                        //IDT_Device.setCallbackIP(MessageCallBackIP);
                        IDT_Device.startUSBMonitoring();
                        Debug.WriteLine("DeviceCfg::DeviceInit(): - device TYPE={0}", IDT_Device.getDeviceType());

                        NotificationRaise(new DeviceNotificationEventArgs {
                            NotificationType = NOTIFICATION_TYPE.NT_INITIALIZE_DEVICE, Message = new object[] { "COMPLETED" }
                        });
                    }
                    else
                    {
                        // connect to device
                        Device.Connect();
                    }
                    // Set as Attached
                    attached = true;
                }
                else
                {
                    throw new Exception("NoDevice");
                }
            }
            catch (Exception xcp)
            {
                throw xcp;
            }
        }