[chirp_devel] [PATCH 3 of 7] [ic2200] New bank model support
Dan Smith
Tue Feb 7 20:08:29 PST 2012
# HG changeset patch
# User Dan Smith <dsmith at danplanet.com>
# Date 1328673682 28800
# Node ID d447fde6f900f53d8a0ec5e27e87c13a18a276c2
# Parent 74c27f2df96137b1b07289a7bcdd31cf424e1dfd
[ic2200] New bank model support
diff -r 74c27f2df961 -r d447fde6f900 chirp/ic2200.py
--- a/chirp/ic2200.py Tue Feb 07 20:01:20 2012 -0800
+++ b/chirp/ic2200.py Tue Feb 07 20:01:22 2012 -0800
@@ -83,6 +83,45 @@
chirp_common.PowerLevel("MidLow", watts=10),
chirp_common.PowerLevel("Low", watts=5)]
+class IC2200BankModel(chirp_common.BankModel):
+ def get_num_banks(self):
+ return 10 # A-J
+
+ def get_banks(self):
+ banks = []
+ for i in range(0, 10):
+ index = chr(ord("A") + i)
+ bank = chirp_common.Bank(self, index, "BANK-%s" % index)
+ bank.index = i
+ banks.append(bank)
+ return banks
+
+ def add_memory_to_bank(self, memory, bank):
+ _flag = self._radio._memobj.flags[memory.number]
+ _flag.bank = bank and bank.index or 0x0A
+
+ def remove_memory_from_bank(self, memory, bank):
+ _flag = self._radio._memobj.flags[memory.number]
+ if bank and _flag.bank != bank.index:
+ raise Exception("Memory %i not in bank %s. Cannot remove." % \
+ (memory.number, bank))
+ _flag.bank = 0x0A
+
+ def get_bank_memories(self, bank):
+ memories = []
+ for i in range(0, 199):
+ _flag = self._radio._memobj.flags[i]
+ if _flag.bank == bank.index:
+ memories.append(self._radio.get_memory(i))
+ return memories
+
+ def get_memory_banks(self, memory):
+ _flag = self._radio._memobj.flags[memory.number]
+ if _flag.bank == 0x0A:
+ return []
+ else:
+ return [self.get_banks()[_flag.bank]]
+
class IC2200Radio(icf.IcomCloneModeRadio, chirp_common.IcomDstarSupport):
VENDOR = "Icom"
MODEL = "IC-2200H"
@@ -258,17 +297,8 @@
def get_raw_memory(self, number):
return repr(self._memobj.memory[number])
- def get_banks(self):
- banks = []
-
- for i in range(0, 10):
- bank = chirp_common.ImmutableBank("BANK-%s" % (chr(ord("A")+i)))
- banks.append(bank)
-
- return banks
-
- def set_banks(self, banks):
- raise errors.InvalidDataError("Bank naming not supported on this model")
+ def get_bank_model(self):
+ return IC2200BankModel(self)
def get_urcall_list(self):
return [str(x.call).rstrip() for x in self._memobj.urcalls]
More information about the chirp_devel
mailing list