コード例 #1
0
    def testMultipleTagLines(self):
        queue = tag_block.TagQueue()
        queue.put(r'\s:station1,c:1425344187*78\a')
        queue.put(r'\s:spacecraft2,c:1425344304*0E\b')
        queue.put(r'\c:1425344187,s:station1*78\c')

        self.assertEqual(queue.qsize(), 3)

        item = queue.get()
        self.assertDictContainsSubset2(
            item, {
                'line_nums': [1],
                'lines': ['\\s:station1,c:1425344187*78\\a'],
                'times': [1425344187]
            })
        expected_match = {
            'group': None,
            'group_id': None,
            'metadata': 's:station1,c:1425344187*78',
            'payload': 'a',
            'rcvr': 'station1',
            'tag_checksum': '78',
            'time': 1425344187
        }
        self.assertDictContainsSubset2(item['matches'][0], expected_match)

        item = queue.get()
        self.assertDictContainsSubset2(
            item, {
                'line_nums': [2],
                'lines': ['\\s:spacecraft2,c:1425344304*0E\\b'],
                'times': [1425344304]
            })
        expected_match = {
            'group': None,
            'group_id': None,
            'metadata': 's:spacecraft2,c:1425344304*0E',
            'payload': 'b',
            'rcvr': 'spacecraft2',
            'tag_checksum': '0E',
            'time': 1425344304
        }
        self.assertDictContainsSubset2(item['matches'][0], expected_match)

        item = queue.get()
        self.assertDictContainsSubset2(
            item, {
                'line_nums': [3],
                'lines': ['\\c:1425344187,s:station1*78\\c'],
                'times': [1425344187]
            })
        expected_match = {
            'group': None,
            'group_id': None,
            'metadata': 'c:1425344187,s:station1*78',
            'rcvr': 'station1',
            'tag_checksum': '78',
            'time': 1425344187
        }
        self.assertDictContainsSubset2(item['matches'][0], expected_match)
コード例 #2
0
ファイル: tag_block_test.py プロジェクト: rutsky/libais
  def testTwoLines(self):
    lines = (r'\s:rcvr42,g:1-2-13*2A\abc', r'\g:2-2-13*5F\def')
    queue = tag_block.TagQueue()
    queue.put(lines[0])
    self.assertEqual(queue.qsize(), 0)

    queue.put(lines[1])
    self.assertEqual(queue.qsize(), 1)
コード例 #3
0
    def testSingleLineMessage(self):
        # Do one detailed comparison.
        expected = {
            'decoded': {
                'cog': 142,
                'gnss': True,
                'id': 27,
                'md5': 'fb6a0946b7dc8a6a4f5d06db113793d5',
                'mmsi': 577305000,
                'nav_status': 5,
                'position_accuracy': 1,
                'raim': False,
                'repeat_indicator': 0,
                'sog': 0,
                'spare': 0,
                'x': -90.20666666666666,
                'y': 29.145
            },
            'line_nums': [1],
            # pylint: disable=line-too-long
            'lines': [
                '\\n:852057,s:b003669955,c:1428451729*1B\\!ABVDM,1,1,,A,K8VSqb9LdU28WP8p,0*49'
            ],
            'matches': [{
                'dest': None,
                'group': None,
                'group_id': None,
                'line_num': 852057,
                'metadata': 'n:852057,s:b003669955,c:1428451729*1B',
                'payload': '!ABVDM,1,1,,A,K8VSqb9LdU28WP8p,0*49',
                'quality': None,
                'rcvr': 'b003669955',
                'rel_time': None,
                'sentence_num': None,
                'sentence_tot': None,
                'tag_checksum': '1B',
                'text': None,
                'text_date': None,
                'time': 1428451729
            }],
            'times': [1428451729]
        }

        line = (
            # pylint: disable=line-too-long
            r'\n:852057,s:b003669955,c:1428451729*1B\!ABVDM,1,1,,A,K8VSqb9LdU28WP8p,0*49'
        )

        queue = tag_block.TagQueue()
        queue.put(line)
        self.assertEqual(queue.qsize(), 1)
        msg = queue.get(line)
        self.assertEqual(msg, expected)
コード例 #4
0
ファイル: tag_block_test.py プロジェクト: rutsky/libais
 def testTwoLineGroupWithTwoLineMessage(self):
   lines = (
       # pylint: disable=line-too-long
       r'\g:1-2-9459,s:rORBCOMM009,c:1426032120,T:2015-03-11 00.02.00*31\!AIVDM,2,1,9,A,59NS9142>SW@7PQWR20u84pLF1=Dr2222222221SDHa?A0l;`CDhCU3lp888,0*5B',
       r'\g:2-2-9459,s:rORBCOMM009,c:1426032120,T:2015-03-11 00.02.00*32\!AIVDM,2,2,9,A,88888888880,2*2D',
       )
   queue = tag_block.TagQueue()
   for line in lines:
     queue.put(line)
   self.assertEqual(queue.qsize(), 1)
   msg = queue.get()
   self.assertEqual(msg['decoded']['id'], 5)
   self.assertEqual(msg['times'], [1426032120, 1426032120])
