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

Support TX Permit column in Digital-Others files #92

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/dzcb/farnsworth.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import attr

from dzcb.model import (
AdmitCriteria,
AnalogChannel,
Contact,
DigitalChannel,
Expand Down Expand Up @@ -173,15 +174,26 @@ def AnalogChannel_to_dict(c, codeplug):
color_code="ColorCode",
)

AdmitCriteria_map = {
AdmitCriteria.ALWAYS: "Always",
AdmitCriteria.CHANNEL_FREE: "Channel free",
AdmitCriteria.SAME_COLOR: "Color code",
}

def DigitalChannel_to_dict(c, codeplug, contacts_by_id):
d = DefaultChannel.copy()
talkgroup_name = "Parrot 1"
if c.talkgroup:
# get the dedupe'd contact's name for the given ID
talkgroup_name = str(contacts_by_id.get(c.talkgroup.dmrid, c.talkgroup).name)

admit_criteria = AdmitCriteria_map.get(c.admit_criteria, None)
if not admit_criteria:
raise ValueError("editcp does not support AdmitCriteria: {}".format(c.admit_criteria))

d.update(
{
"AdmitCriteria": admit_criteria,
"ChannelMode": "Digital",
"RepeaterSlot": str(c.talkgroup.timeslot) if c.talkgroup else 1,
"ContactName": talkgroup_name,
Expand Down
2 changes: 2 additions & 0 deletions src/dzcb/k7abd.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ def DigitalChannels_from_k7abd_csv(digital_others_csv, talkgroups_by_name):
color_code = r.pop("Color Code")
power = r.pop("Power")
tg_name = r.pop("Talk Group")
tx_permit = r.pop("TX Permit")
try:
talkgroup = Talkgroup.from_contact(
talkgroups_by_name[tg_name],
Expand All @@ -281,6 +282,7 @@ def DigitalChannels_from_k7abd_csv(digital_others_csv, talkgroups_by_name):
color_code=color_code,
power=power,
talkgroup=talkgroup,
admit_criteria=tx_permit,
)
)
return zones
Expand Down
11 changes: 11 additions & 0 deletions src/dzcb/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,12 @@ def flattened(self, allowed_bandwidths):
)
)

class AdmitCriteria(ConvertibleEnum):
ALWAYS = "Always"
CHANNEL_FREE = "ChannelFree"
SAME_COLOR = "Same Color Code"
DIFFERENT_COLOR = "Different Color Code"


def round_frequency(freq, ndigits=5):
return round(float(freq), ndigits)
Expand Down Expand Up @@ -312,6 +318,11 @@ class DigitalChannel(Channel):
member_validator=attr.validators.instance_of(Talkgroup)
),
)
admit_criteria = attr.ib(
default=AdmitCriteria.SAME_COLOR,
validator=attr.validators.instance_of(AdmitCriteria),
converter=AdmitCriteria.from_any,
)

