-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmonitor.pas
175 lines (153 loc) · 4.25 KB
/
monitor.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
unit Monitor;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, NvInfo, Graphics, Dialogs, ExtCtrls,
StdCtrls, Spin;
type
{ TFrmMonitor }
TFrmMonitor = class(TForm)
BtnUpdateTimer: TButton;
BtnStartTimer: TButton;
BtnStopTimer: TButton;
GrClock: TGroupBox;
GrGpuTemperature: TGroupBox;
GrCuda: TGroupBox;
GrRefreshRate: TGroupBox;
ImgLogo: TImage;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
LblClockGraphics: TLabel;
LblClockMemory: TLabel;
LblClockGraphicsData: TLabel;
LblClockMemData: TLabel;
LblCudaDriverVersionData: TLabel;
LblCudaDriverVersionMajorData: TLabel;
LblCudaDriverVersionMjor: TLabel;
LblCudaDriverVersion: TLabel;
LblThresholdData: TLabel;
LblTemperatureData: TLabel;
LblTemperature: TLabel;
LblDeviceNameData: TLabel;
LblNvmlVersionData: TLabel;
LblDriverVersionData: TLabel;
LblDeviceIndex: TLabel;
LblDriverVersion: TLabel;
LblDevice: TLabel;
Panel1: TPanel;
ShStatus: TShape;
SpnRefreshRate: TSpinEdit;
TmrUpdater: TTimer;
procedure BtnStartTimerClick(Sender: TObject);
procedure BtnStopTimerClick(Sender: TObject);
procedure BtnUpdateTimerClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure TmrUpdaterTimer(Sender: TObject);
private
public
procedure UpdateSystemInfo;
procedure UpdateCudaInfo;
procedure UpdateTemperatureInfo;
procedure UpdateClockInfo;
end;
var
FrmMonitor: TFrmMonitor;
Status: Boolean = False;
implementation
{$R *.lfm}
{ TFrmMonitor }
procedure TFrmMonitor.TmrUpdaterTimer(Sender: TObject);
begin
TThread.Queue(nil, @UpdateTemperatureInfo);
TThread.Queue(nil, @UpdateClockInfo);
if Status then
ShStatus.Brush.Color := clLime
else
ShStatus.Brush.Color := clGray;
Status := not Status;
end;
procedure TFrmMonitor.FormCreate(Sender: TObject);
begin
TThread.Queue(nil, @UpdateSystemInfo);
TThread.Queue(nil, @UpdateCudaInfo);
end;
procedure TFrmMonitor.BtnStartTimerClick(Sender: TObject);
begin
if not TmrUpdater.Enabled then
TmrUpdater.Enabled := True;
end;
procedure TFrmMonitor.BtnStopTimerClick(Sender: TObject);
begin
if TmrUpdater.Enabled then
TmrUpdater.Enabled := False;
end;
procedure TFrmMonitor.BtnUpdateTimerClick(Sender: TObject);
begin
TmrUpdater.Interval := SpnRefreshRate.Value * 1000;
end;
procedure TFrmMonitor.UpdateSystemInfo;
var
info: TObject;
begin
info := TNvInfoSingleton.NewInstance;
try
(info as TNvInfoSingleton).UpdateSystemInfo;
LblDriverVersionData.Caption := (info as TNvInfoSingleton).DriverVersion;
LblDeviceNameData.Caption := (info as TNvInfoSingleton).DeviceName;
LblNvmlVersionData.Caption := (info as TNvInfoSingleton).NvmlVersion;
except
LblDriverVersionData.Caption := '';
LblDeviceNameData.Caption := '';
LblNvmlVersionData.Caption := '';
end;
end;
procedure TFrmMonitor.UpdateCudaInfo;
var
info: TObject;
begin
info := TNvInfoSingleton.NewInstance;
try
(info as TNvInfoSingleton).UpdateCudaInfo;
LblCudaDriverVersionData.Caption :=
(info as TNvInfoSingleton).CudaDriverVersion.ToString;
LblCudaDriverVersionMajorData.Caption :=
(info as TNvInfoSingleton).CudaDriverVersionMajor.ToString;
except
LblCudaDriverVersion.Caption := '';
LblCudaDriverVersionMajorData.Caption := '';
end;
end;
procedure TFrmMonitor.UpdateTemperatureInfo;
var
info: TObject;
begin
info := TNvInfoSingleton.NewInstance;
try
(info as TNvInfoSingleton).UpdateTemperatureInfo;
LblTemperatureData.Caption :=
(info as TNvInfoSingleton).DeviceTemperature.ToString;
LblThresholdData.Caption :=
(info as TNvInfoSingleton).DeviceTemperatureThreshold.ToString;
except
LblTemperatureData.Caption := '';
LblThresholdData.Caption := '';
end;
end;
procedure TFrmMonitor.UpdateClockInfo;
var
info: TObject;
begin
info := TNvInfoSingleton.NewInstance;
try
(info as TNvInfoSingleton).UpdateClockInfo;
LblClockGraphicsData.Caption :=
(info as TNvInfoSingleton).DeviceClockGraphics.ToString;
LblClockMemData.Caption :=
(info as TNvInfoSingleton).DeviceClockMemory.ToString;
except
LblClockGraphicsData.Caption := '';
LblClockMemData.Caption := '';
end;
end;
end.