コード例 #1
0
        private void ExtractFailrePredictThresholds(List <SMARTData> smartDataList, List <SmartFailurePredictThresholds> smartFailurePredictThresholds)
        {
            foreach (var smartFailurePredictThreshold in smartFailurePredictThresholds)
            {
                byte[] bytes = smartFailurePredictThreshold.VendorSpecific;
                for (int i = 0; i < BLOCKS_IN_VENDOR_ARRAY; ++i)
                {
                    int currentBlock = i * BLOCK_SIZE;

                    int attributeId = bytes[currentBlock + ARIBUTE_ID_OFFSET];
                    int threshold   = bytes[currentBlock + THRESHOLD_OFFSET];
                    if (attributeId == 0)
                    {
                        continue;
                    }

                    SMARTData smartData = smartDataList.Where(x => x.InstanceName == smartFailurePredictThreshold.InstanceName).FirstOrDefault();
                    if (smartData == null)
                    {
                        continue;
                    }

                    SmartDataAttribute attribute = smartData.Attributes[attributeId];
                    attribute.Threshold = threshold;
                }
            }
        }
コード例 #2
0
ファイル: HardwareContainers.cs プロジェクト: CJxD/CoreView
        public void GetInfo(ManagementObject wmiATAPISmartData)
        {
            try
            {
                // Convert the Vendor Specific bytes into SMART Data

                byte[] vendorSpecific = DataRetriever.GetValueBytes(wmiATAPISmartData, "VendorSpecific");
                SMARTData data = new SMARTData(vendorSpecific);
                Int32 attributeData = 0;

                // Because the field names above are the same as those given by the SMARTData class,
                // we can loop through all the attributes in the SMART Data variable and add the data to
                // the class's fields using System Reflection methods.
                foreach (SMARTAttribute attribute in data.Attributes)
                {
                    // Convert vendor data byte array to integer
                    attributeData = 0;
                    for (int i = 0; i < 5; i++)
                    {
                        // For each of the 6 bytes (not including the last two for flags), add the byte data multiplied by its offset
                        attributeData += Convert.ToInt32(attribute.VendorData[i]) * (i * 256);
                    }
                    this.GetType().GetField(Convert.ToString(attribute.AttributeType)).SetValue(this, Convert.ToUInt16(attribute.Value));
                }
            }
            catch (Exception e)
            {
                ErrorDialogue errorReporter = new ErrorDialogue(e);
            }
        }