Пример #1
0
 public DeviceHandle(HIDHandle handle)
 {
     this._devType = PortType.HID;
     this._HIDhnd = handle;
 }
Пример #2
0
 private DeviceHandle openDevice()
 {
     try
     {
         DeviceTypeID eid;
         if ((Thread.CurrentThread.Name == string.Empty) || (Thread.CurrentThread.Name == null))
         {
             Thread.CurrentThread.Name = "MAIN thread";
         }
         Hid hid = new Hid();
         foreach (ushort num in new ushort[] { ushort.Parse(SRW006.PID, NumberStyles.HexNumber), ushort.Parse(UDP001.PID, NumberStyles.HexNumber) })
         {
             hid = Hid.Connect(ushort.Parse(SRW006.VID, NumberStyles.HexNumber), num, 20, 20);
             if (hid != null)
             {
                 break;
             }
         }
         if (hid == null)
         {
             return null;
         }
         if (!this.isDeviceAlive(hid.ADT.PortAddress, out eid))
         {
             throw new Exception("HID device opened but not responding...");
         }
         HIDHandle handle = new HIDHandle(hid);
         DeviceHandle handle2 = new DeviceHandle(handle);
         handle2.HIDhnd.hnd.ADT.DeviceInfo = this.queryDeviceInfo(handle2);
         _log.Info("Device Successfully Opened: " + hid.ADT.PortAddress.hidAddr.Serial);
         try
         {
             WDSFrameWindow window = WDS_MainProg.frameWin();
             switch (((AddDeviceResult) window.Invoke(new AddDevice(window.addDevice), new object[] { handle2.HIDhnd.hnd.ADT })))
             {
                 case AddDeviceResult.AppStarted:
                 case AddDeviceResult.FirmwareReplaced:
                 case AddDeviceResult.ExcludeOrCancel:
                 case AddDeviceResult.Aborted:
                     goto Label_019D;
             }
         }
         catch (Exception exception)
         {
             _log.Error("Invoking AddDevice failed " + exception.Message);
         }
     Label_019D:
         this.open();
         return handle2;
     }
     catch (Exception exception2)
     {
         _log.Error(exception2.Message);
         return null;
     }
 }