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

Python plugin doesn't work with mult map #446

Open
VictorDenisov opened this issue Oct 16, 2024 · 15 comments
Open

Python plugin doesn't work with mult map #446

VictorDenisov opened this issue Oct 16, 2024 · 15 comments

Comments

@VictorDenisov
Copy link
Contributor

When mult handling is done by python plugin it breaks mult map. Invoking mult map shows an empty list of multipliers.

@airween
Copy link
Member

airween commented Oct 16, 2024

Could you show your config to reproduce the issue?

@VictorDenisov
Copy link
Contributor Author

Github doesn't allow me to attach python file or logcfg dat. I tried adding mult_list configuration option but it doesn't help because multipliers are processed by the python plugin and python plugin doesn't have any methods for returning full list of expected multipliers

@airween
Copy link
Member

airween commented Oct 18, 2024

Github doesn't allow me to attach python file or logcfg dat.

You can copy the content of those files and paste here, into the comment field. Please enclose them by a ``` separator, like this:

\```
import re

# match trailing call modifier (e.g. /8, /P, /MM, /QRP, etc.)
MODIFIER_PATTERN = re.compile('/(\d|[A-Z]+)$')
...
\```

(Don't put the leading \ in front of ```)

For more info please take a look at the Github formatting.

@VictorDenisov
Copy link
Contributor Author

Rules

########################
# General contest mode #
########################
#
CONTEST_MODE
LOGFILE=sst.log
CABRILLO=UNIVERSAL
#ONE_POINT
#SERIAL_OR_SECTION
GENERIC_MULT=BAND
MULT_LIST=sst_mults
#SECTION_MULT
NO_RST
PLUGIN_CONFIG=hello
#
##################################
#                                #
#  Messages F1= to F12=          #
#  Message CQ_TU_MSG=            #
#  Message S&P_TU_MSG=           #
#                                #
#  % = call                      #
#  @ = hiscall                   #
#  # = serial                    #
#  [ = RST                       #
#  + = increase cw speed         #
#  - = decrease cw speed         #
#                                #
##################################
#
F1=cq sst %
F2=@ DE %
F3=vic ca
F4=TU 
F5=@
F6=%
F7=@ SRI QSO B4 GL
F8=AGN
F9= ?
F10= QRZ?
F11= PSE K
F12=cq sst %
#
CQ_TU_MSG=TU %
S&P_TU_MSG=vic ca
#
#ALT_0=
ALT_1=ca
ALT_2=qth?
ALT_3=vic
ALT_4=name?
#ALT_5=
#ALT_6=
#ALT_7=
#ALT_8=
#ALT_9=
#
#SEND_DE
#
CABRILLO-QSO-FORMAT=SST
CABRILLO-EXCHANGE=vic ca
CABRILLO-CONTEST=
####### END #####################

@VictorDenisov
Copy link
Contributor Author

Python code:

"""
NAQP contest
https://ncjweb.com/NAQP-Rules.pdf
"""

countries = ['CA', 'AL', 'AK', 'AZ', 'AR', 'CO', 'CT', 'DE', 'FL', 'GA', 'HI', 'ID', 'IL', 'IN', 'IA',
'KS', 'KY', 'LA', 'ME', 'MD', 'MA', 'MI', 'MN', 'MS', 'MO', 'MT', 'NE', 'NV', 'NH', 'NJ',
'NM', 'NY', 'NC', 'ND', 'OH', 'OK', 'OR', 'PA', 'RI', 'SC', 'SD', 'TN', 'TX', 'UT', 'VT',
'VA', 'WA', 'WV', 'WI', 'WY', 'DC',
# Canada
'NB', 'NL', 'NS', 'PE', 'QC', 'ON', 'MB', 'SK', 'AB', 'BC', 'NT', 'NU', 'YT',
# Other countries
'4U1/u', '6Y', '8P', 'C6', 'CM', 'CY9', 'CY0', 'FG', 'FJ', 'FM', 'FO', 'FP', 'FS',
'HH', 'HI', 'HK0', 'HP', 'HR', 'J3', 'J6', 'J7', 'J8', 'KG4', 'KP1', 'KP2', 'KP4',
'KP5', 'OX', 'PJ5', 'PJ7', 'TG', 'TI', 'TI9', 'V2', 'V3', 'V4', 'VP2E', 'VP2M', 'VP2V',
'VP5', 'VP9', 'XE', 'XF4', 'YN', 'YS', 'YV0', 'ZF']

