コード例 #1
0
ファイル: t21.py プロジェクト: tww-software/py_ais_nmea
 def __init__(self, msgbinary):
     super().__init__(msgbinary)
     self.aidtype = self.navaidtypes[self.decode_sixbit_integer(
         msgbinary[38:43])]
     name = binary.decode_sixbit_ascii(msgbinary[43:163]).rstrip()
     self.posfixaccuracy = self.accuracy[self.decode_sixbit_integer(
         msgbinary[163:164])]
     self.longitude = binary.decode_twos_complement(
         msgbinary[164:192]) / 600000.0
     self.latitude = binary.decode_twos_complement(
         msgbinary[192:219]) / 600000.0
     tobow = self.decode_sixbit_integer(msgbinary[219:228])
     tostern = self.decode_sixbit_integer(msgbinary[228:237])
     toport = self.decode_sixbit_integer(msgbinary[237:243])
     tostarboard = self.decode_sixbit_integer(msgbinary[243:249])
     self.length = tobow + tostern
     self.width = toport + tostarboard
     self.epfdfixtype = self.epfdfixtypes[self.decode_sixbit_integer(
         msgbinary[249:253])]
     self.timestampsecond = self.decode_sixbit_integer(msgbinary[253:259])
     self.offposition = self.binaryflag[self.decode_sixbit_integer(
         msgbinary[259:260])]
     self.raim = self.binaryflag[self.decode_sixbit_integer(
         msgbinary[268:269])]
     self.virtualaid = self.binaryflag[self.decode_sixbit_integer(
         msgbinary[269:270])]
     self.assignedmode = self.binaryflag[self.decode_sixbit_integer(
         msgbinary[270:271])]
     nameextension = binary.decode_sixbit_ascii(msgbinary[272:361]).rstrip()
     self.name = name + nameextension
コード例 #2
0
ファイル: t18.py プロジェクト: tww-software/py_ais_nmea
 def __init__(self, msgbinary):
     super().__init__(msgbinary)
     self.speed = self.decode_sixbit_integer(msgbinary[46:56]) / 10
     self.posfixaccuracy = self.accuracy[self.decode_sixbit_integer(
         msgbinary[46:47])]
     self.longitude = binary.decode_twos_complement(
         msgbinary[57:85]) / 600000.0
     self.latitude = binary.decode_twos_complement(
         msgbinary[85:112]) / 600000.0
     self.courseoverground = self.decode_sixbit_integer(
         msgbinary[112:124]) / 10
     self.trueheading = self.decode_sixbit_integer(msgbinary[124:133])
     self.timestampsecond = self.decode_sixbit_integer(msgbinary[133:139])
     self.csunit = self.csdict[self.decode_sixbit_integer(
         msgbinary[141:142])]
     self.displayunit = self.binaryflag[self.decode_sixbit_integer(
         msgbinary[142:143])]
     self.dscflag = self.binaryflag[self.decode_sixbit_integer(
         msgbinary[143:144])]
     self.bandflag = self.binaryflag[self.decode_sixbit_integer(
         msgbinary[144:145])]
     self.message22flag = self.binaryflag[self.decode_sixbit_integer(
         msgbinary[145:146])]
     self.assignedmodeflag = self.assignmentmode[self.decode_sixbit_integer(
         msgbinary[146:147])]
     self.raim = self.binaryflag[self.decode_sixbit_integer(
         msgbinary[147:148])]
     self.radiostatus = self.decode_sixbit_integer(msgbinary[148:168])
コード例 #3
0
ファイル: t123.py プロジェクト: tww-software/py_ais_nmea
 def __init__(self, msgbinary):
     super().__init__(msgbinary)
     self.navstatus = self.navstatustypes[self.decode_sixbit_integer(
         msgbinary[38:42])]
     self.turnrate = decode_turn_rate(msgbinary[42:50])
     self.speed = self.decode_sixbit_integer(msgbinary[50:60]) / 10
     self.posfixaccuracy = self.accuracy[self.decode_sixbit_integer(
         msgbinary[60:61])]
     self.longitude = binary.decode_twos_complement(
         msgbinary[61:89]) / 600000.0
     self.latitude = binary.decode_twos_complement(
         msgbinary[89:116]) / 600000.0
     self.courseoverground = self.decode_sixbit_integer(
         msgbinary[116:128]) / 10
     self.trueheading = self.decode_sixbit_integer(msgbinary[128:137])
     self.timestampsecond = self.decode_sixbit_integer(
         msgbinary[137:143])
     try:
         self.maneuverindicator = self.maneuvers[self.decode_sixbit_integer(
             msgbinary[143:145])]
     except KeyError:
         self.maneuverindicator = 'unknown'
     self.raim = self.binaryflag[self.decode_sixbit_integer(
         msgbinary[148:149])]
     self.radiostatus = self.decode_sixbit_integer(msgbinary[149:168])
