Skip to content

Commit

Permalink
Remove i-nex-cpusage. Add MCPUSAGE.module. Convert from C to Gambas lang
Browse files Browse the repository at this point in the history
  • Loading branch information
eloaders committed Sep 7, 2016
1 parent 80c627a commit 113187f
Show file tree
Hide file tree
Showing 10 changed files with 158 additions and 1,464 deletions.
16 changes: 9 additions & 7 deletions I-Nex/i-nex/.settings
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ File[16]=".src/Input_Devices.module:0.48"
File[17]=".src/Network.module:34.10"
File[18]=".src/Distribution_Detect.module:20.28"
File[19]=".src/FFlags.module:20.0"
File[20]=".src/Finfosys.class:20.329"
File[20]=".src/Finfosys.class:21.1031"
File[21]=".src/FNET_R_T.form"
File[22]=".src/FNET_R_T.class:7.70"
File[23]=".src/FGraphic.module:1.8"
Expand Down Expand Up @@ -78,23 +78,25 @@ File[47]=".src/FDirDialog.class:0.65"
File[48]=".src/FFileDialog.class:75.2"
File[49]=".src/FInputDate.class:0.52"
File[50]=".src/Reports/FCPUID_REPORT.module:44.14"
File[51]=".src/MCPUSAGE.module:20.20"
File[51]=".src/MCPUSAGE.module:34.101"
File[52]=".src/Reports/VALIDATE.module:61.15"
File[53]=".src/FValidate.form"
File[54]=".src/FValidate.class:0.1"
File[55]=".src/FCopyUrl.form"
File[56]=".src/FCopyUrl.class:22.3"
File[57]=".src/MStart.module:19.15"
File[57]=".src/MStart.module:16.19"
File[58]=".src/FSystemInfo.class:63.72"
File[59]=".src/FSystemInfo.form"
File[60]=".src/MConvert.module:20.0"
File[61]=".src/VCore.module:0.0"
File[62]=".src/Main.module:0.0"
File[63]=".src/i2c.module:10.9"
File[64]=".src/MDecode_dimms.module:23.31"
Active=20
Count=65
File[65]="Data/screenfetch-dev:6.4945"
File[64]=".src/MDecode_dimms.module:0.246"
Active=67
Count=67
File[65]="Data/screenfetch-dev:0.3399"
File[66]=".src/JEDEC.module:27.54"
File[67]=".src/MUptime.module:21.20"

[Watches]
Count=0
Expand Down
15 changes: 7 additions & 8 deletions I-Nex/i-nex/.src/Finfosys.class
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ Public Sub Form_Open()
Dim MTRR As New String[]
Logs("Starting log", Logger.Info)
ComboBox10.Visible = False
Object.Call(MCPUSAGE, "GetUSAGE")
''Okno na środku
''
If Settings["Window/X"] = Null Then
Expand Down Expand Up @@ -262,7 +261,9 @@ Public Sub Form_Open()
Timer1.Start
Timer1.Delay = 1500
TextLabel21.Visible = False


Logs("Set Combobox to cpu0", Logger.Info)
ComboBox1.Index = 0 ''Ustawienie combobox na Procesor0 / W przeciwnym wypadku nie pokaże nic
'Uruchomienie instrukcji dla poszczególnych zakładek w celu wydobycia informacji z systemu
Logs("Check Dospam uptime", Logger.Info)
dospam_uptime()
Expand All @@ -277,9 +278,6 @@ Public Sub Form_Open()
Logs("Check graphic card", Logger.Info)
grafika()
''END Uruchomienie instrukcji dla poszczególnych zakładek w celu wydobycia informacji z systemu
Logs("Set Combobox to cpu0", Logger.Info)
ComboBox1.Index = 0 ''Ustawienie combobox na Procesor0 / W przeciwnym wypadku nie pokaże nic

Label25.Text = Application.version
Logs(Label25.Text, Logger.Info)
TabStrip1_Click()
Expand Down Expand Up @@ -701,8 +699,8 @@ Public Sub dospam_uptime()

