Esempio n. 1
0
        public override void Initialize(MagicHomeLedOutputInfo outputInfo)
        {
            IPAddress ip;
            int       port = 5577;

            switch (outputInfo.AddressType)
            {
            case AddressType.MacAddress:
                DeviceFindResult foundDevice = DeviceFinder.FindDevices().FirstOrDefault(x => x.MacAddress.Equals(outputInfo.MacAddress));
                if (foundDevice == null)
                {
                    throw new Exception(string.Format("device with mac {0} could not be found", outputInfo.MacAddress));
                }
                ip = foundDevice.IpAddress;
                break;

            case AddressType.IpAddress:
                ip = outputInfo.IPAddress;
                if (outputInfo.Port.HasValue)
                {
                    port = outputInfo.Port.Value;
                }
                break;

            default:
                throw new IndexOutOfRangeException();
            }

            _device = new Device(new IPEndPoint(ip, port), outputInfo.DeviceType);
            _device.TurnOn();
        }
Esempio n. 2
0
    /// <summary>
    /// 唤醒函数
    /// </summary>
    private void Awake()
    {
        HeadSet = DeviceFinder.HeadsetCamera().gameObject;
        GameObject go = new GameObject("Temp");

        orientionTrans = go.transform;
        curMenuCanvas  = videoMenuCanvas;
    }
Esempio n. 3
0
        private void RefreshDevicesList()
        {
            var task = new Task <IEnumerable <DeviceFindResult> >(() => DeviceFinder.FindDevices().ToList());

            task.Start();
            refreshButton.Text = "...";
            task.ContinueWith(tsk => this.Invoke((MethodInvoker)(() => RefreshListDone(tsk.Result))));
        }
Esempio n. 4
0
        public static void UnpairByName(string name, int discoveryTime, Utils.DeviceType deviceType)
        {
            var devices = DeviceFinder.FindDevicesByName(DeviceDiscoverer.DiscoverPairedBluetoothDevices(discoveryTime), name, deviceType);

            if (devices.Count > 1)
            {
                throw new Exception($"{devices.Count} devices found, don't know which one to choose");
            }

            DevicePairer.UnpairDevice(devices[0]);
        }
Esempio n. 5
0
    public virtual void ToggleBeam(bool state)
    {
        var index = DeviceFinder.GetControllerIndex(gameObject);

        if (state)
        {
        }
        else
        {
        }
    }
