Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added loading telemetry from recent TLM text files #3

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions SatsDecoder/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -579,13 +579,24 @@ def __init__(self, master, config, name):
self.dv_frame = DataViewFrame(self)
self.dv_frame.grid(column=1, row=0, rowspan=2, sticky=tk.NSEW, padx=2, pady=2)

def openfiles(self):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

функция внезапно оказалась выше всех остальных. лучше следовать порядку, в котором расположен список источника данных и разместить ее под _hex_values.
ну и название - мы таки открываем файлы или загружаем их?

path = HOMEDIR
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

одноразовое имя - не хорошо

files = filedialog.askopenfilenames(title='Choose packets', initialdir=path, filetypes=(("TLM file", "*.txt"), ("All files", "*.*")))
for f in files:
Comment on lines +584 to +585
Copy link
Owner

@baskiton baskiton Jun 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

тоже одноразовая files, можно прямо по результату функции итерироваться.
также askopenfilenames лучше заменить на askopenfiles, где открытие файла сделается само.
тут же - одна строка в одинарных кавычках, другие в двойных

file = open(f, 'r')
line = file.readline().strip()
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

только одну строку? а если в файле их будет много?
в целом, итерация по строкам уже есть в _hex_values, надо лишь генерализовать, выведя в отдельную функцию для скармливания данных

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Предполагалось, что будут загружаться файлы телеметрии, уже созданные ранее декодером. А в них оригинальный пакет хранится в первой строке.

x = bytes.fromhex(line)
self.feed(x)
file.close()

def named_conn_btn(self, _=None, **kw):
m = utils.ConnMode(self.conn_mode.current())
d = {
utils.ConnMode.AGWPE_CLI: ('Connect', 'Disconnect'),
utils.ConnMode.TCP_CLI: ('Connect', 'Disconnect'),
utils.ConnMode.TCP_SRV: ('Start', 'Stop'),
utils.ConnMode.HEX: ('Run', 'Stop'),
utils.ConnMode.HEX_TXT: ('Load packets', 'Stop'),
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

таки packets или files?

}
self.con_btn.config(text=d[m]['d' in kw])

Expand Down Expand Up @@ -618,9 +629,12 @@ def con(self):
m = utils.ConnMode(self.conn_mode.current())
if m == utils.ConnMode.HEX:
self._hex_values()
elif m == utils.ConnMode.HEX_TXT:
self.openfiles()
else:
self.stop() if self.sk else self._start()


Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

лишнее

def set_merge_mode(self):
if self.decoder.ir:
self.decoder.ir.set_merge_mode(self.merge_mode_v.get())
Expand Down
2 changes: 2 additions & 0 deletions SatsDecoder/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@ class ConnMode(enum.IntEnum):
TCP_CLI = 1
TCP_SRV = 2
HEX = 3
HEX_TXT = 4


con_mode_names = {
ConnMode.AGWPE_CLI: 'AGWPE Client',
ConnMode.TCP_CLI: 'TCP Client',
ConnMode.TCP_SRV: 'TCP Server',
ConnMode.HEX: 'HEX values',
ConnMode.HEX_TXT: 'HEX from TLM file',
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TLM явно лишнее

}


Expand Down