Ejemplo n.º 1
0
        public void Initialize()
        {
            int devicesToRetryNo = 0;

            foreach (Device device in devices)
            {
                if (device.IsInitialized() || Global.Configuration.devices_disabled.Contains(device.GetType()))
                {
                    continue;
                }

                if (device.Initialize())
                {
                    anyInitialized = true;
                }
                else
                {
                    devicesToRetryNo++;
                }

                Global.logger.LogLine("Device, " + device.GetDeviceName() + ", was" + (device.IsInitialized() ? "" : " not") + " initialized", Logging_Level.Info);
            }

            NewDevicesInitialized?.Invoke(this, new EventArgs());

            if (devicesToRetryNo > 0 && !retryActivated)
            {
                retryThread = new Thread(RetryInitialize);
                retryThread.Start();

                retryActivated = true;
            }

            _InitializeOnceAllowed = true;
        }
Ejemplo n.º 2
0
        private void RetryInitialize()
        {
            for (int try_count = 0; try_count < retryAttemps; try_count++)
            {
                Global.logger.LogLine("Retrying Device Initialization", Logging_Level.Info);

                foreach (Device device in devices)
                {
                    if (device.IsInitialized())
                    {
                        continue;
                    }

                    if (device.Initialize())
                    {
                        anyInitialized = true;
                    }

                    Global.logger.LogLine("Device, " + device.GetDeviceName() + ", was" + (device.IsInitialized() ? "" : " not") + " initialized", Logging_Level.Info);
                }

                retryAttemptsLeft--;

                NewDevicesInitialized?.Invoke(this, new EventArgs());

                Thread.Sleep(retryInterval);
            }
        }
Ejemplo n.º 3
0
        public void Initialize()
        {
            foreach (Device device in devices)
            {
                if (device.IsInitialized())
                {
                    continue;
                }

                if (device.Initialize())
                {
                    anyInitialized = true;
                }

                Global.logger.LogLine("Device, " + device.GetDeviceName() + ", was" + (device.IsInitialized() ? "" : " not") + " initialized", Logging_Level.Info);
            }

            NewDevicesInitialized?.Invoke(this, new EventArgs());

            if ((Global.Configuration.desktop_profile.Settings as Profiles.Desktop.DesktopSettings).isEnabled)
            {
                if (!retryActivated)
                {
                    Thread retryThread = new Thread(RetryInitialize);
                    retryThread.Start();

                    retryActivated = true;
                }
            }
        }
Ejemplo n.º 4
0
        private void RetryInitialize()
        {
            if (suspended)
            {
                return;
            }
            for (int try_count = 0; try_count < retryAttemps; try_count++)
            {
                Global.logger.Info("Retrying Device Initialization");
                if (suspended)
                {
                    continue;
                }
                int  devicesAttempted = 0;
                bool _anyInitialized  = false;
                foreach (DeviceContainer device in devices)
                {
                    if (device.Device.IsInitialized() || Global.Configuration.devices_disabled.Contains(device.Device.GetType()))
                    {
                        continue;
                    }

                    devicesAttempted++;
                    if (device.Device.Initialize())
                    {
                        _anyInitialized = true;
                    }

                    Global.logger.Info("Device, " + device.Device.GetDeviceName() + ", was" + (device.Device.IsInitialized() ? "" : " not") + " initialized");
                }

                retryAttemptsLeft--;

                //We don't need to continue the loop if we aren't trying to initialize anything
                if (devicesAttempted == 0)
                {
                    break;
                }

                //There is only a state change if something suddenly becomes initialized
                if (_anyInitialized)
                {
                    NewDevicesInitialized?.Invoke(this, new EventArgs());
                    anyInitialized = true;
                }

                Thread.Sleep(retryInterval);
            }
        }
Ejemplo n.º 5
0
        public void Initialize(bool forceRetry = false)
        {
            if (suspended)
            {
                return;
            }

            int devicesToRetryNo = 0;

            foreach (DeviceContainer device in devices)
            {
                if (device.Device.IsInitialized() || Global.Configuration.devices_disabled.Contains(device.Device.GetType()))
                {
                    continue;
                }

                if (device.Device.Initialize())
                {
                    anyInitialized = true;
                }
                else
                {
                    devicesToRetryNo++;
                }

                Global.logger.Info("Device, " + device.Device.GetDeviceName() + ", was" + (device.Device.IsInitialized() ? "" : " not") + " initialized");
            }


            if (anyInitialized)
            {
                _InitializeOnceAllowed = true;
                NewDevicesInitialized?.Invoke(this, new EventArgs());
            }

            if (devicesToRetryNo > 0 && (retryThread == null || forceRetry || retryThread?.ThreadState == System.Threading.ThreadState.Stopped))
            {
                retryActivated = true;
                if (forceRetry)
                {
                    retryThread?.Abort();
                }
                retryThread = new Thread(RetryInitialize);
                retryThread.Start();
                return;
            }
        }
Ejemplo n.º 6
0
        public void Initialize()
        {
            foreach (Device device in devices)
            {
                if (device.Initialize())
                {
                    anyInitialized = true;
                }

                Global.logger.LogLine("Device, " + device.GetDeviceName() + ", was" + (device.IsInitialized() ? "" : " not") + " initialized", Logging_Level.Info);
            }

            NewDevicesInitialized?.Invoke(this, new EventArgs());

            if (!retryActivated)
            {
                Thread retryThread = new Thread(RetryInitialize);
                retryThread.Start();

                retryActivated = true;
            }
        }