Esempio n. 6
0
        public void GetSerialNumber_shouldReturnValidSerialNumberAccordingToPNPDeviceIDProvided()
        {
            var deviceFinder = new DeviceFinder(string.Empty, string.Empty);

            var serialNumber = "412312312344";
            var pnpDeviceID  = $@"USB\VID_0D8C&PID_000C\{serialNumber}";

            var result = deviceFinder.GetSerialNumber(pnpDeviceID);

            Assert.AreEqual(serialNumber, result);
        }
 private void OnEnable()
 {
     hec     = FindObjectOfType <HandleEventController>();
     HeadSet = DeviceFinder.HeadsetCamera().gameObject;
     hec.ApplicationMenuPressedDownEvent += new HandleEventHandler(ApplicationPressedDown);
     hec.ApplicationMenuPressedUpEvent   += new HandleEventHandler(ApplicationPressedUp);
     hec.TriggerPressedDownEvent         += new global::HandleEventHandler(TriggerPressedDown);
     hec.TriggerPressedUpEvent           += new HandleEventHandler(TriggerPressedUp);
     hec.TriggerPressedEvent             += new HandleEventHandler(TriggerPressed);
     hec.TouchPadPressedDownEvent        += new HandleEventHandler(TouchpadPressedDown);
     hec.TouchPadPressedUpEvent          += new HandleEventHandler(TouchpadPressedUp);
     hec.GrispPressedDownEvent           += new HandleEventHandler(GripPressedDown);
 }
    private void Start()
    {
        this.name           = "PlayerObject_" + this.name;
        lastGoodPositionSet = false;
        headset             = DeviceFinder.HeadsetTransform();
        CreateCollider();
        InitHeadsetListeners();

        var controllerManager = GameObject.FindObjectOfType <SteamVR_ControllerManager>();

        InitControllerListeners(controllerManager.left);
        InitControllerListeners(controllerManager.right);
    }
        private PDManager()
        {
            var existing_devices = DeviceFinder.FindObjects("Win32_USBHub");

            foreach (var device in existing_devices)
            {
                if (device.ContainsKey("PNPDeviceID"))
                {
                    var    device_id = device["PNPDeviceID"];
                    string VidPid = "", UniqueId = "";
                    if (USBUtil.pnp_device_id_to_vidpid_and_unique_id(device_id, ref VidPid, ref UniqueId))
                    {
                        lock (this)
                            vidpid_to_unique_id_.Add(VidPid, UniqueId);
                    }
                }
            }
            var existing_controller_devices = DeviceFinder.FindObjects("Win32_USBControllerDevice");

            foreach (var device in existing_controller_devices)
            {
                if (device.ContainsKey("Dependent"))
                {
                    var    device_id = device["Dependent"];
                    string VidPid = "", UniqueId = "";
                    if (USBUtil.dependent_to_vidpid_and_unique_id(device_id, ref VidPid, ref UniqueId))
                    {
                        lock (this)
                            if (!vidpid_to_unique_id_.ContainsKey(VidPid))
                            {
                                vidpid_to_unique_id_.Add(VidPid, UniqueId);
                            }
                    }
                }
            }

            Refresh();

            monitor_usbhub_devices_.DeviceAddedEvent   += DeviceAdded;
            monitor_usbhub_devices_.DeviceDeletedEvent += DeviceRemoved;
            monitor_usbhub_devices_.Monitor("Win32_USBHub");

            monitor_controller_devices_.DeviceAddedEvent   += DeviceAddedConroller;
            monitor_controller_devices_.DeviceDeletedEvent += DeviceRemovedConroller;
            monitor_controller_devices_.Monitor("Win32_USBControllerDevice");

            new Thread(Win32Util.check_for_dialogs_thread)
            {
                IsBackground = true
            }.Start();
        }
        private void UpdateDeviceList()
        {
            var devices = DeviceFinder.GetDeviceList();

            this.DeviceList.Clear();

            devices.ForEach(d => this.DeviceList.Add(d));
            this.deviceCombo.SelectedIndex = 0;

            if (this.DeviceList.Contains(this.selectedDevice))
            {
                this.deviceCombo.SelectedItem = this.selectedDevice;
            }
        }
