def _make_mem_spec(self, mem): if mem.duplex in " -+": duplex = util.get_dict_rev(DUPLEX, mem.duplex) else: duplex = 0 spec = ("%011i" % mem.freq, "%X" % STEPS.index(mem.tuning_step), "%i" % duplex, "0", "%i" % (mem.tmode == "Tone"), "%i" % (mem.tmode == "TSQL"), "%i" % (mem.tmode == "DTCS"), "%02i" % (self._kenwood_valid_tones.index(mem.rtone) + 1), "%03i0" % (chirp_common.DTCS_CODES.index(mem.dtcs) + 1), "%02i" % (self._kenwood_valid_tones.index(mem.ctone) + 1), "%09i" % mem.offset, "%i" % util.get_dict_rev(MODES, mem.mode), "%i" % ((mem.skip == "S") and 1 or 0)) return spec
def _make_mem_spec(self, mem): if mem.duplex in " +-": duplex = util.get_dict_rev(THF6A_DUPLEX, mem.duplex) offset = mem.offset elif mem.duplex == "split": duplex = 0 offset = 0 else: print "Bug: unsupported duplex `%s'" % mem.duplex spec = ( \ "%011i" % mem.freq, "%X" % THF6A_STEPS.index(mem.tuning_step), "%i" % duplex, "0", "%i" % (mem.tmode == "Tone"), "%i" % (mem.tmode == "TSQL"), "%i" % (mem.tmode == "DTCS"), "%02i" % (self._kenwood_valid_tones.index(mem.rtone)), "%02i" % (self._kenwood_valid_tones.index(mem.ctone)), "%03i" % (chirp_common.DTCS_CODES.index(mem.dtcs)), "%09i" % offset, "%i" % (THF6_MODES.index(mem.mode)), "%i" % (mem.skip == "S")) return spec
def _make_mem_spec(self, mem): spec = ("%011i" % mem.freq, "%X" % THG71_STEPS.index(mem.tuning_step), "%i" % util.get_dict_rev(DUPLEX, mem.duplex), "0", "%i" % (mem.tmode == "Tone"), "%i" % (mem.tmode == "TSQL"), "0", "%02i" % (self._kenwood_valid_tones.index(mem.rtone) + 1), "000", "%02i" % (self._kenwood_valid_tones.index(mem.ctone) + 1), "%09i" % mem.offset, "%i" % ((mem.skip == "S") and 1 or 0)) return spec
def _make_mem_spec(self, mem): if mem.duplex in " -+": duplex = util.get_dict_rev(DUPLEX, mem.duplex) else: duplex = 0 spec = ( \ "%011i" % mem.freq, "%X" % STEPS.index(mem.tuning_step), "%i" % duplex, "0", "%i" % (mem.tmode == "Tone"), "%i" % (mem.tmode == "TSQL"), "%i" % (mem.tmode == "DTCS"), "%02i" % (self._kenwood_valid_tones.index(mem.rtone) + 1), "%03i0" % (chirp_common.DTCS_CODES.index(mem.dtcs) + 1), "%02i" % (self._kenwood_valid_tones.index(mem.ctone) + 1), "%09i" % mem.offset, "%i" % util.get_dict_rev(MODES, mem.mode), "%i" % ((mem.skip == "S") and 1 or 0)) return spec
def get_memory(self, number): number = _resolve_memory_number(number) bitpos = (1 << (number % 8)) bytepos = number / 8 _mem = self._memobj.memory[number] _used = self._memobj.used_flags[bytepos] is_used = ((_used & bitpos) == 0) if is_used and MODES[_mem.mode] == "DV": mem = chirp_common.DVMemory() mem.dv_urcall = str(_mem.urcall).rstrip() mem.dv_rpt1call = str(_mem.r1call).rstrip() mem.dv_rpt2call = str(_mem.r2call).rstrip() else: mem = chirp_common.Memory() mem.number = number if number < 500: _skip = self._memobj.skip_flags[bytepos] _pskip = self._memobj.pskip_flags[bytepos] if _skip & bitpos: mem.skip = "S" elif _pskip & bitpos: mem.skip = "P" else: mem.extd_number = util.get_dict_rev(_get_special(), number) mem.immutable = [ "number", "skip", "bank", "bank_index", "extd_number" ] if not is_used: mem.empty = True return mem mem.freq = int(_mem.freq) mem.offset = int(_mem.offset) mem.rtone = chirp_common.TONES[_mem.rtone] mem.ctone = chirp_common.TONES[_mem.ctone] mem.tmode = TMODES[_mem.tmode] mem.duplex = DUPLEX[_mem.duplex] mem.mode = MODES[_mem.mode] mem.dtcs = chirp_common.DTCS_CODES[_mem.dtcs] mem.dtcs_polarity = DTCSP[_mem.dtcs_polarity] if _mem.tune_step > 8: mem.tuning_step = 5.0 # Sometimes TS is garbage? else: mem.tuning_step = chirp_common.TUNING_STEPS[_mem.tune_step] mem.name = str(_mem.name).rstrip() return mem
def get_memory(self, number): number = _resolve_memory_number(number) bitpos = (1 << (number % 8)) bytepos = number / 8 _mem = self._memobj.memory[number] _used = self._memobj.used_flags[bytepos] is_used = ((_used & bitpos) == 0) if is_used and MODES[_mem.mode] == "DV": mem = chirp_common.DVMemory() mem.dv_urcall = str(_mem.urcall).rstrip() mem.dv_rpt1call = str(_mem.r1call).rstrip() mem.dv_rpt2call = str(_mem.r2call).rstrip() else: mem = chirp_common.Memory() mem.number = number if number < 500: _skip = self._memobj.skip_flags[bytepos] _pskip = self._memobj.pskip_flags[bytepos] if _skip & bitpos: mem.skip = "S" elif _pskip & bitpos: mem.skip = "P" else: mem.extd_number = util.get_dict_rev(_get_special(), number) mem.immutable = ["number", "skip", "bank", "bank_index", "extd_number"] if not is_used: mem.empty = True return mem mem.freq = int(_mem.freq) mem.offset = int(_mem.offset) mem.rtone = chirp_common.TONES[_mem.rtone] mem.ctone = chirp_common.TONES[_mem.ctone] mem.tmode = TMODES[_mem.tmode] mem.duplex = DUPLEX[_mem.duplex] mem.mode = MODES[_mem.mode] mem.dtcs = chirp_common.DTCS_CODES[_mem.dtcs] mem.dtcs_polarity = DTCSP[_mem.dtcs_polarity] if _mem.tune_step > 8: mem.tuning_step = 5.0 # Sometimes TS is garbage? else: mem.tuning_step = chirp_common.TUNING_STEPS[_mem.tune_step] mem.name = str(_mem.name).rstrip() return mem
def get_memory(self, number): if isinstance(number, str): number = _get_special()[number] _mem = self._memobj.memory[number] _flag = self._memobj.flags[number] if _mem.mode_dv and not _flag.empty: mem = chirp_common.DVMemory() mem.dv_urcall = \ str(self._memobj.urcalls[_mem.urcall].call).rstrip() mem.dv_rpt1call = \ str(self._memobj.rptcalls[_mem.r1call].call).rstrip() mem.dv_rpt2call = \ str(self._memobj.rptcalls[_mem.r2call].call).rstrip() else: mem = chirp_common.Memory() mem.number = number if number < 200: mem.skip = _flag.skip and "S" or "" else: mem.extd_number = util.get_dict_rev(_get_special(), number) mem.immutable = [ "number", "skip", "bank", "bank_index", "extd_number" ] if _flag.empty: mem.empty = True mem.power = POWER_LEVELS[0] return mem mult = _mem.is_625 and 6250 or 5000 mem.freq = (_mem.freq * mult) mem.offset = (_mem.offset * mult) mem.rtone = chirp_common.TONES[_mem.rtone] mem.ctone = chirp_common.TONES[_mem.ctone] mem.tmode = TMODES[_mem.tmode] mem.duplex = DUPLEX[_mem.duplex] mem.mode = _mem.mode_dv and "DV" or _mem.mode_am and "AM" or "FM" if _mem.mode_narrow: mem.mode = "N%s" % mem.mode mem.dtcs = chirp_common.DTCS_CODES[_mem.dtcs] mem.dtcs_polarity = DTCSP[_mem.dtcs_polarity] mem.tuning_step = STEPS[_mem.tuning_step] mem.name = str(_mem.name).replace("\x0E", "").rstrip() mem.power = POWER_LEVELS[_mem.power] return mem
def _make_mem_spec(self, mem): if mem.duplex in " -+": duplex = util.get_dict_rev(DUPLEX, mem.duplex) offset = mem.offset else: duplex = 0 offset = 0 spec = ( "%011i" % mem.freq, "%X" % STEPS.index(mem.tuning_step), "%i" % duplex, "0", "%i" % (mem.tmode == "Tone"), "%i" % (mem.tmode == "TSQL"), "", # DCS Flag "%02i" % (self._kenwood_valid_tones.index(mem.rtone) + 1), "", # DCS Code "%02i" % (self._kenwood_valid_tones.index(mem.ctone) + 1), "%09i" % offset, "%i" % util.get_dict_rev(MODES, mem.mode), "%i" % ((mem.skip == "S") and 1 or 0)) return spec
def _make_mem_spec(self, mem): if mem.duplex in " -+": duplex = util.get_dict_rev(DUPLEX, mem.duplex) offset = mem.offset else: duplex = 0 offset = 0 spec = ( \ "%011i" % mem.freq, "%X" % STEPS.index(mem.tuning_step), "%i" % duplex, "0", "%i" % (mem.tmode == "Tone"), "%i" % (mem.tmode == "TSQL"), "", # DCS Flag "%02i" % (self._kenwood_valid_tones.index(mem.rtone) + 1), "", # DCS Code "%02i" % (self._kenwood_valid_tones.index(mem.ctone) + 1), "%09i" % offset, "%i" % util.get_dict_rev(MODES, mem.mode), "%i" % ((mem.skip == "S") and 1 or 0)) return spec
def _make_mem_spec(self, mem): spec = ( \ "%011i" % mem.freq, "%X" % THG71_STEPS.index(mem.tuning_step), "%i" % util.get_dict_rev(DUPLEX, mem.duplex), "0", "%i" % (mem.tmode == "Tone"), "%i" % (mem.tmode == "TSQL"), "0", "%02i" % (self._kenwood_valid_tones.index(mem.rtone) + 1), "000", "%02i" % (self._kenwood_valid_tones.index(mem.ctone) + 1), "%09i" % mem.offset, "%i" % ((mem.skip == "S") and 1 or 0)) return spec
def get_memory(self, number): if isinstance(number, str): number = _get_special()[number] _mem = self._memobj.memory[number] _flag = self._memobj.flags[number] if _mem.mode_dv and not _flag.empty: mem = chirp_common.DVMemory() mem.dv_urcall = \ str(self._memobj.urcalls[_mem.urcall].call).rstrip() mem.dv_rpt1call = \ str(self._memobj.rptcalls[_mem.r1call].call).rstrip() mem.dv_rpt2call = \ str(self._memobj.rptcalls[_mem.r2call].call).rstrip() else: mem = chirp_common.Memory() mem.number = number if number < 200: mem.skip = _flag.skip and "S" or "" else: mem.extd_number = util.get_dict_rev(_get_special(), number) mem.immutable = ["number", "skip", "bank", "bank_index", "extd_number"] if _flag.empty: mem.empty = True mem.power = POWER_LEVELS[0] return mem mult = _mem.is_625 and 6250 or 5000 mem.freq = (_mem.freq * mult) mem.offset = (_mem.offset * mult) mem.rtone = chirp_common.TONES[_mem.rtone] mem.ctone = chirp_common.TONES[_mem.ctone] mem.tmode = TMODES[_mem.tmode] mem.duplex = DUPLEX[_mem.duplex] mem.mode = _mem.mode_dv and "DV" or _mem.mode_am and "AM" or "FM" if _mem.mode_narrow: mem.mode = "N%s" % mem.mode mem.dtcs = chirp_common.DTCS_CODES[_mem.dtcs] mem.dtcs_polarity = DTCSP[_mem.dtcs_polarity] mem.tuning_step = STEPS[_mem.tuning_step] mem.name = str(_mem.name).replace("\x0E", "").rstrip() mem.power = POWER_LEVELS[_mem.power] return mem
def _make_mem_spec(self, mem): spec = ( "%011i" % mem.freq, "%X" % STEPS.index(mem.tuning_step), "%i" % util.get_dict_rev(DUPLEX, mem.duplex), "0", "%i" % (mem.tmode == "Tone"), "%i" % (mem.tmode == "TSQL"), "0", "%02i" % (self._kenwood_valid_tones.index(mem.rtone) + 1), "000", "%02i" % (self._kenwood_valid_tones.index(mem.ctone) + 1), "", "0") return spec
def _make_mem_spec(self, mem): spec = ( \ "%011i" % mem.freq, "%X" % STEPS.index(mem.tuning_step), "%i" % util.get_dict_rev(DUPLEX, mem.duplex), "0", "%i" % (mem.tmode == "Tone"), "%i" % (mem.tmode == "TSQL"), "0", "%02i" % (self._kenwood_valid_tones.index(mem.rtone) + 1), "000", "%02i" % (self._kenwood_valid_tones.index(mem.ctone) + 1), "", "0") return spec
def get_memory(self, number): mem = chirp_common.Memory() if isinstance(number, str): if number == "C": number = _get_special()[number] _mem = self._memobj.call[0] else: number = _get_special()[number] _mem = self._memobj.special[number - 500] empty = False else: number -= 1 _mem = self._memobj.memory[number] _emt = self._memobj.usedflags[number / 8].flagbits empty = (1 << (number % 8)) & int(_emt) if not empty: mem.name = str(_mem.name).rstrip() _skp = self._memobj.skipflags[number / 8].flagbits isskip = (1 << (number % 8)) & int(_skp) mem.number = number + 1 if number <= 100: mem.skip = isskip and "S" or "" else: mem.extd_number = util.get_dict_rev(_get_special(), number) mem.immutable = ["number", "skip", "extd_number"] if empty: mem.empty = True return mem mem.freq = _get_freq(_mem) mem.offset = _get_offset(_mem) mem.rtone = chirp_common.TONES[_mem.rtone] mem.ctone = chirp_common.TONES[_mem.ctone] mem.tmode = TMODES[_mem.tmode] mem.duplex = DUPLEX[_mem.duplex] mem.extra = RadioSettingGroup("Extra", "extra") rs = RadioSetting("anm", "Alphanumeric Name", RadioSettingValueBoolean(_mem.anm)) mem.extra.append(rs) return mem
def _make_mem_spec(self, mem): if mem.duplex in " +-": duplex = util.get_dict_rev(TS2000_DUPLEX, mem.duplex) offset = mem.offset elif mem.duplex == "split": duplex = 0 offset = 0 else: print("Bug: unsupported duplex `%s'" % mem.duplex) if mem.mode in ["AM", "FM"]: step = TS2000_FM_STEPS.index(mem.tuning_step) else: step = TS2000_SSB_STEPS.index(mem.tuning_step) # TS-2000 won't accept channels with tone mode off if they have # tone values if mem.tmode == "": rtone = 0 ctone = 0 dtcs = 0 else: # PL and T-SQL are 1 indexed, DTCS is 0 indexed rtone = (self._kenwood_valid_tones.index(mem.rtone) + 1) ctone = (self._kenwood_valid_tones.index(mem.ctone) + 1) dtcs = (chirp_common.DTCS_CODES.index(mem.dtcs)) spec = ( "%011i" % mem.freq, "%i" % (TS2000_MODES.index(mem.mode)), "%i" % (mem.skip == "S"), "%i" % TS2000_TMODES.index(mem.tmode), "%02i" % (rtone), "%02i" % (ctone), "%03i" % (dtcs), "0", # REVERSE status "%i" % duplex, "%09i" % offset, "%02i" % step, "0", # Memory Group number (0-9) "%s" % mem.name, ) return spec
def _make_mem_spec(self, mem): if mem.duplex in " +-": duplex = util.get_dict_rev(TS2000_DUPLEX, mem.duplex) offset = mem.offset elif mem.duplex == "split": duplex = 0 offset = 0 else: print "Bug: unsupported duplex `%s'" % mem.duplex if mem.mode in ["AM", "FM"]: step = TS2000_FM_STEPS.index(mem.tuning_step) else: step = TS2000_SSB_STEPS.index(mem.tuning_step) # TS-2000 won't accept channels with tone mode off if they have # tone values if mem.tmode == "": rtone = 0 ctone = 0 dtcs = 0 else: # PL and T-SQL are 1 indexed, DTCS is 0 indexed rtone = self._kenwood_valid_tones.index(mem.rtone) + 1 ctone = self._kenwood_valid_tones.index(mem.ctone) + 1 dtcs = chirp_common.DTCS_CODES.index(mem.dtcs) spec = ( "%011i" % mem.freq, "%i" % (TS2000_MODES.index(mem.mode)), "%i" % (mem.skip == "S"), "%i" % TS2000_TMODES.index(mem.tmode), "%02i" % (rtone), "%02i" % (ctone), "%03i" % (dtcs), "0", # REVERSE status "%i" % duplex, "%09i" % offset, "%02i" % step, "0", # Memory Group number (0-9) "%s" % mem.name, ) return spec
def get_memory(self, number): if isinstance(number, str): try: number = IC9X_SPECIAL[self.vfo][number] except KeyError: raise errors.InvalidMemoryLocation("Unknown channel %s" % number) if number < -2 or number > 999: raise errors.InvalidValueError("Number must be between 0 and 999") if number in self.__memcache: return self.__memcache[number] self._lock.acquire() try: self._maybe_send_magic() mem = ic9x_ll.get_memory(self.pipe, self.vfo, number) except errors.InvalidMemoryLocation: mem = chirp_common.Memory() mem.number = number if number < self._upper: mem.empty = True except: self._lock.release() raise self._lock.release() if number > self._upper or number < 0: mem.extd_number = util.get_dict_rev(IC9X_SPECIAL, [self.vfo][number]) mem.immutable = [ "number", "skip", "bank", "bank_index", "extd_number" ] self.__memcache[mem.number] = mem return mem
def get_memory(self, number): if isinstance(number, str): number = _get_special()[number] _mem = self._memobj.memory[number] _flg = self._memobj.flag[number] mem = chirp_common.Memory() mem.number = number if number < 100: # Normal memories mem.skip = _flg.skip and "S" or "" else: # Special memories mem.extd_number = util.get_dict_rev(_get_special(), number) if _flg.empty: mem.empty = True return mem mem.freq = chirp_common.fix_rounded_step(int(_mem.freq) * 1000) mem.offset = int(_mem.offset) * 100 if str(_mem.name)[0] != chr(0xFF): mem.name = str(_mem.name).rstrip() mem.rtone = chirp_common.TONES[_mem.rtone] mem.ctone = chirp_common.TONES[_mem.ctone] mem.mode = _flg.am and "AM" or "FM" mem.duplex = DUPLEX[_flg.duplex] mem.tmode = TONE[_flg.tmode] if number > 100: mem.immutable = ["number", "skip", "extd_number", "name"] return mem