Skip to content
This repository was archived by the owner on Dec 25, 2025. It is now read-only.

Commit a4b1873

Browse files
committed
Cache comment for new QSO
1 parent af6f5dd commit a4b1873

3 files changed

Lines changed: 108 additions & 4 deletions

File tree

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ Types marked with auto are prefilled but can be overwritten. Types marked with m
132132
| Callsign | xx9xx | | format checked |
133133
| Locator/QTH | @xx99xx or @QTH(Locator) | | format checked |
134134
| Name | 'xxxx | | _ for spaces |
135-
| Comment | #xxxx | | _ for spaces |
135+
| Comment | #xxxx | memory | _ for spaces |
136136
| Band | valid ADIF band | memory | |
137137
| Mode | valid ADIF mode | memory | |
138138
| RST rcvd | .599 | auto | default CW 599, phone 59 |
@@ -143,8 +143,8 @@ Types marked with auto are prefilled but can be overwritten. Types marked with m
143143
| Time | HHMMt | memory | partly time will be filled |
144144
| Date | YYYYMMDDd | memory | partly date will be filled |
145145
| Date/Time | = | auto | sync date/time to now |
146-
| Frequency | 99999f | | in kHz |
147-
| TX Power | 99p | | in W |
146+
| Frequency | 99999f | memory | in kHz |
147+
| TX Power | 99p | memory | in W |
148148
| Your Call | -cxx9xx | memory | |
149149
| Your Locator | -lxx99xx | memory | |
150150
| Your Name | -nxxxx | memory | _ for spaces |

src/hamcc/hamcc.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ def __init__(self, my_call: str = '', my_loc: str = '', my_name: str = '',
129129
# Optional
130130
self.__freq__ = init_qso.get('FREQ', '')
131131
self.__pwr__ = init_qso.get('TX_PWR', '')
132+
self.__comment__ = init_qso.get('COMMENT', '')
132133

133134
# Special
134135
self.__event__ = event
@@ -242,6 +243,8 @@ def clear(self):
242243
self.__cur_qso__['TX_PWR'] = self.__pwr__
243244
if self.__freq__:
244245
self.__cur_qso__['FREQ'] = self.__freq__
246+
if self.__comment__:
247+
self.__cur_qso__['COMMENT'] = self.__comment__
245248

246249
if self.__event__:
247250
self.clear_event()
@@ -274,6 +277,7 @@ def reset(self):
274277
# Optional
275278
self.__freq__ = ''
276279
self.__pwr__ = ''
280+
self.__comment__ = ''
277281

278282
# Special
279283
self.__event__ = ''
@@ -600,8 +604,10 @@ def evaluate(self, seq: str) -> str:
600604
elif seq.startswith('#'): # Comment
601605
if seq == '#':
602606
self.__cur_qso__.pop('COMMENT', '')
607+
self.__comment__ = ''
603608
return ''
604-
self.__cur_qso__['COMMENT'] = seq[1:].replace('_', ' ')
609+
self.__comment__ = seq[1:].replace('_', ' ')
610+
self.__cur_qso__['COMMENT'] = self.__comment__
605611
elif seq.startswith('\''): # Name
606612
if seq == '\'':
607613
self.__cur_qso__.pop('NAME', '')

test/test_instantiate.py

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,104 @@ def test_20_exception(self):
1515
self.assertRaises(Exception, hamcc.CassiopeiaConsole, 'XX1XXX222', 'AA11aa')
1616
self.assertRaises(Exception, hamcc.CassiopeiaConsole, 'XX1XXX', 'AA11zz')
1717

18+
def test_30_init_qso(self):
19+
init_qso = {
20+
'STATION_CALLSIGN': 'XX1XXX',
21+
'MY_GRIDSQUARE': 'AA11aa',
22+
'QSO_DATE': '20241122',
23+
'TIME_ON': '2233',
24+
'BAND': '2M',
25+
'MODE': 'SSB',
26+
'CALL': '1Y1YY',
27+
'GRIDSQUARE': 'BB22bb',
28+
'MY_NAME': 'Tester',
29+
'COMMENT': 'Test Comment',
30+
'FREQ': '123456',
31+
'TX_PWR': '23',
32+
'NAME': 'Nobody',
33+
}
34+
35+
init_res = {
36+
'STATION_CALLSIGN': 'XX1XXX',
37+
'MY_GRIDSQUARE': 'AA11aa',
38+
'QSO_DATE': '20241122',
39+
'TIME_ON': '2233',
40+
'BAND': '2M',
41+
'MODE': 'SSB',
42+
'CALL': '',
43+
'GRIDSQUARE': '',
44+
'MY_NAME': 'Tester',
45+
'COMMENT': 'Test Comment',
46+
'RST_RCVD': '59',
47+
'RST_SENT': '59',
48+
'FREQ': '123456',
49+
'TX_PWR': '23',
50+
}
51+
52+
cc = hamcc.CassiopeiaConsole('XX1XXX', 'AA11aa', 'Tester',
53+
init_qso=init_qso)
54+
55+
self.assertDictEqual(init_res, cc.current_qso)
56+
57+
def test_40_qso(self):
58+
qso = [
59+
'20241122d',
60+
'2233t',
61+
'2m',
62+
's',
63+
'1Y1YY',
64+
'@BB22bb',
65+
'#Test_Comment',
66+
'123456f',
67+
'23p',
68+
'\'Nobody',
69+
]
70+
71+
qso_res = {
72+
'STATION_CALLSIGN': 'XX1XXX',
73+
'MY_GRIDSQUARE': 'AA11aa',
74+
'QSO_DATE': '20241122',
75+
'TIME_ON': '2233',
76+
'BAND': '2m',
77+
'MODE': 'SSB',
78+
'CALL': '1Y1YY',
79+
'NAME': 'Nobody',
80+
'GRIDSQUARE': 'BB22bb',
81+
'MY_NAME': 'Tester',
82+
'COMMENT': 'Test Comment',
83+
'RST_RCVD': '59',
84+
'RST_SENT': '59',
85+
'FREQ': '123.456',
86+
'TX_PWR': '23',
87+
}
88+
89+
new_qso = {
90+
'STATION_CALLSIGN': 'XX1XXX',
91+
'MY_GRIDSQUARE': 'AA11aa',
92+
'QSO_DATE': '20241122',
93+
'TIME_ON': '2233',
94+
'BAND': '2m',
95+
'MODE': 'SSB',
96+
'CALL': '',
97+
'GRIDSQUARE': '',
98+
'MY_NAME': 'Tester',
99+
'COMMENT': 'Test Comment',
100+
'RST_RCVD': '59',
101+
'RST_SENT': '59',
102+
'FREQ': '123.456',
103+
'TX_PWR': '23',
104+
}
105+
106+
cc = hamcc.CassiopeiaConsole('XX1XXX', 'AA11aa', 'Tester')
107+
108+
for e in qso:
109+
self.assertEqual('', cc.evaluate(e))
110+
111+
self.assertDictEqual(qso_res, cc.current_qso)
112+
self.assertIn('Last QSO cached: 1Y1YY', cc.append_char('\n'))
113+
114+
self.assertDictEqual(new_qso, cc.current_qso)
115+
18116

19117
if __name__ == '__main__':
20118
unittest.main()

0 commit comments

Comments
 (0)