Esempio n. 11
0
        public static void Main(string[] args)
        {
            /*
             * ForeignDevicePortOptions options = new ForeignDevicePortOptions()
             * {
             *  PortId = 1,
             *  BbmdHost = "<bbmd-ip-here>",
             *  BbmdPort = 47808,
             *  LocalHost = "0.0.0.0",
             *  LocalPort = 47808,
             *  RegistrationInterval = TimeSpan.FromSeconds(30)
             * };
             */

            EthernetPortOptions ethOptions = new EthernetPortOptions()
            {
                PortId = 1
            };

            PortManagerOptions portMgrOptions = new PortManagerOptions();
            RouterOptions      routerOpts     = new RouterOptions();

            routerOpts.PortNetworkMappings.Add(new KeyValuePair <byte, ushort>(1, 0));
            HostOptions         hostOpts   = new HostOptions();
            DeviceFinderOptions finderOpts = new DeviceFinderOptions();

            //using (ForeignDevicePort port = new ForeignDevicePort(options))
            using (EthernetPort port = new EthernetPort(ethOptions))
                using (PortManager manager = new PortManager(portMgrOptions))
                    using (Router router = new Router(routerOpts))
                        using (Host host = new Host(hostOpts))
                            using (DeviceFinder finder = new DeviceFinder(finderOpts))
                                using (Session session = new Session(port, manager, router, host, finder))
                                {
                                    var client = new BACnet.Client.Client(host);

                                    // as long as there is at least 1 new devices found every 10 seconds,
                                    // for each found device, read that devices name and print it to the console

                                    finder.Timeout(TimeSpan.FromSeconds(10))
                                    .Catch(Observable.Empty <DeviceTableEntry>())
                                    .ForEachAsync(entry =>
                                    {
                                        Console.WriteLine(entry.Instance);
                                    })
                                    .Wait();
                                }
        }
        /*
         * private static void PairWithMac(MacAddress mac, int discoveryTime, Utils.DeviceType deviceType, string pin)
         * {
         *  var devices = DeviceFinder.FindDevicesByMac(DeviceDiscoverer.DiscoverBluetoothDevices(discoveryTime), mac, deviceType);
         *
         *  if (devices.Count == 1)
         *  {
         *      DevicePairer.PairDevice(devices[0], pin);
         *      return;
         *  }
         *
         *  if (devices.Count == 2)
         *  {
         *      throw new Exception(
         *          $"2 devices with the mac '{mac}' found \"{devices[0]}\" and \"{devices[1]}\". Don't know which one to choose.\n");
         *  }
         *
         *  throw new Exception(
         *      $"{devices.Count} devices with the mac '{mac}' found. Don't know which one to choose");
         * }
         */

        private static async Task <bool> PairWithName(string name, int discoveryTime, Utils.DeviceType deviceType, string pin)
        {
            var devices = DeviceFinder.FindDevicesByName(DeviceDiscoverer.DiscoverBluetoothDevices(discoveryTime), name, deviceType);

            if (devices.Count == 1)
            {
                return(await DevicePairer.PairDevice(devices[0], pin));
            }

            if (devices.Count == 2 && devices[0].Type == Bluetooth.DeviceType.BluetoothLE && devices[1].Type == Bluetooth.DeviceType.BluetoothLE)
            {
                return(await HandleSituation_2_BluetoothLe_devices_with_the_same_name_found(devices[0], devices[1], pin));
            }

            throw new Exception($"{devices.Count} devices with the name '{name}' found. Don't know which one to choose");
        }
Esempio n. 13
0
        public static void Main(string[] args)
        {
            /*
            ForeignDevicePortOptions options = new ForeignDevicePortOptions()
            {
                PortId = 1,
                BbmdHost = "<bbmd-ip-here>",
                BbmdPort = 47808,
                LocalHost = "0.0.0.0",
                LocalPort = 47808,
                RegistrationInterval = TimeSpan.FromSeconds(30)
            };
            */

            EthernetPortOptions ethOptions = new EthernetPortOptions()
            {
                PortId = 1
            };

            PortManagerOptions portMgrOptions = new PortManagerOptions();
            RouterOptions routerOpts = new RouterOptions();
            routerOpts.PortNetworkMappings.Add(new KeyValuePair<byte, ushort>(1, 0));
            HostOptions hostOpts = new HostOptions();
            DeviceFinderOptions finderOpts = new DeviceFinderOptions();

            //using (ForeignDevicePort port = new ForeignDevicePort(options))
            using (EthernetPort port = new EthernetPort(ethOptions))
            using (PortManager manager = new PortManager(portMgrOptions))
            using (Router router = new Router(routerOpts))
            using (Host host = new Host(hostOpts))
            using (DeviceFinder finder = new DeviceFinder(finderOpts))
            using (Session session = new Session(port, manager, router, host, finder))
            {
                var client = new BACnet.Client.Client(host);

                // as long as there is at least 1 new devices found every 10 seconds,
                // for each found device, read that devices name and print it to the console

                finder.Timeout(TimeSpan.FromSeconds(10))
                    .Catch(Observable.Empty<DeviceTableEntry>())
                    .ForEachAsync(entry =>
                    {
                        Console.WriteLine(entry.Instance);
                    })
                    .Wait();
            }
        }