コード例 #4
0
ファイル: t19.py プロジェクト: tww-software/py_ais_nmea
 def __init__(self, msgbinary):
     super().__init__(msgbinary)
     self.speed = self.decode_sixbit_integer(msgbinary[46:56]) / 10
     self.posfixaccuracy = self.accuracy[self.decode_sixbit_integer(
         msgbinary[46:47])]
     self.longitude = binary.decode_twos_complement(
         msgbinary[57:85]) / 600000.0
     self.latitude = binary.decode_twos_complement(
         msgbinary[85:112]) / 600000.0
     self.courseoverground = self.decode_sixbit_integer(
         msgbinary[112:124]) / 10
     self.trueheading = self.decode_sixbit_integer(msgbinary[124:133])
     self.timestampsecond = self.decode_sixbit_integer(msgbinary[133:139])
     self.name = binary.decode_sixbit_ascii(msgbinary[143:263]).rstrip()
     try:
         self.shiptype = self.shiptypes[self.decode_sixbit_integer(
             msgbinary[263:271])]
     except KeyError:
         self.shiptype = 'Unknown'
     tobow = self.decode_sixbit_integer(msgbinary[271:280])
     tostern = self.decode_sixbit_integer(msgbinary[280:289])
     toport = self.decode_sixbit_integer(msgbinary[289:295])
     tostarboard = self.decode_sixbit_integer(msgbinary[295:301])
     self.length = tobow + tostern
     self.width = toport + tostarboard
     self.epfdfixtype = self.epfdfixtypes[self.decode_sixbit_integer(
         msgbinary[301:305])]
     self.raim = self.binaryflag[self.decode_sixbit_integer(
         msgbinary[305:306])]
     self.dte = self.dtevalues[self.decode_sixbit_integer(
         msgbinary[306:307])]
コード例 #5
0
 def __init__(self, msgbinary):
     super().__init__(msgbinary)
     self.posfixaccuracy = self.accuracy[self.decode_sixbit_integer(
         msgbinary[38:39])]
     self.raim = self.binaryflag[self.decode_sixbit_integer(
         msgbinary[39:40])]
     self.navstatus = self.navstatustypes[self.decode_sixbit_integer(
         msgbinary[40:44])]
     self.longitude = binary.decode_twos_complement(
         msgbinary[44:62]) / 600.0
     self.latitude = binary.decode_twos_complement(msgbinary[62:79]) / 600.0
     self.speed = self.decode_sixbit_integer(msgbinary[79:85]) / 10
     self.courseoverground = self.decode_sixbit_integer(msgbinary[85:94])
     self.gnsspositon = self.binaryflag[self.decode_sixbit_integer(
         msgbinary[94:95])]
コード例 #6
0
ファイル: t123.py プロジェクト: tww-software/py_ais_nmea
def decode_turn_rate(rawvalue):
    """
    decode the turn rate value to something meaningful

    Args:
        rawvalue(str): turn rate encoded as binary string

    Returns:
        turnvalue(str): actual turn rate of the vessel
    """
    decodedturnrate = binary.decode_sixbit_integer(rawvalue)
    decodedvalues = {
        0: 'not turning', 128: 'no turn rate available',
        127: ('turning right at more than 10 degrees per minute'
              ' - NO TURN INDICATOR'),
        129: ('turning left at more than -10 degrees per minute'
              ' - NO TURN INDICATOR')}
    if decodedturnrate in decodedvalues:
        turnvalue = decodedvalues[decodedturnrate]
    else:
        twos = binary.decode_twos_complement(rawvalue)
        rot = (twos / 4.733) ** 2
        if rawvalue[0] == '1':
            rot = rot * -1
            direction = 'left'
        else:
            direction = 'right'
        turnvalue = 'turning {} at {} degrees per minute'.format(
            direction, round(rot, 1))
    return turnvalue
コード例 #7
0
 def __init__(self, msgbinary):
     super().__init__(msgbinary)
     self.altitude = self.decode_sixbit_integer(msgbinary[38:50])
     self.speedoverground = self.decode_sixbit_integer(msgbinary[50:60])
     self.posfixaccuracy = self.accuracy[self.decode_sixbit_integer(
         msgbinary[60:61])]
     self.longitude = binary.decode_twos_complement(
         msgbinary[61:89]) / 600000.0
     self.latitude = binary.decode_twos_complement(
         msgbinary[89:116]) / 600000.0
     self.courseoverground = self.decode_sixbit_integer(
         msgbinary[116:128]) / 10
     self.timestampsecond = self.decode_sixbit_integer(msgbinary[128:134])
     self.dte = self.dtevalues[self.decode_sixbit_integer(
         msgbinary[142:143])]
     self.raim = self.binaryflag[self.decode_sixbit_integer(
         msgbinary[147:148])]
     self.radiostatus = self.decode_sixbit_integer(msgbinary[148:168])
コード例 #8
0
ファイル: t4.py プロジェクト: tww-software/py_ais_nmea
 def __init__(self, msgbinary):
     super().__init__(msgbinary)
     year = self.decode_sixbit_integer(msgbinary[38:52])
     month = self.decode_sixbit_integer(msgbinary[52:56])
     day = self.decode_sixbit_integer(msgbinary[56:61])
     hour = self.decode_sixbit_integer(msgbinary[61:66])
     minute = self.decode_sixbit_integer(msgbinary[66:72])
     second = self.decode_sixbit_integer(msgbinary[72:78])
     self.timestamp = '{}/{:02d}/{:02d} {:02d}:{:02d}:{:02d}'.format(
         year, month, day, hour, minute, second)
     self.posfixaccuracy = self.accuracy[self.decode_sixbit_integer(
         msgbinary[78:79])]
     self.longitude = binary.decode_twos_complement(
         msgbinary[79:107]) / 600000.0
     self.latitude = binary.decode_twos_complement(
         msgbinary[107:134]) / 600000.0
     self.epfdfixtype = self.epfdfixtypes[self.decode_sixbit_integer(
         msgbinary[134:138])]
     self.raim = self.binaryflag[self.decode_sixbit_integer(
         msgbinary[148:149])]
     self.sotdmastate = self.decode_sixbit_integer(msgbinary[149:168])
コード例 #9
0
ファイル: test_ais.py プロジェクト: tww-software/py_ais_nmea
 def test_empty_string_decode_twos_complement(self):
     """
     an empty string should raise a NoBinaryData exception
     """
     with self.assertRaises(binary.NoBinaryData):
         binary.decode_twos_complement('')