示例#1
0
 public void AddUsbDevice(UsbDeviceInformation device)
 {
     if (UsbDeviceIsPresent(device))
     {
         throw new InvalidOperationException(String.Format("Device {0} is already added", device));
     }
     devices.Add(device);
 }
示例#2
0
 public Boolean UsbDeviceIsPresent(UsbDeviceInformation device)
 {
     foreach (UsbDeviceInformation deviceInList in devices)
     {
         if (device.Equals(deviceInList))
         {
             return(true);
         }
     }
     return(false);
 }
示例#3
0
 public void RemoveUsbDevice(UsbDeviceInformation device)
 {
     for (int i = 0; i < devices.Count; i++)
     {
         if (device.Equals(devices[i]))
         {
             devices.RemoveAt(i);
             return;
         }
     }
     throw new InvalidOperationException(String.Format("Device {0} is not present", device));
 }
        static void RawControlExample(EndPoint serverEndPoint)
        {
            NpcClient npcClient = new NpcClient(serverEndPoint);

            npcClient.UpdateAndVerifyEnumAndObjectTypes();

            /*
             * npcClient.VerifyMethodDefinitions(false, new SosMethodDefinition[] {
             *  new SosMethodDefinition("UsbImpl.GetDevices", "UsbDeviceInformation[]"),
             *  new SosMethodDefinition("UsbImpl.AddUsbDevice", "Void", "UsbDeviceInformation", "device"),
             * });
             */

            //
            // Call Example 1
            //
            UInt32 id = (UInt32)npcClient.Call("testnamespace.device.getid");

            Console.WriteLine("id is {0}", id);

            npcClient.Call("testnamespace.device.setid", 293);
            //
            // Call Example 2 (using namespace client)
            // This means that you can just call the method name instead of providing the whole namespace/class
            //
            NpcClientNamespaceCaller npcNamespaceClient =
                new NpcClientNamespaceCaller(npcClient, "testnamespace.device");

            id = (UInt32)npcNamespaceClient.Call("getid");
            Console.WriteLine("id is {0}", id);

            npcClient.Dispose();


            UsbDeviceInformation deviceInfo = new UsbDeviceInformation(UsbLegacyName.CAT, 24, "Manufacturer\nwith newline");

            npcClient.Call("UsbImpl.AddUsbDevice", deviceInfo);

            deviceInfo.legacyName   = UsbLegacyName.KBD;
            deviceInfo.@class       = 88;
            deviceInfo.manufacturer = "HP INC";
            npcClient.Call("UsbImpl.AddUsbDevice", deviceInfo);

            UsbDeviceInformation[] deviceInfos = (UsbDeviceInformation[])npcClient.Call("UsbImpl.GetDevices");
        }
示例#5
0
 public Boolean Equals(UsbDeviceInformation device)
 {
     return(this.legacyName == device.legacyName &&
            this.@class == device.@class &&
            this.manufacturer.Equals(device.manufacturer));
 }
示例#6
0
 /// <summary>The UsbDeviceIsPresent method</summary>
 /// <param name="device">The device parameter of type UsbDeviceInformation</param>
 /// <returns>Return type is Boolean</returns>
 public Boolean UsbDeviceIsPresent(UsbDeviceInformation device)
 {
     return((Boolean)npcClientCaller.Call(typeof(Boolean), "UsbImpl.UsbDeviceIsPresent", device));
 }
示例#7
0
 /// <summary>The RemoveUsbDevice method</summary>
 /// <param name="device">The device parameter of type UsbDeviceInformation</param>
 public void RemoveUsbDevice(UsbDeviceInformation device)
 {
     npcClientCaller.Call(typeof(void), "UsbImpl.RemoveUsbDevice", device);
 }