Skip to content

Commit c5bb118

Browse files
committed
add usp-specific dating images name
1 parent 0ceec65 commit c5bb118

2 files changed

Lines changed: 33 additions & 2 deletions

File tree

SatsDecoder/systems/usp.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
#
66
# SPDX-License-Identifier: MIT
77

8+
import pathlib
9+
810
import construct
911

1012
from SatsDecoder import utils
@@ -1477,12 +1479,22 @@
14771479
class UspImageReceiver(ImageReceiver):
14781480
def __init__(self, outdir):
14791481
super().__init__(outdir, '.jpg')
1482+
self.last_fname = ''
1483+
1484+
def re_fname(self, fname, t):
1485+
if fname and self.dated_img:
1486+
if fname == self.last_fname:
1487+
t = self.last_date
1488+
self.last_fname = fname
1489+
x = pathlib.Path(fname)
1490+
return str(x.with_stem(x.stem + '_' + self.strftime(t)))
1491+
return fname
14801492

14811493
def generate_fid(self, fname='', force=0, t=None):
14821494
if self.current_fid.startswith('unknown_') and fname:
1483-
self.rename_image(self.current_fid, fname)
1495+
self.rename_image(self.current_fid, self.re_fname(fname, t))
14841496
elif force or not (self.current_fid and self.merge_mode):
1485-
self.current_fid = fname or f'USP_unknown_{self.strftime(t)}'
1497+
self.current_fid = self.re_fname(fname, t) or f'USP_unknown_{self.strftime(t)}'
14861498
return self.current_fid
14871499

14881500
def push_data(self, data, t=None, **kw):

SatsDecoder/ui.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -591,6 +591,18 @@ def __init__(self, master, config, name):
591591
self.new_btn = ttk.Button(self.ctrl_frame, text='New image', command=self.new_img)
592592
self.new_btn.grid(column=4, row=2, sticky=tk.EW, pady=3, padx=3)
593593

594+
# specific ctrl
595+
self.specific_frame = tk.Frame(self.ctrl_frame)
596+
self.specific_frame.grid(column=0, columnspan=5, row=3, sticky=tk.EW)
597+
self.specific_cfg = {}
598+
if self.proto == 'usp':
599+
cfg_name = 'usp dated image'
600+
self.specific_cfg[cfg_name] = self.usp_dated_img_v = tk.IntVar(self.specific_frame, int(config.get(cfg_name, 0)))
601+
self.usp_dated_img_ckb = ttk.Checkbutton(self.specific_frame, text='Dated images',
602+
variable=self.usp_dated_img_v, command=self.usp_set_dated_img)
603+
self.usp_dated_img_ckb.grid(column=0, row=0, sticky=tk.EW, pady=3)
604+
self.usp_set_dated_img()
605+
594606
# history frame
595607
self.history_frame = HistoryFrame(self, config)
596608
self.history_frame.grid(column=0, row=1, sticky=tk.NSEW, padx=2, pady=2)
@@ -684,6 +696,10 @@ def new_img(self):
684696
self.dv_frame.set_img(img, 1)
685697
self.history_frame.put('img', self.proto, *args)
686698

699+
def usp_set_dated_img(self):
700+
if self.decoder.ir and self.proto == 'usp':
701+
self.decoder.ir.set_dated_img(self.usp_dated_img_v.get())
702+
687703
def stop(self, _=None):
688704
if self.sk:
689705
s = self.sk
@@ -1069,6 +1085,9 @@ def close_df(self, name, df):
10691085
self.config.set(name, 'filter', str(';'.join(k for k, v in df.history_frame.filters.items() if v.get())))
10701086
self.config.set(name, 'autoscroll', str(df.history_frame.autoscroll_val.get()))
10711087

1088+
for k, v in df.specific_cfg.items():
1089+
self.config.set(name, k, str(v.get()))
1090+
10721091
def about(self, evt=None):
10731092
seq = queue.Queue(5)
10741093
img = img_l = None

0 commit comments

Comments
 (0)