-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
262 lines (202 loc) · 7.65 KB
/
main.py
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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
import customtkinter as ctk
from customtkinter import filedialog
import matplotlib.pyplot as plt
from functions import data_organization
from functions import log_reading_function
def log_file_retriever():
# Open file select dialog to select the miner log
filepath = filedialog.askopenfilename(title="Select the \"miner-state\" or \"long-miner-state log\"")
read_file = open(filepath, "r")
# Read the data in the file opened above
file_header, file_data = log_reading_function.long_miner_state_log_reader(read_file)
read_file.close()
# Open/append read data to the output log to be graphed
output_file = open('functions/output_data.log', 'w')
output_file.write(file_header)
output_file = open('functions/output_data.log', 'a')
for data in file_data:
output_file.write(f'\n{data}')
output_file.close()
def output_file_graphing(file):
(
hashrate_hashboard_avg,
sm0_hashrates, sm0_freqs, sm0_temps, sm0_chips,
sm1_hashrates, sm1_freqs, sm1_temps, sm1_chips,
sm2_hashrates, sm2_freqs, sm2_temps, sm2_chips,
psu_wattages
) = data_organization.output_file_unpacker(file)
hashrate_x, hashrate_y = data_organization.overall_hashrate(hashrate_hashboard_avg)
(
chip_temp_x, chip_temp_y1, chip_temp_y2, chip_temp_y3
) = data_organization.hashboard_chip_temps(sm0_chips, sm1_chips, sm2_chips)
(
freq_x, freq_y1, freq_y2, freq_y3
) = data_organization.hashboard_freqs(sm0_freqs, sm1_freqs, sm2_freqs)
wattage_x, wattage_y = data_organization.overall_wattage(psu_wattages)
# Plot the data on the axes
plt.subplot(2, 2, 1)
plt.plot(hashrate_x, hashrate_y, label='Hashrate')
plt.legend()
plt.autoscale(True)
# plot the data on the axes
plt.subplot(2, 2, 2)
plt.plot(wattage_x, wattage_y, label='PSU Wattage')
plt.legend()
plt.autoscale(True)
# plot the data on the axes
plt.subplot(2, 2, 3)
plt.plot(chip_temp_x, chip_temp_y1, label='SM0 Chip Temp')
plt.plot(chip_temp_x, chip_temp_y2, label='SM1 Chip Temp')
plt.plot(chip_temp_x, chip_temp_y3, label='SM2 Chip Temp')
plt.legend()
plt.autoscale(True)
# plot the data on the axes
plt.subplot(2, 2, 4)
plt.plot(freq_x, freq_y1, label='SM0 Frequency')
plt.plot(freq_x, freq_y2, label='SM1 Frequency')
plt.plot(freq_x, freq_y3, label='SM2 Frequency')
plt.legend()
plt.autoscale(True)
plt.show()
def output_file_hashrate(file):
# Unpack the data from the output file
(
hashrate_hashboard_avg,
sm0_hashrates, sm0_freqs, sm0_temps, sm0_chips,
sm1_hashrates, sm1_freqs, sm1_temps, sm1_chips,
sm2_hashrates, sm2_freqs, sm2_temps, sm2_chips,
psu_wattages
) = data_organization.output_file_unpacker(file)
# Organize the data for the hashrate graph
hashrate_x, hashrate_y = data_organization.overall_hashrate(hashrate_hashboard_avg)
# Create a figure and axes for the hashrate graph
fig1, ax1 = plt.subplots()
# Plot the data on the axes
ax1.plot(hashrate_x, hashrate_y, label='Hashrate')
ax1.legend()
plt.autoscale(True)
plt.show()
def output_file_wattage(file):
# Unpack the data from the output file
(
hashrate_hashboard_avg,
sm0_hashrates, sm0_freqs, sm0_temps, sm0_chips,
sm1_hashrates, sm1_freqs, sm1_temps, sm1_chips,
sm2_hashrates, sm2_freqs, sm2_temps, sm2_chips,
psu_wattages
) = data_organization.output_file_unpacker(file)
# Organize the data for the wattage graph
wattage_x, wattage_y = data_organization.overall_wattage(psu_wattages)
# Create a figure and axes for the wattage graph
fig3, ax3 = plt.subplots()
# Plot the data on the axes
ax3.plot(wattage_x, wattage_y, label='PSU Wattage')
ax3.legend()
plt.autoscale(True)
plt.show()
def output_file_chip_temps(file):
# Unpack the data from the output file
(
hashrate_hashboard_avg,
sm0_hashrates, sm0_freqs, sm0_temps, sm0_chips,
sm1_hashrates, sm1_freqs, sm1_temps, sm1_chips,
sm2_hashrates, sm2_freqs, sm2_temps, sm2_chips,
psu_wattages
) = data_organization.output_file_unpacker(file)
# Organize the data for the chip temperature graph
(
chip_temp_x, chip_temp_y1, chip_temp_y2, chip_temp_y3
) = data_organization.hashboard_chip_temps(sm0_chips, sm1_chips, sm2_chips)
# Create a figure and axes for the chip temperature graph
fig2, ax2 = plt.subplots()
# Plot the data on the axes
ax2.plot(chip_temp_x, chip_temp_y1, label='SM0 Chip Temp')
ax2.plot(chip_temp_x, chip_temp_y2, label='SM1 Chip Temp')
ax2.plot(chip_temp_x, chip_temp_y3, label='SM2 Chip Temp')
ax2.legend()
plt.autoscale(True)
plt.show()
def output_file_frequency(file):
# Unpack the data from the output file
(
hashrate_hashboard_avg,
sm0_hashrates, sm0_freqs, sm0_temps, sm0_chips,
sm1_hashrates, sm1_freqs, sm1_temps, sm1_chips,
sm2_hashrates, sm2_freqs, sm2_temps, sm2_chips,
psu_wattages
) = data_organization.output_file_unpacker(file)
# Organize the data for the frequency graph
(
freq_x, freq_y1, freq_y2, freq_y3
) = data_organization.hashboard_freqs(sm0_freqs, sm1_freqs, sm2_freqs)
# Create a figure and axes for the frequency graph
fig4, ax4 = plt.subplots()
# Plot the data on the axes
ax4.plot(freq_x, freq_y1, label='SM0 Frequency')
ax4.plot(freq_x, freq_y2, label='SM1 Frequency')
ax4.plot(freq_x, freq_y3, label='SM2 Frequency')
ax4.legend()
plt.autoscale(True)
plt.show()
# Create the main window
root = ctk.CTk()
root.title("Log Visualizer")
# Create the file selection button
file_output = ctk.CTkButton(
root,
text="Select File",
command=log_file_retriever
)
# Place the file selection button at (15, 10) in pixels
file_output.place(x=15, y=10, width=115)
# Create the graph all button
graph_all_button = ctk.CTkButton(
root,
text="Graph All",
command=lambda: output_file_graphing(open('functions/output_data.log'))
)
# Place the graph all button at (15, 70) in pixels
graph_all_button.place(x=15, y=70, width=115)
# Create the graph hashrate button
graph_hashrate_button = ctk.CTkButton(
root,
text="Graph Hashrate",
command=lambda: output_file_hashrate(open('functions/output_data.log'))
)
# Place the graph hashrate button at (130, 10) in pixels
graph_hashrate_button.place(x=130, y=10, width=150)
# Create the graph wattage button
graph_wattage_button = ctk.CTkButton(
root,
text="Graph Wattage",
command=lambda: output_file_wattage(open('functions/output_data.log'))
)
# Place the graph wattage button at (130, 50) in pixels
graph_wattage_button.place(x=130, y=50, width=150)
# Create the graph chip temps button
graph_chip_temps_button = ctk.CTkButton(
root,
text="Graph Chip Temps",
command=lambda: output_file_chip_temps(open('functions/output_data.log'))
)
# Place the graph chip temps button at (130, 90) in pixels
graph_chip_temps_button.place(x=130, y=90, width=150)
# Create the graph frequency button
graph_frequency_button = ctk.CTkButton(
root,
text="Graph Frequency",
command=lambda: output_file_frequency(open('functions/output_data.log'))
)
# Place the graph frequency button at (130, 130) in pixels
graph_frequency_button.place(x=130, y=130, width=150)
# Create the close button
close_frame_button = ctk.CTkButton(
root,
text="Close",
command=root.destroy
)
# Place the close button at (15, 130) in pixels
close_frame_button.place(x=15, y=130, width=115)
# Set the size of the main window and start the main loop
root.geometry("280x175")
root.mainloop()