Advertisement
SemlerPDX

AVCS SENS Reports TTS-v8 Inline Function in VB.net for VoiceAttack & AIDA64

Jun 14th, 2022
2,072
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 11.08 KB | None | 0 0
  1. 'AVCS AIDA Sensors Report Readout System
  2. ' by SemlerPDX Mar2022
  3. ' VETERANS-GAMING.COM
  4.  
  5. Imports Microsoft.VisualBasic
  6. Imports System
  7. Imports System.Collections
  8. Imports System.Collections.Generic
  9. Imports System.Data
  10. Imports System.Drawing
  11. Imports System.Diagnostics
  12. Imports System.Windows.Forms
  13. Imports System.Linq
  14. Imports System.Xml.Linq
  15. Imports System.Threading
  16. Imports System.Threading.Tasks
  17.  
  18.  
  19. Public Class VAInline
  20.     dim countAtypicalLow as integer = 0
  21.     dim countAtypicalHigh as integer = 0
  22.     dim countTypical as integer = 0
  23.     dim countTotal as integer = 0
  24.     'dim sensorsArray() as string = {"PercentCPU","PercentRAM","PercentGPU","PercentVRAM","TempMOBO","TempCPU","TempCPUD","TempCPUP","TempPCH","TempVRM","TempGPU","FanCPU","FanCPUO","FanPCH","FanTOP","FanREAR","FanGPU1","FanGPU2"}
  25.     dim sensorsArray() as string = {"CPU_Use","CPU_temp","CPU_Diode_temp","CPU_Package_temp","CPU_fan","CPU_OPT_fan","Memory_Use","GPU_Use","Video_Memory_Use","GPU_temp","GPU_fan","Motherboard_temp","PCH_temp","PCH_fan","Southbridge_temp","Southbridge_fan","Northbridge_temp","Northbridge_fan","VRM_temp","VRM_fan","Intake_fan","Exhaust_fan","Top_fan","Rear_fan","Back_fan","Left_fan","Right_fan","Bottom_fan","Front_fan","Side_fan"}
  26.    
  27.     'dim commandsArray() as string = {"CPU Usage","RAM Usage","GPU Usage","V RAM Usage","Motherboard Temp","CPU Temp","CPU Diode Temp","CPU Package Temp","Southbridge Temp","V R M Temp","GPU Temp","CPU Fan","ignore","P C H Fan","Top Case Fan","Rear case fan","GPU Fan","ignore"}
  28.     dim commandsArray() as string = {"CPU Usage","CPU Temp","CPU Diode Temp","CPU Package Temp","CPU Fan","Optional CPU Fan","RAM Usage","GPU Usage","V RAM Usage","GPU Temp","GPU Fan","Motherboard Temp","PCH Temp","PCH Fan","Southbridge Temp","Southbridge Fan","Northbridge Temp","Northbridge Fan","V R M Temp","V R M Fan","Intake case fan","Exhaust case fan","Top case fan","Rear case fan","Back case fan","Left case fan","Right case fan","Bottom case fan","Front case fan","Side case fan"}
  29.     dim sensorsAtypicalHigh as string = ""
  30.     dim sensorsAtypicalLow as string = ""
  31.     dim sensorsTypical as string = ""
  32.     dim diagnosticLevel as integer = 0
  33.     dim diagnoseSystem as string = ""
  34.    
  35.     dim diagnosticsDebugging as boolean = false
  36.     dim diagnosticsTesting as boolean = false
  37.    
  38.     Public Sub ExecuteDiagnosticsLevel(ByVal diagnosticCount as integer, ByVal diagnosticSensors as string, ByVal andConjunctions as boolean)
  39.         dim diagnosticSensorsArray() as string
  40.         if ((diagnosticCount > 1) and (diagnosticSensors.Contains(",")))
  41.             diagnosticSensorsArray = diagnosticSensors.Replace("ignore", "").Split(New String() {","}, StringSplitOptions.RemoveEmptyEntries)
  42.             if (diagnoseSystem = "GPU")
  43.                 try
  44.                     VA.Command.Execute("How is the graphics card clock", true)
  45.                 catch
  46.                     if (diagnosticsDebugging)
  47.                         VA.WriteToLog("AVCS AIDA ERROR: at ExecuteDiagnosticsLevel (GPU) VA Proxy Command Execute...", "red")
  48.                     end if
  49.                 end try
  50.             end if
  51.             for i as integer = 0 to diagnosticSensorsArray.GetUpperBound(0)
  52.                 if (diagnosticsDebugging)
  53.                     VA.WriteToLog("sensorsArray(" + i.ToString() + ") = " + diagnosticSensorsArray(i).ToString(), "orange")
  54.                     VA.WriteToLog("sensorsArray Length = " + diagnosticSensorsArray.GetUpperBound(0).ToString(), "orange")
  55.                 end if
  56.                 try
  57.                     if ((i < diagnosticSensorsArray.GetUpperBound(0)) and (i > 0) and (i Mod 2 = 0) and (andConjunctions))
  58.                         VA.SetText("AVCS_SENS_TTS_WILDCARD", "[also,;and,;also,;;;;;;;]")
  59.                         VA.Command.Execute("F_SAY_TTS", true)
  60.                     elseif ((i = diagnosticSensorsArray.GetUpperBound(0)) and ((diagnosticSensorsArray.GetUpperBound(0) = 1) or (diagnosticSensorsArray.GetUpperBound(0) = 2)))
  61.                         VA.SetText("AVCS_SENS_TTS_WILDCARD", "and,")
  62.                         VA.Command.Execute("F_SAY_TTS", true)
  63.                     elseif ((i = diagnosticSensorsArray.GetUpperBound(0)) and (diagnosticSensorsArray.GetUpperBound(0) >= 3))
  64.                         VA.SetText("AVCS_SENS_TTS_WILDCARD", "and finally")
  65.                         VA.Command.Execute("F_SAY_TTS", true)
  66.                     end if
  67.                     VA.Command.Execute("How is the " + diagnosticSensorsArray(i), true)
  68.                 catch
  69.                     if (diagnosticsDebugging)
  70.                         VA.WriteToLog("AVCS AIDA ERROR: at VA Proxy Command Execute...", "red")
  71.                     end if
  72.                 end try
  73.             next
  74.         elseif (diagnosticCount = 1)
  75.             if (diagnosticSensors <> "ignore")
  76.                 try
  77.                     diagnosticSensors = diagnosticSensors.Replace("," ,"")
  78.                     VA.Command.Execute("How is the " + diagnosticSensors, true)
  79.                 catch
  80.                     if (diagnosticsDebugging)
  81.                         VA.WriteToLog("AVCS AIDA ERROR: at VA Proxy Command Execute...", "red")
  82.                     end if
  83.                 end try
  84.             end if
  85.         else
  86.             if (diagnosticCount = 0)
  87.                 try
  88.                     VA.SetText("AVCS_SENS_TTS_WILDCARD", "[we are;all systems are] [functioning within normal parameters;operating within normal parameters;operating at peak efficiency]; [we are;all systems are] [functioning within normal parameters;operating within normal parameters;operating at peak efficiency] [sir;captain;]")
  89.                     VA.Command.Execute("F_SAY_TTS", false)
  90.                 catch
  91.                     if (diagnosticsDebugging)
  92.                         VA.WriteToLog("AVCS AIDA ERROR: at VA Proxy Command Execute 'How are we doing'...", "red")
  93.                     end if
  94.                 end try
  95.             end if
  96.             if (diagnosticsDebugging)
  97.                 VA.WriteToLog("AVCS AIDA: No diagnostic data to report", "red")
  98.             end if
  99.         end if
  100.     End Sub
  101.    
  102.    
  103.     Public Sub Main()
  104.         VA.SetBoolean("AVCS_SENS_Diagnostics_Active", true)
  105.         if (VA.GetText("AVCS_SENS_DIAGNOSTIC_SENSORS") isNot nothing)
  106.             sensorsArray = VA.GetText("AVCS_SENS_DIAGNOSTIC_SENSORS").Split(New String() {","}, StringSplitOptions.RemoveEmptyEntries)
  107.         end if
  108.         if (VA.GetText("AVCS_SENS_DIAGNOSTIC_COMMANDS") isNot nothing)
  109.             commandsArray = VA.GetText("AVCS_SENS_DIAGNOSTIC_COMMANDS").Split(New String() {","}, StringSplitOptions.RemoveEmptyEntries)
  110.         end if
  111.         if ((VA.GetBoolean("AVCS_SENS_DebugDiagnostics") isNot nothing) andAlso (VA.GetBoolean("AVCS_SENS_DebugDiagnostics")))
  112.             diagnosticsDebugging = true
  113.         end if
  114.        
  115.         if (VA.GetText("AVCS_SENS_DIAGNOSTIC_SYSTEM") isNot nothing)
  116.             diagnoseSystem = VA.GetText("AVCS_SENS_DIAGNOSTIC_SYSTEM")
  117.         end if
  118.        
  119.         'For each sensor noted as 'diagnostic', assemble current typical/atypical diagnostics data (if any)
  120.         for i as integer = 0 to sensorsArray.GetUpperBound(0)
  121.             if ((VA.GetBoolean("AVCS_SENS_ATYPICAL_" + sensorsArray(i)) isNot nothing) andAlso (VA.GetBoolean("AVCS_SENS_ATYPICAL_" + sensorsArray(i))))
  122.                 if (diagnoseSystem = "") or ((diagnoseSystem <> "") andAlso (((diagnoseSystem = "GPU") and ((commandsArray(i).StartsWith("GPU")) or (sensorsArray(i).EndsWith("VRAM")))) or ((diagnoseSystem = "CPU") and (commandsArray(i).StartsWith("CPU")))))
  123.                     sensorsAtypicalHigh = sensorsAtypicalHigh + commandsArray(i) + ","
  124.                     countAtypicalHigh += 1
  125.                 end if
  126.             elseif ((VA.GetBoolean("AVCS_SENS_ATYPICAL_" + sensorsArray(i)) isNot nothing) andAlso (VA.GetBoolean("AVCS_SENS_ATYPICAL_" + sensorsArray(i)) = false))
  127.                 if (diagnoseSystem = "") or ((diagnoseSystem <> "") andAlso (((diagnoseSystem = "GPU") and ((commandsArray(i).StartsWith("GPU")) or (sensorsArray(i).EndsWith("VRAM")))) or ((diagnoseSystem = "CPU") and (commandsArray(i).StartsWith("CPU")))))
  128.                     sensorsAtypicalLow = sensorsAtypicalLow + commandsArray(i) + ","
  129.                     countAtypicalLow += 1
  130.                 end if
  131.             elseif ((VA.GetBoolean("AVCS_SENS_ATYPICAL_" + commandsArray(i)) is nothing) andAlso (VA.GetDecimal("AVCS_SENS_LastAverage_" + sensorsArray(i)) isNot nothing))
  132.                 if (diagnoseSystem = "") or ((diagnoseSystem <> "") andAlso (((diagnoseSystem = "GPU") and ((commandsArray(i).StartsWith("GPU")) or (sensorsArray(i).EndsWith("VRAM")))) or ((diagnoseSystem = "CPU") and (commandsArray(i).StartsWith("CPU")))))
  133.                     countTypical += 1
  134.                     sensorsTypical = sensorsTypical + commandsArray(i) + ","
  135.                 end if
  136.             end if
  137.         next
  138.        
  139.         countTotal = countAtypicalHigh + countTypical + countAtypicalLow
  140.        
  141.         'Testing Debug set (disregards actual atypical/typical status)
  142.         'diagnosticsTesting = true 'uncomment this line to use the Test Run button in Inline Function editor window
  143.         if (diagnosticsTesting)
  144.             VA.ClearLog()
  145.             VA.WriteToLog("Total Count: " + countTotal.ToString(), "red")
  146.             countAtypicalHigh += 1
  147.             sensorsAtypicalHigh = sensorsAtypicalHigh + "CPU Temp" + ","
  148.             countAtypicalHigh += 1
  149.             sensorsAtypicalHigh = sensorsAtypicalHigh + "GPU Temp" + ","
  150.             'countAtypicalHigh += 1
  151.             'sensorsAtypicalHigh = sensorsAtypicalHigh + "Southbridge Temp" + ","
  152.             VA.SetInt("AVCS_SENS_DIAGNOSTIC_LEVEL", 4)
  153.         end if
  154.        
  155.         'For use when not split, trim the final comma from the string, else let it be removed when split
  156.         if (sensorsAtypicalHigh <> "")
  157.             sensorsAtypicalHigh = sensorsAtypicalHigh.Substring(0, sensorsAtypicalHigh.Length - 1)
  158.         end if
  159.         if (sensorsAtypicalLow <> "")
  160.             sensorsAtypicalLow = sensorsAtypicalLow.Substring(0, sensorsAtypicalLow.Length - 1)
  161.         end if
  162.         if (sensorsTypical <> "")
  163.             sensorsTypical = sensorsTypical.Substring(0, sensorsTypical.Length - 1)
  164.         end if
  165.        
  166.         'Based on requested level, begin automated diagnostic command calls for any/all individual sensors of the requested level type
  167.         if ((VA.GetInt("AVCS_SENS_DIAGNOSTIC_LEVEL") isNot nothing) andAlso (Integer.TryParse(VA.GetInt("AVCS_SENS_DIAGNOSTIC_LEVEL"), diagnosticLevel)))
  168.            
  169.             if (diagnosticsDebugging)
  170.                 VA.WriteToLog("Atypical High Sensors = " + sensorsAtypicalHigh, "green")
  171.                 VA.WriteToLog("Atypical High Sensor Count = " + countAtypicalHigh.ToString(), "green")
  172.                 VA.WriteToLog("Atypical Low Sensors = " + sensorsAtypicalLow, "green")
  173.                 VA.WriteToLog("Atypical Low Sensor Count = " + countAtypicalLow.ToString(), "green")
  174.                 VA.WriteToLog("Typical Sensor Count = " + countTypical.ToString(), "blue")
  175.                 VA.WriteToLog("diagnosticLevel = " + diagnosticLevel.ToString(), "green")
  176.             end if
  177.            
  178.             'Level 5 runs only AtypicalHigh if >=25% are High, 4 is any High, 3 is High+Low, and 2 is High+Typical+Low (all), 1 is Menu for (all)
  179.             'NEW DIAGNOSTIC LEVELS SYSTEM ===============================
  180.             select case (diagnosticLevel)
  181.                 case 4
  182.                     ExecuteDiagnosticsLevel(countAtypicalHigh, sensorsAtypicalHigh, true)
  183.                 case 3
  184.                     sensorsAtypicalHigh = sensorsAtypicalHigh + "," + sensorsAtypicalLow
  185.                     countTotal = countAtypicalHigh + countAtypicalLow
  186.                     ExecuteDiagnosticsLevel(countTotal, sensorsAtypicalHigh, true)
  187.                 case 2
  188.                     sensorsTypical = sensorsAtypicalHigh + "," + sensorsTypical + "," + sensorsAtypicalLow
  189.                     ExecuteDiagnosticsLevel(countTotal, sensorsTypical, false)
  190.                     VA.SetBoolean("ungraceful_Exit", nothing)
  191.                 case 1
  192.                     VA.Command.Execute("F_AIDA_DIAGNOSE", false)
  193.                     VA.WriteToLog("diagnoseSystem Report = " + diagnoseSystem.ToString(), "green")
  194.                 case else
  195.                     if (countAtypicalHigh >= countTotal/4)
  196.                         ExecuteDiagnosticsLevel(countAtypicalHigh, sensorsAtypicalHigh, true)
  197.                     else
  198.                         ExecuteDiagnosticsLevel(0, sensorsTypical, false)
  199.                     end if
  200.             end select
  201.            
  202.         else
  203.             if (diagnosticsDebugging)
  204.                 VA.WriteToLog("AVCS AIDA ERROR: Reports Inline - TryParse Int or Variable error...", "red")
  205.             end if
  206.         end if
  207.        
  208.         VA.SetInt("AVCS_SENS_DIAGNOSTIC_LEVEL", nothing)
  209.         VA.SetBoolean("AVCS_SENS_Diagnostics_Active", nothing)
  210.         VA.SetBoolean("AVCS_SENS_Diagnosing", false)
  211.     End Sub
  212. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement