[chirp_devel] [PATCH 5 of 7] [vx8] New bank model support
Dan Smith
Tue Feb 7 20:08:31 PST 2012
# HG changeset patch
# User Dan Smith <dsmith at danplanet.com>
# Date 1328673811 28800
# Node ID 5f81b0536807cb84da7685d1014dd7f44da9f3fb
# Parent 4688777e2c3a5a27df9240962fe26de3355df4f9
[vx8] New bank model support
diff -r 4688777e2c3a -r 5f81b0536807 chirp/vx8.py
--- a/chirp/vx8.py Fri May 27 19:09:35 2011 +0200
+++ b/chirp/vx8.py Tue Feb 07 20:03:31 2012 -0800
@@ -82,6 +82,74 @@
chirp_common.PowerLevel("L2", watts=1.00),
chirp_common.PowerLevel("L1", watts=0.05)]
+class VX8Bank(chirp_common.NamedBank):
+ def set_name(self, name):
+ _bank = self._model._radio._memobj.bank_info[self.index]
+ _bank.name = [CHARSET.index(x) for x in name.ljust(16)[:16]]
+
+class VX8BankModel(chirp_common.BankModel):
+ def get_num_banks(self):
+ return 24
+
+ def get_banks(self):
+ banks = []
+ _banks = self._radio._memobj.bank_info
+
+ index = 0
+ for _bank in _banks:
+ name = ""
+ for i in _bank.name:
+ if i == 0xFF:
+ break
+ name += CHARSET[i & 0x7F]
+ bank = VX8Bank(self, "%i" % index, name.rstrip())
+ bank.index = index
+ banks.append(bank)
+ index += 1
+
+ return banks
+
+ def add_memory_to_bank(self, memory, bank):
+ _members = self._radio._memobj.bank_members[bank.index]
+ for i in range(0, 100):
+ if _members.channel[i] == 0xFFFF:
+ _members.channel[i] = memory.number
+ break
+
+ def remove_memory_from_bank(self, memory, bank):
+ _members = self._radio._memobj.bank_members[bank.index]
+ old_members = [x.number for x in self.get_bank_memories(bank)]
+ if not memory.number in old_members:
+ raise Exception("Memory %i is not in bank %s. Cannot remove" % \
+ (memory.number, bank))
+ old_members.remove(memory.number)
+ idx = 0
+ for number in old_members:
+ _members.channel[idx] = number
+ idx += 1
+ if idx < 100:
+ _members.channel[idx] = 0xFFFF
+
+ def get_bank_memories(self, bank):
+ memories = []
+ _members = self._radio._memobj.bank_members[bank.index]
+
+ for channel in _members.channel:
+ if channel == 0xffff:
+ break
+ memories.append(self._radio.get_memory(int(channel)))
+
+ return memories
+
+ def get_memory_banks(self, memory):
+ banks = []
+ for bank in self.get_banks():
+ if memory.number in \
+ [x.number for x in self.get_bank_memories(bank)]:
+ banks.append(bank)
+
+ return banks
+
class VX8Radio(yaesu_clone.YaesuCloneModeRadio):
BAUD_RATE = 38400
VENDOR = "Yaesu"
@@ -98,7 +166,6 @@
def get_features(self):
rf = chirp_common.RadioFeatures()
- rf.has_bank = False
rf.has_dtcs_polarity = False
rf.valid_modes = list(MODES)
rf.valid_tmodes = list(TMODES)
@@ -112,6 +179,7 @@
rf.memory_bounds = (1, 900)
rf.can_odd_split = True
rf.has_ctone = False
+ rf.has_bank_names = True
return rf
def get_raw_memory(self, number):
@@ -191,30 +259,8 @@
skipbits = SKIPS.index(mem.skip) << 2
flag.flag |= skipbits
- def get_banks(self):
- _banks = self._memobj.bank_info
-
- banks = []
- for _bank in _banks:
- name = ""
- for i in _bank.name:
- if i == 0xFF:
- break
- name += CHARSET[i & 0x7F]
- banks.append(name.rstrip())
-
- return banks
-
- # Return channels for a bank. Bank given as number
- def get_bank_channels(self, bank):
- _members = self._memobj.bank_members[bank]
- channels = []
- for channel in _members.channel:
- if channel == 0xffff:
- break
- channels.append(int(channel))
-
- return channels
+ def get_bank_model(self):
+ return VX8BankModel(self)
class VX8DRadio(VX8Radio):
_model = "AH29D"
More information about the chirp_devel
mailing list