public override int GetHashCode() { unchecked { var hashCode = AlertID; hashCode = (hashCode * 397) ^ Code; hashCode = (hashCode * 397) ^ (Source != null ? Source.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Title != null ? Title.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Severity != null ? Severity.GetHashCode() : 0); hashCode = (hashCode * 397) ^ Created.GetHashCode(); hashCode = (hashCode * 397) ^ SnoozedEndDate.GetHashCode(); hashCode = (hashCode * 397) ^ (ThresholdValue1 != null ? ThresholdValue1.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (ThresholdValue2 != null ? ThresholdValue2.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (ThresholdValue3 != null ? ThresholdValue3.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (ThresholdValue4 != null ? ThresholdValue4.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (ThresholdValue5 != null ? ThresholdValue5.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (DeviceGuid != null ? DeviceGuid.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (AdditionalInfo != null ? AdditionalInfo.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (AlertCategoryID != null ? AlertCategoryID.GetHashCode() : 0); hashCode = (hashCode * 397) ^ Archived.GetHashCode(); hashCode = (hashCode * 397) ^ ArchivedDate.GetHashCode(); hashCode = (hashCode * 397) ^ TicketID.GetHashCode(); hashCode = (hashCode * 397) ^ (AlertMessage != null ? AlertMessage.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (DeviceName != null ? DeviceName.GetHashCode() : 0); hashCode = (hashCode * 397) ^ CustomerID; hashCode = (hashCode * 397) ^ (CustomerName != null ? CustomerName.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (MessageTemplate != null ? MessageTemplate.GetHashCode() : 0); hashCode = (hashCode * 397) ^ FolderID.GetHashCode(); hashCode = (hashCode * 397) ^ PollingCyclesCount.GetHashCode(); return(hashCode); } }
public override int GetHashCode() { unchecked { var hashCode = AgentID; hashCode = (hashCode * 397) ^ (MachineID != null ? MachineID.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (DeviceGuid != null ? DeviceGuid.GetHashCode() : 0); hashCode = (hashCode * 397) ^ CustomerID; hashCode = (hashCode * 397) ^ (CustomerName != null ? CustomerName.GetHashCode() : 0); hashCode = (hashCode * 397) ^ FolderID.GetHashCode(); hashCode = (hashCode * 397) ^ (AgentName != null ? AgentName.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (SystemName != null ? SystemName.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (MachineName != null ? MachineName.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (DomainName != null ? DomainName.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (CurrentLoggedUsers != null ? CurrentLoggedUsers.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (ComputerDescription != null ? ComputerDescription.GetHashCode() : 0); hashCode = (hashCode * 397) ^ Monitored.GetHashCode(); hashCode = (hashCode * 397) ^ LastPatchManagementReceived.GetHashCode(); hashCode = (hashCode * 397) ^ (AgentVersion != null ? AgentVersion.GetHashCode() : 0); hashCode = (hashCode * 397) ^ Favorite.GetHashCode(); hashCode = (hashCode * 397) ^ ThresholdID.GetHashCode(); hashCode = (hashCode * 397) ^ MonitoredAgentID.GetHashCode(); hashCode = (hashCode * 397) ^ Created.GetHashCode(); hashCode = (hashCode * 397) ^ Modified.GetHashCode(); hashCode = (hashCode * 397) ^ Online.GetHashCode(); hashCode = (hashCode * 397) ^ (ReportedFromIP != null ? ReportedFromIP.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (AppViewUrl != null ? AppViewUrl.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Motherboard != null ? Motherboard.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Processor != null ? Processor.GetHashCode() : 0); hashCode = (hashCode * 397) ^ Memory.GetHashCode(); hashCode = (hashCode * 397) ^ (Display != null ? Display.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Sound != null ? Sound.GetHashCode() : 0); hashCode = (hashCode * 397) ^ ProcessorCoresCount.GetHashCode(); hashCode = (hashCode * 397) ^ (SystemDrive != null ? SystemDrive.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (ProcessorClock != null ? ProcessorClock.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Vendor != null ? Vendor.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (VendorSerialNumber != null ? VendorSerialNumber.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (VendorBrandModel != null ? VendorBrandModel.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (ProductName != null ? ProductName.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (OS != null ? OS.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (OSType != null ? OSType.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (OSVersion != null ? OSVersion.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (OSBuild != null ? OSBuild.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (WindowsSerialNumber != null ? WindowsSerialNumber.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Office != null ? Office.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (OfficeSP != null ? OfficeSP.GetHashCode() : 0); hashCode = (hashCode * 397) ^ OfficeOEM.GetHashCode(); hashCode = (hashCode * 397) ^ (OfficeSerialNumber != null ? OfficeSerialNumber.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (OfficeFullVersion != null ? OfficeFullVersion.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (LastLoginUser != null ? LastLoginUser.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (HardwareDisks?.Sum(x => x.GetHashCode()) ?? 0); hashCode = (hashCode * 397) ^ (MacAddresses?.Sum(x => x.GetHashCode()) ?? 0); hashCode = (hashCode * 397) ^ (IpAddresses?.Sum(x => x.GetHashCode()) ?? 0); return(hashCode); } }
public override void ToOutputStream(DataOutputStream writer) { //From server to client //Tell the client if they are going to receive a device Guid writer.WriteBoolean(!hasDeviceGuid); if (!hasDeviceGuid) { DeviceGuid = Guid.NewGuid(); writer.WriteUTF(DeviceGuid.ToString()); } }
public override int GetHashCode() { unchecked { var hashCode = _hashCode; hashCode = (hashCode * 397) ^ FullKey.GetHashCode(); hashCode = (hashCode * 397) ^ (LoadtypeGuid != null ? LoadtypeGuid.GetHashCode() : 0); hashCode = (hashCode * 397) ^ DeviceCategory.GetHashCode(); hashCode = (hashCode * 397) ^ LocationGuid.GetHashCode(); hashCode = (hashCode * 397) ^ DeviceGuid.GetHashCode(); hashCode = (hashCode * 397) ^ HouseholdKey.GetHashCode(); hashCode = (hashCode * 397) ^ (int)ThisDeviceType; return(hashCode); } }
public int CompareTo(object reference) { if (reference is ChannelGuid == false) { throw new ArgumentException( $@"Unable to compare with unequivalent type: {reference.GetType()}", nameof(reference)); } var compareTo = (ChannelGuid)reference; var guidCompare = DeviceGuid.CompareTo(compareTo.DeviceGuid); return(guidCompare != 0 ? guidCompare : ChannelIndex.CompareTo(compareTo.ChannelIndex)); }
/// <summary> /// Queries BMC for the GUID of the system. /// </summary> /// <returns>GUID reported by Baseboard Management Controller.</returns> public virtual DeviceGuid GetSystemGuid(bool retry = false) { GetSystemGuidRequest req = new GetSystemGuidRequest(); GetSystemGuidResponse response = (GetSystemGuidResponse)this.IpmiSendReceive(req, typeof(GetSystemGuidResponse), retry); DeviceGuid responseObj = new DeviceGuid(response.CompletionCode); if (response.CompletionCode == 0x00) { responseObj.SetParamaters(response.Guid); } return(responseObj); }
public OefcKey([NotNull] CalcDeviceDto dto, StrGuid loadtypeGuid) { HouseholdKey = dto.HouseholdKey; ThisDeviceType = dto.DeviceType; DeviceGuid = dto.Guid; LocationGuid = dto.LocationGuid; LoadtypeGuid = loadtypeGuid; DeviceCategory = dto.DeviceCategoryName; unchecked { _hashCode = LocationGuid.GetHashCode(); if (loadtypeGuid != null) { _hashCode = (_hashCode * 397) ^ loadtypeGuid.GetHashCode(); } _hashCode = (_hashCode * 397) ^ DeviceGuid.GetHashCode(); _hashCode = (_hashCode * 397) ^ HouseholdKey.Key.GetHashCode(); _hashCode = (_hashCode * 397) ^ (int)ThisDeviceType; } //needed for the makekey due to compiler error FullKey = ""; FullKey = MakeKey(); }
/// <summary> /// Function that gets all the fan speed requirements /// from the Blade. It also updates the balde state /// </summary> private void GetAllBladePwmRequirements() { // Rate is required to timestep over each individual Blade call double rate = (double)GetTimePeriod / (double)MaxSledCount; double timeDiff = 0; for (byte blade = 1; blade <= MaxSledCount; blade++) { // Handle shutdown state if (ChassisState.ShutDown) { return; } // default PWM setting byte PWM = (byte)ConfigLoaded.MinPWM; // Query blade type from IPMI layer ChassisState.BladeTypeCache[blade - 1] = (byte)WcsBladeFacade.clients[blade].BladeClassification; // wait for rate limiter which includes the previous time difference for sensor get, and then issue get fan requirement double sleepTime = rate - timeDiff; if (sleepTime > rate) { sleepTime = rate; } if (sleepTime > 0) { Thread.Sleep(TimeSpan.FromMilliseconds(sleepTime)); } if (CommunicationDevice.IsSafeMode()) { // Do not perform any sensor reading - continue in the for loop Tracer.WriteInfo("Monitoring thread: Safe Mode, Skipping sensor read"); continue; } Tracer.WriteInfo("GetBladeRequirement called at {0} for sledId {1} (state: {2})", DateTime.Now, blade, ChassisState.GetStateName(blade)); // Check for the condition where known state is hardpoweroff, but someone plugged a new blade in if (ChassisState.GetBladeState(blade) == (byte)BladeState.HardPowerOff) { ChassisState.PowerFailCount[blade - 1]++; // TODO: identify if this period is sufficient to do this check if (ChassisState.PowerFailCount[blade - 1] > (ConfigLoaded.MaxRetries * ConfigLoaded.Population)) { CheckPowerEnableState(blade); ChassisState.PowerFailCount[blade - 1] = 0; } } // Log Start time DateTime startTime = DateTime.Now; // If blade was in Fail state if (ChassisState.GetBladeState(blade) == (byte)BladeState.Fail) { // If failed count is greater than a maximum value, we move it to Initialization state if (ChassisState.FailCount[blade - 1] > ConfigLoaded.MaxFailCount) { // Move to Initialization state so that this sled could be reinitialized Tracer.WriteInfo("State Transition for Sled {0}: {1} -> Initialization", blade, ChassisState.GetStateName(blade)); ChassisState.SetBladeState(blade, (byte)BladeState.Initialization); } else { // Moving out of Fail state - First we use a light-weight get GUID to check whether the blade is there DeviceGuid guid = WcsBladeFacade.GetSystemGuid(blade); if (guid.CompletionCode == (byte)CompletionCode.Success) { Tracer.WriteInfo("GUID present for sled {0}, GUID: {1}", blade, guid.Guid.ToString()); // Change state to Probation Tracer.WriteInfo("State Transition for Sled {0}: {1} -> Probation", blade, ChassisState.GetStateName(blade)); ChassisState.SetBladeState(blade, (byte)BladeState.Probation); } else { Tracer.WriteInfo("Get System GUID returns a bad completion status: {0}", guid.CompletionCode); } } // Increase time spent in Fail state everytime we are in this state ChassisState.FailCount[blade - 1]++; } // Handles Initialization if (ChassisState.GetBladeState(blade) == (byte)BladeState.Initialization) { this.ReInitialize(blade); } // Normal operation - possible states are probation or healthy if (ChassisState.GetBladeState(blade) == (byte)BladeState.Probation || ChassisState.GetBladeState(blade) == (byte)BladeState.Healthy) { if (ChassisState.GetBladeType(blade) == (byte)BladeType.Jbod) { DeviceGuid guid = WcsBladeFacade.GetSystemGuid(blade); if (guid.CompletionCode == (byte)CompletionCode.Success) { Tracer.WriteInfo("GUID present for jbod {0}, GUID: {1}", blade, guid.Guid.ToString()); // Change state to Probation Tracer.WriteInfo("State Transition for jbod {0}: {1} -> Healthy", blade, ChassisState.GetStateName(blade)); ChassisState.SetBladeState(blade, (byte)BladeState.Healthy); } else { Tracer.WriteInfo("Get System GUID for jbod {0} failed with status {1}", blade, guid.CompletionCode); // Set it to failed state, where we will retry guids and reinitialize if needed Tracer.WriteInfo("State Transition for jbod {0}: {1} -> Fail", blade, ChassisState.GetStateName(blade)); ChassisState.SetBladeState(blade, (byte)BladeState.Fail); } // No need to check for sensor reading, just continue continue; } // Call temperature reading list command SensorReading Temps = WcsBladeFacade.GetSensorReading((byte)blade, (byte)ConfigLoaded.InputSensor, PriorityLevel.System); if (Temps.CompletionCode != (byte)CompletionCode.Success) { Tracer.WriteWarning("SledId: {0} - getTempSensorReading failed with code {1:X}", blade, Temps.CompletionCode); // Move to Fail state if no readings were obtained Tracer.WriteInfo("State Transition for Sled {0}: {1} -> Fail", blade, ChassisState.GetStateName(blade)); ChassisState.SetBladeState(blade, (byte)BladeState.Fail); } else { Tracer.WriteInfo("#### Sledid= " + blade + " Sensor id= " + ConfigLoaded.InputSensor + " Sensor reading= " + Temps.Reading + " Raw= " + Temps.RawReading + ", LowerNonCritical= " + ConfigLoaded.SensorLowThreshold + ", UpperNonCritical= " + ConfigLoaded.SensorHighThreshold); // Handle state logic if needed // Probation state should be shifted to Healthy since there was no timeout, & sensorread succeeded if (ChassisState.GetBladeState(blade) == (byte)BladeState.Probation) { // Change state to healthy Tracer.WriteInfo("State Transition for Sled {0}: {1} -> Healthy", blade, ChassisState.GetStateName(blade)); ChassisState.SetBladeState(blade, (byte)BladeState.Healthy); ChassisState.FailCount[blade - 1] = 0; // reset the fail count } PWM = GetPwmFromTemperature(Temps.Reading, ConfigLoaded.SensorLowThreshold, ConfigLoaded.SensorHighThreshold); Tracer.WriteInfo("PWM value for Sensor {0} = {1}", InputSensor, PWM); } } // write value into requirements table BladeRequirementTable[blade - 1] = PWM; // Log end time and capture time of execution for sensor get command DateTime endTime = DateTime.Now; timeDiff = endTime.Subtract(startTime).TotalMilliseconds; // convert time difference into milliseconds } }
public IEnumerable <DeviceInfo> EnumerateDevices(DeviceGuid deviceGuid) { return(Device.EnumerateDevicesInternal(null, _hostName, deviceGuid)); }
internal static IEnumerable <DeviceInfo> EnumerateDevicesCore(string hostName, DeviceGuid deviceGuid, bool getAllProperties) { if (Utils.IsNullOrWhiteSpace(hostName)) { hostName = Environment.MachineName; } // CM_Connect_Machine() // MSDN Note: Beginning in Windows 8 and Windows Server 2012 functionality to access remote machines has been removed. // You cannot access remote machines when running on these versions of Windows. // http://msdn.microsoft.com/en-us/library/windows/hardware/ff537948%28v=vs.85%29.aspx SafeCmConnectMachineHandle safeMachineHandle; var lastError = NativeMethods.CM_Connect_Machine(Host.GetUncName(hostName), out safeMachineHandle); NativeMethods.IsValidHandle(safeMachineHandle, lastError); var classGuid = new Guid(Utils.GetEnumDescription(deviceGuid)); // Start at the "Root" of the device tree of the specified machine. using (safeMachineHandle) using (var safeHandle = NativeMethods.SetupDiGetClassDevsEx(ref classGuid, IntPtr.Zero, IntPtr.Zero, NativeMethods.SetupDiGetClassDevsExFlags.Present | NativeMethods.SetupDiGetClassDevsExFlags.DeviceInterface, IntPtr.Zero, hostName, IntPtr.Zero)) { NativeMethods.IsValidHandle(safeHandle, Marshal.GetLastWin32Error()); uint memberInterfaceIndex = 0; var interfaceStructSize = (uint)Marshal.SizeOf(typeof(NativeMethods.SP_DEVICE_INTERFACE_DATA)); var dataStructSize = (uint)Marshal.SizeOf(typeof(NativeMethods.SP_DEVINFO_DATA)); // Start enumerating device interfaces. while (true) { var interfaceData = new NativeMethods.SP_DEVICE_INTERFACE_DATA { cbSize = interfaceStructSize }; var success = NativeMethods.SetupDiEnumDeviceInterfaces(safeHandle, IntPtr.Zero, ref classGuid, memberInterfaceIndex++, ref interfaceData); lastError = Marshal.GetLastWin32Error(); if (!success) { if (lastError != Win32Errors.NO_ERROR && lastError != Win32Errors.ERROR_NO_MORE_ITEMS) { NativeError.ThrowException(lastError, hostName); } break; } // Create DeviceInfo instance. var diData = new NativeMethods.SP_DEVINFO_DATA { cbSize = dataStructSize }; var deviceInfo = new DeviceInfo(hostName) { DevicePath = GetDeviceInterfaceDetail(safeHandle, ref interfaceData, ref diData).DevicePath }; if (getAllProperties) { deviceInfo.InstanceId = GetDeviceInstanceId(safeMachineHandle, hostName, diData); SetDeviceProperties(safeHandle, deviceInfo, diData); } else { SetMinimalDeviceProperties(safeHandle, deviceInfo, diData); } yield return(deviceInfo); } } }
public static IEnumerable <DeviceInfo> EnumerateDevices(string hostName, DeviceGuid deviceGuid) { return(EnumerateDevicesCore(hostName, deviceGuid, true)); }
public static IEnumerable <DeviceInfo> EnumerateDevices(DeviceGuid deviceGuid) { return(EnumerateDevicesCore(null, deviceGuid, true)); }
internal static IEnumerable <DeviceInfo> EnumerateDevicesCore(SafeHandle safeHandle, string hostName, DeviceGuid deviceInterfaceGuid) { bool callerHandle = safeHandle != null; var deviceGuid = new Guid(Utils.GetEnumDescription(deviceInterfaceGuid)); // CM_Connect_Machine() // MSDN Note: Beginning in Windows 8 and Windows Server 2012 functionality to access remote machines has been removed. // You cannot access remote machines when running on these versions of Windows. // http://msdn.microsoft.com/en-us/library/windows/hardware/ff537948%28v=vs.85%29.aspx SafeCmConnectMachineHandle safeMachineHandle; int lastError = NativeMethods.CM_Connect_Machine(Path.LocalToUncCore(Host.GetUncName(hostName), false, false, false), out safeMachineHandle); if (safeMachineHandle.IsInvalid) { safeMachineHandle.Close(); NativeError.ThrowException(lastError, Resources.Handle_Is_Invalid); } using (safeMachineHandle) { // Start at the "Root" of the device tree of the specified machine. if (!callerHandle) { safeHandle = NativeMethods.SetupDiGetClassDevsEx(ref deviceGuid, IntPtr.Zero, IntPtr.Zero, NativeMethods.SetupDiGetClassDevsExFlags.Present | NativeMethods.SetupDiGetClassDevsExFlags.DeviceInterface, IntPtr.Zero, hostName, IntPtr.Zero); } if (safeHandle.IsInvalid) { safeHandle.Close(); NativeError.ThrowException(Marshal.GetLastWin32Error(), Resources.Handle_Is_Invalid); } try { uint memberInterfaceIndex = 0; NativeMethods.SP_DEVICE_INTERFACE_DATA deviceInterfaceData = CreateDeviceInterfaceDataInstance(); // Start enumerating Device Interfaces. while (NativeMethods.SetupDiEnumDeviceInterfaces(safeHandle, IntPtr.Zero, ref deviceGuid, memberInterfaceIndex++, ref deviceInterfaceData)) { lastError = Marshal.GetLastWin32Error(); if (lastError != Win32Errors.NO_ERROR) { NativeError.ThrowException(lastError, hostName); } NativeMethods.SP_DEVINFO_DATA deviceInfoData = CreateDeviceInfoDataInstance(); NativeMethods.SP_DEVICE_INTERFACE_DETAIL_DATA deviceInterfaceDetailData = GetDeviceInterfaceDetailDataInstance(safeHandle, deviceInterfaceData, deviceInfoData); // Get device interace details. if (!NativeMethods.SetupDiGetDeviceInterfaceDetail(safeHandle, ref deviceInterfaceData, ref deviceInterfaceDetailData, NativeMethods.DefaultFileBufferSize, IntPtr.Zero, ref deviceInfoData)) { lastError = Marshal.GetLastWin32Error(); if (lastError != Win32Errors.NO_ERROR) { NativeError.ThrowException(lastError, hostName); } } // Create DeviceInfo instance. // Set DevicePath property of DeviceInfo instance. var deviceInfo = new DeviceInfo(hostName) { DevicePath = deviceInterfaceDetailData.DevicePath }; // Current InstanceId is at the "USBSTOR" level, so we // need up "move up" one level to get to the "USB" level. uint ptrPrevious; // CM_Get_Parent_Ex() // Note: Using this function to access remote machines is not supported // beginning with Windows 8 and Windows Server 2012, as this functionality has been removed. // http://msdn.microsoft.com/en-us/library/windows/hardware/ff538615%28v=vs.85%29.aspx lastError = NativeMethods.CM_Get_Parent_Ex(out ptrPrevious, deviceInfoData.DevInst, 0, safeMachineHandle); if (lastError != Win32Errors.CR_SUCCESS) { NativeError.ThrowException(lastError, hostName); } // Now we get the InstanceID of the USB level device. using (var safeBuffer = new SafeGlobalMemoryBufferHandle(NativeMethods.DefaultFileBufferSize)) { // CM_Get_Device_ID_Ex() // Note: Using this function to access remote machines is not supported beginning with Windows 8 and Windows Server 2012, // as this functionality has been removed. // http://msdn.microsoft.com/en-us/library/windows/hardware/ff538411%28v=vs.85%29.aspx lastError = NativeMethods.CM_Get_Device_ID_Ex(deviceInfoData.DevInst, safeBuffer, (uint)safeBuffer.Capacity, 0, safeMachineHandle); if (lastError != Win32Errors.CR_SUCCESS) { NativeError.ThrowException(lastError, hostName); } // Add to instance. deviceInfo.InstanceId = safeBuffer.PtrToStringUni(); } #region Get Registry Properties using (var safeBuffer = new SafeGlobalMemoryBufferHandle(NativeMethods.DefaultFileBufferSize)) { uint regType; string dataString; uint safeBufferCapacity = (uint)safeBuffer.Capacity; if (NativeMethods.SetupDiGetDeviceRegistryProperty(safeHandle, ref deviceInfoData, NativeMethods.SetupDiGetDeviceRegistryPropertyEnum.BaseContainerId, out regType, safeBuffer, safeBufferCapacity, IntPtr.Zero)) { dataString = safeBuffer.PtrToStringUni(); if (!Utils.IsNullOrWhiteSpace(dataString)) { deviceInfo.BaseContainerId = new Guid(dataString); } } if (NativeMethods.SetupDiGetDeviceRegistryProperty(safeHandle, ref deviceInfoData, NativeMethods.SetupDiGetDeviceRegistryPropertyEnum.ClassGuid, out regType, safeBuffer, safeBufferCapacity, IntPtr.Zero)) { dataString = safeBuffer.PtrToStringUni(); if (!Utils.IsNullOrWhiteSpace(dataString)) { deviceInfo.ClassGuid = new Guid(dataString); } } if (NativeMethods.SetupDiGetDeviceRegistryProperty(safeHandle, ref deviceInfoData, NativeMethods.SetupDiGetDeviceRegistryPropertyEnum.Class, out regType, safeBuffer, safeBufferCapacity, IntPtr.Zero)) { deviceInfo.Class = safeBuffer.PtrToStringUni(); } if (NativeMethods.SetupDiGetDeviceRegistryProperty(safeHandle, ref deviceInfoData, NativeMethods.SetupDiGetDeviceRegistryPropertyEnum.CompatibleIds, out regType, safeBuffer, safeBufferCapacity, IntPtr.Zero)) { deviceInfo.CompatibleIds = safeBuffer.PtrToStringUni(); } if (NativeMethods.SetupDiGetDeviceRegistryProperty(safeHandle, ref deviceInfoData, NativeMethods.SetupDiGetDeviceRegistryPropertyEnum.DeviceDescription, out regType, safeBuffer, safeBufferCapacity, IntPtr.Zero)) { deviceInfo.DeviceDescription = safeBuffer.PtrToStringUni(); } if (NativeMethods.SetupDiGetDeviceRegistryProperty(safeHandle, ref deviceInfoData, NativeMethods.SetupDiGetDeviceRegistryPropertyEnum.Driver, out regType, safeBuffer, safeBufferCapacity, IntPtr.Zero)) { deviceInfo.Driver = safeBuffer.PtrToStringUni(); } if (NativeMethods.SetupDiGetDeviceRegistryProperty(safeHandle, ref deviceInfoData, NativeMethods.SetupDiGetDeviceRegistryPropertyEnum.EnumeratorName, out regType, safeBuffer, safeBufferCapacity, IntPtr.Zero)) { deviceInfo.EnumeratorName = safeBuffer.PtrToStringUni(); } if (NativeMethods.SetupDiGetDeviceRegistryProperty(safeHandle, ref deviceInfoData, NativeMethods.SetupDiGetDeviceRegistryPropertyEnum.FriendlyName, out regType, safeBuffer, safeBufferCapacity, IntPtr.Zero)) { deviceInfo.FriendlyName = safeBuffer.PtrToStringUni(); } if (NativeMethods.SetupDiGetDeviceRegistryProperty(safeHandle, ref deviceInfoData, NativeMethods.SetupDiGetDeviceRegistryPropertyEnum.HardwareId, out regType, safeBuffer, safeBufferCapacity, IntPtr.Zero)) { deviceInfo.HardwareId = safeBuffer.PtrToStringUni(); } if (NativeMethods.SetupDiGetDeviceRegistryProperty(safeHandle, ref deviceInfoData, NativeMethods.SetupDiGetDeviceRegistryPropertyEnum.LocationInformation, out regType, safeBuffer, safeBufferCapacity, IntPtr.Zero)) { deviceInfo.LocationInformation = safeBuffer.PtrToStringUni(); } if (NativeMethods.SetupDiGetDeviceRegistryProperty(safeHandle, ref deviceInfoData, NativeMethods.SetupDiGetDeviceRegistryPropertyEnum.LocationPaths, out regType, safeBuffer, safeBufferCapacity, IntPtr.Zero)) { deviceInfo.LocationPaths = safeBuffer.PtrToStringUni(); } if (NativeMethods.SetupDiGetDeviceRegistryProperty(safeHandle, ref deviceInfoData, NativeMethods.SetupDiGetDeviceRegistryPropertyEnum.Manufacturer, out regType, safeBuffer, safeBufferCapacity, IntPtr.Zero)) { deviceInfo.Manufacturer = safeBuffer.PtrToStringUni(); } if (NativeMethods.SetupDiGetDeviceRegistryProperty(safeHandle, ref deviceInfoData, NativeMethods.SetupDiGetDeviceRegistryPropertyEnum.PhysicalDeviceObjectName, out regType, safeBuffer, safeBufferCapacity, IntPtr.Zero)) { deviceInfo.PhysicalDeviceObjectName = safeBuffer.PtrToStringUni(); } if (NativeMethods.SetupDiGetDeviceRegistryProperty(safeHandle, ref deviceInfoData, NativeMethods.SetupDiGetDeviceRegistryPropertyEnum.Service, out regType, safeBuffer, safeBufferCapacity, IntPtr.Zero)) { deviceInfo.Service = safeBuffer.PtrToStringUni(); } } #endregion // Get Registry Properties yield return(deviceInfo); // Get new structure instance. deviceInterfaceData = CreateDeviceInterfaceDataInstance(); } } finally { // Handle is ours, dispose. if (!callerHandle && safeHandle != null) { safeHandle.Close(); } } } }
public IEnumerable <DeviceInfo> EnumerateDevices(DeviceGuid deviceGuid) { return(Device.EnumerateDevicesCore(HostName, deviceGuid, true)); }
public bool Equals(OefcKey other) { return(_hashCode == other._hashCode && FullKey == other.FullKey && Equals(LoadtypeGuid, other.LoadtypeGuid) && DeviceCategory == other.DeviceCategory && LocationGuid.Equals(other.LocationGuid) && DeviceGuid.Equals(other.DeviceGuid) && HouseholdKey.Equals(other.HouseholdKey) && ThisDeviceType == other.ThisDeviceType); }
public static IEnumerable <DeviceInfo> EnumerateDevices(string hostName, DeviceGuid deviceGuid) { return(EnumerateDevicesInternal(null, hostName, deviceGuid)); }
public override string ToString() { return(DeviceGuid.ToString("N") + ChannelIndex.ToString("D5")); }
public override int GetHashCode() { return(DeviceGuid.GetHashCode() ^ ChannelIndex.GetHashCode()); }
public override int GetHashCode() { unchecked { return(((FriendlyName != null ? FriendlyName.GetHashCode() : 0) * 397) ^ DeviceGuid.GetHashCode()); } }
protected bool Equals(DirectSoundOutInfo other) { return(FriendlyName == other.FriendlyName && DeviceGuid.Equals(other.DeviceGuid)); }
public IEnumerable<DeviceInfo> EnumerateDevices(DeviceGuid deviceGuid) { return Device.EnumerateDevicesInternal(null, _hostName, deviceGuid); }
/// <summary> /// Function that gets fan speed requirements /// from all blades. It also updates the blade states. /// </summary> private static void GetAllBladePwmRequirements() { // Rate is required to timestep over each individual Blade call double rate = (double)getBladePwmReqtTimePeriodInMilliseconds / (double)MaxSledCount; double timeDiff = 0; for (byte blade = 1; blade <= MaxSledCount; blade++) { // Handle shutdown state if (ChassisState.ShutDown) { return; } // default PWM setting byte PWM = (byte)ConfigLoaded.MinPWM; // Query blade type from IPMI layer ChassisState.BladeTypeCache[blade - 1] = (byte)WcsBladeFacade.clients[blade].BladeClassification; // wait for rate limiter which includes the previous time difference for sensor get, and then issue get fan requirement double sleepTime = rate - timeDiff; if (sleepTime > rate) { sleepTime = rate; } if (sleepTime > 0) { Thread.Sleep(TimeSpan.FromMilliseconds(sleepTime)); } Tracer.WriteInfo("GetBladeRequirement called at {0} for BladeId {1} (state: {2})", DateTime.Now, blade, ChassisState.GetStateName(blade)); // Check for the condition where known state is hardpoweroff, but someone plugged a new blade in if (ChassisState.GetBladeState(blade) == (byte)BladeState.HardPowerOff) { CheckPowerEnableState(blade); } // Log Start time DateTime startTime = DateTime.Now; #region Check fail State -> Initialize // If blade was in Fail state if (ChassisState.GetBladeState(blade) == (byte)BladeState.Fail) { // If failed count is greater than a maximum value, we move it to Initialization state if (ChassisState.FailCount[blade - 1] > ConfigLoaded.MaxFailCount) { // Move to Initialization state so that this blade could be reinitialized Tracer.WriteInfo("GetAllBladePwmRequirements: State Transition for blade {0}: {1} -> Initialization", blade, ChassisState.GetStateName(blade)); ChassisState.SetBladeState(blade, (byte)BladeState.Initialization); } else { // Moving out of Fail state - First we use a light-weight get GUID to check whether the blade is there. // do not allow retries on Get System Guid DeviceGuid guid = WcsBladeFacade.GetSystemGuid(blade, false); if (guid.CompletionCode == (byte)CompletionCode.Success) { Tracer.WriteInfo("GetAllBladePwmRequirements: GUID present for blade {0}, GUID: {1}", blade, guid.Guid.ToString()); DeviceGuid cachedGuid = WcsBladeFacade.GetCachedGuid(blade); if (guid.Guid == cachedGuid.Guid) { // Change state to Probation and assume the system was in fail due to timeout. Tracer.WriteInfo("GetAllBladePwmRequirements: State Transition for blade {0}: {1} -> Probation", blade, ChassisState.GetStateName(blade)); ChassisState.SetBladeState(blade, (byte)BladeState.Probation); } else { // Change state to Initialization as the device has changed. Tracer.WriteInfo("GetAllBladePwmRequirements: State Transition for blade {0}: {1} -> Probation", blade, ChassisState.GetStateName(blade)); ChassisState.SetBladeState(blade, (byte)BladeState.Initialization); } } else { Tracer.WriteInfo("GetAllBladePwmRequirements: Get System GUID returns a bad completion status: {0}", guid.CompletionCode); } } // Increase time spent in Fail state everytime we are in this state ChassisState.FailCount[blade - 1]++; } #endregion #region Move Initialize -> Probation // Handles Initialization if (ChassisState.GetBladeState(blade) == (byte)BladeState.Initialization) { BladePowerStatePacket powerstate = ChassisState.BladePower[blade - 1].GetCachedBladePowerState(); if (powerstate.CompletionCode == 0) { if (powerstate.DecompressionTime == 0) { // Will result in Hard Power off or Probation ReInitialize(blade); } } } #endregion // Normal operation - possible states are probation or healthy if (ChassisState.GetBladeState(blade) == (byte)BladeState.Probation || ChassisState.GetBladeState(blade) == (byte)BladeState.Healthy) { #region Jbod (no sensor reading) if (ChassisState.GetBladeType(blade) == (byte)BladeType.Jbod) { // Do not allow retries on system guid. DeviceGuid guid = WcsBladeFacade.GetSystemGuid(blade, false); if (guid.CompletionCode == (byte)CompletionCode.Success) { Tracer.WriteInfo("GetAllBladePwmRequirements: GUID present for JBOD {0}, GUID: {1}", blade, guid.Guid.ToString()); // Change state to Healthy if (ChassisState.GetBladeState(blade) == (byte)BladeState.Probation) { Tracer.WriteInfo("GetAllBladePwmRequirements: State Transition for JBOD {0}: {1} -> Healthy", blade, ChassisState.GetStateName(blade)); ChassisState.SetBladeState(blade, (byte)BladeState.Healthy); } } else { Tracer.WriteInfo("GetAllBladePwmRequirements: Get System GUID for JBOD {0} failed with status {1}", blade, guid.CompletionCode); // Set it to failed state, where we will retry guids and reinitialize if needed Tracer.WriteInfo("GetAllBladePwmRequirements: State Transition for JBOD {0}: {1} -> Fail", blade, ChassisState.GetStateName(blade)); ChassisState.SetBladeState(blade, (byte)BladeState.Fail); } // No need to check for sensor reading, just continue continue; } #endregion #region Server -> Get PWM move to Healthy or move to Fail // Call temperature reading list command SensorReading Temps = WcsBladeFacade.GetSensorReading((byte)blade, (byte)ConfigLoaded.InputSensor, PriorityLevel.System); if (Temps.CompletionCode != (byte)CompletionCode.Success) { Tracer.WriteWarning("GetAllBladePwmRequirements: BladeId: {0} - GetSensorReading for temperature failed with code {1:X}", blade, Temps.CompletionCode); // Move to Fail state if no readings were obtained Tracer.WriteInfo("GetAllBladePwmRequirements: State Transition for blade {0}: {1} -> Fail", blade, ChassisState.GetStateName(blade)); ChassisState.SetBladeState(blade, (byte)BladeState.Fail); } else { Tracer.WriteInfo("GetAllBladePwmRequirements: #### BladeId = " + blade + " Sensor id= " + ConfigLoaded.InputSensor + " Sensor reading = " + Temps.Reading + " Raw = " + Temps.RawReading + ", LowerNonCritical= " + ConfigLoaded.SensorLowThreshold + ", UpperNonCritical= " + ConfigLoaded.SensorHighThreshold); // Handle state logic if needed // Probation state should be shifted to Healthy since there was no timeout, & sensorread succeeded if (ChassisState.GetBladeState(blade) == (byte)BladeState.Probation) { // Change state to healthy Tracer.WriteInfo("GetAllBladePwmRequirements: State Transition for blade {0}: {1} -> Healthy", blade, ChassisState.GetStateName(blade)); ChassisState.SetBladeState(blade, (byte)BladeState.Healthy); ChassisState.FailCount[blade - 1] = 0; // reset the fail count // When a blade transitions to 'Healthy' state, enable/disable default blade operations EnableDisableDefaultBladeOperations(blade); } if (ConfigLoaded.InputSensor != 1) // Non-PWM sensor. { PWM = GetPwmFromTemperature(Temps.Reading, ConfigLoaded.SensorLowThreshold, ConfigLoaded.SensorHighThreshold); } else { // PWM should never be higher or lower than the threshold. if (Temps.Reading < ConfigLoaded.MinPWM || Temps.Reading > ConfigLoaded.MaxPWM) { Tracer.WriteWarning("PWM value " + Temps.Reading + " on blade " + blade + " is out of range (lowThreshold: " + ConfigLoaded.MinPWM + " - highThreshold: " + ConfigLoaded.MaxPWM); PWM = (byte)ConfigLoaded.MinPWM; } else { PWM = (byte)Temps.Reading; } } Tracer.WriteInfo("PWM value on blade {0} for Sensor {1} = {2}", blade, InputSensor, PWM); } #endregion } // write value into requirements table BladeRequirementTable[blade - 1] = PWM; // Log end time and capture time of execution for sensor get command DateTime endTime = DateTime.Now; timeDiff = endTime.Subtract(startTime).TotalMilliseconds; // convert time difference into milliseconds } }