Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'AVCS SENS Parse Data Last Average or Differential Diagnostic* Report per Sensor Label
- ' *(When paired with AVCS-DHT1) - Based on current & historic PC operational state level bracket data (low/medium/high/extreme)
- ' by SemlerPDX Mar2022
- ' VETERANS-GAMING.COM
- 'Format of incoming data from global variable:
- 'VA.SetText("AVCS_SENS_DIAGNOSTICS_" + currentLabel, differentialDiagnosis)
- 'differentialDiagnosis =
- ' currentAverage.ToString() + "," +
- ' historicAverage.ToString() + "," +
- ' averageDistance.ToString() + "," +
- ' percentDifference.ToString() + "," +
- ' differentialDiagnosis ("stable","higher","lower")
- ' output to ~~avcs_sens_tts_final
- Imports Microsoft.VisualBasic
- Imports System
- Imports System.IO
- Imports System.IO.Ports
- Imports System.Math
- Imports System.Text.RegularExpressions
- Imports System.Collections
- Imports System.Collections.Generic
- Imports System.Data
- Imports System.Drawing
- Imports System.Diagnostics
- Imports System.Text
- Imports System.Windows.Forms
- Imports System.Linq
- Imports System.Xml
- Imports System.Xml.Linq
- Imports System.Threading
- Imports System.Threading.Tasks
- Public Class VAInline
- dim contents() as string
- dim sensorName as string = ""
- dim sensorUnit as string = ""
- dim differentialDiagnosis as string = ""
- dim lastAverage as decimal = 0
- dim percentDifference as decimal = 0
- dim decimalPlacesMax as integer = 1
- dim roundedFanValue as string = "0"
- dim debugReports as boolean = false
- Public Function GetRoundedDecimal(ByVal thisDecimal as decimal, ByVal decimalPlaces as integer)
- try
- 'Try to compare decimal with integer version of itself to discover decimal places, then round
- dim checkInteger as Int32 = Convert.ToInt32(thisDecimal)
- if (thisDecimal = checkInteger)
- 'For TTS brevity use the one that couldn't end with .000
- thisDecimal = checkInteger
- elseif (checkInteger <> thisDecimal)
- dim roundDecimal as Double = thisDecimal
- thisDecimal = Round(roundDecimal, decimalPlaces)
- end if
- catch
- 'Result is a whole number already, does not need rounding for TTS brevity
- end try
- return thisDecimal
- end function
- Public Function GetRoundedFanRPM(ByVal thisFanRPM as decimal)
- dim thisRoundedRPM as string = GetRoundedDecimal(thisFanRPM, 0).ToString()
- thisFanRPM = GetRoundedDecimal(thisFanRPM, 0)
- if (thisFanRPM > 1000)
- thisFanRPM /= 100
- thisFanRPM = GetRoundedDecimal(thisFanRPM, 0)
- if (thisFanRPM.ToString().EndsWith("0"))
- thisRoundedRPM = "around " + (thisFanRPM * 100).ToString()
- else
- thisRoundedRPM = "around " + thisFanRPM.ToString() + " hundred"
- end if
- elseif (thisFanRPM <= 999) and (thisFanRPM > 100)
- thisFanRPM /= 10
- thisRoundedRPM = "around " + ((GetRoundedDecimal(thisFanRPM, 0)) * 10).ToString()
- end if
- return thisRoundedRPM
- end function
- Public Sub Main()
- if (debugReports)
- 'AVCS_SENS_DIAGNOSTICS_dTa_TempCPU
- 'VA.SetText("~~avcs_sens_tts_label", "CPU")
- 'VA.SetText("~~avcs_sens_sensor_label", "dTa_TempCPU")
- 'VA.SetText("~~avcs_sens_tts_unit", "degrees over ambient")
- 'VA.SetText("AVCS_SENS_Current_LevelBracket", "HIGH") (phased out in v4)
- end if
- if ((VA.GetBoolean("AVCS_SENS_DebugReports") isNot nothing) andAlso (VA.GetBoolean("AVCS_SENS_DebugReports")))
- debugReports = true
- end if
- if ((VA.GetText("~~avcs_sens_tts_label") isNot nothing) andAlso (VA.GetText("~~avcs_sens_tts_unit") isNot nothing) andAlso (VA.GetText("~~avcs_sens_sensor_label") isNot nothing) andAlso (VA.GetText("~~avcs_sens_sensor_type") isNot nothing))
- sensorName = VA.GetText("~~avcs_sens_tts_label")
- sensorUnit = VA.GetText("~~avcs_sens_tts_unit")
- if (VA.GetText("~~avcs_sens_sensor_label") isNot nothing)
- VA.GetText("~~avcs_sens_sensor_label")
- if (VA.GetText("AVCS_SENS_DIAGNOSTICS_" + VA.GetText("~~avcs_sens_sensor_label")) isNot nothing)
- 'VA.WriteToLog("HAS DIAGNOSTIC DATA!!","green")
- try
- contents = VA.GetText("AVCS_SENS_DIAGNOSTICS_" + VA.GetText("~~avcs_sens_sensor_label")).Replace(" ","").Split(",")
- if (debugReports)
- for i as integer = 0 to contents.GetUpperBound(0)
- VA.WriteToLog("contents("+ i.ToString() +") = " + contents(i).ToString(), "yellow")
- next
- end if
- VA.SetText("AVCS_SENS_TTS_LastQuery_CurrentAverage", contents(1).ToString())
- VA.SetText("AVCS_SENS_TTS_LastQuery_HistoricAverage", contents(2).ToString())
- VA.SetText("AVCS_SENS_TTS_LastQuery_AverageDistance", contents(3).ToString())
- VA.SetText("AVCS_SENS_TTS_LastQuery_PercentDifference", contents(4).ToString())
- VA.SetText("AVCS_SENS_TTS_LastQuery_DifferentialDiagnosis", contents(5).ToString())
- 'Set this value to be available immediately as "that" in AVCS Voice Calculator & Conversions Profile
- VA.SetDecimal("AVCS_CALC_LastResult", contents(1).ToString())
- if (contents(5) <> "")
- if (contents(5) = "stable")
- if ((VA.GetText("~~avcs_sens_sensor_label").EndsWith("fan")) or (VA.GetText("~~avcs_sens_sensor_label").EndsWith("Fan")))' or (sensorName.StartsWith("fan")) or (sensorName.Contains("Fan")) or (sensorName.Contains("fan")) or (sensorName.Contains("Fan")))
- sensorName = sensorName + " fan"
- roundedFanValue = GetRoundedFanRPM(Convert.ToDecimal(contents(1)))
- differentialDiagnosis = "[The;My;] " + sensorName + " is [;;;;;reporting;;;reading;] [;;;;;stable;;;standard;;;typical;;;nominal;;;] at " + roundedFanValue + " " + sensorUnit
- VA.WriteToLog("Current Average " + sensorName.Replace("_"," ").Replace("dTa","ΔT/a") + " value: " + roundedFanValue.Replace("around ", "").Replace(" hundred", "00") + " " + sensorUnit, "blank")
- else
- if ((sensorName.ToLower() = "cpu") andAlso (VA.GetText("~~avcs_sens_sensor_type") = "temp"))
- sensorName = sensorName + " core"
- end if
- differentialDiagnosis = "[The;My;] " + sensorName + " is [;;;;;reporting;;;reading;;;] [;;;;stable;;;standard;;;typical;;;nominal;;;] at " + GetRoundedDecimal(Convert.ToDecimal(contents(1)), 1).ToString() + " " + sensorUnit
- VA.WriteToLog("Current Average " + sensorName.Replace("_"," ").Replace("dTa","ΔT/a") + " value: " + GetRoundedDecimal(Convert.ToDecimal(contents(1)), 1).ToString() + " " + sensorUnit.Replace("percent", "%"), "blank")
- end if
- else
- if ((VA.GetText("~~avcs_sens_sensor_label").EndsWith("fan")) or (VA.GetText("~~avcs_sens_sensor_label").EndsWith("Fan")))' or (sensorName.StartsWith("fan")) or (sensorName.Contains("Fan")) or (sensorName.Contains("fan")) or (sensorName.Contains("Fan")))
- sensorName = sensorName + " fan"
- roundedFanValue = GetRoundedFanRPM(Convert.ToDecimal(contents(1)))
- differentialDiagnosis = "[The;My;] " + sensorName + " is [;;;;;averaging;reporting;reading;] " + contents(5) + " than [standard;typical;baseline] at " + roundedFanValue + " " + sensorUnit
- VA.WriteToLog("Current Average " + sensorName.Replace("_"," ").Replace("dTa","ΔT/a") + " value: " + roundedFanValue.Replace("around ", "").Replace(" hundred", "00") + " " + sensorUnit + " (" + contents(5) + " than typical)", "blank")
- else
- if ((sensorName.ToLower() = "cpu") andAlso (VA.GetText("~~avcs_sens_sensor_type") = "temp"))
- sensorName = sensorName + " core"
- end if
- differentialDiagnosis = "[The;My;] " + sensorName + " is [;;;;;averaging;reporting;reading;] " + GetRoundedDecimal(Convert.ToDecimal(contents(4)), 0).ToString() + " percent " + contents(5) + " than [standard;typical;baseline] at " + GetRoundedDecimal(Convert.ToDecimal(contents(1)), 1).ToString() + " " + sensorUnit
- VA.WriteToLog("Current Average " + sensorName.Replace("_"," ").Replace("dTa","ΔT/a") + " value: " + GetRoundedDecimal(Convert.ToDecimal(contents(1)), 1).ToString() + " " + sensorUnit.Replace("percent", "%") + " (" + contents(5) + " than typical)", "blank")
- end if
- end if
- else
- differentialDiagnosis = "[The;My;] " + sensorName + " is currently [unavailable;not reporting;silent] for some reason."
- differentialDiagnosis = "[I do not have;There is no;I cannot locate] " + sensorName + " sensor data."
- differentialDiagnosis = "[I do not have;There is no;I cannot locate] " + sensorName + " " + VA.GetText("~~avcs_sens_sensor_type").Replace("temp","temperature").Replace("fan_use","fan use").Replace("use","utilization") + " sensor data. Please check configuration."
- VA.WriteToLog("Current Average " + VA.GetText("~~avcs_sens_sensor_label").Replace("_"," ").Replace("dTa","ΔT/a") + " is unavailable. Please check configuration.", "red")
- end if
- catch
- differentialDiagnosis = "[The;My;] " + sensorName + " is currently [unavailable;not reporting;silent] for some reason."
- differentialDiagnosis = "[I do not have;There is no;I cannot locate] " + sensorName + " sensor data."
- differentialDiagnosis = "[I do not have;There is no;I cannot locate] " + sensorName + " " + VA.GetText("~~avcs_sens_sensor_type").Replace("temp","temperature").Replace("fan_use","fan use").Replace("use","utilization") + " sensor data. Please check configuration."
- VA.WriteToLog("Current Average " + VA.GetText("~~avcs_sens_sensor_label").Replace("_"," ").Replace("dTa","ΔT/a") + " is unavailable. Please check configuration.", "red")
- finally
- VA.SetText("~~avcs_sens_tts_final", differentialDiagnosis.Replace("_"," "))
- if (debugReports)
- VA.WriteToLog("~~avcs_sens_tts_final = " + VA.ParseTokens("{TXT:~~avcs_sens_tts_final}"), "yellow")
- end if
- end try
- else
- 'VA.WriteToLog("HAS NO DIAGNOSTIC DATA!!","red")
- if ((VA.GetDecimal("AVCS_SENS_LastAverage_" + VA.GetText("~~avcs_sens_sensor_label")) isNot nothing) andAlso (Decimal.TryParse(VA.GetDecimal("AVCS_SENS_LastAverage_" + VA.GetText("~~avcs_sens_sensor_label")), lastAverage)))
- 'Set this value to be available immediately as "that" in AVCS Voice Calculator & Conversions Profile
- VA.SetDecimal("AVCS_CALC_LastResult", lastAverage.ToString())
- if ((VA.GetText("~~avcs_sens_sensor_label").EndsWith("fan")) or (VA.GetText("~~avcs_sens_sensor_label").EndsWith("Fan"))) ' or (sensorName.StartsWith("fan")) or (sensorName.Contains("Fan")) or (sensorName.Contains("fan")) or (sensorName.Contains("Fan")))
- sensorName = sensorName + " fan"
- roundedFanValue = GetRoundedFanRPM(lastAverage)
- differentialDiagnosis = "[The;My;] " + sensorName + " is [;;;;;reporting;;;reading;] [at;;;] " + roundedFanValue + " " + sensorUnit
- VA.WriteToLog("Current Average " + sensorName.Replace("_"," ").Replace("dTa","ΔT/a") + " value: " + roundedFanValue.Replace("around ", "").Replace(" hundred", "00") + " " + sensorUnit, "blank")
- else
- if ((sensorName.ToLower() = "cpu") andAlso (VA.GetText("~~avcs_sens_sensor_type") = "temp"))
- sensorName = sensorName + " core"
- end if
- if ((VA.GetText("~~avcs_sens_sensor_type") = "voltage") or (VA.GetText("~~avcs_sens_sensor_type") = "amperage") or (VA.GetText("~~avcs_sens_sensor_type") = "wattage"))
- decimalPlacesMax = 2
- else
- decimalPlacesMax = 1
- end if
- differentialDiagnosis = "[The;My;] " + sensorName + " is [;;;;;reporting;;;reading;;;] [;;;;stable;;;standard;;;typical;;;nominal;;;] at " + GetRoundedDecimal(lastAverage, decimalPlacesMax).ToString() + " " + sensorUnit
- VA.WriteToLog("Current Average " + sensorName.Replace("_"," ").Replace("dTa","ΔT/a") + " value: " + GetRoundedDecimal(lastAverage, decimalPlacesMax).ToString() + " " + sensorUnit.Replace("percent", "%"), "blank")
- end if
- else
- differentialDiagnosis = "[The;My;] " + sensorName + " is currently unavailable. Please check configuration."
- differentialDiagnosis = "[I do not have;There is no;I cannot locate] " + sensorName + " " + VA.GetText("~~avcs_sens_sensor_type").Replace("temp","temperature").Replace("fan_use","fan use").Replace("use","utilization") + " sensor data. Please check configuration."
- VA.WriteToLog("Current Average " + VA.GetText("~~avcs_sens_sensor_label").Replace("_"," ").Replace("dTa","ΔT/a") + " is unavailable. Please check configuration.", "red")
- end if
- VA.SetText("~~avcs_sens_tts_final", differentialDiagnosis.Replace("_"," "))
- if (debugReports)
- VA.WriteToLog("~~avcs_sens_tts_final = " + VA.ParseTokens("{TXT:~~avcs_sens_tts_final}"), "yellow")
- end if
- end if
- end if
- end if
- End Sub
- End Class
Add Comment
Please, Sign In to add comment