internal void DiscoverDevices() { DeviceList.Clear(); CameraList.Clear(); foreach (var userCamera in SavedCameras) { if (userCamera.DeviceInfo != null) { try { DeviceList.Add(userCamera.DeviceInfo); } catch (Exception ex) { } } if (userCamera.Camera != null) { try { CameraList.Add(userCamera.Camera); } catch (Exception ex) { } } } DiscoverUsbDevices(); IPCameraFactory.DiscoverDevices(); }
async void OnDeviceAdded() { // Return immediately and do all the work asynchronously await Task.Yield(); // Loop through devices List <Device> NewDeviceList = getDeviceList(); foreach(Device dev in NewDeviceList) { if(!(DeviceIdList.Contains(dev.DeviceID))) { DeviceIdList.Add(dev.DeviceID); DeviceList.Add(dev); // Raise event if there are any subscribers if (RaiseDeviceAddedEvent!=null) { RaiseDeviceAddedEvent(this, dev); } } } // Try to connect to the device if we are not already connected if(ConnectionStatus!=UsbConnectionStatus.Connected) { SelectDevice(DeviceToConnectTo); } }
private void OnMessageReceived(object aObj, MessageReceivedEventArgs aEvent) { var op = Dispatcher.InvokeAsync(() => { switch (aEvent.Message) { case DeviceAdded m: _devices.Add(new Device(m.DeviceIndex, m.DeviceName, m.DeviceMessages)); break; case DeviceRemoved d: var device = from dl in _devices where dl.Index == d.DeviceIndex select dl; foreach (var dr in device.ToList()) { _devices.Remove(dr); } break; } }); _ops.Add(op); op.Completed += OperationCompletedHandler; }
public override void OnReceive(Context context, Intent intent) { System.String action = intent.Action; if (Android.Bluetooth.BluetoothDevice.ActionFound.Equals(action)) { Android.Bluetooth.BluetoothDevice device = (Android.Bluetooth.BluetoothDevice)intent.GetParcelableExtra(Android.Bluetooth.BluetoothDevice.ExtraDevice); var btDevice = new KeyVendor.Models.BluetoothDevice() { Name = device.Name, Address = device.Address }; bool itemAlreadyAdded = false; foreach (var item in DeviceList) { if (item.Address == btDevice.Address) { itemAlreadyAdded = true; break; } } if (!itemAlreadyAdded) { DeviceList.Add(btDevice); } } }
private async void DiscoverDevices() { var accessStatus = await RemoteSystem.RequestAccessAsync(); if (accessStatus == RemoteSystemAccessStatus.Allowed) { _remoteSystemWatcher = RemoteSystem.CreateWatcher(); //Add RemoteSystem to DeviceList (on the UI Thread) _remoteSystemWatcher.RemoteSystemAdded += async(sender, args) => await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => DeviceList.Add(args.RemoteSystem)); //Remove RemoteSystem from DeviceList (on the UI Thread) _remoteSystemWatcher.RemoteSystemRemoved += async(sender, args) => await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => DeviceList.Remove(DeviceList.FirstOrDefault(system => system.Id == args.RemoteSystemId))); //Update RemoteSystem on DeviceList (on the UI Thread) _remoteSystemWatcher.RemoteSystemUpdated += async(sender, args) => await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { DeviceList.Remove(DeviceList.FirstOrDefault(system => system.Id == args.RemoteSystem.Id)); DeviceList.Add(args.RemoteSystem); }); _remoteSystemWatcher.Start(); } }
public void LoadDevices() { DeviceList.Clear(); if (Devices.Count > 0) { foreach (IDevice item in Devices) { if (item.Name == CommonDefine.UserSetting) { continue; } DeviceList.Add(new DeviceNode(item)); } //User setting always be the last one in the devices menu. IDevice iUserSetting = Devices.GetDevice(CommonDefine.UserSetting); if (iUserSetting != null) { DeviceList.Add(new DeviceNode(iUserSetting)); } } else { LoadDefault(); } }
/// <summary> /// The devices list changed /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BluetoothLEDevices_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) { string msg = string.Empty; lock (deviceListLock) { if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add) { foreach (ObservableBluetoothLEDevice newDev in e.NewItems) { if (ShouldShow(newDev)) { DeviceList.Add(newDev); } } } else if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Remove) { foreach (ObservableBluetoothLEDevice oldDev in e.OldItems) { DeviceList.Remove(oldDev); } } else if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Reset) { DeviceList.Clear(); } } UpdateDeviceList(); }
private void UpdateDeviceList() { List <ObservableBluetoothLEDevice> toRemove = new List <ObservableBluetoothLEDevice>(); lock (deviceListLock) { foreach (ObservableBluetoothLEDevice dev in DeviceList) { if (ShouldShow(dev) == false) { toRemove.Add(dev); } } foreach (ObservableBluetoothLEDevice dev in toRemove) { DeviceList.Remove(dev); } foreach (ObservableBluetoothLEDevice dev in Context.BluetoothLEDevices) { if (ShouldShow(dev) && DeviceList.Contains(dev) == false) { DeviceList.Add(dev); } } } }
/// <summary> /// Given a Path, attempts to read the file from the specified path /// </summary> /// <param name="path"></param> public void LoadFromFile(string path, FileMode fileMode) { try { using (BinaryReader reader = new BinaryReader(File.Open(@path, FileMode.OpenOrCreate, FileAccess.ReadWrite))) { // Header int fileVersion = reader.ReadInt32(); int devicesCount = reader.ReadInt32(); // Begin the Read for (int index = 0; index < devicesCount; index++) { Device.Attributes attributes = new Device.Attributes(); IPAddress ip = new IPAddress(reader.ReadInt32()); attributes.StringAddress = ip.ToString(); attributes.PingInterval = reader.ReadInt32(); attributes.PingTimeout = reader.ReadInt32(); attributes.PingTimeToLive = reader.ReadInt32(); DeviceList.Add(new Device(attributes)); } reader.Close(); } } catch (IOException exception) { Console.WriteLine(Tag + ": " + exception.Message); } }
private async void RemoteSystemWatcher_RemoteSystemAdded(RemoteSystemWatcher sender, RemoteSystemAddedEventArgs args) { if (DeviceList != null) { await Windows.ApplicationModel.Core.CoreApplication.MainView.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { DeviceList.Add(new DeviceDetails() { DeviceName = args.RemoteSystem.DisplayName, UniqueId = args.RemoteSystem.Id, Type = RemoteSystemHelper.ConvertToDeviceType(args.RemoteSystem.Kind), StatusMessage = RemoteSystemHelper.GetStatusMessage(args.RemoteSystem.Status, args.RemoteSystem.Id), Credential = DatabaseHelper.GetKey(args.RemoteSystem.Id), RemoteSys = args.RemoteSystem }); RaisePropertyChanged("ShowEmptyErrorMessage"); }); } else { await Windows.ApplicationModel.Core.CoreApplication.MainView.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { DeviceList = new ObservableCollection <DeviceDetails>(); DeviceList.Add(new DeviceDetails() { DeviceName = args.RemoteSystem.DisplayName, UniqueId = args.RemoteSystem.Id, Type = RemoteSystemHelper.ConvertToDeviceType(args.RemoteSystem.Kind), StatusMessage = RemoteSystemHelper.GetStatusMessage(args.RemoteSystem.Status, args.RemoteSystem.Id), Credential = DatabaseHelper.GetKey(args.RemoteSystem.Id), RemoteSys = args.RemoteSystem }); RaisePropertyChanged("ShowEmptyErrorMessage"); }); } }
internal EgsDevice CreateNewEgsDeviceAndAddToDeviceList() { var device = EgsDevice.GetEgsDeviceForEgsDevicesManager(DeviceList.Count); DeviceList.Add(device); return(device); }
public DeviceNode AddDevice() { IDevice device = _deviceSet.CreateDevice(GetNoteName()); DeviceNode node = new DeviceNode(device); DeviceList.Add(node); return(node); }
public void RefreshList() { DeviceList.Clear(); numDevices = VIWrapper.ListDevices(); for (int i = 0; i < numDevices; i++) { DeviceList.Add(VIWrapper.GetDeviceName(i)); } }
public void Add(Device device) { if (device == null) { return; } DeviceList.Add(device); device.Start(); }
void BindDeviceList() { var list = _blueToothService.GetDeviceList(); DeviceList.Clear(); foreach (var item in list) { DeviceList.Add(item); } }
internal EgsDevice CreateNewEgsDeviceAndAddToDeviceList() { var device = EgsDevice.GetEgsDeviceForEgsDevicesManager(DeviceList.Count); DeviceList.Add(device); // TODO: MUSTDO: This is ad-hoc implementation. This way cannot recognize multiple device's connection and disconnection. This is very bad way, it should be fixed. MessageReceivingForm.CurrentDevice = device; return(device); }
/// <summary> /// Scan result event /// </summary> /// <param name="sender">Sender</param> /// <param name="e">Event args including device information</param> private void Ble_DeviceDiscoveredEvent(object sender, DeviceInfoEventArgs e) { DeviceInfo device = e.Device; // Add if not already on the list if (DeviceList.FirstOrDefault(d => d.DeviceId == device.DeviceId) == null) { DeviceList.Add(device); AdaptorState += Environment.NewLine + string.Format("Device found: {0} [{1}]", e.Device.Name, MacAddressUtils.MacAddressAsString(e.Device.DeviceId, true)); } }
/// <summary> /// Looks for new devices async /// </summary> public static void LookForNewDevicesAsync() { //var found = false; //while (!found) //{ // Console.WriteLine("INFO > Looking for new devices"); // const string unwantedPort = "/dev/ttyAMA0"; // var newDevices = SerialPort.GetPortNames() // .Where(port => port != unwantedPort && !Devices.IsDeviceKnown(port)).ToList(); // Console.WriteLine(newDevices.Count); // if (!newDevices.Any()) // continue; // found = true; // AddNewDevices(newDevices); //} Devices.Add("", Utility.Sensor.Force); }
private async void DeviceWatcher_Added(DeviceWatcher sender, DeviceInformation dev) { SerialDevice serialDevice = await SerialDevice.FromIdAsync(dev.Id); var deviceAccessStatus = DeviceAccessInformation.CreateFromId(dev.Id).CurrentStatus; if (serialDevice != null) { SerialDeviceInfo devinfo; devinfo.devInfo = dev; devinfo.serialDevice = serialDevice; DeviceList.Add(serialDevice.PortName, devinfo); NotifySerialDeviceStatus?.Invoke("Serial Device added."); } }
private void CreateDeviceList() { int deviceHandle = -1; while (true) { deviceHandle = synAPICtrl.FindDevice(SynConnectionType.SE_ConnectionAny, SynDeviceType.SE_DeviceTouchPad, deviceHandle); if (-1 == deviceHandle) { break; } DeviceList.Add(new SynapticsMouse(deviceHandle)); } }
// 図から必要な要素を取得し、リストを作成する internal void LoadDeployDiagramObjectsInformation(EA.Repository Repository) { // ノードの配置に関するモデルの作成,親をたどることにより必要な情報を入手 // 配置図の要素を環境、デバイス、ノード、コンポーネントのリストに格納 EA.Diagram diagram = Repository.GetCurrentDiagram(); var TmpCommunicationList = new List <Communication>(); for (short i = 0; i < diagram.DiagramObjects.Count; i++) { DiagramObject diagramObject = diagram.DiagramObjects.GetAt(i); Element element = Repository.GetElementByID(diagramObject.ElementID); var ConnectorList = new List <Connector>(); var xdoc = element.Notes.ToXDocument(); switch (element.MetaType) { case "ExecutionEnvironment": ExecutionEnvironmentList.Add(new ExecutionEnvironment(element.Name, element.ElementID, element.ParentID, xdoc)); break; case "Device": // デバイスが保持している接続を取得 for (short j = 0; j < element.Connectors.Count; j++) { Connector connector = element.Connectors.GetAt(j); ConnectorList.Add(connector); TmpCommunicationList.Add(new Communication(connector.Name, connector.ConnectorID, connector.DiagramID, connector.Notes.ToXDocument())); } DeviceList.Add(new Device(element.Name, element.ElementID, element.ParentID, xdoc, element.Stereotype, ConnectorList)); break; case "Node": NodeList.Add(new Node(element.Name, element.ElementID, element.ParentID, xdoc)); break; case "Component": ComponentList.Add(new Component(element.Name, element.ElementID, element.ParentID, xdoc)); break; } } TmpCommunicationList.GroupBy(communication => communication.Name) .Select(x => x.FirstOrDefault()) .ToList() .ForEach(Communication => CommunicationList.Add(Communication)); }
/// <summary> /// Get Bluetooth device list with DependencyService /// </summary> void BindDeviceList() { var list = _blueToothService.GetDeviceList(); DeviceList.Clear(); if (list != null) { foreach (var item in list) { DeviceList.Add(item); } } else { DeviceList.Add("Bağlanılacak Cihaz Yok"); } }
public void OnGet() { using (var db = new Model.DeviceChannels()) { foreach (var device in db.Devices) { DeviceList.Add(new SelectListItem { Value = device.DeviceName, Text = device.DeviceName }); } foreach (var channel in db.Channels) { ChannelList.Add(new SelectListItem { Value = channel.ChannelID.ToString(), Text = channel.ChannelName }); } } }
public void DeviceAdded(ButtplugDeviceInfo aDev) { var devAdd = from dl in _devices where dl.Info.Index == aDev.Index select dl; if (devAdd.Any()) { foreach (var dr in devAdd.ToList()) { dr.Connected = true; _devices.UpdateList(); } } else { _devices.Add(new DeviceListItem(aDev)); } }
public INode FactoryShallowCopy(int newId, int newIdNum, String newImei) { lock (DeviceList) { if (DeviceList.ContainsKey(newId)) { return(DeviceList[newId]); } var nuevo = (BaseCodec)MemberwiseClone(); nuevo.OnMemberwiseClone(); nuevo.Id = newId; nuevo.IdNum = newIdNum; nuevo.Imei = newImei; nuevo._deviceLock = new AutoResetEvent(true); DeviceList.Add(newId, nuevo); return(nuevo); } }
public void StartDiscovering() { if (bluetoothAdapter == null) { return; } receiver.ClearDeviceList(); foreach (var item in bluetoothAdapter.BondedDevices) { DeviceList.Add(new KeyVendor.Models.BluetoothDevice() { Name = item.Name, Address = item.Address }); } bluetoothAdapter.StartDiscovery(); }
public override void AddDeviceId(string deviceId, string deviceName) { var device = DeviceList?.FirstOrDefault(m => m.DeviceId == deviceId); if (device != null) { device.DeviceName = deviceName; return; } device = new DeviceInfo() { AddDate = DateTime.Now, DeviceId = deviceId, DeviceName = deviceName, LastInCome = DateTime.Now, }; if (DeviceList == null) { DeviceList = new List <DeviceInfo>(); } DeviceList.Add(device); }
private void BackWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { try { foreach (DeviceDetailInfo deviceInfo in deviceDetails) { foreach (DeviceDetailInfo.DataInfo data in deviceInfo.deviceInfo) { DeviceDetailModel mdl = new DeviceDetailModel(); mdl.DeviceName = data.deviceName; mdl.DeviceStatus = "未知"; mdl.GroupName = deviceInfo.deviceGroupName; mdl.IpAddress = data.ipAddress; mdl.DeviceMac = data.macAddress; mdl.IsChecked = false; DeviceList.Add(mdl); } } } catch (Exception ex) { } }
private void LoadDefault() { IDevice device = _deviceSet.CreateDevice(CommonDefine.PresetOff); DeviceList.Add(new DeviceNode(device)); device = _deviceSet.CreateDevice(CommonDefine.PCRetina); device.Width = 2560; device.Height = 1600; DeviceList.Add(new DeviceNode(device, DeviceType.PCWeb)); device = _deviceSet.CreateDevice(CommonDefine.PC1280); device.Width = 1280; device.Height = 800; DeviceList.Add(new DeviceNode(device, DeviceType.PCWeb)); device = _deviceSet.CreateDevice(CommonDefine.PC1024); device.Width = 1024; device.Height = 768; DeviceList.Add(new DeviceNode(device, DeviceType.PCWeb)); device = _deviceSet.CreateDevice(CommonDefine.IPhone6Plus); device.Width = 1242; device.Height = 2208; DeviceList.Add(new DeviceNode(device, DeviceType.Mobile)); device = _deviceSet.CreateDevice(CommonDefine.IPhone6); device.Width = 750; device.Height = 1334; DeviceList.Add(new DeviceNode(device, DeviceType.Mobile)); device = _deviceSet.CreateDevice(CommonDefine.IPhone5); device.Width = 640; device.Height = 1136; DeviceList.Add(new DeviceNode(device, DeviceType.Mobile)); device = _deviceSet.CreateDevice(CommonDefine.GalaxyS6); device.Width = 1440; device.Height = 2560; DeviceList.Add(new DeviceNode(device, DeviceType.Mobile)); device = _deviceSet.CreateDevice(CommonDefine.GalaxyS5); device.Width = 1080; device.Height = 1920; DeviceList.Add(new DeviceNode(device, DeviceType.Mobile)); device = _deviceSet.CreateDevice(CommonDefine.GalaxyS3); device.Width = 720; device.Height = 1280; device.IsChecked = true; DeviceList.Add(new DeviceNode(device, DeviceType.Mobile)); device = _deviceSet.CreateDevice(CommonDefine.LGOptimusG3); device.Width = 1440; device.Height = 2560; DeviceList.Add(new DeviceNode(device, DeviceType.Mobile)); device = _deviceSet.CreateDevice(CommonDefine.GoogleNexus5); device.Width = 1080; device.Height = 1920; DeviceList.Add(new DeviceNode(device, DeviceType.Mobile)); device = _deviceSet.CreateDevice(CommonDefine.IPadPro); device.Width = 2732; device.Height = 2048; DeviceList.Add(new DeviceNode(device, DeviceType.Tablet)); device = _deviceSet.CreateDevice(CommonDefine.IpadMini2); device.Width = 2048; device.Height = 1536; DeviceList.Add(new DeviceNode(device, DeviceType.Tablet)); device = _deviceSet.CreateDevice(CommonDefine.IpadMini1); device.Width = 1024; device.Height = 768; DeviceList.Add(new DeviceNode(device, DeviceType.Tablet)); device = _deviceSet.CreateDevice(CommonDefine.GalaxyTabS2); device.Width = 2048; device.Height = 1536; DeviceList.Add(new DeviceNode(device, DeviceType.Tablet)); device = _deviceSet.CreateDevice(CommonDefine.GalaxyTabA); device.Width = 1024; device.Height = 768; DeviceList.Add(new DeviceNode(device, DeviceType.Tablet)); device = _deviceSet.CreateDevice(CommonDefine.GoogleNexus7); device.Width = 1824; device.Height = 1200; DeviceList.Add(new DeviceNode(device, DeviceType.Tablet)); device = _deviceSet.CreateDevice(CommonDefine.Watch42mm); device.Width = 312; device.Height = 390; DeviceList.Add(new DeviceNode(device, DeviceType.Watch)); device = _deviceSet.CreateDevice(CommonDefine.Watch38mm); device.Width = 272; device.Height = 340; DeviceList.Add(new DeviceNode(device, DeviceType.Watch)); device = _deviceSet.CreateDevice(CommonDefine.UserSetting); DeviceList.Add(new DeviceNode(device)); }
/// <summary> /// Add a system device /// </summary> /// <param name="name"></param> /// <param name="device"></param> public void AddDevice(string name, object device) { DeviceList.Add(name, device); RaiseDeviceManagerEvent("Added device", name); }