def from_talkgroups(self, talkgroups, **kwargs):
"""
Expand Down
10 changes: 9 additions & 1 deletion src/dzcb/output/dmrconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
from dzcb import __version__
import dzcb.munge
from dzcb.model import (
AdmitCriteria,
Bandwidth,
Codeplug,
Power,
Expand Down Expand Up @@ -529,6 +530,13 @@ def normal_dcs(tone):
)


digital_admit_criteria = {
AdmitCriteria.ALWAYS: "-",
AdmitCriteria.CHANNEL_FREE: "Free",
AdmitCriteria.SAME_COLOR: "Color",
AdmitCriteria.DIFFERENT_COLOR: "NColor",
}

class DigitalChannelTable(ChannelTable):
"""
# Table of digital channels.
Expand Down Expand Up @@ -600,7 +608,7 @@ def item_to_dict(self, index, ch):
Scan=self.scanlist_ix(ch) or "-",
TOT=90, # TODO: how to expose this parameter
RO=plus_minus[ch.rx_only],
Admit="Color",
Admit=digital_admit_criteria[ch.admit_criteria],
Color=ch.color_code,
Slot=ch.talkgroup.timeslot.value if ch.talkgroup else 1,
RxGL=self.grouplist_ix(ch) or "-",
Expand Down
22 changes: 11 additions & 11 deletions tests/default-codeplug-expect-output/dmrconfig/d878uv-int.conf
Original file line number Diff line number Diff line change
Expand Up @@ -214,16 +214,16 @@ Analog Name Receive Transmit Power Scan TOT RO Admit Squelch RxTon
# 12) Receive group list: - or index in Grouplist table
# 13) Contact for transmit: - or index in Contacts table
Digital Name Receive Transmit Power Scan TOT RO Admit Color Slot RxGL TxContact
179 SP_V01_145.790 145.79 145.79 High 11 90 - Color 1 1 - 46 # Simplex 99
180 SP_V02_145.510 145.51 145.51 High 11 90 - Color 1 1 - 46 # Simplex 99
181 SP_U01_441.000 441.0 441.0 High 10 90 - Color 1 1 - 46 # Simplex 99
182 SP_U02_446.5 446.5 446.5 High 10 90 - Color 1 1 - 46 # Simplex 99
183 SP_U03_446.075 446.075 446.075 High 10 90 - Color 1 1 - 46 # Simplex 99
184 SP_U04_433.45 433.45 433.45 High 10 90 - Color 1 1 - 46 # Simplex 99
185 SP_U05_430.4125 430.4125 430.4125 Low 10 90 - Color 1 1 - 46 # Simplex 99
186 SP_U06_439.4125 439.4125 439.4125 Low 10 90 - Color 1 1 - 46 # Simplex 99
187 SP_U07_430.425 430.425 430.425 Low 10 90 - Color 1 1 - 46 # Simplex 99
188 SP_U08_439.425 439.425 439.425 Low 10 90 - Color 1 1 - 46 # Simplex 99
179 SP_V01_145.790 145.79 145.79 High 11 90 - - 1 1 - 46 # Simplex 99
180 SP_V02_145.510 145.51 145.51 High 11 90 - - 1 1 - 46 # Simplex 99
181 SP_U01_441.000 441.0 441.0 High 10 90 - - 1 1 - 46 # Simplex 99
182 SP_U02_446.5 446.5 446.5 High 10 90 - - 1 1 - 46 # Simplex 99
183 SP_U03_446.075 446.075 446.075 High 10 90 - - 1 1 - 46 # Simplex 99
184 SP_U04_433.45 433.45 433.45 High 10 90 - - 1 1 - 46 # Simplex 99
185 SP_U05_430.4125 430.4125 430.4125 Low 10 90 - - 1 1 - 46 # Simplex 99
186 SP_U06_439.4125 439.4125 439.4125 Low 10 90 - - 1 1 - 46 # Simplex 99
187 SP_U07_430.425 430.425 430.425 Low 10 90 - - 1 1 - 46 # Simplex 99
188 SP_U08_439.425 439.425 439.425 Low 10 90 - - 1 1 - 46 # Simplex 99
189 R_U09_430.4375 430.4375 439.4375 Low 12 90 - Color 1 1 - 5 # Local 1
190 R_U10_430.450 430.45 439.45 Low 12 90 - Color 1 1 - 5 # Local 1
191 R_U11_430.4625 430.4625 439.4625 Low 12 90 - Color 1 1 - 5 # Local 1
Expand Down Expand Up @@ -2480,4 +2480,4 @@ Name: My Radio

