From e02d5f43ab67ebae3409c5617c9a55838bb48734 Mon Sep 17 00:00:00 2001 From: zcsahok Date: Mon, 8 Jul 2024 19:50:32 +0000 Subject: [PATCH] add EU-DX rules --- rules/eudx/eudx | 44 ++++++++++++++++++ rules/eudx/eudx.py | 87 +++++++++++++++++++++++++++++++++++ test/rules/eudx/eudx.log | 11 +++++ test/rules/eudx/logcfg.dat | 2 + test/rules/eudx/rules/eudx | 1 + test/rules/eudx/rules/eudx.py | 1 + 6 files changed, 146 insertions(+) create mode 100644 rules/eudx/eudx create mode 100644 rules/eudx/eudx.py create mode 100644 test/rules/eudx/eudx.log create mode 100644 test/rules/eudx/logcfg.dat create mode 120000 test/rules/eudx/rules/eudx create mode 120000 test/rules/eudx/rules/eudx.py diff --git a/rules/eudx/eudx b/rules/eudx/eudx new file mode 100644 index 00000000..c75e600d --- /dev/null +++ b/rules/eudx/eudx @@ -0,0 +1,44 @@ +######################## +# EU-DX contest # +######################## +# https://www.eudx-contest.com/rules/ +# +# Provided by: HA5CQZ +# +CONTEST_MODE +LOGFILE=eudx.log + +CABRILLO=UNIVERSAL +CABRILLO-CONTEST=EUDXC + +#================================ +# Select one of following blocks: +#-------------------------------- +# +# non-EU stations send ITU zone +# +#CABRILLO-EXCHANGE=00 +#F3=@ ++5NN-- 00 +#S&P_TU_MSG=TU ++5NN-- 00 +#PLUGIN_CONFIG=DX +#-------------------------------- +# +# EU stations send region code +# +CABRILLO-EXCHANGE=XX00 +F3=@ ++5NN-- XX00 +S&P_TU_MSG=TU ++5NN-- XX00 +PLUGIN_CONFIG=IT +#================================ + +MIXED + +# Scoring: +# (handled by eudx.py) + + +# Multipliers: +# EU regions and DXCC countries per band +# (handled by eudx.py) +GENERIC_MULT=BAND + diff --git a/rules/eudx/eudx.py b/rules/eudx/eudx.py new file mode 100644 index 00000000..6e082445 --- /dev/null +++ b/rules/eudx/eudx.py @@ -0,0 +1,87 @@ +""" +EU-DX contest +https://www.eudx-contest.com/ +""" +import re + +MY_COUNTRY = None +MY_PREFIX = None +MY_CONTINENT = None + +EU_REGION_PATTERN = re.compile('([A-Z]{2})\d{2}') # two letters and two numbers + +EU_COUNTRIES = ['AT', 'BE', 'BG', 'CZ', 'CY', 'HR', 'DK', 'EE', + 'FI', 'FR', 'DE', 'GR', 'HU', 'IE', 'IT', 'LV', + 'LT', 'LX', 'MT', 'NL', 'PL', 'PT', 'RO', 'SK', + 'SI', 'ES', 'SE'] + +# +# - EU stations shall provide their ISO_3166-1_alpha-2 country code +# as used in the contest (NOT the DXCC country code) +# - non-EU stations shall use simply DX +# +def init(cfg): + global MY_COUNTRY + if cfg in EU_COUNTRIES: + MY_COUNTRY = cfg + else: + MY_COUNTRY = 'DX' # normalize to DX + + dxcc = tlf.get_dxcc(tlf.MY_CALL) + global MY_PREFIX + MY_PREFIX = dxcc.main_prefix + global MY_CONTINENT + MY_CONTINENT = dxcc.continent + + +# a. European Union stations: +# - your own country 2 points, +# - another European Union country 10 points, +# - with a non-European Union country in your continent 3 points, +# - another continent 5 points. +# b. Non- European Union stations: +# - European Union 10 points, +# - your own country 2 points, +# - a different country in your continent 3 points, +# - another continent 5 points. +def score(qso): + xchg = qso.exchange.strip() + + m = EU_REGION_PATTERN.match(xchg) + if m: + eu_country = m.group(1) + else: + eu_country = None + + if MY_COUNTRY != 'DX': + if eu_country == MY_COUNTRY: + return 2 + if eu_country: + return 10 + dxcc = tlf.get_dxcc(qso.call) + if dxcc.continent == MY_CONTINENT: + return 3 + else: + return 5 + else: + if eu_country: + return 10 + dxcc = tlf.get_dxcc(qso.call) + if dxcc.main_prefix == MY_PREFIX: + return 2 + if dxcc.continent == MY_CONTINENT: + return 3 + else: + return 5 + + + +def check_exchange(qso): + xchg = qso.exchange.strip() + dxcc = tlf.get_dxcc(qso.call) + mult = dxcc.main_prefix + + if EU_REGION_PATTERN.match(xchg): + mult += ' ' + xchg + + return {'mult1_value': mult} diff --git a/test/rules/eudx/eudx.log b/test/rules/eudx/eudx.log new file mode 100644 index 00000000..f2ecfd33 --- /dev/null +++ b/test/rules/eudx/eudx.log @@ -0,0 +1,11 @@ + 40CW 31-Jan-24 19:53 0001 OE1AAA 599 599 AT03 OE AT03 10 + 40CW 31-Jan-24 19:53 0002 OE3BBB 599 599 AT04 AT04 10 + 40CW 31-Jan-24 19:54 0003 OE5CCC 599 599 AT03 10 + 40CW 31-Jan-24 19:54 0004 LZ1DDD 599 599 BG01 LZ BG01 10 + 20CW 31-Jan-24 19:54 0005 LZ2EEE 599 599 BG01 LZ BG01 10 + 40SSB 31-Jan-24 19:56 0006 LZ1DDD 599 599 BG01 10 + 40CW 31-Jan-24 19:57 0007 IS9FFF 599 599 IT15 IS IT15 2 + 40CW 31-Jan-24 19:58 0008 IG9X 599 599 IT17 IG9 IT17 2 + 40CW 31-Jan-24 19:59 0009 I9QQQ 599 599 IT04 I IT04 2 + 40CW 31-Jan-24 20:00 0010 K1WWW 599 599 07 K 5 + 40CW 31-Jan-24 20:01 0011 ER9RRR 599 599 29 ER 3 diff --git a/test/rules/eudx/logcfg.dat b/test/rules/eudx/logcfg.dat new file mode 100644 index 00000000..642e4350 --- /dev/null +++ b/test/rules/eudx/logcfg.dat @@ -0,0 +1,2 @@ +RULES=eudx +CALL=IK1AAA diff --git a/test/rules/eudx/rules/eudx b/test/rules/eudx/rules/eudx new file mode 120000 index 00000000..1e425c26 --- /dev/null +++ b/test/rules/eudx/rules/eudx @@ -0,0 +1 @@ +../../../../rules/eudx/eudx \ No newline at end of file diff --git a/test/rules/eudx/rules/eudx.py b/test/rules/eudx/rules/eudx.py new file mode 120000 index 00000000..d412d043 --- /dev/null +++ b/test/rules/eudx/rules/eudx.py @@ -0,0 +1 @@ +../../../../rules/eudx/eudx.py \ No newline at end of file