コード例 #5
0
ファイル: tag_block_test.py プロジェクト: rutsky/libais
  def testTwoLineGroupWithSingleLineMessage(self):

    lines = (
        # pylint: disable=line-too-long
        r'\g:1-2-89372,n:192113,s:r003669946,c:1428451252*41\!AIVDM,1,1,,A,181520h000JstMLHbOFc1CUd0<07,0*35',
        r'\g:2-2-89372,n:192114*1C\$ARVSI,r003669946,,000052.59031009,1972,-108,0*1B'
        )
    queue = tag_block.TagQueue()
    for line in lines:
      queue.put(line)
    self.assertEqual(queue.qsize(), 1)
    msg = queue.get()
    self.assertEqual(msg['decoded']['id'], 1)
コード例 #6
0
ファイル: tag_block_test.py プロジェクト: rutsky/libais
 def testThreeLineGroupWithTwoLineMessage(self):
   lines = (
       # pylint: disable=line-too-long
       r'\g:1-3-6417,n:4504,s:D13MN-PS-MTEBS1,c:1428451206*07\!SAVDM,2,1,7,B,59NSGLD2Cn5@CDLkN21Tu8dL5@F2222222222216EHMC=4w`0L@hEPC`8888,0*1A',
       r'\g:2-3-6417,n:4505*24\!SAVDM,2,2,7,B,88888888880,2*3A',
       r'\g:3-3-6417,n:4506*26\$SAVSI,D13MN-PS-MTEBS1,7,000006.831194,256,-97,19*67',
   )
   queue = tag_block.TagQueue()
   for line in lines:
     queue.put(line)
   self.assertEqual(queue.qsize(), 1)
   msg = queue.get()
   self.assertEqual(msg['decoded']['id'], 5)
   self.assertEqual(msg['times'], [1428451206, None, None])
コード例 #7
0
ファイル: tag_block_test.py プロジェクト: rutsky/libais
 def testManySingleLineMessages(self):
   lines = [line for line in SINGLE_LINE_MESSAGES.split('\n') if 'VD' in line]
   queue = tag_block.TagQueue()
   for line in lines:
     queue.put(line)
   self.assertEqual(queue.qsize(), len(lines))
   msgs = []
   while not queue.empty():
     msgs.append(queue.get())
   self.assertEqual(len(msgs), len(lines))
   for msg in msgs:
     self.assertIn('decoded', msg)
   id_list = [msg['decoded']['id'] for msg in msgs]
   self.assertEqual(
       id_list,
       [
           1, 2, 3, 1, 2, 2, 3, 3, 4, 7, 10, 11, 12, 12, 14, 14, 15, 15, 18,
           18, 20, 20, 20, 21, 21, 22, 23, 24, 24, 24, 25, 26, 26, 26, 27
       ])
コード例 #8
0
ファイル: tag_block_test.py プロジェクト: rutsky/libais
 def testNonTagBlockLines(self):
   queue = tag_block.TagQueue()
   queue.put('1')
   self.assertEqual(queue.qsize(), 1)
   queue.put('2')
   self.assertEqual(queue.qsize(), 2)
   self.assertEqual(queue.get(), {
       'line_nums': [1],
       'lines': ['1'],
   })
   self.assertEqual(queue.qsize(), 1)
   self.assertEqual(queue.get(), {
       'line_nums': [2],
       'lines': ['2'],
   })
   self.assertEqual(queue.qsize(), 0)
   queue.put('3')
   self.assertEqual(queue.get(), {
       'line_nums': [3],
       'lines': ['3'],
   })
コード例 #9
0
ファイル: tag_block_test.py プロジェクト: rutsky/libais
 def testMissingFirst(self):
   queue = tag_block.TagQueue()
   # Queue should drop the message without the first part.
   queue.put(r'\g:2-2-13*5F\def')
   self.assertEqual(queue.qsize(), 0)
   self.assertEqual(len(queue.groups), 0)
コード例 #10
0
ファイル: nmea_queue.py プロジェクト: hsiboy/seabus
 def __init__(self):
   self.bare_queue = vdm.BareQueue()
   self.tagb_queue = tag_block.TagQueue()
   self.uscg_queue = uscg.UscgQueue()
   self.line_num = 0
   Queue.Queue.__init__(self)