Skip to content

Commit

Permalink
Add Option to set CPU Vendor from env
Browse files Browse the repository at this point in the history
Example:

env INEXCPU_VENDOR="Pentium(R) Dual-Core CPU       T4200  "
./inex.gambas
  • Loading branch information
eloaders committed Feb 15, 2014
1 parent 3f438c4 commit bd6b6d3
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 32 deletions.
60 changes: 36 additions & 24 deletions src/i-nex/.src/FCpudb.module
Original file line number Diff line number Diff line change
Expand Up @@ -19,33 +19,45 @@ Public Logs As New Logger
Public i As Integer
Public database As Collection
Public Sub _inits()
Dim buffer, cpucache As String
Dim buffer As String
Dim cpucache As String
Dim z As Integer
Select Case Finfosys.Label14.Text
Case Like "*Opteron*"
Logs("Use AMD Opteron CPU Database", Logger.Info)
buffer = File.Load("Database/Opteron")
Case Like "*amd*"
Logs("Use AMD CPU Database", Logger.Info)
buffer = File.Load("Database/amd")
Case Like "*Xeon*"
Logs("Use Intel Xeon CPU Database", Logger.Info)
buffer = File.Load("Database/Xeon")
Case Like "*atom*"
Logs("Use Intel Atom CPU Database", Logger.Info)
buffer = File.Load("Database/atom")
Case Like "*intel*"
Logs("Use Intel CPU Database", Logger.Info)
buffer = File.Load("Database/intel")
Case Like "*Pentium*"
Logs("Use Intel CPU Database", Logger.Info)
buffer = File.Load("Database/intel")
End Select
If Application.Env["INEXCPU_VENDOR"] = Null Then
Logs("Not Use CPU Vendor from ENV", Logger.Info)
Else
Logs("Use CPU Vendor from ENV", Logger.Info)
Finfosys.Label14.Text = Application.Env["INEXCPU_VENDOR"]
Endif
' The use Of the database In JSON format.To decode the information about the processor.
' The database Is Divided into several parts To the model processor manufacturer.
'
If Finfosys.Label14.Text Like "*Opteron*" Then 'Use Opteron databese if TextBox Like Opteron
Logs("Use AMD Opteron CPU Database", Logger.Info)
buffer = File.Load("Database/Opteron") 'Load the database to a temporary buffer
Else If Finfosys.Label14.Text Like "*amd*" Then
Logs("Use AMD CPU Database", Logger.Info)
buffer = File.Load("Database/amd") 'Load the database to a temporary buffer
Else If Finfosys.Label14.Text Like "*Xeon*" Then 'Use Xeon databese if TextBox Like Xeon
Logs("Use Intel Xeon CPU Database", Logger.Info)
buffer = File.Load("Database/Xeon") 'Load the database to a temporary buffer
Else If Finfosys.Label14.Text Like "*atom*" Then
Logs("Use Intel Atom CPU Database", Logger.Info)
buffer = File.Load("Database/atom") 'Load the database to a temporary buffer
Else If Finfosys.Label14.Text Like "*intel*" Then
Logs("Use Intel CPU Database", Logger.Info)
buffer = File.Load("Database/intel") 'Load the database to a temporary buffer
Else If Finfosys.Label14.Text Like "*Pentium*" Then
Logs("Use Intel CPU Database", Logger.Info)
buffer = File.Load("Database/intel") 'Load the database to a temporary buffer
Endif

Logs("Decode CPU Database", Logger.Info)
database = JSON.Decode(buffer)
database = JSON.Decode(buffer) 'Convert JSON data to Collection
buffer = Null
cpucache = Finfosys.Label14.Text
Logs("Replace CPU Strings to Null", Logger.Info)