# Text displayed when the radio powers up.
Intro Line 1: dzcb
Intro Line 2: 2021-03-07
Intro Line 2: 2021-03-07
22 changes: 11 additions & 11 deletions tests/default-codeplug-expect-output/dmrconfig/md-uv380-int.conf
Original file line number Diff line number Diff line change
Expand Up @@ -216,16 +216,16 @@ Analog Name Receive Transmit Power Scan TOT RO Admit Squelch RxTon
# 12) Receive group list: - or index in Grouplist table
# 13) Contact for transmit: - or index in Contacts table
Digital Name Receive Transmit Power Scan TOT RO Admit Color Slot RxGL TxContact
179 SP_V01_145.790 145.79 145.79 High 11 90 - Color 1 1 - 46 # Simplex 99
180 SP_V02_145.510 145.51 145.51 High 11 90 - Color 1 1 - 46 # Simplex 99
181 SP_U01_441.000 441.0 441.0 High 10 90 - Color 1 1 - 46 # Simplex 99
182 SP_U02_446.5 446.5 446.5 High 10 90 - Color 1 1 - 46 # Simplex 99
183 SP_U03_446.075 446.075 446.075 High 10 90 - Color 1 1 - 46 # Simplex 99
184 SP_U04_433.45 433.45 433.45 High 10 90 - Color 1 1 - 46 # Simplex 99
185 SP_U05_430.4125 430.4125 430.4125 Low 10 90 - Color 1 1 - 46 # Simplex 99
186 SP_U06_439.4125 439.4125 439.4125 Low 10 90 - Color 1 1 - 46 # Simplex 99
187 SP_U07_430.425 430.425 430.425 Low 10 90 - Color 1 1 - 46 # Simplex 99
188 SP_U08_439.425 439.425 439.425 Low 10 90 - Color 1 1 - 46 # Simplex 99
179 SP_V01_145.790 145.79 145.79 High 11 90 - - 1 1 - 46 # Simplex 99
180 SP_V02_145.510 145.51 145.51 High 11 90 - - 1 1 - 46 # Simplex 99
181 SP_U01_441.000 441.0 441.0 High 10 90 - - 1 1 - 46 # Simplex 99
182 SP_U02_446.5 446.5 446.5 High 10 90 - - 1 1 - 46 # Simplex 99
183 SP_U03_446.075 446.075 446.075 High 10 90 - - 1 1 - 46 # Simplex 99
184 SP_U04_433.45 433.45 433.45 High 10 90 - - 1 1 - 46 # Simplex 99
185 SP_U05_430.4125 430.4125 430.4125 Low 10 90 - - 1 1 - 46 # Simplex 99
186 SP_U06_439.4125 439.4125 439.4125 Low 10 90 - - 1 1 - 46 # Simplex 99
187 SP_U07_430.425 430.425 430.425 Low 10 90 - - 1 1 - 46 # Simplex 99
188 SP_U08_439.425 439.425 439.425 Low 10 90 - - 1 1 - 46 # Simplex 99
189 R_U09_430.4375 430.4375 439.4375 Low 12 90 - Color 1 1 - 5 # Local 1
190 R_U10_430.450 430.45 439.45 Low 12 90 - Color 1 1 - 5 # Local 1
191 R_U11_430.4625 430.4625 439.4625 Low 12 90 - Color 1 1 - 5 # Local 1
Expand Down Expand Up @@ -2537,4 +2537,4 @@ Name: My Radio

