Exemplo n.º 1
0
        public async Task Refresh()
        {
            if (sw.ElapsedMilliseconds < 1000 && sw.ElapsedMilliseconds != 0)
            {
                Logger.Log($"[DepCheck] Skipping refresh - Only {sw.ElapsedMilliseconds}ms have passed since last refresh!");
                return;
            }

            sw.Restart();
            Logger.Log("[DepCheck] Refreshing...");

            gpuAvail     = false;
            nvGpuAvail   = false;
            sysPyAvail   = false;
            embedPyAvail = false;
            torchAvail   = false;
            cv2Avail     = false;

            SetChecking(gpu);
            if (HasGpu())
            {
                SetGreen(gpu, "Available");
                gpuAvail = true;
            }
            else
            {
                SetRed(gpu);
            }

            await Task.Delay(10);

            SetChecking(nvGpu);
            string nvGpuName = NvApi.GetGpuName().Replace("GeForce ", "");

            Logger.Log("[DepCheck] GPU Name: " + nvGpuName);
            if (!string.IsNullOrWhiteSpace(nvGpuName))
            {
                SetGreen(nvGpu, nvGpuName);
                nvGpuAvail = true;
            }
            else
            {
                SetRed(nvGpu);
            }

            await Task.Delay(10);

            SetChecking(sysPython);
            string sysPyVer = GetSysPyVersion();

            if (!string.IsNullOrWhiteSpace(sysPyVer) && !sysPyVer.ToLower().Contains("not found") && sysPyVer.Length <= 35)
            {
                SetGreen(sysPython, sysPyVer);
                sysPyAvail = true;
            }
            else
            {
                SetRed(sysPython);
            }

            await Task.Delay(10);

            SetChecking(embedPython);
            string embedPyVer = GetEmbedPyVersion();

            if (!string.IsNullOrWhiteSpace(embedPyVer) && !embedPyVer.ToLower().Contains("not found") && embedPyVer.Length <= 35)
            {
                SetGreen(embedPython, embedPyVer);
                embedPyAvail = true;
            }
            else
            {
                SetRed(embedPython);
            }

            await Task.Delay(10);

            SetChecking(torch);
            string torchVer = GetPytorchVer();

            if (!string.IsNullOrWhiteSpace(torchVer) && torchVer.Length <= 35)
            {
                SetGreen(torch, torchVer);
                torchAvail = true;
            }
            else
            {
                SetRed(torch);
            }

            await Task.Delay(10);

            SetChecking(cv2);
            string cv2Ver = GetOpenCvVer();

            if (!string.IsNullOrWhiteSpace(cv2Ver) && !cv2Ver.ToLower().Contains("ModuleNotFoundError") && cv2Ver.Length <= 35)
            {
                SetGreen(cv2, cv2Ver);
                cv2Avail = true;
            }
            else
            {
                SetRed(cv2);
            }

            RefreshAvailOptions();
        }