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

Rescore upon reading the log #292

Merged
merged 13 commits into from
Jan 4, 2022
Merged

Rescore upon reading the log #292

merged 13 commits into from
Jan 4, 2022

Conversation

zcsahok
Copy link
Member

@zcsahok zcsahok commented Nov 24, 2021

Too simple to be true. :-) But let's see.

Here is an example: in the OK-OM contest I didn't set ONE_POINT, so all QSOs were scored with zero points. Mults were configured correctly, so that part is fine.
image

Added the missing ONE_POINT to the rule file and restarted Tlf: now I've 39 points for the 39 QSOs.
image

All QSOs were on 80, so as a test I moved the one with section MYJ to 40. I worked MYJ on 80 before, so the net result is that I "earn" it as a new one on 40. This operation was done from within Tlf using :EDIt, no restart was required.
image

As discussed in #248 the log itself is not updated (currently neither on disk nor in memory), hence the lines still show 0 points in the screenshots above. This could be seen as bug, but the fix must be discussed.

@zcsahok zcsahok linked an issue Nov 24, 2021 that may be closed by this pull request
@dl1jbe
Copy link
Member

dl1jbe commented Nov 25, 2021

Too simple to be true. :-) But let's see.

Yes, that step was obvious. If you compare old code in readcalls() and the code in addcall() carefully you will find some subtle differences in handling of corner cases like arrl contests for the w/ve side. I was not quite sure which behavior is the right one, so I hesitated from the simple change before understanding all implications. But lets go on.

As discussed in #248 the log itself is not updated (currently neither on disk nor in memory), hence the lines still show 0 points in the screenshots above. This could be seen as bug, but the fix must be discussed.

I think it can be made simple (but not without some changes). Let us keep the parsed records ('struct qso_t') and add them to a ptr array. That array would be a complete internal representation of all qsos and comments.

Than we can reconstruct the display line from the record when needed for display. That way it will always be up to date.

As an additional side effect it enables us later to generate the display line in different width (and detail) as soon as we support a variable display width in xterm

Both ideas were the main reason to introduce the 'struct qso'. To keep it simple I just started in spring with only the struct and left out the collection of all structs in the array for later.

As a sidenote, let me ask to keep the commits a little more clean. Having the unrelated changes for station info or scoring in the same commit makes it harder in the review to focus on the real core of the commit.

@zcsahok
Copy link
Member Author

zcsahok commented Nov 25, 2021

re station info: it had to be moved before reading the log (country has to be known) and since it used plain printw's it got partially obscured by readcalls' output (via showmsg with its internal line number tracking), hence the rework.

@dl1jbe
Copy link
Member

dl1jbe commented Nov 26, 2021

re station info: it had to be moved before reading the log (country has to be known) and since it used plain printw's it got partially obscured by readcalls' output (via showmsg with its internal line number tracking), hence the rework.

Oh, thanks. I missed that point.