Esempio n. 14
0
    protected virtual void Awake()
    {
        if (controller == null)
        {
            controller = GetComponent <ControllerEvent>();
        }

        if (controller == null)
        {
            Debug.Log("");
            return;
        }

        //Utilities

        headset  = DeviceFinder.HeadsetTransform();
        playArea = DeviceFinder.PlayAreaTransform();
        playAreaCursorBoundaries = new GameObject[4];
    }
        private static void PairWithMac(MacAddress mac, int discoveryTime, Utils.DeviceType deviceType, string pin)
        {
            var devices = DeviceFinder.FindDevicesByMac(DeviceDiscoverer.DiscoverBluetoothDevices(discoveryTime), mac, deviceType);

            if (devices.Count == 1)
            {
                DevicePairer.PairDevice(devices[0], pin);
                return;
            }

            if (devices.Count == 2)
            {
                throw new Exception(
                          $"2 devices with the mac '{mac}' found \"{devices[0]}\" and \"{devices[1]}\". Don't know which one to choose.\n");
            }

            throw new Exception(
                      $"{devices.Count} devices with the mac '{mac}' found. Don't know which one to choose");
        }
Esempio n. 16
0
    static void Main(string[] aArgs)
    {
        Helper helper = new Helper(aArgs);

        OptionParser optParser = helper.OptionParser;

        optParser.Usage = "usage: FindDevice [options] [device name]";
        OptionParser.OptionInt optTimeout = new OptionParser.OptionInt("-w", "--wait", 5, "Time to wait for finding the device (s)", "TIMEOUT");
        optParser.AddOption(optTimeout);

        helper.ProcessCommandLine();

        if (optParser.PosArgs.Count != 1)
        {
            Console.WriteLine(optParser.Help());
            return;
        }

        string uglyname = optParser.PosArgs[0];
        int    timeout  = optTimeout.Value;

        DeviceFinder finder = new DeviceFinder(uglyname);

        Device device;

        try
        {
            device = finder.Find(helper.Interface.Interface.Info.IPAddress, timeout * 1000);
        }
        catch (DeviceFinderException)
        {
            Console.WriteLine("Device not found");
            return;
        }

        helper.Dispose();

        Console.WriteLine("Udn: " + device.Udn);

        System.Environment.Exit(0);
    }
Esempio n. 17
0
        string FindDevice()
        {
            BeginStep("Transmit multicast PROBE message");
            LogStepEvent("Retransmit once per 5 seconds until a response is received or timeout (no more than 50 times)");

            DeviceFinder finder = new DeviceFinder(_nic.IP, _semaphore.StopEvent);

            finder.OnProgress += finder_OnProgress;

            Uri uri = new Uri(_cameraAddress);

            System.Net.IPAddress ip = System.Net.IPAddress.Parse(uri.Host);

            DeviceFinder.FindDeviceDelegate del = new DeviceFinder.FindDeviceDelegate(finder.ProbeDevice);

            IAsyncResult result = del.BeginInvoke(ip, 50, 5000, null, null);

            WaitHandle[] handles = new WaitHandle[] { _semaphore.StopEvent, result.AsyncWaitHandle };

            int handle = WaitHandle.WaitAny(handles);

            if (handle == 0)
            {
                finder.Stop();
                throw new StopEventException();
            }

            string data = del.EndInvoke(result);

            if (!string.IsNullOrEmpty(data))
            {
                LogStepEvent(string.Format("PROBE match message: {0}", data));
            }

            StepPassed();

            Assert(data != null, "Device not found", "Check that answer has been received");
            return(data);
        }
Esempio n. 18
0
        static void Main(string[] args)
        {
            ConfigureLog4Net();

            var df = new DeviceFinder();
            var d  = df.FindLoggerOnPort(DeviceFinder.DefaultPreferredPort);

            if (d == null)
            {
                Console.WriteLine("No device found. Terminating.");
                return;
            }
            Console.WriteLine($"Device located : {d.SerialNumber}");

            var dd = d.GetDetailsFromDevice();

            Console.WriteLine("Device details:");
            Console.WriteLine($"Serial Number   : {dd.SerialNumber}");
            Console.WriteLine($"Description     : {dd.Description}");
            Console.WriteLine($"Model           : {dd.Model}");
            Console.WriteLine($"Log Count       : {dd.NumberOfSamples}");
            Console.WriteLine($"Sample Interval : {dd.SampleInterval}");
            Console.WriteLine($"Delay Time      : {dd.DelayTime}");
            Console.WriteLine($"Offset CH1      : {dd.OffsetCh1}");
            Console.WriteLine($"Offset CH2      : {dd.OffsetCh2}");

            Console.ReadLine();

            var s = d.GetSamplesFromDevice(null).Result;

            Console.WriteLine($"Received {s.Length} samples");

            for (int i = 0; i < 10; i++)
            {
                var x = s[i];
                Console.WriteLine($"{x.ID:5} {x.TimeStamp:yyyy-MM-dd HH:mm:ss} {x.Temperature}");
            }
        }