# Text displayed when the radio powers up.
Intro Line 1: dzcb
Intro Line 2: 2021-03-07
Intro Line 2: 2021-03-07
18 changes: 9 additions & 9 deletions tests/default-codeplug-expect-output/dmrconfig/md380-int.conf
Original file line number Diff line number Diff line change
Expand Up @@ -154,14 +154,14 @@ Analog Name Receive Transmit Power Scan TOT RO Admit Squelch RxTon
# 12) Receive group list: - or index in Grouplist table
# 13) Contact for transmit: - or index in Contacts table
Digital Name Receive Transmit Power Scan TOT RO Admit Color Slot RxGL TxContact
28 SP_U01_441.000 441.0 441.0 High 6 90 - Color 1 1 - 46 # Simplex 99
29 SP_U02_446.5 446.5 446.5 High 6 90 - Color 1 1 - 46 # Simplex 99
30 SP_U03_446.075 446.075 446.075 High 6 90 - Color 1 1 - 46 # Simplex 99
31 SP_U04_433.45 433.45 433.45 High 6 90 - Color 1 1 - 46 # Simplex 99
32 SP_U05_430.4125 430.4125 430.4125 Low 6 90 - Color 1 1 - 46 # Simplex 99
33 SP_U06_439.4125 439.4125 439.4125 Low 6 90 - Color 1 1 - 46 # Simplex 99
34 SP_U07_430.425 430.425 430.425 Low 6 90 - Color 1 1 - 46 # Simplex 99
35 SP_U08_439.425 439.425 439.425 Low 6 90 - Color 1 1 - 46 # Simplex 99
28 SP_U01_441.000 441.0 441.0 High 6 90 - - 1 1 - 46 # Simplex 99
29 SP_U02_446.5 446.5 446.5 High 6 90 - - 1 1 - 46 # Simplex 99
30 SP_U03_446.075 446.075 446.075 High 6 90 - - 1 1 - 46 # Simplex 99
31 SP_U04_433.45 433.45 433.45 High 6 90 - - 1 1 - 46 # Simplex 99
32 SP_U05_430.4125 430.4125 430.4125 Low 6 90 - - 1 1 - 46 # Simplex 99
33 SP_U06_439.4125 439.4125 439.4125 Low 6 90 - - 1 1 - 46 # Simplex 99
34 SP_U07_430.425 430.425 430.425 Low 6 90 - - 1 1 - 46 # Simplex 99
35 SP_U08_439.425 439.425 439.425 Low 6 90 - - 1 1 - 46 # Simplex 99
103 R_U09_430.4375 430.4375 439.4375 Low 7 90 - Color 1 1 - 5 # Local 1
104 R_U10_430.450 430.45 439.45 Low 7 90 - Color 1 1 - 5 # Local 1
105 R_U11_430.4625 430.4625 439.4625 Low 7 90 - Color 1 1 - 5 # Local 1
Expand Down Expand Up @@ -1314,4 +1314,4 @@ Name: My Radio