def score(qso):
    return 1

def check_exchange(qso):
    parts = qso.exchange.split()

    file1 = open("myfile.txt" , "a" )
    file1.write(" ".join(parts))


    file1.close()

    mult = ''
    if len(parts) == 2:
        if parts[1] in countries:
            mult = parts[1]
        else:
            mult = ''
    else:
        mult = ''
    return {'mult1_value': mult}

@VictorDenisov
Copy link
Contributor Author

RULES=sst
#
#################################
#                               #
#         LOGCFG.DAT            #
#                               #
#  Uncomment the options you    #
#  want to enable.              #
#  See 'man tlf'                #
#  for a description of the     #
#  options. You can keep diff-  #
#  erent versions for different #
#  contests. I keep separate    #
#  configuration files for      #
#  each contest. If you enable  #
#  more than 1 mutually exclu-  #
#  sive options, the last one   #
#  will be efective.            #
#                               #
#                               #
#################################
#
#CTCOMPATIBLE
#
#################################
#                               #
#   EDITOR                      #
#                               #
#################################
#
#EDITOR=nano
#EDITOR=joe
EDITOR=nvim
#EDITOR=e3
#EDITOR=mcedit
#
#################################
#                               #
#  CALL                         #
#                               #
#################################
#
CALL=N6DVS
#
#
#################################
#                               #
#  Time offset from UTC         #
#                               #
#################################
#
TIME_OFFSET=0
TIME_MASTER
#
#################################
#                               #
#  LAN PORT                     #
#                               #
#################################
#  use 'addnode' only for OTHER nodes !!
#
#ADDNODE=10.0.0.115
#ADDNODE=192.168.1.2
#
THISNODE=A
#
#LAN_DEBUG
#
#################################
#                               #
#  KEYERPORT                    #
#                               #
#################################
#
NETKEYER
#NETKEYERPORT=6789
#NETKEYERHOST=127.0.0.1
#
#################################
#                               #
#  KEYERPARAMETERS              #
#                               #
#################################
#---speed (6 ... 60 wpm)
CWSPEED=25
#---weight (-5 ... 5 ms)
WEIGHT=0
#---cq delay (in 0.5 s units)
CQDELAY=28
#---txdelay (ms)
TXDELAY=2
#---sidetone (200...800, 0 = mute)
CWTONE=400
#################################
#                               #
#  PACKET INTERFACE             #
#                               #
#################################
# Check the web for DX cluster nodes with telnet access
#TELNETHOST=aaa.bbb.ccc.ddd
#TELNETPORT=8000
# automatic login ###############
#CLUSTERLOGIN=yourcall
# write log to disk #############
#CLUSTER_LOG
#
# use tnc instead of telnet #####
#TNCPORT=/dev/ttyS0
#TNCPORT=/dev/ttyUSB1
#TNCSPEED=2400
#
# get clusterinfo from network ##
#FIFO_INTERFACE
#
#################################
#                               #
#  RADIO CONTROL                #
# (comment out if not present)  #
# Rigmodel = Hamlib index, here #
#           for ten tec OMNI VI #
#################################
#
RADIO_CONTROL
RIGMODEL=2045
RIGSPEED=38400
#RIGPORT=/dev/ttyS0
RIGPORT=/dev/ttyUSB0
#RIGPTT
#
#SSBMODE
#
#RIT_CLEAR
#
#################################
#                               #
#  INFORMATION WINDOWS          #
#                               #
#################################
#
#CLUSTER
BANDMAP=S,900  # skip dupes, 900s lifetime
#FILTER
#
SCOREWINDOW
#
CHECKWINDOW
#################################
#                               #
#  CHECK PARTIAL FUNCTION       #
#                               #
#################################
# 
PARTIALS
#USEPARTIALS
#
#################################
#                               #
#  CABRILLO                     #
#                               #
#################################
#
# Note: some of these logically
# belong to the rule file
#
#-------------------------------
# Example values for internal configs.
# These are not written to the Cabrillo file.
# Default value for all 3 fields below is empty (unset).
#
# The sent exchange. # stands for QSO number
CABRILLO-EXCHANGE= # trin
# Example for fixed exchange (e.g. CQ WW):
#CABRILLO-EXCHANGE= 14
#
# A template with fields having the semantics as below.
# The template is processed when the config is evaluated.
# Note that in Cabrillo file the separator is ':'.
#CABRILLO-TEMPLATE= station.cbr
#
# Format of QSO/QTC lines.
# Same as the CABRILLO keyword, but can also be used in a template.
CABRILLO-QSO-FORMAT= UNIVERSAL
# or alternatively
#CABRILLO= UNIVERSAL

