private void GetDefaultDevicePowerInfo(string customerId)
        {
            var deviceSummaryList = _customerEquipmentService.GetCustomerEquipmentTable(customerId);

            if (deviceSummaryList == null)
            {
                return;
            }
            List <EquipmentDTO> deviceList = new List <EquipmentDTO>();

            deviceSummaryList.areaList.ForEach(a => a.switchingRoomList.ForEach(r =>
            {
                var result = r.equipmentList.Where(e => e.equipmentType != 0);
                deviceList.AddRange(result);
            }));
            deviceList = deviceList.Distinct(new EquipmentIdComparer()).ToList();
            Application.Current.Dispatcher.Invoke(new Action(() =>
            {
                DeviceList.Clear();
                DeviceList                = new ObservableCollection <EquipmentDTO>(deviceList);
                SelectedPowerDevice       = DeviceList.Count != 0 ? DeviceList[0] : null;
                SelectedPowerFactorDevice = DeviceList.Count != 0 ? DeviceList[0] : null;
            }));
            if (SelectedPowerDevice != null)
            {
                GetDevicePowerInfoTaskAsync(SelectedPowerDevice.equipmentId.ToString(), DateTime.Now);
            }
            if (SelectedPowerFactorDevice != null)
            {
                GetDevicePowerFactorTaskAsync(SelectedPowerFactorDevice.equipmentId.ToString(), DateTime.Now);
            }
        }
示例#2
0
        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();
        }
示例#3
0
 internal void Initialize()
 {
     DeviceList.Clear();
     ComponentList.Clear();
     ExecutionEnvironmentList.Clear();
     NodeList.Clear();
 }
示例#4
0
 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();
     }
 }
        public async Task BuildDeviceList()
        {
            await Windows.ApplicationModel.Core.CoreApplication.MainView.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
            {
                if (DeviceList != null)
                {
                    DeviceList.Clear();
                }
                RaisePropertyChanged("ShowEmptyErrorMessage");
            });

            if (m_remoteSystemWatcher != null)
            {
                m_remoteSystemWatcher.Stop();
            }
            RemoteSystemAccessStatus accessStatus = await RemoteSystem.RequestAccessAsync();

            if (accessStatus == RemoteSystemAccessStatus.Allowed)
            {
                m_remoteSystemWatcher = RemoteSystem.CreateWatcher();
                // Subscribing to the event raised when a new remote system is found by the watcher.
                m_remoteSystemWatcher.RemoteSystemAdded += RemoteSystemWatcher_RemoteSystemAdded;
                // Subscribing to the event raised when a previously found remote system is no longer available.
                m_remoteSystemWatcher.RemoteSystemRemoved += RemoteSystemWatcher_RemoteSystemRemoved;
                m_remoteSystemWatcher.Start();
            }
        }
        /// <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();
        }
示例#7
0
 public void Refresh(bool refr_1 = true, bool refr_2 = true, bool refr_3 = true)
 {
     if (refr_1)
     {
         DeviceList.Clear();
         DeviceList.AddRange(PubMaster.Mod.DevSql.QueryDeviceList());
     }
 }
 public void RefreshList()
 {
     DeviceList.Clear();
     numDevices = VIWrapper.ListDevices();
     for (int i = 0; i < numDevices; i++)
     {
         DeviceList.Add(VIWrapper.GetDeviceName(i));
     }
 }
        void BindDeviceList()
        {
            var list = _blueToothService.GetDeviceList();

            DeviceList.Clear();
            foreach (var item in list)
            {
                DeviceList.Add(item);
            }
        }
