示例#1
0
        public static string PGPUUtilisationString(PGPU pGpu, MetricUpdater MetricUpdater)
        {
            PCI    pci         = pGpu.Connection.Resolve(pGpu.PCI);
            Host   host        = pGpu.Connection.Resolve(pGpu.host);
            string pci_id      = pci.pci_id.Replace(@":", "/");
            double utilisation = MetricUpdater.GetValue(host, String.Format("gpu_utilisation_computer_{0}", pci_id));

            if (utilisation == 0 || Double.IsNaN(utilisation) || Double.IsNaN(utilisation))
            {
                return(Messages.HYPHEN);
            }
            else
            {
                return(utilisation.ToString());
            }
        }
示例#2
0
        public static string PGPUPowerUsageString(PGPU pGpu, MetricUpdater MetricUpdater)
        {
            PCI    pci        = pGpu.Connection.Resolve(pGpu.PCI);
            string pci_id     = pci.pci_id.Replace(@":", "/");
            Host   host       = pGpu.Connection.Resolve(pGpu.host);
            double powerUsage = MetricUpdater.GetValue(host, String.Format("gpu_power_usage_{0}", pci_id));

            if (powerUsage == 0 || Double.IsNaN(powerUsage) || Double.IsNaN(powerUsage))
            {
                return(Messages.HYPHEN);
            }
            else
            {
                return(powerUsage.ToString());
            }
        }
示例#3
0
        public void RefreshGpu(PGPU pGpu)
        {
            Program.AssertOnEventThread();
            if (!Visible)
            {
                return;
            }

            GpuShinyBar gpuShinyBar = FindGpuShinyBar(pGpu);

            if (gpuShinyBar != null)
            {
                gpuShinyBar.Initialize(pGpu);
                gpuShinyBar.Refresh();
            }
        }
示例#4
0
        public static string PGPUMemoryUsageString(PGPU pGpu, MetricUpdater MetricUpdater)
        {
            PCI    pci    = pGpu.Connection.Resolve(pGpu.PCI);
            string pci_id = pci.pci_id.Replace(@":", "/");
            Host   host   = pGpu.Connection.Resolve(pGpu.host);
            double free   = MetricUpdater.GetValue(host, String.Format("gpu_memory_free_{0}", pci_id));
            double used   = MetricUpdater.GetValue(host, String.Format("gpu_memory_used_{0}", pci_id));
            double total  = free + used;

            if (total == 0 || Double.IsNaN(total) || Double.IsNaN(free))
            {
                return(Messages.HYPHEN);
            }
            else
            {
                return(String.Format(Messages.QUERY_MEMORY_USAGE, (used / (free + used) * 100).ToString("0.") + "%", Util.MemorySizeString(free + used)));
            }
        }
        protected override void Run()
        {
            this.Description = Messages.UPDATING_PROPERTIES;

            RelatedTask = enable
                ? Host.async_enable_display(Session, Host.opaque_ref)
                : Host.async_disable_display(Session, Host.opaque_ref);

            PollToCompletion(0, 50);

            var pGpu = Host.SystemDisplayDevice;

            if (pGpu != null)
            {
                RelatedTask = enable
                    ? PGPU.async_enable_dom0_access(Session, pGpu.opaque_ref)
                    : PGPU.async_disable_dom0_access(Session, pGpu.opaque_ref);
                PollToCompletion(50, 100);
            }
            PercentComplete = 100;
            Description     = Messages.UPDATED_PROPERTIES;
        }
示例#6
0
 private void RepopulateAllowedTypes(PGPU pGpu)
 {
     allowedTypesGrid.SuspendLayout();
     allowedTypesGrid.Rows.Clear();
     allowedTypesGrid.Cursor = Cursors.WaitCursor;
     try
     {
         allowedTypesGrid.Rows.Clear();
         if (pGpu.supported_VGPU_types != null && pGpu.supported_VGPU_types.Count > 0)
         {
             allowedTypesGrid.Rows.AddRange((from vGpuTypeRef in pGpu.supported_VGPU_types
                                             let vGpuType = pGpu.Connection.Resolve(vGpuTypeRef)
                                                            let enabledType = pGpu.enabled_VGPU_types.Contains(vGpuTypeRef)
                                                                              orderby vGpuType descending
                                                                              select new VGpuTypeRow(vGpuType, enabledType)).ToArray());
         }
         allowedTypesGrid.Height = allowedTypesGrid.Rows[0].Height * (allowedTypesGrid.RowCount);
     }
     finally
     {
         allowedTypesGrid.ResumeLayout();
         allowedTypesGrid.Cursor = Cursors.Default;
     }
 }
示例#7
0
 private void UnregisterPgpuHandlers(PGPU pgpu)
 {
     pgpu.PropertyChanged -= pgpu_PropertyChanged;
 }
示例#8
0
 private GpuRow FindRow(PGPU pgpu)
 {
     return(pgpu != null?pageContainerPanel.Controls.OfType <GpuRow>().FirstOrDefault(row => row.PGPUs.Contains(pgpu)) : null);
 }