If IsNull(MEMINFO_FILE) = True Then
MEMINFO_FILE = Open "/proc/meminfo"
Else
MEMINFO_FILE = Open MStart.MEMINFO_FILE
' Else
' MEMINFO_FILE = Open MStart.MEMINFO_FILE
Endif

For Each sLine In MEMINFO_FILE.Lines
Expand Down Expand Up @@ -1001,6 +999,7 @@ End
Public Sub Timer1_Timer()
''Refresh temp 1500/ms
dospam_uptime()

'Check for temperature on this machine is supported.
'See "thermal_zone". You can add own code.
thermal_zone._inits
Expand All @@ -1020,6 +1019,7 @@ Public Sub Timer1_Timer()
Try LCDLabel3.Text = VCore.CoreVoltage
Try LCDLabel3.Visible = VCore.Visible
'Fix me if english translation is wrong.
MCPUSAGE.proc_stat()
End

Public Sub Button6_Click()
Expand Down Expand Up @@ -1218,7 +1218,6 @@ Public Sub Form_Close()
Settings["Tab/Pos"] = TabStrip1.Orientation
Logs("Good bye!", Logger.Info)
DATAT.Clear
MCPUSAGE.CPUusage.Kill
Me.Close

End
Expand Down
4 changes: 2 additions & 2 deletions I-Nex/i-nex/.src/Finfosys.form
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,7 @@
Move(133,462,329,14)
#Translate = False
Font = Font["Bold,8"]
ToolTip = "CPU Usage"
ToolTip = "CPU usage by the current core or thread"
}
Index = 1
Text = "GPU"
Expand Down Expand Up @@ -1650,7 +1650,7 @@
}
}
{ HPanel6 HPanel
Move(119,168,336,224)
Move(0,168,336,224)
Expand = True
{ Label85 Label
Move(0,0,168,28)
Expand Down
122 changes: 110 additions & 12 deletions I-Nex/i-nex/.src/MCPUSAGE.module
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
' Gambas module file

' Copyright(C) 2011-2014, Michał Głowienka aka eloaders <eloaders@linux.pl>
' Copyright(C) 2011-2016, Michał Głowienka aka eloaders <eloaders@linux.pl>
'
' This program is free software; you can redistribute it and/or modify
' it under the terms of the GNU General Public License as published by
Expand All @@ -14,18 +14,116 @@
'
' You should have received a copy of the GNU General Public License
' along with this program. If not, see <http://www.gnu.org/licenses/>.
Public CPUusage As Process
Private CPUusageOutput As String
Public Sub GetUSAGE()

CPUusage = Exec ["/usr/bin/i-nex-cpusage"] For Input Output As "CPUusage"
Public Sub proc_stat()
Dim PREV_STAT_PROC As File
Dim CURRENT_STAT_PROC As File
Dim sLine As String
Dim iPos As Integer
Dim Character As Integer
Dim sKey As String
Dim sVal As String
Dim PREV_SELT As String[]
Dim CURRENT_SELT As String[]
Dim prev_user As Integer
Dim prev_nice As Integer
Dim prev_System As Integer
Dim prev_idle As Integer
Dim prev_iowait As Integer
Dim prev_irq As Integer
Dim prev_softirq As Integer
Dim prev_steal As Integer
Dim prev_guest As Integer
Dim prev_guest_nice As Integer
Dim current_user As Integer
Dim current_nice As Integer
Dim current_System As Integer
Dim current_idle As Integer
Dim current_iowait As Integer
Dim current_irq As Integer
Dim current_softirq As Integer
Dim current_steal As Integer
Dim current_guest As Integer
Dim current_guest_nice As Integer
Dim PrevIdle As Integer
Dim Idle As Integer
Dim PrevNonIdle As Integer
Dim NonIdle As Integer
Dim PrevTotal As Integer
Dim Total As Integer
Dim totald As Integer
Dim idled As Integer

PREV_STAT_PROC = Open "/proc/stat"

For Each sLine In PREV_STAT_PROC.Lines
sLine = Trim(sLine)
If Not sLine Then Continue

End
iPos = InStr(sLine, " ")
If iPos = 0 Then Continue

Public Sub CPUusage_read()
Dim CPUusageLines As String[]
Line Input #CPUusage, CPUusageOutput
CPUusagelines = Split(CPUusageOutput, "\n")
Finfosys.ProgressBar7.Value = CInt(CFloat(CPUusageLines[0])) / 100
End
sKey = Trim(Left$(sLine, iPos - 1))
sVal = Trim(Mid$(sLine, iPos + 1))

Select Case sKey
Case Finfosys.ComboBox1.Text
PREV_SELT = Scan(sVal, "* * * * * * * * * *")
prev_user = CInt(PREV_SELT[0])
prev_nice = CInt(PREV_SELT[1])
prev_system = CInt(PREV_SELT[2])
prev_idle = CInt(PREV_SELT[3])
prev_iowait = CInt(PREV_SELT[4])
prev_irq = CInt(PREV_SELT[5])
prev_softirq = CInt(PREV_SELT[6])
'prev_steal = CInt(CURRENT_SELT[7])
' prev_guest = CInt(CURRENT_SELT[8])
' prev_guest_nice = CInt(CURRENT_SELT[9])
End Select
Next

Close #PREV_STAT_PROC

Wait 1

CURRENT_STAT_PROC = Open "/proc/stat"

For Each sLine In CURRENT_STAT_PROC.Lines
sLine = Trim(sLine)
If Not sLine Then Continue

iPos = InStr(sLine, " ")
If iPos = 0 Then Continue

sKey = Trim(Left$(sLine, iPos - 1))
sVal = Trim(Mid$(sLine, iPos + 1))

Select Case sKey
Case Finfosys.ComboBox1.Text
CURRENT_SELT = Scan(sVal, "* * * * * * * * * *")
current_user = CInt(CURRENT_SELT[0])
current_nice = CInt(CURRENT_SELT[1])
current_system = CInt(CURRENT_SELT[2])
current_idle = CInt(CURRENT_SELT[3])
current_iowait = CInt(CURRENT_SELT[4])
current_irq = CInt(CURRENT_SELT[5])
current_softirq = CInt(CURRENT_SELT[6])
'current_steal = CInt(CURRENT_SELT[7])
' current_guest = CInt(CURRENT_SELT[8])
' current_guest_nice = CInt(CURRENT_SELT[9])
End Select
Next

Close #CURRENT_STAT_PROC

PrevIdle = (prev_idle + prev_iowait)
Idle = (current_idle + current_iowait)
PrevNonIdle = (prev_user + prev_nice + prev_system + prev_irq + prev_softirq) ' + prev_steal
NonIdle = (current_user + current_nice + current_system + current_irq + current_softirq) '+ current_steal
PrevTotal = (PrevIdle + PrevNonIdle)
Total = (Idle + NonIdle)
totald = (Total - PrevTotal)
idled = (Idle - PrevIdle)

Finfosys.ProgressBar7.Value = (totald - idled) / totald
End
2 changes: 1 addition & 1 deletion I-Nex/i-nex/.src/MDecode_dimms.module
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ Public Sub _inits()
spd_data[96],
spd_data[97],
spd_data[98])

Case Else
MANUFACTURER = "Unknown"
DRAM_MANUFACTURER = "Unknown"
Expand Down
25 changes: 25 additions & 0 deletions I-Nex/i-nex/.src/MUptime.module
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
' Gambas module file

Public Sub _inits()
Dim sLine As String
Dim iPos As Integer
Dim SUptime As String
Dim SIdle As String
Dim UPTIME_FILE As File

If IsNull(UPTIME_FILE) = True Then
UPTIME_FILE = Open "/proc/uptime"
Endif

For Each sLine In UPTIME_FILE.Lines
sLine = Trim(sLine)
If Not sLine Then Continue
Print Left$(sLine, (InStr(sLine, ".") - 1)) / 60
Print Left$(sLine, (InStr(sLine, ".") - 1)) / 60 / 60
Print (4319 / 60) / 60
Next
'Print Time(00, 00, 3600)
Close #UPTIME_FILE
'awk '{printf("%d:%02d:%02d:%02d",($1/60/60/24),($1/60/60%24),($1/60%60),($1%60))}' /proc/uptime

End
33 changes: 2 additions & 31 deletions JSON/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ else
endif

make-binary: compile-i-nex-edid \
compile-i-nex-cpuid \
compile-i-nex-cpusage \
compile-i-nex-glinfo
compile-i-nex-cpuid

compile-i-nex-edid:
@echo -e '$(OK_COLOR)Compile i-nex-edid $(OK_STRING)$(NO_COLOR)'
Expand All @@ -21,33 +19,17 @@ compile-i-nex-cpuid:
@echo -e '$(OK_COLOR)Compile i-nex-cpuid $(OK_STRING)$(NO_COLOR)'
$(CC) -o i-nex-cpuid i-nex-cpuid.c $(CC_OPTS_LIBCPUID) $(additional_confflags)

compile-i-nex-cpusage:
@echo -e '$(OK_COLOR)Compile i-nex-cpusage $(OK_STRING)$(NO_COLOR)'
$(CC) -o i-nex-cpusage i-nex-cpusage.c $(additional_confflags)

compile-i-nex-glinfo:
@echo -e '$(OK_COLOR)Compile i-nex-glinfo $(OK_STRING)$(NO_COLOR)'
$(CC) -o i-nex-glinfo glinfo_common.c i-nex-glinfo.c $(libx11) $(libgl) $(libxext) $(additional_confflags)

install: install-set-executables install-bin
install-set-executables: set-executable-i-nex-edid \
set-executable-i-nex-cpuid \
set-executable-i-nex-cpusage \
set-executable-i-nex-glinfo
set-executable-i-nex-cpuid

set-executable-i-nex-edid:
chmod +x i-nex-edid
set-executable-i-nex-cpuid:
chmod +x i-nex-cpuid
set-executable-i-nex-cpusage:
chmod +x i-nex-cpusage
set-executable-i-nex-glinfo:
chmod +x i-nex-glinfo

install-bin: install-bin-i-nex-edid \
install-bin-i-nex-cpuid \
install-bin-i-nex-cpusage \
install-bin-i-nex-glinfo \
install-bin-i-nex-dimms


Expand All @@ -58,15 +40,6 @@ install-bin-i-nex-edid:
install-bin-i-nex-cpuid:
test -d $(DESTDIR)$(bindir) || mkdir $(DESTDIR)$(bindir)
$(INSTALL) 0755 i-nex-cpuid $(DESTDIR)$(bindir)
install-bin-i-nex-usage:
test -d $(DESTDIR)$(bindir) || mkdir $(DESTDIR)$(bindir)
$(INSTALL) 0755 i-nex-usage $(DESTDIR)$(bindir)
install-bin-i-nex-cpusage:
test -d $(DESTDIR)$(bindir) || mkdir $(DESTDIR)$(bindir)
$(INSTALL) 0755 i-nex-cpusage $(DESTDIR)$(bindir)
install-bin-i-nex-glinfo:
test -d $(DESTDIR)$(bindir) || mkdir $(DESTDIR)$(bindir)
$(INSTALL) 0755 i-nex-glinfo $(DESTDIR)$(bindir)
install-bin-i-nex-dimms:
test -d $(DESTDIR)$(bindir) || mkdir $(DESTDIR)$(bindir)
$(INSTALL) 0755 i-nex-dimms $(DESTDIR)$(bindir)
Expand All @@ -75,5 +48,3 @@ clean:
$(RM_COM) $(RMFILE_OPT) i-nex-edid
$(RM_COM) $(RMFILE_OPT) i-nex-cpuid
$(RM_COM) $(RMFILE_OPT) i-nex-usage
$(RM_COM) $(RMFILE_OPT) i-nex-cpusage
$(RM_COM) $(RMFILE_OPT) i-nex-glinfo

0 comments on commit 113187f

Please sign in to comment.