Esempio n. 19
0
        static void Main(string[] args)
        {
            var lst = DeviceFinder.GetDevices();

            if (lst.Count > 0)
            {
                for (int i = 0; i < 1000; i++)
                {
                    int deviceCounter = 0;
                    foreach (var d in lst)
                    {
                        d.Open();
                        deviceCounter++;
                        for (int j = 0; j < 10; j++)
                        {
                            Console.WriteLine("Device {0} : {1}", deviceCounter, d.GetTemperature());
                        }
                        d.Close();
                    }
                    System.Threading.Thread.Sleep(100);
                }
            }
        }
Esempio n. 20
0
        public async Task <List <Bridge> > SearchBridgesUsingUPNPAsync()
        {
            var          discoveredBridges = new List <Bridge>();
            DeviceFinder finder            = new DeviceFinder();
            await finder.DiscoverDevices();

            foreach (var url in finder.DiscoveredUrls)
            {
                if (!url.EndsWith("/description.xml"))
                {
                    continue;
                }

                Bridge bridge = await BridgeFromDescriptionAsync(url);

                if (bridge != null)
                {
                    discoveredBridges.Add(bridge);
                }
            }

            return(discoveredBridges);
        }
Esempio n. 21
0
        static SmartPlug DeviceFinderDemo(IPAddress ipAddressToUse)
        {
            DeviceFinder deviceFinder = new DeviceFinder(SENDINGPORT, LISTENINGPORT, TIMEOUTPERIOD);

            // finding devices in the network(s), the computer is located, as these could be
            // more than one, tell the FindDevices method, which IP to use.
            deviceFinder.FindDevices(ipAddressToUse);
            while (deviceFinder.IsStillSearching)
            {
                System.Threading.Thread.Sleep(500);
            }
            //System.Threading.Thread.Sleep(30000);
            IEnumerable <Contrequarte.SmartPlug.Core.SmartPlug> smartPlugs = deviceFinder.SmartPlugList;

            foreach (var smartP in smartPlugs)
            {
                System.Console.WriteLine(string.Format("Name: {0} IP:{1} model: {2} sw version: {3} "
                                                       , smartP.Name, smartP.IpAddress, smartP.Model, smartP.SoftwareVersion));
            }

            int i = smartPlugs.Count();

            return(smartPlugs.First());
        }
 public static List <Dictionary <string, string> > get_all_usb_pnp_device_info()
 {
     return(DeviceFinder.FindObjects("Win32_USBHub"));
 }
        public static List <string> get_all_usb_dependent_ids()
        {
            var existing_devices = DeviceFinder.FindObjects("Win32_USBControllerDevice");

            return(existing_devices.Select(d => d.ContainsKey("Dependent") ? d["Dependent"] : "--INVALID-DEVICE--").ToList());
        }
        // for testing - run into problems? please run this:

        /*
         *  foreach ( var p in USBUtil.get_all_portable_paths())
         *      Console.WriteLine(p);
         *  foreach ( var p in USBUtil.get_all_usb_pnp_device_ids())
         *      Console.WriteLine(p);
         *  foreach ( var p in USBUtil.get_all_usb_dependent_ids())
         *      Console.WriteLine(p);
         */
        public static List <string> get_all_usb_pnp_device_ids()
        {
            var existing_devices = DeviceFinder.FindObjects("Win32_USBHub");

            return(existing_devices.Select(d => d.ContainsKey("PNPDeviceID") ? d["PNPDeviceID"] : "--INVALID-DEVICE--").ToList());
        }
Esempio n. 25
0
        public void GetSerialNumber_PNPDeviceIDwithEmptySeriaNumberShouldThrowEmtySerialNumberException()
        {
            var deviceFinder = new DeviceFinder(string.Empty, string.Empty);

            deviceFinder.GetSerialNumber(string.Empty);
        }