# Text displayed when the radio powers up.
Intro Line 1: dzcb
Intro Line 2: 2021-03-07
Intro Line 2: 2021-03-07
22 changes: 11 additions & 11 deletions tests/default-codeplug-expect-output/editcp/md-uv380.json
Original file line number Diff line number Diff line change
Expand Up @@ -9271,7 +9271,7 @@
"Power": "Medium"
},
{
"AdmitCriteria": "Color code",
"AdmitCriteria": "Always",
"AllowTalkaround": "Off",
"Autoscan": "Off",
"ColorCode": "1",
Expand Down Expand Up @@ -9322,7 +9322,7 @@
"Power": "High"
},
{
"AdmitCriteria": "Color code",
"AdmitCriteria": "Always",
"AllowTalkaround": "Off",
"Autoscan": "Off",
"ColorCode": "1",
Expand Down Expand Up @@ -9373,7 +9373,7 @@
"Power": "High"
},
{
"AdmitCriteria": "Color code",
"AdmitCriteria": "Always",
"AllowTalkaround": "Off",
"Autoscan": "Off",
"ColorCode": "1",
Expand Down Expand Up @@ -9424,7 +9424,7 @@
"Power": "High"
},
{
"AdmitCriteria": "Color code",
"AdmitCriteria": "Always",
"AllowTalkaround": "Off",
"Autoscan": "Off",
"ColorCode": "1",
Expand Down Expand Up @@ -9475,7 +9475,7 @@
"Power": "High"
},
{
"AdmitCriteria": "Color code",
"AdmitCriteria": "Always",
"AllowTalkaround": "Off",
"Autoscan": "Off",
"ColorCode": "1",
Expand Down Expand Up @@ -9526,7 +9526,7 @@
"Power": "High"
},
{
"AdmitCriteria": "Color code",
"AdmitCriteria": "Always",
"AllowTalkaround": "Off",
"Autoscan": "Off",
"ColorCode": "1",
Expand Down Expand Up @@ -9577,7 +9577,7 @@
"Power": "High"
},
{
"AdmitCriteria": "Color code",
"AdmitCriteria": "Always",
"AllowTalkaround": "Off",
"Autoscan": "Off",
"ColorCode": "1",
Expand Down Expand Up @@ -9628,7 +9628,7 @@
"Power": "Low"
},
{
"AdmitCriteria": "Color code",
"AdmitCriteria": "Always",
"AllowTalkaround": "Off",
"Autoscan": "Off",
"ColorCode": "1",
Expand Down Expand Up @@ -9679,7 +9679,7 @@
"Power": "Low"
},
{
"AdmitCriteria": "Color code",
"AdmitCriteria": "Always",
"AllowTalkaround": "Off",
"Autoscan": "Off",
"ColorCode": "1",
Expand Down Expand Up @@ -9730,7 +9730,7 @@
"Power": "Low"
},
{
"AdmitCriteria": "Color code",
"AdmitCriteria": "Always",
"AllowTalkaround": "Off",
"Autoscan": "Off",
"ColorCode": "1",
Expand Down Expand Up @@ -115749,4 +115749,4 @@
]
}
]
}
}
22 changes: 11 additions & 11 deletions tests/default-codeplug-expect-output/editcp/md-uv390.json
Original file line number Diff line number Diff line change
Expand Up @@ -9271,7 +9271,7 @@
"Power": "Medium"
},
{
"AdmitCriteria": "Color code",
"AdmitCriteria": "Always",
"AllowTalkaround": "Off",
"Autoscan": "Off",
"ColorCode": "1",
Expand Down Expand Up @@ -9322,7 +9322,7 @@
"Power": "High"
},
{
"AdmitCriteria": "Color code",
"AdmitCriteria": "Always",
"AllowTalkaround": "Off",
"Autoscan": "Off",
"ColorCode": "1",
Expand Down Expand Up @@ -9373,7 +9373,7 @@
"Power": "High"
},
{
"AdmitCriteria": "Color code",
"AdmitCriteria": "Always",
"AllowTalkaround": "Off",
"Autoscan": "Off",
"ColorCode": "1",
Expand Down Expand Up @@ -9424,7 +9424,7 @@
"Power": "High"
},
{
"AdmitCriteria": "Color code",
"AdmitCriteria": "Always",
"AllowTalkaround": "Off",
"Autoscan": "Off",
"ColorCode": "1",
Expand Down Expand Up @@ -9475,7 +9475,7 @@
"Power": "High"
},
{
"AdmitCriteria": "Color code",
"AdmitCriteria": "Always",
"AllowTalkaround": "Off",
"Autoscan": "Off",
"ColorCode": "1",
Expand Down Expand Up @@ -9526,7 +9526,7 @@
"Power": "High"
},
{
"AdmitCriteria": "Color code",
"AdmitCriteria": "Always",
"AllowTalkaround": "Off",
"Autoscan": "Off",
"ColorCode": "1",
Expand Down Expand Up @@ -9577,7 +9577,7 @@
"Power": "High"
},
{
"AdmitCriteria": "Color code",
"AdmitCriteria": "Always",
"AllowTalkaround": "Off",
"Autoscan": "Off",
"ColorCode": "1",
Expand Down Expand Up @@ -9628,7 +9628,7 @@
"Power": "Low"
},
{
"AdmitCriteria": "Color code",
"AdmitCriteria": "Always",
"AllowTalkaround": "Off",
"Autoscan": "Off",
"ColorCode": "1",
Expand Down Expand Up @@ -9679,7 +9679,7 @@
"Power": "Low"
},
{
"AdmitCriteria": "Color code",
"AdmitCriteria": "Always",
"AllowTalkaround": "Off",
"Autoscan": "Off",
"ColorCode": "1",
Expand Down Expand Up @@ -9730,7 +9730,7 @@
"Power": "Low"
},
{
"AdmitCriteria": "Color code",
"AdmitCriteria": "Always",
"AllowTalkaround": "Off",
"Autoscan": "Off",
"ColorCode": "1",
Expand Down Expand Up @@ -115749,4 +115749,4 @@
]
}
]
}
}
Loading
Loading