public bool OpenHID(string deviceID) { _deviceID = deviceID; _device = GetHidDevice(); if (_device == null) { return false; } _device.OpenDevice(); _device.MonitorDeviceEvents = true; _device.Inserted += Device_Inserted; _device.Removed += Device_Removed; _device.ReadReport(ReadInProcess); return true; }
public void Init() { var flag1 = IPCAPI.F75111_Init(); if (flag1 == 0) { //MessageBox.Show("初始化主板失败!"); } var list = HidDevices.Enumerate().Where(s => s.DevicePath.Contains(vid)).ToList(); _deviceIn = list.FirstOrDefault(s => s.DevicePath.Contains(intdeviceId.ToLower())); if (_deviceIn != null) { _deviceIn.OpenDevice(); _deviceIn.MonitorDeviceEvents = true; _deviceIn.Inserted += () => { DeskoHIDReaderStatus = "已连接"; }; _deviceIn.Removed += () => { DeskoHIDReaderStatus = "未连接"; }; _deviceIn.ReadReport(ReadInProcess); } _accessQRReader = new AccessQRReader((data) => { QRCode = data; }); _nfcReader = new NFCSerialPort((data) => { ICSerialNumber = data; }); }
private void RegisterHidDevice(HidDevice device) { device.OpenDevice(); device.MonitorDeviceEvents = true; device.Inserted += Device_Inserted; device.Removed += Device_Removed; device.ReadReport(ReadInProcess); }
public void Run() { var boardInit = IPCAPI.F75111_Init(); if (boardInit <= 0) { InitMessage = "主板初始化失败!"; return; } else { ShowPassenger = Visibility.Visible; CurrentDateTime = string.Format(datetimeFormate, DateTime.Now.ToStandard(), GetWeekOfDay()); QRCodeInfo = "二维码:请刷二维码"; PassengerCount = string.Format(passengerFormate, 0); } if (Config.Protocol == "com") { if (!Config.InPortName.IsEmpty() && Config.InPortName != "None") { _InReader.SetQRCodeCallback(OnInChannelGetQRcode); _InReader.Open(Config.InPortName); } else { LogHelper.Info("未配置【入】阅读器"); } if (!Config.OutPortName.IsEmpty() && Config.OutPortName != "None") { _OutReader.SetQRCodeCallback(OnChannelOutGetQRcode); _OutReader.Open(Config.OutPortName); } else { LogHelper.Info("未配置【出】阅读器"); } } else { //HID协议 if (_deskoHIDs == null) { LogHelper.Info("未发现USB HID设备!"); return; } _deviceIn = _deskoHIDs.FirstOrDefault(s => !string.IsNullOrEmpty(Config.InHID) && s.DevicePath.Contains(Config.InHID.ToLower())); _deviceOut = _deskoHIDs.FirstOrDefault(s => !string.IsNullOrEmpty(Config.OutHID) && s.DevicePath.Contains(Config.OutHID.ToLower())); if (_deviceIn != null) { _deviceIn.OpenDevice(); _deviceIn.MonitorDeviceEvents = true; _deviceIn.Inserted += Device_Inserted; _deviceIn.Removed += Device_Removed; _deviceIn.ReadReport(ReadInProcess); } else { LogHelper.Info("未配置【入】USB HID设备"); } if (_deviceOut != null) { _deviceOut.OpenDevice(); _deviceOut.MonitorDeviceEvents = true; _deviceOut.Inserted += Device_Inserted; _deviceOut.Removed += Device_Removed; _deviceOut.ReadReport(ReadOutProcess); } else { LogHelper.Info("未发现【出】USB HID设备"); } } _rebootWeekofday = ConfigProfile.Instance.RebootWeekofDay.Split(','); _updateTimer.Interval = TimeSpan.FromSeconds(1); _updateTimer.Tick += UpdateTimer_Tick; _updateTimer.Start(); _udpServer = new Code.UdpServer(); _udpServer.Start(); CheatCallApi(); }