class Channel:
    channel_map = {
        # 2.402 - 2.494 GHz
        1:   {"f0": 2412,
              "width":  20,
              "komondor": {"min_channel_allowed":  1,
                           "max_channel_allowed":  1,
                           "central_freq":         2.412}},
        2:   {"f0": 2417,
              "width":  20,
              "komondor": {"min_channel_allowed":  2,
                           "max_channel_allowed":  2,
                           "central_freq":         2.417}},
        3:   {"f0": 2422,
              "width":  20,
              "komondor": {"min_channel_allowed":  3,
                           "max_channel_allowed":  3,
                           "central_freq":         2.422}},
        4:   {"f0": 2427,
              "width":  20,
              "komondor": {"min_channel_allowed":  4,
                           "max_channel_allowed":  4,
                           "central_freq":         2.427}},
        5:   {"f0": 2432,
              "width":  20,
              "komondor": {"min_channel_allowed":  5,
                           "max_channel_allowed":  5,
                           "central_freq":         2.432}},
        6:   {"f0": 2437,
              "width":  20,
              "komondor": {"min_channel_allowed":  6,
                           "max_channel_allowed":  6,
                           "central_freq":         2.437}},
        7:   {"f0": 2442,
              "width":  20,
              "komondor": {"min_channel_allowed":  7,
                           "max_channel_allowed":  7,
                           "central_freq":         2.442}},
        8:   {"f0": 2447,
              "width":  20,
              "komondor": {"min_channel_allowed":  8,
                           "max_channel_allowed":  8,
                           "central_freq":         2.447}},
        9:   {"f0": 2452,
              "width":  20,
              "komondor": {"min_channel_allowed":  9,
                           "max_channel_allowed":  9,
                           "central_freq":         2.452}},
        10:  {"f0": 2457,
              "width":  20,
              "komondor": {"min_channel_allowed": 10,
                           "max_channel_allowed": 10,
                           "central_freq":         2.457}},
        11:  {"f0": 2462,
              "width":  20,
              "komondor": {"min_channel_allowed": 11,
                           "max_channel_allowed": 11,
                           "central_freq":         2.462}},
        12:  {"f0": 2467,
              "width":  20,
              "komondor": {"min_channel_allowed": 12,
                           "max_channel_allowed": 12,
                           "central_freq":         2.467}},
        13:  {"f0": 2472,
              "width":  20,
              "komondor": {"min_channel_allowed": 13,
                           "max_channel_allowed": 13,
                           "central_freq":         2.472}},
        14:  {"f0": 2484,
              "width":  20,
              "komondor": {"min_channel_allowed": 14,
                           "max_channel_allowed": 14,
                           "central_freq":         2.484}},
        # 5.150 - 5.330 GHz
        32:  {"f0": 5160,
              "width":  20,
              "komondor": {"min_channel_allowed": 15,
                           "max_channel_allowed": 15,
                           "central_freq":         5.160}},
        34:  {"f0": 5170,
              "width":  40,
              "komondor": {"min_channel_allowed": 15,
                           "max_channel_allowed": 16,
                           "central_freq":         5.170}},
        36:  {"f0": 5180,
              "width":  20,
              "komondor": {"min_channel_allowed": 16,
                           "max_channel_allowed": 16,
                           "central_freq":         5.180}},
        38:  {"f0": 5190,
              "width":  40,
              "komondor": {"min_channel_allowed": 16,
                           "max_channel_allowed": 17,
                           "central_freq":         5.190}},
        40:  {"f0": 5200,
              "width":  20,
              "komondor": {"min_channel_allowed": 17,
                           "max_channel_allowed": 17,
                           "central_freq":         5.200}},
        42:  {"f0": 5210,
              "width":  80,
              "komondor": {"min_channel_allowed": 16,
                           "max_channel_allowed": 19,
                           "central_freq":         5.210}},
        44:  {"f0": 5220,
              "width":  20,
              "komondor": {"min_channel_allowed": 18,
                           "max_channel_allowed": 18,
                           "central_freq":         5.220}},
        46:  {"f0": 5230,
              "width":  40,
              "komondor": {"min_channel_allowed": 18,
                           "max_channel_allowed": 19,
                           "central_freq":         5.230}},
        48:  {"f0": 5240,
              "width":  20,
              "komondor": {"min_channel_allowed": 19,
                           "max_channel_allowed": 19,
                           "central_freq":         5.240}},
        50:  {"f0": 5250,
              "width": 160,
              "komondor": {"min_channel_allowed": 16,
                           "max_channel_allowed": 23,
                           "central_freq":         5.250}},
        52:  {"f0": 5260,
              "width":  20,
              "komondor": {"min_channel_allowed": 20,
                           "max_channel_allowed": 20,
                           "central_freq":         5.260}},
        54:  {"f0": 5270,
              "width":  40,
              "komondor": {"min_channel_allowed": 20,
                           "max_channel_allowed": 21,
                           "central_freq":         5.270}},
        56:  {"f0": 5280,
              "width":  20,
              "komondor": {"min_channel_allowed": 21,
                           "max_channel_allowed": 21,
                           "central_freq":         5.280}},
        58:  {"f0": 5290,
              "width":  80,
              "komondor": {"min_channel_allowed": 20,
                           "max_channel_allowed": 23,
                           "central_freq":         5.290}},
        60:  {"f0": 5300,
              "width":  20,
              "komondor": {"min_channel_allowed": 22,
                           "max_channel_allowed": 22,
                           "central_freq":         5.300}},
        62:  {"f0": 5310,
              "width":  40,
              "komondor": {"min_channel_allowed": 22,
                           "max_channel_allowed": 23,
                           "central_freq":         5.310}},
        64:  {"f0": 5320,
              "width":  20,
              "komondor": {"min_channel_allowed": 23,
                           "max_channel_allowed": 23,
                           "central_freq":         5.320}},
        # 5.330 - 5350 GHz
        68:  {"f0": 5340,
              "width":  20,
              "komondor": {"min_channel_allowed": 24,
                           "max_channel_allowed": 24,
                           "central_freq":         5.340}},
        # 5.470 - 5.490 GHz
        96:  {"f0": 5480,
              "width":  20,
              "komondor": {"min_channel_allowed": 25,
                           "max_channel_allowed": 25,
                           "central_freq":         5.480}},
        # 5490 - 5650 GHz
        100: {"f0": 5500,
              "width":  20,
              "komondor": {"min_channel_allowed": 26,
                           "max_channel_allowed": 26,
                           "central_freq":         5.500}},
        102: {"f0": 5510,
              "width":  40,
              "komondor": {"min_channel_allowed": 26,
                           "max_channel_allowed": 27,
                           "central_freq":         5510}},
        104: {"f0": 5520,
              "width":  20,
              "komondor": {"min_channel_allowed": 27,
                           "max_channel_allowed": 27,
                           "central_freq":         5.520}},
        106: {"f0": 5530,
              "width":  80,
              "komondor": {"min_channel_allowed": 26,
                           "max_channel_allowed": 29,
                           "central_freq":         5.530}},
        108: {"f0": 5540,
              "width":  20,
              "komondor": {"min_channel_allowed": 28,
                           "max_channel_allowed": 28,
                           "central_freq":         5.540}},
        110: {"f0": 5550,
              "width":  40,
              "komondor": {"min_channel_allowed": 28,
                           "max_channel_allowed": 29,
                           "central_freq":         5.550}},
        112: {"f0": 5560,
              "width":  20,
              "komondor": {"min_channel_allowed": 29,
                           "max_channel_allowed": 29,
                           "central_freq":         5.560}},
        114: {"f0": 5570,
              "width": 160,
              "komondor": {"min_channel_allowed": 26,
                           "max_channel_allowed": 33,
                           "central_freq":         5.570}},
        116: {"f0": 5580,
              "width":  20,
              "komondor": {"min_channel_allowed": 30,
                           "max_channel_allowed": 30,
                           "central_freq":         5.580}},
        118: {"f0": 5590,
              "width":  40,
              "komondor": {"min_channel_allowed": 30,
                           "max_channel_allowed": 31,
                           "central_freq":         5.590}},
        120: {"f0": 5600,
              "width":  20,
              "komondor": {"min_channel_allowed": 31,
                           "max_channel_allowed": 31,
                           "central_freq":         5.600}},
        122: {"f0": 5610,
              "width":  80,
              "komondor": {"min_channel_allowed": 30,
                           "max_channel_allowed": 33,
                           "central_freq":         5.610}},
        124: {"f0": 5620,
              "width":  20,
              "komondor": {"min_channel_allowed": 32,
                           "max_channel_allowed": 32,
                           "central_freq":         5.620}},
        126: {"f0": 5630,
              "width":  40,
              "komondor": {"min_channel_allowed": 32,
                           "max_channel_allowed": 33,
                           "central_freq":         5.630}},
        128: {"f0": 5640,
              "width":  20,
              "komondor": {"min_channel_allowed": 33,
                           "max_channel_allowed": 33,
                           "central_freq":         5.640}},
        # 5.650 - 5.730GHz
        132: {"f0": 5660,
              "width":  20,
              "komondor": {"min_channel_allowed": 34,
                           "max_channel_allowed": 34,
                           "central_freq":         5.660}},
        134: {"f0": 5670,
              "width":  40,
              "komondor": {"min_channel_allowed": 34,
                           "max_channel_allowed": 35,
                           "central_freq":         5.670}},
        136: {"f0": 5680,
              "width":  20,
              "komondor": {"min_channel_allowed": 35,
                           "max_channel_allowed": 35,
                           "central_freq":         5.680}},
        138: {"f0": 5690,
              "width":  80,
              "komondor": {"min_channel_allowed": 34,
                           "max_channel_allowed": 37,
                           "central_freq":         5.690}},
        140: {"f0": 5700,
              "width":  20,
              "komondor": {"min_channel_allowed": 36,
                           "max_channel_allowed": 36,
                           "central_freq":         5.700}},
        142: {"f0": 5710,
              "width":  40,
              "komondor": {"min_channel_allowed": 36,
                           "max_channel_allowed": 37,
                           "central_freq":         5.710}},
        144: {"f0": 5720,
              "width":  20,
              "komondor": {"min_channel_allowed": 37,
                           "max_channel_allowed": 37,
                           "central_freq":         5.720}},
        # 5.735 - 5.815 GHz
        149: {"f0": 5745,
              "width":  20,
              "komondor": {"min_channel_allowed": 38,
                           "max_channel_allowed": 38,
                           "central_freq":         5.745}},
        151: {"f0": 5755,
              "width":  40,
              "komondor": {"min_channel_allowed": 38,
                           "max_channel_allowed": 39,
                           "central_freq":         5.755}},
        153: {"f0": 5765,
              "width":  20,
              "komondor": {"min_channel_allowed": 39,
                           "max_channel_allowed": 39,
                           "central_freq":         5.765}},
        155: {"f0": 5775,
              "width":  80,
              "komondor": {"min_channel_allowed": 38,
                           "max_channel_allowed": 41,
                           "central_freq":         5.775}},
        157: {"f0": 5785,
              "width":  20,
              "komondor": {"min_channel_allowed": 40,
                           "max_channel_allowed": 40,
                           "central_freq":         5.785}},
        159: {"f0": 5795,
              "width":  40,
              "komondor": {"min_channel_allowed": 40,
                           "max_channel_allowed": 41,
                           "central_freq":         5.795}},
        161: {"f0": 5805,
              "width":  20,
              "komondor": {"min_channel_allowed": 41,
                           "max_channel_allowed": 41,
                           "central_freq":         5.805}},
        # 5.835 - 5.855 GHz
        169: {"f0": 5845,
              "width":  20,
              "komondor": {"min_channel_allowed": 42,
                           "max_channel_allowed": 42,
                           "central_freq":         5.845}},
        # 5.855 - 5.875 GHz
        173: {"f0": 5865,
              "width":  20,
              "komondor": {"min_channel_allowed": 43,
                           "max_channel_allowed": 43,
                           "central_freq":         5.865}}}

    @classmethod
    def channel_num(cls, min_channel_allowed, max_channel_allowed):
        for ch, val in cls.channel_map.items():
            k_conf = val['komondor']
            if k_conf['min_channel_allowed'] == int(min_channel_allowed) and \
               k_conf['max_channel_allowed'] == int(max_channel_allowed):
                   return ch
        return None

    def __init__(self, channel_num):
        self.num = channel_num
        channel_dict = Channel.channel_map[channel_num]
        self.f0 = channel_dict["f0"]
        self.width = channel_dict["width"]
        self.komondor_channel_params = channel_dict["komondor"]

    def __eq__(self, other):
        return self.num == other.num

    def __lt__(self, other):
        return self.num < other.num