示例#10
0
        protected virtual void Dispose(bool disposing)
        {
            if (disposed)
            {
                return;
            }
            if (disposing)
            {
                if (hasOnDisposingCalled == false)
                {
                    hasOnDisposingCalled = true;
                    OnDisposing(EventArgs.Empty);
                    if (disposed)
                    {
                        return;
                    }
                }

                // dispose managed objects, and dispose objects that implement IDisposable
                if (EachDeviceStatusMonitoringTimer != null)
                {
                    EachDeviceStatusMonitoringTimer.Dispose(); EachDeviceStatusMonitoringTimer = null;
                }
                if (OnDeviceConnectedDelayTimer != null)
                {
                    OnDeviceConnectedDelayTimer.Stop(); OnDeviceConnectedDelayTimer.Dispose(); OnDeviceConnectedDelayTimer = null;
                }
                if (OnDeviceDisconnectedDelayTimer != null)
                {
                    OnDeviceDisconnectedDelayTimer.Stop(); OnDeviceDisconnectedDelayTimer.Dispose(); OnDeviceDisconnectedDelayTimer = null;
                }
                if (MessageReceivingForm != null)
                {
                    MessageReceivingForm.CurrentDevice = null;
                }
                if (DeviceList != null)
                {
                    foreach (var device in DeviceList)
                    {
                        device.Close();
                    }
                    DeviceList.Clear();
                    DeviceList = null;
                }
                if (MessageReceivingForm != null)
                {
                    MessageReceivingForm.Dispose(); MessageReceivingForm = null;
                }
            }
            // release any unmanaged objects and set the object references to null
            disposed = true;
            OnDisposed(EventArgs.Empty);
        }
示例#11
0
        private void CommandScanExecute()
        {
            try
            {
                DeviceList.Clear();

                DeviceList = new ObservableCollection <BluetoothDevice>(_Adapter.GetBluetoothDevices());
            }
            catch (Exception ex)
            {
                UserDialogs.Instance.Alert("Error in fetching devices!");
            }
        }
 /// <summary>
 /// Clear all values
 /// </summary>
 public void Clear()
 {
     FileSystemCreationTime     = DateTime.MinValue;
     FileSystemModificationTime = DateTime.MinValue;
     DatasetID     = 0;
     DatasetName   = string.Empty;
     FileExtension = string.Empty;
     AcqTimeStart  = DateTime.MinValue;
     AcqTimeEnd    = DateTime.MinValue;
     ScanCount     = 0;
     FileSizeBytes = 0;
     DeviceList.Clear();
     InstrumentFiles.Clear();
     OverallQualityScore = 0;
 }
示例#13
0
        /// <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");
            }
        }
        protected virtual void Dispose(bool disposing)
        {
            if (disposed)
            {
                return;
            }
            if (disposing)
            {
                if (hasOnDisposingCalled == false)
                {
                    hasOnDisposingCalled = true;
                    OnDisposing(EventArgs.Empty);
                    if (disposed)
                    {
                        return;
                    }
                }

                // dispose managed objects, and dispose objects that implement IDisposable
#if false
                if (EachDeviceStatusMonitoringTimer != null)
                {
                    EachDeviceStatusMonitoringTimer.Dispose(); EachDeviceStatusMonitoringTimer = null;
                }
#endif
                if (DeviceList != null)
                {
                    foreach (var device in DeviceList)
                    {
                        device.Close();
                    }
                    DeviceList.Clear();
                    DeviceList = null;
                }
            }
            // release any unmanaged objects and set the object references to null
            disposed = true;
            OnDisposed(EventArgs.Empty);
        }
        public bool InitDevice()
        {
            SettingView     = false;
            AuthProcessView = false;

            ThermostatAPI api = Global.Instance.ThermostatAPI;

            Windows.Storage.ApplicationDataContainer localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;
            string token = localSettings.Values["NestAccessToken"] as string;

            if (string.IsNullOrEmpty(token))
            {
                Setting();

                return(false);
            }
            else
            {
                api.ApplyAccessToken(token);

                Task <bool> t = Task.Run(async() => await api.GetDevices());
                t.Wait();

                if (t.Result)
                {
                    int count = DeviceList.Count;
                    if (0 == count)
                    {
                        foreach (ThermostatDevice d in api.ThermostatDevices)
                        {
                            FanDuration nfd = DurationList.Where(L => L.Duration == d.fan_timer_duration.ToString()).SingleOrDefault();

                            Models.Thermostat nts = new Models.Thermostat(d);
                            nts.Duration     = nfd;
                            nts.RollDuration = nfd;

                            nts.Tick = 1; //("C" == nts.temperature_scale) ? 1 : 2;

                            nts.FanRun  = nts.fan_timer_active == true;
                            nts.FanStop = nts.fan_timer_active == false;

                            if (d == api.ThermostatDevices.First())
                            {
                                nts.FanBrush     = new SolidColorBrush(Colors.White);
                                nts.FanBallBrush = new SolidColorBrush(Colors.White);

                                nts.Duration.Brush     = new SolidColorBrush(Color.FromArgb(0xff, 0xff, 0xcb, 0x00));
                                nts.Duration.BallBrush = new SolidColorBrush(Color.FromArgb(0xff, 0xff, 0xcb, 0x00));
                            }

                            DeviceList.Add(nts);
                        }
                    }
                    else
                    {
                        if (api.ThermostatDevices.Count < count)
                        {
                            DeviceList.Clear();
                        }

                        foreach (ThermostatDevice d in api.ThermostatDevices)
                        {
                            FanDuration nfd = DurationList.Where(L => L.Duration == d.fan_timer_duration.ToString()).SingleOrDefault();

                            Models.Thermostat tm = DeviceList.Where(T => T.device_id == d.device_id).SingleOrDefault();
                            if (null == tm || string.IsNullOrEmpty(tm.device_id))
                            {
                                Models.Thermostat nts = new Models.Thermostat(d);
                                nts.Duration     = nfd;
                                nts.RollDuration = nfd;

                                nts.Tick = 1; //("C" == nts.temperature_scale) ? 1 : 2;

                                nts.FanRun  = nts.fan_timer_active == true;
                                nts.FanStop = nts.fan_timer_active == false;

                                DeviceList.Add(nts);
                                continue;
                            }

                            if (null != tm || false == string.IsNullOrEmpty(tm.device_id))
                            {
                                tm.Update(d, nfd);
                            }
                        }
                    }

                    if (firstInit)
                    {
                        firstInit            = false;
                        OnTemperatureSetting = true;
                    }

                    return(true);
                }
                else
                {
                    Setting();
                }

                return(false);
            }
        }
