예제 #1
0
 def doUpdate(self, sv, parser, namespace, values, option_string):
     if namespace.message_type == "zero":
         messageL1 = ConstMessage(1)
         messageL2 = messageL1
     elif namespace.message_type == "one":
         messageL1 = ConstMessage(-1)
         messageL2 = messageL1
     elif namespace.message_type == "zero+one":
         messageL1 = ZeroOneMessage()
         messageL2 = messageL1
     elif namespace.message_type == "crc":
         if isinstance(sv, GPSSatellite):
             messageL1 = LNavMessage(sv.prn)
             messageL2 = CNavMessage(sv.prn)
         elif isinstance(sv, GLOSatellite):
             messageL1 = GLOMessage(sv.prn)
             messageL2 = GLOMessage(sv.prn)
         else:
             raise ValueError(
                 "Message type is not supported for a satellite type")
     else:
         raise ValueError("Unsupported message type")
     if isinstance(sv, GPSSatellite):
         sv.setL1CAMessage(messageL1)
         sv.setL2CMessage(messageL2)
     elif isinstance(sv, GLOSatellite):
         sv.setL1Message(messageL1)
         sv.setL2Message(messageL2)
     else:
         raise ValueError("Unsupported object type in SV list")
예제 #2
0
def test_CNavMessage_str():
    '''
  GPS CNav message: string representation
  '''
    msg = CNavMessage(1, tow0=2, n_msg=1, n_prefixBits=30)
    value = str(msg)
    assert value.find('CNAV') >= 0
예제 #3
0
def test_CNavMessage_getDataBits0():
    '''
  GPS CNav message: fetch data bits
  '''
    dataAll_idx = numpy.linspace(0, 299, 300, dtype=numpy.long)
    msg = CNavMessage(1, tow0=2, n_msg=1, n_prefixBits=30)
    bits = msg.getDataBits(dataAll_idx)
    assert isinstance(bits, numpy.ndarray)
    assert bits.shape == (300, )
    assert (bits == msg.symbolData[:300]).all()
예제 #4
0
def test_GPSSV_messages():
    '''
  GPS SV messages test
  '''
    sv = GPSSatellite(1)
    assert sv.l1caMessage == sv.getL1CAMessage()
    assert sv.l2cMessage == sv.getL2CMessage()
    lnav = LNavMessage(1)
    cnav = CNavMessage(1)
    sv.setL1CAMessage(lnav)
    sv.setL2CMessage(cnav)
    assert sv.l1caMessage == sv.getL1CAMessage() == lnav
    assert sv.l2cMessage == sv.getL2CMessage() == cnav
예제 #5
0
def test_CNavMessage_init0():
    '''
  GPS LNav message construction: empty
  '''
    msg = CNavMessage(1, tow0=0, n_msg=0, n_prefixBits=0)
    assert msg.n_msg0 == 0
    assert msg.prn == 1
    assert msg.tow0 == 0
    assert msg.nextTow == 0
    assert msg.n_prefixBits == 0
    assert msg.messageLen == 0
    assert msg.messageCount == 0
    assert isinstance(msg.symbolData, numpy.ndarray)
예제 #6
0
def test_CNavMessage_init3():
    '''
  GPS LNav message construction: ToW rollover
  '''
    msg = CNavMessage(1, tow0=100800 - 2, n_msg=1, n_prefixBits=30)
    assert msg.n_msg0 == 1
    assert msg.prn == 1
    assert msg.tow0 == 100798
    assert msg.nextTow == 0
    assert msg.n_prefixBits == 30
    assert msg.messageLen == 660
    assert msg.messageCount == 1
    assert isinstance(msg.symbolData, numpy.ndarray)
    assert msg.symbolData.shape == (660, )
예제 #7
0
def test_CNavMessage_init2():
    '''
  GPS LNav message construction: 2 messages + prefix
  '''
    msg = CNavMessage(1, tow0=2, n_msg=2, n_prefixBits=30)
    assert msg.n_msg0 == 2
    assert msg.prn == 1
    assert msg.tow0 == 2
    assert msg.nextTow == 6
    assert msg.n_prefixBits == 30
    assert msg.messageLen == 1260
    assert msg.messageCount == 2
    assert isinstance(msg.symbolData, numpy.ndarray)
    assert msg.symbolData.shape == (1260, )
예제 #8
0
def test_CNavMessage_init1():
    '''
  GPS LNav message construction: prefix only
  '''
    msg = CNavMessage(1, tow0=1, n_msg=0, n_prefixBits=30)
    assert msg.n_msg0 == 0
    assert msg.prn == 1
    assert msg.tow0 == 1
    assert msg.nextTow == 1
    assert msg.n_prefixBits == 30
    assert msg.messageLen == 60
    assert msg.messageCount == 0
    assert isinstance(msg.symbolData, numpy.ndarray)
    assert msg.symbolData.shape == (60, )