total = 0;
nr_qsolines = readcalls(logfile);
if (qtcdirection > 0) {
readqtccalls();
Copy link
Member Author

Choose a reason for hiding this comment

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

On startup readqtccalls() is called before readcalls(). Hopefully the order is not relevant.

Copy link
Member

Choose a reason for hiding this comment

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

Not quite sure. That needs to be checked.

Copy link
Member

Choose a reason for hiding this comment

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

See issue #310


// dummy functions
void readqtccalls() {}
void shownr(char *msg, int x) {}
void spaces(int n) {} /* needs more care */
const char *spaces(int n) { return "";} /* needs more care */
Copy link
Member Author

Choose a reason for hiding this comment

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

Dummies for getexchange...

@zcsahok
Copy link
Member Author

zcsahok commented Nov 26, 2021

Will add (probably next week) updating the in-memory log using makelogline.
If there were changes the user will be asked whether to update the log on disk.

@zcsahok
Copy link
Member Author

zcsahok commented Dec 3, 2021

Fixed (or at least improved) WPX rescoring. For this the add_pfx call hidden in makelogline had to be moved to addcall where it logically belongs. The somewhat obscure excl_add_veto flag thus could be made local. The condition for WPX has been changed to a hopefully more readable form (if not excluded || not pfxab). I'm not sure if this is actually correct, though.
For the sake of addcall2 tests excl_add_veto has been kept as excl_add_veto2 (will be removed later together with addcall2 as soon we get to the networking part...). Plain addcall tests now check countryscore instead.


init_scoring();

if ((fp = fopen(logfile, "r")) == NULL) {
showmsg("Error opening logfile ");
refreshp();
Copy link
Member Author

Choose a reason for hiding this comment

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

Already done in showmsg()

@zcsahok
Copy link
Member Author

zcsahok commented Dec 5, 2021

Log lines are re-created using makelogline() and checked against the ones in the file. If a change is detected then once all lines are loaded user is prompted if they want to save (update) the log. Previous log is backed up as <timestamp>_<logfilename>.

Next makelogline() has to be "de-globalized". This will also involve replacing linedata_t with qso_t.

@dl1jbe
Copy link
Member

dl1jbe commented Dec 5, 2021

The somewhat obscure excl_add_veto flag thus could be made local.

I did some checks for that variable and tried to make some comments about its working - see dl1jbe@842feaf

@dl1jbe
Copy link
Member

dl1jbe commented Dec 5, 2021

The condition for WPX has been changed to a hopefully more readable form (if not excluded || not pfxab). I'm not sure if this is actually correct, though.

I will try to check the handling in the existing code and compare with older versions. Maybe we can sort it out.

bool log_changed = false;
// array of qso's
// FIXME use this instead of qsos[] (make it global and don't free it here)
// FIXME also include comments/notes into qso_t
Copy link
Member

Choose a reason for hiding this comment

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

We could just add a 'iscomment' flag and a pointer to the comment string or save some memory by using a union union from the actual qso_t and the comment field pointer.

@zcsahok
Copy link
Member Author

zcsahok commented Dec 5, 2021

Ideally scoring and mult handling shall be independent of whether the QSO originated locally, received from network or read from a file. Therefore any veto logic have to be an internal detail of the processing.

@dl1jbe
Copy link
Member

dl1jbe commented Dec 5, 2021

We are on the way to it.
I think the best point is that the rules are now conentrated on a single place. In old code we had two places to keep in sync.

comment[4] = 'X';
comment[5] = '\0';
char buf[80];
strcpy(buf, qso->comment);
Copy link
Member Author

Choose a reason for hiding this comment

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

Change a private copy of comment.

@zcsahok
Copy link
Member Author

zcsahok commented Dec 6, 2021

Unless there are issues to fix this is it for the moment. I'd let it get used to see if other problems pop up.
There's still a long way ahead: swapping qsos[] with an array of qso_t and moving all QSO-related globals to qso_t are both major changes that have to be done mid term.

@zcsahok
Copy link
Member Author

zcsahok commented Dec 20, 2021

Let me know if you see something open here. If there are none then I'd merge this and also close #248.

Copy link
Member

@dl1jbe dl1jbe left a comment

Choose a reason for hiding this comment

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

Besides the question about 'freq' if no rig control is active I think all should be well.

Please double check and feel free to merge it in afterwards.


/* add points to logline if in contest */
if (iscontest && !CONTEST_IS(DXPED)) {
sprintf(logline4 + 76, "%2d", qso_points);
sprintf(logline + 76, "%2d", qso_points); //FIXME qso->score
Copy link
Member

Choose a reason for hiding this comment

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

Yes, we should keep ALL information for the qso after evaluating it with addcall/addmult.
Question is - should we just extend qso_t or use the parsed data as part of another struct which provides the additional data (points, zone, cty, ...)

if (trx_control) {
snprintf(freq_buff, 8, "%7.1f", freq / 1000.0);
strcat(logline4, freq_buff);
if (qso->freq > 0) {
Copy link
Member

Choose a reason for hiding this comment

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

If someone use TLF without radio control is freq then set to 0.?
At the moment we do not record a frequency in these case.

Copy link
Member Author

Choose a reason for hiding this comment

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

trx_control tells whether rig control is currently in use, whereas qso->freq > 0 checks if freq was known at the time of the QSO. Generally this could have been earlier or even currently but on another Tlf node. So relying on trx_control is not correct.

If trx control is disabled while Tlf is running then freq is not set to zero (previous value is kept). Similarly if trx control is enabled then rig connection is not initialized, freq stays zero. IMO both are bugs.

addcall(qso);
score_qso(); //FIXME argument?

char *logline = makelogline(qso);
Copy link
Member

Choose a reason for hiding this comment

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

After finishing all migration away from qsos[], we do not need to record such things as points, multis or prefixes in the written log.
The we could drop these check for a change of logfile. The file would be the same as long as we do not change some of the qso information (time, call, exchange, band...).
But that leads us again to a discussion of logfile format. We should keep that for later.

src/readcalls.c Outdated
char *backup = g_strdup_printf("%s_%s", prefix, logfile);
rename(logfile, backup);
// rewrite log
remove(logfile);
Copy link
Member

Choose a reason for hiding this comment

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

There should be no 'logfile' after the rename.

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed

@zcsahok zcsahok merged commit ceef327 into Tlf:master Jan 4, 2022
@dl1jbe
Copy link
Member

dl1jbe commented Jan 5, 2022 via email

@zcsahok zcsahok deleted the rescore_log branch February 26, 2022 18:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TLF should calculate points and multis on every start
2 participants