示例#16
0
        static bool InitDevice()
        {
            Task <bool> t = Task.Run(async() => await ThermostatAPI.GetDevices());

            t.Wait();

            if (t.Result)
            {
                int count = DeviceList.Count;
                if (0 == count)
                {
                    foreach (ThermostatDevice d in ThermostatAPI.ThermostatDevices)
                    {
                        FanDuration nfd = DurationList.Where(L => L.Duration == d.fan_timer_duration.ToString()).SingleOrDefault();

                        Thermostat nts = new Thermostat(d);
                        nts.Duration     = nfd;
                        nts.RollDuration = nfd;

                        nts.Tick = 1; //("C" == nts.temperature_scale) ? 1 : 2;

                        nts.FanRun  = nts.fan_timer_active == true;
                        nts.FanStop = nts.fan_timer_active == false;

                        DeviceList.Add(nts);
                    }
                }
                else
                {
                    if (ThermostatAPI.ThermostatDevices.Count < count)
                    {
                        DeviceList.Clear();
                    }

                    foreach (ThermostatDevice d in ThermostatAPI.ThermostatDevices)
                    {
                        FanDuration nfd = DurationList.Where(L => L.Duration == d.fan_timer_duration.ToString()).SingleOrDefault();

                        Thermostat tm = DeviceList.Where(T => T.device_id == d.device_id).SingleOrDefault();
                        if (null == tm || string.IsNullOrEmpty(tm.device_id))
                        {
                            Thermostat nts = new Thermostat(d);
                            nts.Duration     = nfd;
                            nts.RollDuration = nfd;

                            nts.Tick = 1; //("C" == nts.temperature_scale) ? 1 : 2;

                            nts.FanRun  = nts.fan_timer_active == true;
                            nts.FanStop = nts.fan_timer_active == false;

                            DeviceList.Add(nts);
                            continue;
                        }

                        if (null != tm || false == string.IsNullOrEmpty(tm.device_id))
                        {
                            tm.Update(d, nfd);
                        }
                    }
                }

                return(true);
            }

            return(false);
        }
 public void ClearDeviceList()
 {
     DeviceList.Clear();
 }
示例#18
0
 public void Reset()
 {
     _devices.Clear();
     StoppedScanning();
 }