~eloaders/i-nex/I-Nex

« back to all changes in this revision

Viewing changes to src/i-nex/.src/FCpudb.module

  • Committer: eloaders
  • Date: 2014-07-15 16:31:30 UTC
  • Revision ID: git-v1:64e92b39f32ea7a292985dee67d4c6de1333f9fa
Move src to I-Nex

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
' Gambas module file
2
 
 
3
 
' Copyright(C) 2011-2014, Michał Głowienka aka eloaders <eloaders@linux.pl>
4
 
'
5
 
' This program is free software; you can redistribute it and/or modify
6
 
' it under the terms of the GNU General Public License as published by
7
 
' the Free Software Foundation; either version 3 of the License, or
8
 
' (at your option) any later version.
9
 
'
10
 
' This program is distributed in the hope that it will be useful,
11
 
' but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 
' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 
' GNU General Public License for more details.
14
 
'
15
 
' You should have received a copy of the GNU General Public License
16
 
' along with this program. If not, see <http://www.gnu.org/licenses/>.
17
 
 
18
 
Public Logs As New Logger
19
 
Public i As Integer
20
 
Public database As Collection
21
 
Public Sub _inits()
22
 
  Dim buffer As String
23
 
  Dim cpucache As String
24
 
  Dim z As Integer
25
 
  If Application.Env["INEXCPU_VENDOR"] = Null Then
26
 
   Logs("Not Use CPU Vendor from ENV", Logger.Info)
27
 
  Else
28
 
   Logs("Use CPU Vendor from ENV", Logger.Info)
29
 
   Finfosys.Label14.Text = Application.Env["INEXCPU_VENDOR"]
30
 
  Endif
31
 
  ' The use Of the database In JSON format.To decode the information about the processor. 
32
 
  ' The database Is Divided into several parts To the model processor manufacturer.
33
 
  ' 
34
 
  If Finfosys.Label14.Text Like "*Opteron*" Then 'Use Opteron databese if TextBox Like Opteron
35
 
   Logs("Use AMD Opteron CPU Database", Logger.Info)
36
 
    buffer = File.Load("Database/Opteron") 'Load the database to a temporary buffer
37
 
    Finfosys.Label14.Text = Replace(Finfosys.Label14.Text, "AMD", "")
38
 
  Else If Finfosys.Label14.Text Like "*amd*" Then
39
 
   Logs("Use AMD CPU Database", Logger.Info)
40
 
    buffer = File.Load("Database/amd") 'Load the database to a temporary buffer
41
 
    Finfosys.Label14.Text = Replace(Finfosys.Label14.Text, "AMD", "")
42
 
  Else If Finfosys.Label14.Text Like "*Xeon*" Then 'Use Xeon databese if TextBox Like Xeon
43
 
   Logs("Use Intel Xeon CPU Database", Logger.Info)
44
 
    buffer = File.Load("Database/Xeon") 'Load the database to a temporary buffer
45
 
    Finfosys.Label14.Text = Replace(Finfosys.Label14.Text, "Intel", "")
46
 
  Else If Finfosys.Label14.Text Like "*atom*" Then
47
 
   Logs("Use Intel Atom CPU Database", Logger.Info)
48
 
    buffer = File.Load("Database/atom") 'Load the database to a temporary buffer
49
 
    Finfosys.Label14.Text = Replace(Finfosys.Label14.Text, "Intel", "")
50
 
  Else If Finfosys.Label14.Text Like "*intel*" Then
51
 
   Logs("Use Intel CPU Database", Logger.Info)
52
 
    buffer = File.Load("Database/intel") 'Load the database to a temporary buffer
53
 
    Finfosys.Label14.Text = Replace(Finfosys.Label14.Text, "Intel", "")
54
 
  Else If Finfosys.Label14.Text Like "*Pentium*" Then
55
 
   Logs("Use Intel CPU Database", Logger.Info)
56
 
    buffer = File.Load("Database/intel") 'Load the database to a temporary buffer
57
 
  Endif
58
 
  
59
 
  Logs("Decode CPU Database", Logger.Info)
60
 
  database = JSON.Decode(buffer) 'Convert JSON data to Collection
61
 
  buffer = Null
62
 
  cpucache = Finfosys.Label14.Text
63
 
  Logs("Replace CPU Strings to Null", Logger.Info)
64
 
  
65
 
  'For the purpose of the database, certain words have to be converted to an empty value.
66
 
  cpucache = Replace(Replace(Replace(Replace(cpucache, "with", "*"), "APU", "*"), "Graphics", "*"), "Radeon", "*")
