channel information done

channel table modify
This commit is contained in:
YiChin2018
2019-07-18 19:27:01 +08:00
parent cfe57b152f
commit 2e011084ed
3 changed files with 59 additions and 4 deletions
+18 -1
View File
@@ -60,6 +60,17 @@ def rearrange_channel_mux_table(channel_table: List[bool]) -> Optional[List[int]
return channel_mux
def channel_used_count(channel_mux: List[int]) -> Optional[List[int]]:
channel_uc = [0] * 16
for i in range(16):
for j in range(1,17):
if channel_mux[i] == j:
channel_uc[j-1] += 1
return channel_uc
class UniRearrangeMuxChannelTest(unittest.TestCase):
def test_empty_channel(self):
self.assertIsNone(rearrange_channel_mux_table(to_channel_table()))
@@ -69,7 +80,7 @@ class UniRearrangeMuxChannelTest(unittest.TestCase):
c = randint(0, REC_CHANNEL_COUNT - 1)
expect = [c if i == 0 else 0 for i in range(REC_CHANNEL_COUNT)]
print(expect)
# print(expect)
self.assertEqual(expect, rearrange_channel_mux_table(to_channel_table(c)))
def test_two_channel(self):
@@ -98,6 +109,12 @@ class UniRearrangeMuxChannelTest(unittest.TestCase):
self.assertEqual([7, 8, 3, 4, 5, 6, 7, 8, 0, 0, 0, 0, 0, 0, 0, 0, ],
rearrange_channel_mux_table(to_channel_table(3, 4, 5, 6, 7, 8)))
channel_uc = []
channel_mux = []
ch_mux = rearrange_channel_mux_table(to_channel_table(3, 4, 5, 6, 7, 8))
ch_used = channel_used_count(ch_mux)
print(ch_used)
print(ch_mux)
if __name__ == '__main__':