SemlerPDX

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

Jun 14th, 2022 (edited)
254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 11.32 KB | None | 0 0
  1. 'AVCS AIDA Diagnostic 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","dTa_CPU_temp","dTa_CPU_Diode_temp","dTa_CPU_Package_temp","CPU_fan","CPU_OPT_fan","Memory_Use","GPU_Use","Video_Memory_Use","dTa_GPU_temp","GPU_fan","dTa_Motherboard_temp","dTa_PCH_temp","PCH_fan","dTa_Southbridge_temp","Southbridge_fan","dTa_Northbridge_temp","Northbridge_fan","dTa_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.                 if ((VA.GetBoolean("AVCS_SENS_Diagnostics_Active") isNot nothing) andAlso (VA.GetBoolean("AVCS_SENS_Diagnostics_Active")))
  57.                     try
  58.                         if ((i < diagnosticSensorsArray.GetUpperBound(0)) and (i > 0) and (i Mod 2 = 0) and (andConjunctions))
  59.                             VA.SetText("AVCS_SENS_TTS_WILDCARD", "[also,;and,;also,;;;;;;;]")
  60.                             VA.Command.Execute("F_SAY_TTS", true)
  61.                         elseif ((i = diagnosticSensorsArray.GetUpperBound(0)) and ((diagnosticSensorsArray.GetUpperBound(0) = 1) or (diagnosticSensorsArray.GetUpperBound(0) = 2)))
  62.                             VA.SetText("AVCS_SENS_TTS_WILDCARD", "and,")
  63.                             VA.Command.Execute("F_SAY_TTS", true)
  64.                         elseif ((i = diagnosticSensorsArray.GetUpperBound(0)) and (diagnosticSensorsArray.GetUpperBound(0) >= 3))
  65.                             VA.SetText("AVCS_SENS_TTS_WILDCARD", "and finally")
  66.                             VA.Command.Execute("F_SAY_TTS", true)
  67.                         end if
  68.                         VA.Command.Execute("How is the " + diagnosticSensorsArray(i), true)
  69.                     catch
  70.                         if (diagnosticsDebugging)
  71.                             VA.WriteToLog("AVCS AIDA ERROR: at VA Proxy Command Execute...", "red")
  72.                         end if
  73.                     end try
  74.                 end if
  75.             next
  76.         elseif (diagnosticCount = 1)
  77.             if (diagnosticSensors <> "ignore")
  78.                 try
  79.                     diagnosticSensors = diagnosticSensors.Replace("," ,"")
  80.                     VA.Command.Execute("How is the " + diagnosticSensors, true)
  81.                 catch
  82.                     if (diagnosticsDebugging)
  83.                         VA.WriteToLog("AVCS AIDA ERROR: at VA Proxy Command Execute...", "red")
  84.                     end if
  85.                 end try
  86.             end if
  87.         else
  88.             if (diagnosticCount = 0)
  89.                 try
  90.                     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;]")
  91.                     VA.Command.Execute("F_SAY_TTS", false)
  92.                 catch
  93.                     if (diagnosticsDebugging)
  94.                         VA.WriteToLog("AVCS AIDA ERROR: at VA Proxy Command Execute 'How are we doing'...", "red")
  95.                     end if
  96.                 end try
  97.             end if
  98.             if (diagnosticsDebugging)
  99.                 VA.WriteToLog("AVCS AIDA: No diagnostic data to report", "red")
  100.             end if
  101.         end if
  102.     End Sub
  103.    
  104.    
  105.     Public Sub Main()
  106.         VA.SetBoolean("AVCS_SENS_Diagnostics_Active", true)
  107.         if (VA.GetText("AVCS_SENS_DIAGNOSTIC_SENSORS") isNot nothing)
  108.             sensorsArray = VA.GetText("AVCS_SENS_DIAGNOSTIC_SENSORS").Split(New String() {","}, StringSplitOptions.RemoveEmptyEntries)
  109.         end if
  110.         if (VA.GetText("AVCS_SENS_DIAGNOSTIC_COMMANDS") isNot nothing)
  111.             commandsArray = VA.GetText("AVCS_SENS_DIAGNOSTIC_COMMANDS").Split(New String() {","}, StringSplitOptions.RemoveEmptyEntries)
  112.         end if
  113.         if ((VA.GetBoolean("AVCS_SENS_DebugDiagnostics") isNot nothing) andAlso (VA.GetBoolean("AVCS_SENS_DebugDiagnostics")))
  114.             diagnosticsDebugging = true
  115.         end if
  116.        
  117.         if (VA.GetText("AVCS_SENS_DIAGNOSTIC_SYSTEM") isNot nothing)
  118.             diagnoseSystem = VA.GetText("AVCS_SENS_DIAGNOSTIC_SYSTEM")
  119.         end if
  120.        
  121.         'For each sensor noted as 'diagnostic', assemble current typical/atypical diagnostics data (if any)
  122.         for i as integer = 0 to sensorsArray.GetUpperBound(0)
  123.             if ((VA.GetBoolean("AVCS_SENS_ATYPICAL_" + sensorsArray(i)) isNot nothing) andAlso (VA.GetBoolean("AVCS_SENS_ATYPICAL_" + sensorsArray(i))))
  124.                 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")))))
  125.                     sensorsAtypicalHigh = sensorsAtypicalHigh + commandsArray(i) + ","
  126.                     countAtypicalHigh += 1
  127.                 end if
  128.             elseif ((VA.GetBoolean("AVCS_SENS_ATYPICAL_" + sensorsArray(i)) isNot nothing) andAlso (VA.GetBoolean("AVCS_SENS_ATYPICAL_" + sensorsArray(i)) = false))
  129.                 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")))))
  130.                     sensorsAtypicalLow = sensorsAtypicalLow + commandsArray(i) + ","
  131.                     countAtypicalLow += 1
  132.                 end if
  133.             elseif ((VA.GetBoolean("AVCS_SENS_ATYPICAL_" + commandsArray(i)) is nothing) andAlso (VA.GetDecimal("AVCS_SENS_LastAverage_" + sensorsArray(i)) isNot nothing))
  134.                 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")))))
  135.                     countTypical += 1
  136.                     sensorsTypical = sensorsTypical + commandsArray(i) + ","
  137.                 end if
  138.             end if
  139.         next
  140.        
  141.         countTotal = countAtypicalHigh + countTypical + countAtypicalLow
  142.        
  143.         'Testing Debug set (disregards actual atypical/typical status)
  144.         'diagnosticsTesting = true 'uncomment this line to use the Test Run button in Inline Function editor window
  145.         if (diagnosticsTesting)
  146.             VA.ClearLog()
  147.             VA.WriteToLog("Total Count: " + countTotal.ToString(), "red")
  148.             countAtypicalHigh += 1
  149.             sensorsAtypicalHigh = sensorsAtypicalHigh + "CPU Temp" + ","
  150.             countAtypicalHigh += 1
  151.             sensorsAtypicalHigh = sensorsAtypicalHigh + "GPU Temp" + ","
  152.             'countAtypicalHigh += 1
  153.             'sensorsAtypicalHigh = sensorsAtypicalHigh + "Southbridge Temp" + ","
  154.             VA.SetInt("AVCS_SENS_DIAGNOSTIC_LEVEL", 4)
  155.         end if
  156.        
  157.         'For use when not split, trim the final comma from the string, else let it be removed when split
  158.         if (sensorsAtypicalHigh <> "")
  159.             sensorsAtypicalHigh = sensorsAtypicalHigh.Substring(0, sensorsAtypicalHigh.Length - 1)
  160.         end if
  161.         if (sensorsAtypicalLow <> "")
  162.             sensorsAtypicalLow = sensorsAtypicalLow.Substring(0, sensorsAtypicalLow.Length - 1)
  163.         end if
  164.         if (sensorsTypical <> "")
  165.             sensorsTypical = sensorsTypical.Substring(0, sensorsTypical.Length - 1)
  166.         end if
  167.        
  168.         'Based on requested level, begin automated diagnostic command calls for any/all individual sensors of the requested level type
  169.         if ((VA.GetInt("AVCS_SENS_DIAGNOSTIC_LEVEL") isNot nothing) andAlso (Integer.TryParse(VA.GetInt("AVCS_SENS_DIAGNOSTIC_LEVEL"), diagnosticLevel)))
  170.            
  171.             if (diagnosticsDebugging)
  172.                 VA.WriteToLog("Atypical High Sensors = " + sensorsAtypicalHigh, "green")
  173.                 VA.WriteToLog("Atypical High Sensor Count = " + countAtypicalHigh.ToString(), "green")
  174.                 VA.WriteToLog("Atypical Low Sensors = " + sensorsAtypicalLow, "green")
  175.                 VA.WriteToLog("Atypical Low Sensor Count = " + countAtypicalLow.ToString(), "green")
  176.                 VA.WriteToLog("Typical Sensor Count = " + countTypical.ToString(), "blue")
  177.                 VA.WriteToLog("diagnosticLevel = " + diagnosticLevel.ToString(), "green")
  178.             end if
  179.            
  180.             '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)
  181.             'NEW DIAGNOSTIC LEVELS SYSTEM ===============================
  182.             select case (diagnosticLevel)
  183.                 case 4
  184.                     ExecuteDiagnosticsLevel(countAtypicalHigh, sensorsAtypicalHigh, true)
  185.                 case 3
  186.                     sensorsAtypicalHigh = sensorsAtypicalHigh + "," + sensorsAtypicalLow
  187.                     countTotal = countAtypicalHigh + countAtypicalLow
  188.                     ExecuteDiagnosticsLevel(countTotal, sensorsAtypicalHigh, true)
  189.                 case 2
  190.                     sensorsTypical = sensorsAtypicalHigh + "," + sensorsTypical + "," + sensorsAtypicalLow
  191.                     ExecuteDiagnosticsLevel(countTotal, sensorsTypical, false)
  192.                     VA.SetBoolean("ungraceful_Exit", nothing)
  193.                 case 1
  194.                     VA.Command.Execute("F_AIDA_DIAGNOSE", false)
  195.                     if (diagnosticsDebugging)
  196.                         VA.WriteToLog("diagnoseSystem = " + diagnoseSystem.ToString(), "green")
  197.                     end if
  198.                 case else
  199.                     if (countAtypicalHigh >= countTotal/4)
  200.                         ExecuteDiagnosticsLevel(countAtypicalHigh, sensorsAtypicalHigh, true)
  201.                     else
  202.                         ExecuteDiagnosticsLevel(0, sensorsTypical, false)
  203.                     end if
  204.             end select
  205.            
  206.         else
  207.             if (diagnosticsDebugging)
  208.                 VA.WriteToLog("AVCS AIDA ERROR: Diagnostics Inline - TryParse Int or Variable error...", "red")
  209.             end if
  210.         end if
  211.        
  212.         VA.SetInt("AVCS_SENS_DIAGNOSTIC_LEVEL", nothing)
  213.         VA.SetBoolean("AVCS_SENS_Diagnostics_Active", nothing)
  214.         VA.SetBoolean("AVCS_SENS_Diagnosing", false)
  215.     End Sub
  216. End Class
Add Comment
Please, Sign In to add comment