67
 
  'Fix for APU with Radeon(TM) R7 Graphics
68
 
   cpucache = Replace(cpucache, "R7", "")
69
 
  '
70
 
  cpucache = Replace(Replace(Replace(Replace(Replace(Replace(Replace(cpucache, "Intel", ""), " ", "*"), "R", ""), "CPU", ""), "TM", ""), ")", ""), "(", "")
71
 
  cpucache = Replace(Replace(Replace(Replace(cpucache, "AMD", "*"), "Dual-Core", "*"), "Processor", "*"), "tm", "*")
72
 
  cpucache = Replace(cpucache, "HD", "*")
73
 
  
74
 
  If cpucache Like "*Eight-Core*" Or "*Triple-Core*" Or "*Six-Core*" Or "*Quad-Core*" Then
75
 
   cpucache = Replace(cpucache, "Eight-Core", "")
76
 
   cpucache = Replace(cpucache, "Triple-Core", "")
77
 
   cpucache = Replace(cpucache, "Six-Core", "")
78
 
   cpucache = Replace(cpucache, "Quad-Core", "")
79
 
  Endif
80
 
  
81
 
  cpucache = Replace(cpucache, "Core2", "Core 2")
82
 
  
83
 
  If cpucache Like "*Quad*" Or "*Core*" Or "*Dual*" Then
84
 
   cpucache = Replace(cpucache, "Quad", "")
85
 
   cpucache = Replace(cpucache, "Core", "")
86
 
   cpucache = Replace(cpucache, "Dual", "")
87
 
  Endif
88
 
  
89
 
  For z = 0 To database["DATABASE"].Count - 1
90
 
    If database["DATABASE"][z]["PROCESSOR_MODEL_NAME"] Like "*" & cpucache & "*" Then 
91
 
      Finfosys.PictureBox3.Name = database["DATABASE"][z]["PROCESSOR_SOCKET_IMAGE"]
92
 
      Finfosys.PictureBox3.Picture = Picture["Database/Logos/" & database["DATABASE"][z]["PROCESSOR_SOCKET_IMAGE"] & ""]
93
 
      Finfosys.Label103.Text = " Integrated GPU: " & database["DATABASE"][z]["PROCESSOR_INTEGRATEDGRAPHIC"]
94
 
      Finfosys.Label104.Text = " TDP: " & database["DATABASE"][z]["PROCESSOR_TDP"]
95
 
      Finfosys.Label110.Text = " PPS: " & database["DATABASE"][z]["PROCESSOR_PROCESS_SIZE"]
96
 
      Finfosys.Label111.Text = " Socket: " & database["DATABASE"][z]["PROCESSOR_SOCKET"]
97
 
      Finfosys.Label112.Text = " Transistors: " & database["DATABASE"][z]["PROCESSOR_TRANSISTORS"]
98
 
      Finfosys.Label113.Text = " Die size: " & database["DATABASE"][z]["PROCESSOR_DIE_SIZE"]
99
 
      Finfosys.Label114.Text = " Package: " & database["DATABASE"][z]["PROCESSOR_PACKAGE"]
100
 
      Finfosys.Label115.Text = " TCaseMax: " & database["DATABASE"][z]["PROCESSOR_TCASEMAX"]
101
 
      Finfosys.Label116.Text = " Turboclock: " & database["DATABASE"][z]["PROCESSOR_TURBOCLOCK"] 
102
 
      Finfosys.Label117.Text = " Multiplier: " & database["DATABASE"][z]["PROCESSOR_MULTIPLIER"]
103
 
      Finfosys.Label118.Text = " Voltage: " & database["DATABASE"][z]["PROCESSOR_VOLTAGE"]
104
 
      Finfosys.Label119.Text = " Codename: " & database["DATABASE"][z]["PROCESSOR_CODENAME"]
105
 
      Finfosys.Label120.Text = " Part: " & database["DATABASE"][z]["PROCESSOR_PART"]
106
 
      Finfosys.Label121.Text = " Memory support: " & database["DATABASE"][z]["PROCESSOR_MEMORYSUPPORT"]
107
 
      i = z
108
 
    Endif
109
 
  Next
110
 
  Logs("Current position of processor = " & cpucache & " is = " & z & "", Logger.Info)
111
 
  Logs("Detect CPU As = " & database["DATABASE"][i]["PROCESSOR_MODEL_NAME"] & "", Logger.Info)
112
 
  Logs("\nIf Detected CPU is wrong CPU. \n"
113
 
       "Please submit report at forum \n"
114
 
       "http://forum.i-nex.pl/ \n", Logger.Info)
115
 
  database = Null
116
 
End