示例#1
0
        /// <summary>
        /// Determines if the given configurable feature is available in the specified firmware revision.
        /// </summary>
        /// <param name="feature">The feature whose availability is desired.</param>
        /// <param name="currentFirmwareVersion">Current firmware version.</param>
        /// <returns><c>true</c> if the configurable feature is available for the specified firmware version; otherwise, <c>false</c>.</returns>
        /// <exception cref="System.ArgumentOutOfRangeException">Thrown if <paramref name="feature"/> specified more than one configurable feature, or hardware status.</exception>
        internal static bool IsConfigurableFeatureAvailable(this DeviceStatusFlagsHi feature, int currentFirmwareVersion)
        {
            ValidateFeatureBits(feature);
            var featureAvailable = (currentFirmwareVersion > 0) && (VersionSpecificConfigurableFeatures.Count > 0) && (currentFirmwareVersion >= feature.GetMinimumRequiredFirmareVersionForFeature());

            return(featureAvailable);
        }
示例#2
0
        /// <summary>
        /// Gets the minimum required firmware version for the given configurable feature.
        /// </summary>
        /// <param name="feature">The feature whose minimum required firmware version is desired.</param>
        /// <returns>The minimum firmware version required for the feature; or <c>0</c> if the feature is available in all firmware versions.</returns>
        /// <exception cref="System.ArgumentOutOfRangeException">Thrown if <paramref name="feature"/> specified more than one configurable feature, or hardware status.</exception>
        internal static int GetMinimumRequiredFirmareVersionForFeature(this DeviceStatusFlagsHi feature)
        {
            ValidateFeatureBits(feature);
            int requiredFirmwareVersion;

            if (!VersionSpecificConfigurableFeatures.TryGetValue(feature, out requiredFirmwareVersion))
            {
                requiredFirmwareVersion = 0;
            }
            return(requiredFirmwareVersion);
        }
示例#3
0
        private static void ValidateFeatureBits(DeviceStatusFlagsHi feature)
        {
            var numFeatures = 0;

            if (feature != DeviceStatusFlagsHi.None)
            {
                if ((feature & DeviceStatusFlagsHi.ResetMenuHistory) != DeviceStatusFlagsHi.None)
                {
                    numFeatures += 2; // Totally bogus - should not have this flag!
                }
                if ((feature & DeviceStatusFlagsHi.FlagsHaveBeenSet) != DeviceStatusFlagsHi.None)
                {
                    numFeatures += 2; // Totally bogus - should not have this flag!
                }
            }
            if (numFeatures > 1)
            {
                throw new System.ArgumentOutOfRangeException();
            }
        }
示例#4
0
 /// <summary>
 /// Gets the high 32 bits of the status.
 /// </summary>
 /// <param name="deviceStatusHi">The device status flags to get the high part from.</param>
 /// <returns>The upper 32 bits of the status flags.</returns>
 internal static uint GetHighBits(this DeviceStatusFlagsHi deviceStatusHi)
 {
     return((uint)(((ulong)deviceStatusHi >> 32) & 0x00000000FFFFFFFF));
 }
示例#5
0
 /// <summary>
 /// Gets the low 32 bits from the status.
 /// </summary>
 /// <param name="deviceStatusHi">The device status flags to get the low part from.</param>
 /// <returns>The lower 32 bits of the status flags.</returns>
 internal static uint GetLowBits(this DeviceStatusFlagsHi deviceStatusHi)
 {
     return((uint)((ulong)deviceStatusHi & 0x00000000FFFFFFFF));
 }
示例#6
0
 /// <summary>
 /// Determines whether one or more bit fields are set in the current instance.
 /// </summary>
 /// <param name="hiFlags">Flags to check.</param>
 /// <returns><c>true</c> if the bit field or bit fields that are set in <paramref name="hiFlags"/> are also set in the current instance; otherwise, <c>false</c>.</returns>
 public bool HasFlag(DeviceStatusFlagsHi hiFlags)
 {
     return(Hi.HasFlag(hiFlags));
 }
示例#7
0
 /// <summary>
 /// Initialize a new instance.
 /// </summary>
 /// <param name="lo">The <see cref="DeviceStatusFlagsLo"/> to store.</param>
 /// <param name="hi">The <see cref="DeviceStatusFlagsHi"/> to store.</param>
 public DeviceStatusFlags(DeviceStatusFlagsLo lo, DeviceStatusFlagsHi hi)
     : this()
 {
     _lo = lo;
     _hi = hi;
 }
示例#8
0
 /// <summary>
 /// Initialize a new instance with only <see cref="Hi"/> flags set.
 /// </summary>
 /// <param name="hi">The <see cref="DeviceStatusFlagsHi"/> to store.</param>
 public DeviceStatusFlags(DeviceStatusFlagsHi hi)
     : this(DeviceStatusFlagsLo.None, hi)
 {
 }