# Cabrillo header fields
#   * value not in parentheses e.g. "9ACW" taken as-is
#   * value in parentheses e.g. "(YES,NO)" will be asked interactively with that hint
#   * a single dash "-" value disables the field (neither asked nor output)
#   * field name without equal sign just enables the field
#
# >>> The values below are the defaults. <<<
# The order of the fields follows the fixed output order.
#
CABRILLO-CONTEST=SST
# Callsign is the same as the one given by CALL. Can't be set or disabled.
CABRILLO-CATEGORY-ASSISTED=NON-ASSISTED
CABRILLO-CATEGORY-BAND=ALL
CABRILLO-CATEGORY-MODE=CW
CABRILLO-CATEGORY-OPERATOR=SINGLE-OP
CABRILLO-CATEGORY-POWER=LOW
CABRILLO-CATEGORY-STATION=FIXED
CABRILLO-CATEGORY-TIME= (6-HOURS, 12-HOURS, 24-HOURS)
CABRILLO-CATEGORY-TRANSMITTER=ONE
CABRILLO-CATEGORY-OVERLAY= (ROOKIE, TB-WIRES, NOVICE-TECH, OVER-50)
CABRILLO-CERTIFICATE= -
# Score is replaced with the calculated score. It can be disabled but not set.
CABRILLO-CLAIMED-SCORE= 0
CABRILLO-CLUB=
CABRILLO-LOCATION=CA
# Locator automatically filled, if enabled and MYQRA is set
CABRILLO-GRID-LOCATOR= -
CABRILLO-NAME=Vic
CABRILLO-EMAIL= -
# 3 generic address lines available
CABRILLO-ADDRESS=
CABRILLO-ADDRESS(2)= -
CABRILLO-ADDRESS(3)= -
CABRILLO-ADDRESS-CITY= -
CABRILLO-ADDRESS-STATE-PROVINCE= -
CABRILLO-ADDRESS-POSTALCODE= -
CABRILLO-ADDRESS-COUNTRY= -
CABRILLO-OPERATORS= (space delimited)
CABRILLO-OFFTIME= (yyyy-mm-dd hhmm yyyy-mm-dd hhmm)
# 3 soapbox lines available
CABRILLO-SOAPBOX= (use any text editor to include more lines)
CABRILLO-SOAPBOX(2)= -
CABRILLO-SOAPBOX(3)= -
#
#################################
#                               #
#  CONDX (info for muf calc.)   #
#                               #
#################################
#
SOUNDCARD
SUNSPOTS=30
SFI=100
# Note: set only one of them, preferred is SUNSPOTS
# These are initial values only,
# they get updated by WWV or WCY messages.
#
#################################
#                               #
#     Misc commands             #
#                               #
#################################
# No automatic 'qso before msg'
NOB4
#
# No automatic cq
#NOAUTOCQ
#
# Left/right arrows don't change band...
#NO_BANDSWITCH_ARROWKEYS
#
# Marker file for Xplanet
#MARKERS=tlfmarkers
# or for just dots
#MARKERDOTS=tlfmarkers
# or for dots+calss
#MARKERCALLS=tlfmarkers
#
#HAMLIB_KEYER
#############END#################

@VictorDenisov
Copy link
Contributor Author

VictorDenisov commented Oct 19, 2024

Maybe I should clarify that python plugin doesn't break the mult list feature. This feature just doesn't work with mults handled by python plugin. I renamed the ticket accordingly.

