public TemperatureDto(int fahrenheit, int celsius, TemperatureSource source, DateTime timestamp) { this.Fahrenheit = fahrenheit; this.Celsius = celsius; this.Source = source; this.Timestamp = timestamp; }
public void Update() { if (!Ring0.WaitIsaBusMutex(10)) { return; } for (int i = 0; i < voltages.Length; i++) { float value = 0.008f * ReadByte(VOLTAGE_REG[i]); bool valid = value > 0; // check if battery voltage monitor is enabled if (valid && VOLTAGE_REG[i] == VOLTAGE_VBAT_REG) { valid = (ReadByte(0x005D) & 0x01) > 0; } voltages[i] = valid ? value : (float?)null; } for (int i = 0; i < TEMPERATURE_REG.Length; i++) { int value = ((sbyte)ReadByte(TEMPERATURE_REG[i])) << 1; if (TEMPERATURE_HALF_BIT[i] > 0) { value |= ((ReadByte(TEMPERATURE_HALF_REG[i]) >> TEMPERATURE_HALF_BIT[i]) & 0x1); } TemperatureSource source = (TemperatureSource) ReadByte(TEMPERATURE_SRC_REG[i]); float?temperature = 0.5f * value; if (temperature > 125 || temperature < -55) { temperature = null; } switch (source) { case TemperatureSource.CPUTIN: temperatures[0] = temperature; break; case TemperatureSource.AUXTIN: temperatures[1] = temperature; break; case TemperatureSource.SYSTIN: temperatures[2] = temperature; break; } } for (int i = 0; i < fans.Length; i++) { byte high = ReadByte(FAN_RPM_REG[i]); byte low = ReadByte((ushort)(FAN_RPM_REG[i] + 1)); int value = (high << 8) | low; fans[i] = value > minFanRPM ? value : 0; } Ring0.ReleaseIsaBusMutex(); }
public TemperatureReading(int temperatureC, TemperatureSource source) { this.TemperatureC = temperatureC; this.Source = (int)source; this.Timestamp = DateTime.Now; this.TemperatureF = (int)(temperatureC * 1.8 + 32); }
private static List <TemperatureSource> FindTemperatureSources() { List <TemperatureSource> sources = new List <TemperatureSource>(); if (Environment.OSVersion.Platform == PlatformID.Unix) { for (int i = 0; i < 10; i++) { foreach (string s in LinuxHwmonDirs) { string dir = string.Format(s, i); string sensorNameFile = Path.Combine(dir, LinuxTempSensorNameFile); if (!Directory.Exists(dir) || !File.Exists(sensorNameFile)) { continue; } string sensorName = File.ReadAllText(sensorNameFile).Trim(); if (LinuxTempSensorNames.Contains(sensorName)) { var lines = new List <string>(); for (int j = 0; j < 10; j++) { string sensorFile = Path.Combine(dir, string.Format(LinuxTempSensorFile, j)); if (File.Exists(sensorFile)) { try { GetTemperature(sensorFile, 0.001); var src = new TemperatureSource(sensorFile, 0.001); sources.Add(src); } catch (Exception) { } } } if (sources.Count > 0) { return(sources); } } } } } return(sources); }
static void TemperatureSource_Start_Post(TemperatureSource __instance) { #region quit if (!__instance.m_item.TryAssign(out var item) || item.ItemID.IsNotContainedIn(TORCH_IDS)) { return; } #endregion __instance.DistanceRanges = new List <Vector2> { new Vector2(0, _torchesTemperatureRadius) }; __instance.m_maxDistance = _torchesTemperatureRadius; if (TemperatureSource.BiggestRangeInScene < _torchesTemperatureRadius) { TemperatureSource.BiggestRangeInScene = _torchesTemperatureRadius; } __instance.m_temperatureCollider.As <SphereCollider>().radius = _torchesTemperatureRadius; item.PerishScript.DontPerishInWorld = !_torchesDecayOnGround; return; }
private static List<TemperatureSource> FindTemperatureSources() { List<TemperatureSource> sources = new List<TemperatureSource>(); if (Environment.OSVersion.Platform == PlatformID.Unix) { for (int i = 0; i < 10; i++) { foreach (string s in LinuxHwmonDirs) { string dir = string.Format(s, i); string sensorNameFile = Path.Combine(dir, LinuxTempSensorNameFile); if (!Directory.Exists(dir) || !File.Exists(sensorNameFile)) { continue; } string sensorName = File.ReadAllText(sensorNameFile).Trim(); if (LinuxTempSensorNames.Contains(sensorName)) { var lines = new List<string>(); for (int j = 0; j < 10; j++) { string sensorFile = Path.Combine(dir, string.Format(LinuxTempSensorFile, j)); if (File.Exists(sensorFile)) { try { GetTemperature(sensorFile, 0.001); var src = new TemperatureSource(sensorFile, 0.001); sources.Add(src); } catch (Exception) { } } } if (sources.Count > 0) { return sources; } } } } } return sources; }