'For the purpose of the database, certain words have to be converted to an empty value.
cpucache = Replace(Replace(Replace(Replace(cpucache, "with", "*"), "APU", "*"), "Graphics", "*"), "Radeon", "*")
cpucache = Replace(Replace(Replace(Replace(Replace(Replace(Replace(cpucache, "Intel", ""), " ", "*"), "R", ""), "CPU", ""), "TM", ""), ")", ""), "(", "")
cpucache = Replace(Replace(Replace(Replace(Replace(cpucache, "AMD", "*"), "Core", "*"), "Dual", "*"), "Processor", "*"), "tm", "*")
Expand All @@ -55,15 +67,14 @@ Public Sub _inits()
If database["DATABASE"][z]["PROCESSOR_MODEL_NAME"] Like "*" & cpucache & "*" Then

Finfosys.PictureBox3.Picture = Picture["Database/Logos/" & database["DATABASE"][z]["PROCESSOR_SOCKET_IMAGE"] & ""]
'Finfosys.PictureBox3.Picture = Picture["Database/Logos/306.gif"]
Finfosys.Label103.Text = " Integrated GPU: " & database["DATABASE"][z]["PROCESSOR_INTEGRATEDGRAPHIC"]
Finfosys.Label104.Text = " TDP: " & database["DATABASE"][z]["PROCESSOR_TDP"]
Finfosys.Label110.Text = " PPS: " & database["DATABASE"][z]["PROCESSOR_PROCESS_SIZE"]
Finfosys.Label111.Text = " Socket: " & database["DATABASE"][z]["PROCESSOR_SOCKET"]
Finfosys.Label112.Text = " Transistors: " & database["DATABASE"][z]["PROCESSOR_TRANSISTORS"]
Finfosys.Label113.Text = " Die size: " & database["DATABASE"][z]["PROCESSOR_DIE_SIZE"]
Finfosys.Label114.Text = " Package: " & database["DATABASE"][z]["PROCESSOR_PACKAGE"]
Finfosys.Label115.Text = " Tcasemax: " & database["DATABASE"][z]["PROCESSOR_TCASEMAX"]
Finfosys.Label115.Text = " TCaseMax: " & database["DATABASE"][z]["PROCESSOR_TCASEMAX"]
Finfosys.Label116.Text = " Turboclock: " & database["DATABASE"][z]["PROCESSOR_TURBOCLOCK"]
Finfosys.Label117.Text = " Multiplier: " & database["DATABASE"][z]["PROCESSOR_MULTIPLIER"]
Finfosys.Label118.Text = " Voltage: " & database["DATABASE"][z]["PROCESSOR_VOLTAGE"]
Expand All @@ -75,4 +86,5 @@ Public Sub _inits()
Endif
Next
Logs("Current position of processor = " & cpucache & " is = " & z & "", Logger.Info)
database = Null
End
26 changes: 18 additions & 8 deletions src/i-nex/.src/Start_App_Args.class
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,25 @@ Public Sub Form_Open()
Select Case Application.Args[1]

Case "--help"
Print ("" & Application.name & "" & Application.version & " running on:\n\nArchitecture: " & System.Architecture & ""
"\nSystem Family: " & System.Family & ""
"\nGambas Version: " & System.FullVersion & ""
"\nSystem Charset: " & System.Charset & ""
"\nHostname: " & System.Host & ""
Print ("\n " & Application.name & " " & Application.version & " running on:\n"
"\n Architecture: " & System.Architecture & ""
"\n"
"\nUsage: " & Application.name & ".gambas [Options]"
"\nOptions:"
"\n--help (Chow Help)")
"\n System Family: " & System.Family & ""
"\n Gambas Version: " & System.FullVersion & ""
"\n System Charset: " & System.Charset & ""
"\n Hostname: " & System.Host & ""
"\n "
"\n Usage: env VARIABLE=\"STRING\" " & Application.name & ".gambas [Options]"
"\n Options:"
"\n --help (Chow Help)"
"\n"
"\n Env Variables:"
"\n"
"\n INEXCPU_VENDOR"
"\n"
"\n Example:"
"\n"
"\n env INEXCPU_VENDOR=\"Pentium(R) Dual-Core CPU T4200 \" ./i-nex.gambas")
S = False
Me.Close

Expand Down

0 comments on commit bd6b6d3

Please sign in to comment.