@VictorDenisov VictorDenisov changed the title Python support breaks mult map Python plugin doesn't work with mult map Oct 19, 2024
@VictorDenisov
Copy link
Contributor Author

I checked code that prints out multipliers and it looks like it only works if it's ARRL sweepstakes contest and section list is a multiplier: https://github.com/Tlf/tlf/blob/master/src/changepars.c#L763

@VictorDenisov
Copy link
Contributor Author

@zcsahok Do you have any proposals as to the best way to implement multiplier list feature for python plugin? My first thought is to add a standard method that python plugins should implement to return full list of multipliers.

@zcsahok
Copy link
Member

zcsahok commented Oct 20, 2024

@VictorDenisov Thanks for bringing up this issue.
When designing the plugin concept the main focus was on the ability to provide correct scoring capability. Multiplier screen was regarded as a prio 2 feature and thus postponed for later. There are a bunch of cans of worms here, so let's just open them one at a time.

There are three flavors of multiplier summary screens:

  • :MUL executes multiplierinfo() which handles Sweepstakes and section configuration. All other cases result in an empty screen. This is what you were experiencing.
  • Alt-M or :CTY calls show_mults() which after handling FOCM and CQWW falls back to multiplierinfo().
    :CTY is supposed to show countries, but it does this only for FOCM and CQWW.
  • Alt-Z: shows zones for CQWW. For other contests it falls back to :MUL.

For sections multiplierinfo() uses strstr() for comparison, which leads to false evaluation when a multiplier string is part of another mult.
It shows only the first 4 characters of the multiplier, which again shows false results for say NAQP that uses 5-char multipliers.
So there are enough issues to fix, even without the plugin story.

But back to the original issue: how about this solution?
Plugin would provide an optional function get_multiplier_info() that returns a (potentially multi-line) string.
This string serves either as just a list of all mults to be handled by the legacy section code part,
or it contains a sort of a simple template that is interpreted and then shown to the user.

The two cases are -

  • no formatting ('{' char) detected:
    • interpret the value as a whitespace separated list of multipliers and show them in the legacy format
    • note: mults are not sorted, they are shown in the order specified
  • else:
    {@n} - evaluate further mults on band N only (default: any band), no output is generated
    {ABC} - if not yet worked according the current band selection then show the value, else show as dots.
    - for the "any band" evaluation the legacy 6-char */- string is appended
    • center the whole multi-line string vertically and per line horizontally
    • if text doesn't fit vertically on one screen then allow scrolling
    • lines longer than 80 chars are silently truncated

This would allow to specify for a 2-band contest the info like this:

Band A B C
40m{@40}  {A} {B} {C}
80m{@80}  {A} {B} {C}

with the resulting output if B has been worked on both bands and C only on 80:

   Band A B C
   40m  A . C
   80m  A . .

@VictorDenisov
Copy link
Contributor Author

Yes. get_multiplier_info() makes sense to me. Can you clarify the second format. Is this exact format that you propose:

Band A B C
40m{@40}  {A} {B} {C}
80m{@80}  {A} {B} {C}

And we detect if this format is used by checking if {} symbols are present in the returned string at all?

@zcsahok
Copy link
Member

zcsahok commented Oct 27, 2024

Yes, that woud be the multiline-string returned by get_multiplier_info(). The easiest way to recognize if it's a template string is just look for '{'. Of course, then '{' shall not be used in plain strings. But as the plain strings contain just the multipliers this is not an issue.

@zcsahok
Copy link
Member

zcsahok commented Jan 7, 2025

https://github.com/zcsahok/tlf/tree/poc_show_mults has the first draft of get_multiplier_info() support.

Added examples for NAQP and MWC.

  • NAQP uses the simple interface by providing the list of multipliers. The use of some basic formatting (line breaks and alignment) is also demonstrated.
    image

  • MWC shows the template approach as this contest runs on 2 bands only.
    image

@df7cb
Copy link
Contributor

df7cb commented Jan 8, 2025

The multiplier markings in the bandmap also ignore the multiplier info from python.

@zcsahok
Copy link
Member

zcsahok commented Jan 8, 2025

@df7cb yes, just saw it this morning, addressed by #453

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

No branches or pull requests

4 participants