コード例 #1
0
 public static CpuInfo GetCpuInfo()
 {
     // win32CompSys = new ManagementObjectSearcher("select * from Win32_ComputerSystem")
     using (ManagementObjectSearcher win32Proc = new ManagementObjectSearcher("select * from Win32_Processor"))
     {
         foreach (ManagementObject obj in win32Proc.Get())
         {
             if (obj != null)
             {
                 CpuInfo info = new CpuInfo(obj);
                 return(info);
             }
         }
     }
     return(null);
 }
コード例 #2
0
        public void Load()
        {
            int version = RegistryUtil.GetHKLMValue <int>(@"SOFTWARE\Perspective Software\Blue Iris", "version", 0);

            ByteUtil.WriteInt32(version, BiVersionBytes, 0);
            BiVersionFromRegistry = string.Join(".", BiVersionBytes);
            OS             = GetOsVersion();
            AdvisorVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();

            RegistryKey camerasKey = RegistryUtil.GetHKLMKey(@"SOFTWARE\Perspective Software\Blue Iris\Cameras");

            if (camerasKey != null)
            {
                global = new BIGlobalConfig();
                global.Load();


                SortedList <string, Camera> camerasByShortname = new SortedList <string, Camera>();
                foreach (string camName in camerasKey.GetSubKeyNames())
                {
                    Camera cam = new Camera(camName, camerasKey.OpenSubKey(camName));
                    if (cam.shortname == null)
                    {
                        throw new Exception("Camera \"" + camName + "\" has null shortname field.");
                    }
                    cameras.Add(camName, cam);
                    // Make a copy of [cam] to put into the second SortedList, because later we are going to be modifying Camera objects in the first SortedList.
                    camerasByShortname.Add(cam.shortname, JsonConvert.DeserializeObject <Camera>(JsonConvert.SerializeObject(cam)));
                }

                {
                    // Implement "sync" functionality where some cameras and some profiles can point at other cameras and/or profiles.
                    // Blue Iris totally allows circular references when syncing between cameras, with undefined and unexplored behavior, so we'll only be implementing one iteration of syncing.

                    // First sync the recordSettings
                    foreach (Camera cam in cameras.Values)
                    {
                        Camera syncFrom = cam;
                        if (cam.recordSettings[1].sync)
                        {
                            // Profile 1 says to sync.  This means every profile with the sync flag set will be synced from a different camera.
                            if (cam.recordSettings[1].camsync != null)
                            {
                                if (camerasByShortname.TryGetValue(cam.recordSettings[1].camsync, out Camera tmp))
                                {
                                    syncFrom = tmp;
                                }
                            }
                        }
                        for (int i = 1; i <= 7; i++)
                        {
                            if (cam.recordSettings[i].sync)
                            {
                                cam.recordSettings[i] = syncFrom.recordSettings[i];
                            }
                        }
                    }
                    // Then sync the triggerSettings
                    foreach (Camera cam in cameras.Values)
                    {
                        Camera syncFrom = cam;
                        if (cam.triggerSettings[1].sync)
                        {
                            // Profile 1 says to sync.  This means every profile with the sync flag set will be synced from a different camera.
                            if (cam.triggerSettings[1].camsync != null)
                            {
                                if (camerasByShortname.TryGetValue(cam.triggerSettings[1].camsync, out Camera tmp))
                                {
                                    syncFrom = tmp;
                                }
                            }
                        }
                        for (int i = 1; i <= 7; i++)
                        {
                            if (cam.triggerSettings[i].sync)
                            {
                                cam.triggerSettings[i] = syncFrom.triggerSettings[i];
                            }
                        }
                    }
                }

                cpu  = CpuInfo.GetCpuInfo();
                gpus = GpuInfo.GetGpuInfo();
                mem  = RamInfo.GetRamInfo();

                activeStats = new BIActiveStats();
                activeStats.Load();
            }
        }