Exemple #1
0
        /// <summary>
        /// Creates motherboard instance by retrieving information from <see cref="LibreHardwareMonitor.Hardware.SMBios"/> and creates a new <see cref="SubHardware"/> based on data from <see cref="LpcIO"/> and <see cref="EmbeddedController"/>.
        /// </summary>
        /// <param name="smBios"><see cref="LibreHardwareMonitor.Hardware.SMBios"/> table containing motherboard data.</param>
        /// <param name="settings">Additional settings passed by <see cref="IComputer"/>.</param>
        public Motherboard(SMBios smBios, ISettings settings)
        {
            IReadOnlyList <ISuperIO> superIO;

            _settings = settings;
            SMBios    = smBios;

            Manufacturer manufacturer = smBios.Board == null ? Manufacturer.Unknown : Identification.GetManufacturer(smBios.Board.ManufacturerName);
            Model        model        = smBios.Board == null ? Model.Unknown : Identification.GetModel(smBios.Board.ProductName);

            if (smBios.Board != null)
            {
                if (!string.IsNullOrEmpty(smBios.Board.ProductName))
                {
                    if (manufacturer == Manufacturer.Unknown)
                    {
                        _name = smBios.Board.ProductName;
                    }
                    else
                    {
                        _name = manufacturer + " " + smBios.Board.ProductName;
                    }
                }
                else
                {
                    _name = manufacturer.ToString();
                }
            }
            else
            {
                _name = Manufacturer.Unknown.ToString();
            }

            _customName = settings.GetValue(new Identifier(Identifier, "name").ToString(), _name);

            if (OperatingSystem.IsUnix)
            {
                _lmSensors = new LMSensors();
                superIO    = _lmSensors.SuperIO;
            }
            else
            {
                _lpcIO  = new LpcIO();
                superIO = _lpcIO.SuperIO;
            }

            EmbeddedController embeddedController = EmbeddedController.Create(model, settings);

            SubHardware = new IHardware[superIO.Count + (embeddedController != null ? 1 : 0)];
            for (int i = 0; i < superIO.Count; i++)
            {
                SubHardware[i] = new SuperIOHardware(this, superIO[i], manufacturer, model, settings);
            }

            if (embeddedController != null)
            {
                SubHardware[superIO.Count] = embeddedController;
            }
        }
 public EmbeddedControllerSensor(EmbeddedControllerSource embeddedControllerSource, int index, EmbeddedController hardware, ISettings settings)
     : base(embeddedControllerSource.Name, index, embeddedControllerSource.Type, hardware, settings)
 {
     _port   = embeddedControllerSource.Port;
     _reader = embeddedControllerSource.Reader;
 }