示例#1
0
def decode(bv, validate=False):
	'''Unpack a gnss_correction message 

	Fields in params:
	  - MessageID(uint): AIS message number.  Must be 17 (field automatically set to "17")
	  - RepeatIndicator(uint): Indicated how many times a message has been repeated
	  - UserID(uint): Base station identification number (MMSI)
	  - Spare(uint): Reserved for definition by a regional authority. (field automatically set to "0")
	  - x(decimal): East West location
	  - y(decimal): North South location
	  - Spare2(uint): Reserved for definition by a regional authority. (field automatically set to "0")
	  - BinaryData(binary): GNSS Differential correction data
	@type bv: BitVector
	@param bv: Bits defining a message
	@param validate: Set to true to cause checking to occur.  Runs slower.  FIX: not implemented.
	@rtype: dict
	@return: params
	'''

	#Would be nice to check the bit count here..
	#if validate:
	#	assert (len(bv)==FIX: SOME NUMBER)
	r = {}
	r['MessageID']=17
	r['RepeatIndicator']=int(bv[6:8])
	r['UserID']=int(bv[8:38])
	r['Spare']=0
	r['x']=Decimal(binary.signedIntFromBV(bv[40:58]))/Decimal('600')
	r['y']=Decimal(binary.signedIntFromBV(bv[58:75]))/Decimal('600')
	r['Spare2']=0
	r['BinaryData']=bv[80:]
	return r
示例#2
0
def decode(bv, validate=False):
	'''Unpack a positionb message 

	Fields in params:
	  - MessageID(uint): AIS message number.  Must be 18 (field automatically set to "18")
	  - RepeatIndicator(uint): Indicated how many times a message has been repeated
	  - UserID(uint): Unique ship identification number (MMSI)
	  - Reserved1(uint): Reseverd for definition by a compentent regional or local authority.  Should be set to zero. (field automatically set to "0")
	  - SOG(udecimal): Speed over ground
	  - PositionAccuracy(uint): Accuracy of positioning fixes
	  - longitude(decimal): Location of the vessel  East West location
	  - latitude(decimal): Location of the vessel  North South location
	  - COG(udecimal): Course over ground
	  - TrueHeading(uint): True heading (relative to true North)
	  - TimeStamp(uint): UTC second when the report was generated
	  - Spare(uint): Not used.  Should be set to zero. (field automatically set to "0")
	  - cs_unit(bool): Does this unit do Carrier Sense?
	  - display_flag(bool): Does this class B unit have an integrated display?
	  - dsc_flag(bool): Does it have dedicated or time-shared DSC radio function?
	  - band_flag(bool): How flexible is the freq handling of the unit?
	  - msg22_flag(bool): Can the unit handle msg 22?
	  - mode_flag(bool): Assigned mode wrt to VDL slots
	  - RAIM(bool): Receiver autonomous integrity monitoring flag
	  - CommStateSelector(uint): SOTDMA or ITDMA
	  - CommState(uint): Not decoded by this software yet
	@type bv: BitVector
	@param bv: Bits defining a message
	@param validate: Set to true to cause checking to occur.  Runs slower.  FIX: not implemented.
	@rtype: dict
	@return: params
	'''

	#Would be nice to check the bit count here..
	#if validate:
	#	assert (len(bv)==FIX: SOME NUMBER)
	r = {}
	r['MessageID']=18
	r['RepeatIndicator']=int(bv[6:8])
	r['UserID']=int(bv[8:38])
	r['Reserved1']=0
	r['SOG']=Decimal(int(bv[46:56]))/Decimal('10')
	r['PositionAccuracy']=int(bv[56:57])
	r['longitude']=Decimal(binary.signedIntFromBV(bv[57:85]))/Decimal('600000')
	r['latitude']=Decimal(binary.signedIntFromBV(bv[85:112]))/Decimal('600000')
	r['COG']=Decimal(int(bv[112:124]))/Decimal('10')
	r['TrueHeading']=int(bv[124:133])
	r['TimeStamp']=int(bv[133:139])
	r['Spare']=0
	r['cs_unit']=bool(int(bv[141:142]))
	r['display_flag']=bool(int(bv[142:143]))
	r['dsc_flag']=bool(int(bv[143:144]))
	r['band_flag']=bool(int(bv[144:145]))
	r['msg22_flag']=bool(int(bv[145:146]))
	r['mode_flag']=bool(int(bv[146:147]))
	r['RAIM']=bool(int(bv[147:148]))
	r['CommStateSelector']=int(bv[148:149])
	r['CommState']=int(bv[149:168])
	return r
    def decode_bits(self, bits, year=None):
        'decode the bits for a message'

        message_id       = int( bits[:6] )
	repeat_indicator = int(bits[6:8])
	self.source_mmsi      = int( bits[8:38] )
        spare            = int( bits[38:40] )
        dac       = int( bits[40:50] )
        fi        = int( bits[50:56] )
        assert(dac==1)
        assert(fi==31)

        self.lon = binary.signedIntFromBV(bits[56:81])/60000.
        self.lat = binary.signedIntFromBV(bits[81:105])/60000.
        self.pos_acc = int( bits[105:106] )

        self.day = int( bits[106:111] )
        self.hour = int( bits[111:116] )
        self.minute = int( bits[116:122] )

        self.wind = int( bits[122:129] )
        self.gust = int( bits[129:136] )
        self.wind_dir = int( bits[136:145] )
        self.gust_dir = int( bits[145:154] )

        self.air_temp = binary.signedIntFromBV(bits[154:165])/10.
        self.humid = int( bits[165:172] )
        self.dew = binary.signedIntFromBV(bits[172:182])/10.
        self.air_pres = int( bits[182:191] ) + 799
        self.air_pres_trend = int( bits[191:193] )

        self.vis = int( bits[193:201] )/ 10.

        self.wl = int(bits[201:213])/100. - 10
        self.wl_trend = int( bits[213:215] )
        self.cur = [
            {'speed':int( bits[215:223] )/10., 'dir':int( bits[223:232] ), 'level':0},
            {'speed':int( bits[232:240] )/10., 'dir':int( bits[240:249] ), 'level':int( bits[249:254] )},
            {'speed':int( bits[254:262] )/10., 'dir':int( bits[262:271] ), 'level':int( bits[271:276] )},
            ]

        self.wave_height = int( bits[276:284] ) / 10.

        self.wave_period = int( bits[284:290] )
        self.wave_dir = int( bits[290:299] )

        self.swell_height = int( bits[299:307] ) / 10.
        self.swell_period = int( bits[307:313] )
        self.swell_dir = int( bits[313:322] )

        self.sea_state = int( bits[322:326] )
        self.water_temp = binary.signedIntFromBV(bits[326:336])/10.

        self.precip = int( bits[336:339] )
        self.salinity = int( bits[339:348] ) / 10.
        self.ice = int( bits[348:350] )
def decode(bv, validate=False):
	'''Unpack a bsreport message

	Fields in params:
	  - MessageID(uint): AIS message number.  Must be 4 (field automatically set to "4")
	  - RepeatIndicator(uint): Indicated how many times a message has been repeated
	  - UserID(uint): Unique ship identification number (MMSI)
	  - Time_year(uint): Current time stamp  year 1-9999
	  - Time_month(uint): Current time stamp  month 1..12
	  - Time_day(uint): Current time stamp  day of the month 1..31
	  - Time_hour(uint): Current time stamp  UTC hours 0..23
	  - Time_min(uint): Current time stamp  minutes
	  - Time_sec(uint): Current time stamp  seconds
	  - PositionAccuracy(uint): Accuracy of positioning fixes
	  - Position_longitude(decimal): Location of base station  East West location
	  - Position_latitude(decimal): Location of base station  North South location
	  - fixtype(uint): Method used for positioning
	  - Spare(uint): Not used.  Should be set to zero. (field automatically set to "0")
	  - RAIM(bool): Receiver autonomous integrity monitoring flag
	  - state_syncstate(uint): Communications State - SOTDMA  Sycronization state
	  - state_slottimeout(uint): Communications State - SOTDMA  Frames remaining until a new slot is selected
	  - state_slotoffset(uint): Communications State - SOTDMA  In what slot will the next transmission occur. BROKEN
	@type bv: BitVector
	@param bv: Bits defining a message
	@param validate: Set to true to cause checking to occur.  Runs slower.  FIX: not implemented.
	@rtype: dict
	@return: params
	'''

	#Would be nice to check the bit count here..
	#if validate:
	#	assert (len(bv)==FIX: SOME NUMBER)
	r = {}
	r['MessageID']=4
	r['RepeatIndicator']=int(bv[6:8])
	r['UserID']=int(bv[8:38])
	r['Time_year']=int(bv[38:52])
	r['Time_month']=int(bv[52:56])
	r['Time_day']=int(bv[56:61])
	r['Time_hour']=int(bv[61:66])
	r['Time_min']=int(bv[66:72])
	r['Time_sec']=int(bv[72:78])
	r['PositionAccuracy']=int(bv[78:79])
	r['Position_longitude']=Decimal(binary.signedIntFromBV(bv[79:107]))/Decimal('600000')
	r['Position_latitude']=Decimal(binary.signedIntFromBV(bv[107:134]))/Decimal('600000')
	r['fixtype']=int(bv[134:138])
	r['Spare']=0
	r['RAIM']=bool(int(bv[148:149]))
        r.update(commstate.sotdma_parse_bits(bv[-19:]))
        #r['commstate'] = commstate.sotdma_parse_bits(bv[-19:])
	#r['state_syncstate']=int(bv[149:151])
	#r['state_slottimeout']=int(bv[151:154])
	#r['state_slotoffset']=int(bv[154:168])
	return r
示例#5
0
def decode(bv, validate=False):
	'''Unpack a SARposition message 

	Fields in params:
	  - MessageID(uint): AIS message number.  Must be 9 (field automatically set to "9")
	  - RepeatIndicator(uint): Indicated how many times a message has been repeated
	  - UserID(uint): Unique ship identification number (MMSI)
	  - Altitude(uint): Altitude (GNSS)
	  - SOG(uint): Speed over ground
	  - PositionAccuracy(uint): Accuracy of positioning fixes
	  - Position_longitude(decimal): Location of the vessel  East West location
	  - Position_latitude(decimal): Location of the vessel  North South location
	  - COG(udecimal): Course over ground
	  - TimeStamp(uint): UTC second when the report was generated
	  - Reserved(uint): Reserved for regional applications.  Should be set to zero. (field automatically set to "0")
	  - DTE(bool): Dtta terminal ready
	  - Spare(uint): Not used.  Should be set to zero. (field automatically set to "0")
	  - assigned_mode(uint): autonomous or assigned mode
	  - RAIM(bool): Receiver autonomous integrity monitoring flag
	  - comm_state(uint): SOTDMA or ITDMA
	  - state_syncstate(uint): Communications State - SOTDMA  Sycronization state
	  - state_slottimeout(uint): Communications State - SOTDMA  Frames remaining until a new slot is selected
	  - state_slotoffset(uint): Communications State - SOTDMA  In what slot will the next transmission occur. BROKEN
	@type bv: BitVector
	@param bv: Bits defining a message
	@param validate: Set to true to cause checking to occur.  Runs slower.  FIX: not implemented.
	@rtype: dict
	@return: params
	'''

	#Would be nice to check the bit count here..
	#if validate:
	#	assert (len(bv)==FIX: SOME NUMBER)
	r = {}
	r['MessageID']=9
	r['RepeatIndicator']=int(bv[6:8])
	r['UserID']=int(bv[8:38])
	r['Altitude']=int(bv[38:50])
	r['SOG']=int(bv[50:60])
	r['PositionAccuracy']=int(bv[60:61])
	r['Position_longitude']=Decimal(binary.signedIntFromBV(bv[61:89]))/Decimal('600000')
	r['Position_latitude']=Decimal(binary.signedIntFromBV(bv[89:116]))/Decimal('600000')
	r['COG']=Decimal(int(bv[116:128]))/Decimal('10')
	r['TimeStamp']=int(bv[128:134])
	r['Reserved']=0
	r['DTE']=bool(int(bv[142:143]))
	r['Spare']=0
	r['assigned_mode']=int(bv[146:147])
	r['RAIM']=bool(int(bv[147:148]))
	r['comm_state']=int(bv[148:149])
	r['state_syncstate']=int(bv[149:151])
	r['state_slottimeout']=int(bv[151:154])
	r['state_slotoffset']=int(bv[154:168])
	return r
示例#6
0
def decode(bv, validate=False):
	'''Unpack a position message 

	Fields in params:
	  - MessageID(uint): AIS message number.  Must be 1 (field automatically set to "1")
	  - RepeatIndicator(uint): Indicated how many times a message has been repeated
	  - UserID(uint): Unique ship identification number (MMSI)
	  - NavigationStatus(uint): What is the vessel doing
	  - ROT(int): RateOfTurn
	  - SOG(udecimal): Speed over ground
	  - PositionAccuracy(uint): Accuracy of positioning fixes
	  - longitude(decimal): Location of the vessel  East West location
	  - latitude(decimal): Location of the vessel  North South location
	  - COG(udecimal): Course over ground
	  - TrueHeading(uint): True heading (relative to true North)
	  - TimeStamp(uint): UTC second when the report was generated
	  - RegionalReserved(uint): Reserved for definition by a regional authority. (field automatically set to "0")
	  - Spare(uint): Not used.  Should be set to zero. (field automatically set to "0")
	  - RAIM(bool): Receiver autonomous integrity monitoring flag
	  - state_syncstate(uint): Communications State - SOTDMA  Sycronization state
	  - state_slottimeout(uint): Communications State - SOTDMA  Frames remaining until a new slot is selected
	  - state_slotoffset(uint): Communications State - SOTDMA  In what slot will the next transmission occur. BROKEN
	@type bv: BitVector
	@param bv: Bits defining a message
	@param validate: Set to true to cause checking to occur.  Runs slower.  FIX: not implemented.
	@rtype: dict
	@return: params
	'''

	#Would be nice to check the bit count here..
	#if validate:
	#	assert (len(bv)==FIX: SOME NUMBER)
	r = {}
	r['MessageID']=1
	r['RepeatIndicator']=int(bv[6:8])
	r['UserID']=int(bv[8:38])
	r['NavigationStatus']=int(bv[38:42])
	r['ROT']=binary.signedIntFromBV(bv[42:50])
	r['SOG']=Decimal(int(bv[50:60]))/Decimal('10')
	r['PositionAccuracy']=int(bv[60:61])
	r['longitude']=Decimal(binary.signedIntFromBV(bv[61:89]))/Decimal('600000')
	r['latitude']=Decimal(binary.signedIntFromBV(bv[89:116]))/Decimal('600000')
	r['COG']=Decimal(int(bv[116:128]))/Decimal('10')
	r['TrueHeading']=int(bv[128:137])
	r['TimeStamp']=int(bv[137:143])
	r['RegionalReserved']=0
	r['Spare']=0
	r['RAIM']=bool(int(bv[148:149]))
	r['state_syncstate']=int(bv[149:151])
	r['state_slottimeout']=int(bv[151:154])
	r['state_slotoffset']=int(bv[154:168])
	return r
示例#7
0
def decode(bv, validate=False):
	'''Unpack a whalenotice message 

	Fields in params:
	  - MessageID(uint): AIS message number.  Must be 8 (field automatically set to "8")
	  - RepeatIndicator(uint): Indicated how many times a message has been repeated
	  - UserID(uint): Unique ship identification number (MMSI)
	  - Spare(uint): Reserved for definition by a regional authority. (field automatically set to "0")
	  - dac(uint): Designated Area Code - 366 for the United States (field automatically set to "366")
	  - fid(uint): Functional IDentifier - 63 for the Whale Notice (field automatically set to "63")
	  - efid(uint): Extended Functional IDentifier.  1 for the Whale Notice (dac+fid+efid defines the exact message type) (field automatically set to "1")
	  - month(uint): Time of most recent whale detection.  UTC month 1..12
	  - day(uint): Time of most recent whale detection.  UTC day of the month 1..31
	  - hour(uint): Time of most recent whale detection.  UTC hours 0..23
	  - min(uint): Time of most recent whale detection.  UTC minutes
	  - sec(uint): Time of most recent whale detection.  UTC seconds
	  - stationid(aisstr6): Identifier of the station that detected the whale.  (e.g. which buoy)
	  - longitude(decimal): Center of the detection zone.  East West location
	  - latitude(decimal): Center of the detection zone.  North South location
	  - timetoexpire(uint): Seconds from the detection time until the notice expires
	  - radius(uint): Distance from center of detection zone (lat/lon above)
	@type bv: BitVector
	@param bv: Bits defining a message
	@param validate: Set to true to cause checking to occur.  Runs slower.  FIX: not implemented.
	@rtype: dict
	@return: params
	'''

	#Would be nice to check the bit count here..
	#if validate:
	#	assert (len(bv)==FIX: SOME NUMBER)
	r = {}
	r['MessageID']=8
	r['RepeatIndicator']=int(bv[6:8])
	r['UserID']=int(bv[8:38])
	r['Spare']=0
	r['dac']=366
	r['fid']=63
	r['efid']=1
	r['month']=int(bv[68:72])
	r['day']=int(bv[72:77])
	r['hour']=int(bv[77:82])
	r['min']=int(bv[82:88])
	r['sec']=int(bv[88:94])
	r['stationid']=aisstring.decode(bv[94:136])
	r['longitude']=Decimal(binary.signedIntFromBV(bv[136:164]))/Decimal('600000')
	r['latitude']=Decimal(binary.signedIntFromBV(bv[164:191]))/Decimal('600000')
	r['timetoexpire']=int(bv[191:207])
	r['radius']=int(bv[207:223])
	return r
示例#8
0
def decode(bv, validate=False):
	'''Unpack a ChanMngmt message 

	Fields in params:
	  - MessageID(uint): AIS message number.  Must be 22 (field automatically set to "22")
	  - RepeatIndicator(uint): Indicated how many times a message has been repeated
	  - UserID(uint): Unique ship identification number (MMSI)
	  - Spare(uint): Not used.  Should be set to zero. (field automatically set to "0")
	  - ChanA(uint): Channel number from ITU-R M.1084 Annex 4
	  - ChanB(uint): Channel number from ITU-R M.1084 Annex 4
	  - TxRxMode(uint): FIX: find the description
	  - power(uint): FIX: put in a description
	  - corner1_lon(decimal): north-east corner of area for assignment  longitude of corner
	  - corner1_lat(decimal): north-east corner of area for assignment  latitude of corner
	  - corner2_lon(decimal): south-west corner of area for assignment  longitude of corner
	  - corner2_lat(decimal): south-west corner of area for assignment  latitude of corner
	  - IndicatorType(uint): FIX: put in a description
	  - ChanABandwidth(uint): FIX: put in a description
	  - ChanBBandwidth(uint): FIX: put in a description
	  - TransZoneSize(uint): FIX: put in a description
	  - Spare2(uint): Not used.  Should be set to zero. (field automatically set to "0")
	@type bv: BitVector
	@param bv: Bits defining a message
	@param validate: Set to true to cause checking to occur.  Runs slower.  FIX: not implemented.
	@rtype: dict
	@return: params
	'''

	#Would be nice to check the bit count here..
	#if validate:
	#	assert (len(bv)==FIX: SOME NUMBER)
	r = {}
	r['MessageID']=22
	r['RepeatIndicator']=int(bv[6:8])
	r['UserID']=int(bv[8:38])
	r['Spare']=0
	r['ChanA']=int(bv[40:52])
	r['ChanB']=int(bv[52:64])
	r['TxRxMode']=int(bv[64:68])
	r['power']=int(bv[68:69])
	r['corner1_lon']=Decimal(binary.signedIntFromBV(bv[69:87]))/Decimal('600')
	r['corner1_lat']=Decimal(binary.signedIntFromBV(bv[87:104]))/Decimal('600')
	r['corner2_lon']=Decimal(binary.signedIntFromBV(bv[104:122]))/Decimal('600')
	r['corner2_lat']=Decimal(binary.signedIntFromBV(bv[122:139]))/Decimal('600')
	r['IndicatorType']=int(bv[139:140])
	r['ChanABandwidth']=int(bv[140:141])
	r['ChanBBandwidth']=int(bv[141:142])
	r['TransZoneSize']=int(bv[142:145])
	r['Spare2']=0
	return r
示例#9
0
def decode(bv, validate=False):
    """Unpack a bsreport message.

    Fields in params:
      - MessageID(uint): AIS message number.  Must be 4 (field automatically set to "4")
      - RepeatIndicator(uint): Indicated how many times a message has been repeated
      - UserID(uint): Unique ship identification number (MMSI)
      - Time_year(uint): Current time stamp  year 1-9999
      - Time_month(uint): Current time stamp  month 1..12
      - Time_day(uint): Current time stamp  day of the month 1..31
      - Time_hour(uint): Current time stamp  UTC hours 0..23
      - Time_min(uint): Current time stamp  minutes
      - Time_sec(uint): Current time stamp  seconds
      - PositionAccuracy(uint): Accuracy of positioning fixes
      - Position_longitude(decimal): Location of base station  East West location
      - Position_latitude(decimal): Location of base station  North South location
      - fixtype(uint): Method used for positioning
      - Spare(uint): Not used.  Should be set to zero. (field automatically set to "0")
      - RAIM(bool): Receiver autonomous integrity monitoring flag
      - state_syncstate(uint): Communications State - SOTDMA  Sycronization state
      - state_slottimeout(uint): Communications State - SOTDMA  Frames remaining until a new slot is selected
      - state_slotoffset(uint): Communications State - SOTDMA  In what slot will the next transmission occur. BROKEN
    @type bv: BitVector
    @param bv: Bits defining a message
    @param validate: Set to true to cause checking to occur.  Runs slower.  FIX: not implemented.
    @rtype: dict
    @return: params
    """

    r = {}
    r['MessageID'] = 4
    r['RepeatIndicator'] = int(bv[6:8])
    r['UserID'] = int(bv[8:38])
    r['Time_year'] = int(bv[38:52])
    r['Time_month'] = int(bv[52:56])
    r['Time_day'] = int(bv[56:61])
    r['Time_hour'] = int(bv[61:66])
    r['Time_min'] = int(bv[66:72])
    r['Time_sec'] = int(bv[72:78])
    r['PositionAccuracy'] = int(bv[78:79])
    r['Position_longitude'] = Decimal(binary.signedIntFromBV(
        bv[79:107])) / Decimal('600000')
    r['Position_latitude'] = Decimal(binary.signedIntFromBV(
        bv[107:134])) / Decimal('600000')
    r['fixtype'] = int(bv[134:138])
    r['Spare'] = 0
    r['RAIM'] = bool(int(bv[148:149]))
    r.update(commstate.sotdma_parse_bits(bv[-19:]))
    return r
def decode(bv, validate=False):
	'''Unpack a timed_circular_notice message 

	Fields in params:
	  - MessageID(uint): AIS message number.  Must be 8 (field automatically set to "8")
	  - RepeatIndicator(uint): Indicated how many times a message has been repeated
	  - UserID(uint): Unique ship identification number (MMSI)
	  - Spare(uint): Reserved for definition by a regional authority. (field automatically set to "0")
	  - dac(uint): Designated Area Code - 366 for the United States (field automatically set to "366")
	  - fid(uint): Functional IDentifier - 63 (field automatically set to "63")
	  - month(uint): Start time of most recent notice  UTC month
	  - day(uint): Start time of most recent notice  UTC day of the month 1..31
	  - hour(uint): Start time of most recent notice  UTC hours 0..23
	  - min(uint): Start time of most recent notice  UTC minutes
	  - longitude(decimal): Center of the area/zone  East West location
	  - latitude(decimal): Center of the area/zone  North South location
	  - timetoexpire(uint): Minutes from the start time until the notice expires.  Max is aprox 23 days
	  - radius(udecimal): Distance from center of detection zone (lat/lon above).  Distance in increments of 10 meters
	  - areatype(uint): What does this circular area represent
	@type bv: BitVector
	@param bv: Bits defining a message
	@param validate: Set to true to cause checking to occur.  Runs slower.  FIX: not implemented.
	@rtype: dict
	@return: params
	'''

	#Would be nice to check the bit count here..
	#if validate:
	#	assert (len(bv)==FIX: SOME NUMBER)
	r = {}
	r['MessageID']=8
	r['RepeatIndicator']=int(bv[6:8])
	r['UserID']=int(bv[8:38])
	r['Spare']=0
	r['dac']=366
	r['fid']=63
	r['month']=int(bv[56:60])
	r['day']=int(bv[60:65])
	r['hour']=int(bv[65:70])
	r['min']=int(bv[70:76])
	r['longitude']=Decimal(binary.signedIntFromBV(bv[76:104]))/Decimal('600000')
	r['latitude']=Decimal(binary.signedIntFromBV(bv[104:131]))/Decimal('600000')
	r['timetoexpire']=int(bv[131:146])
	r['radius']=Decimal(int(bv[146:160]))/Decimal('0.1')
	r['areatype']=int(bv[160:168])
	return r
示例#11
0
def decode(bv, validate=False):
	'''Unpack a ChanMngmt message 

	Fields in params:
	  - MessageID(uint): AIS message number.  Must be 23 (field automatically set to "23")
	  - RepeatIndicator(uint): Indicated how many times a message has been repeated
	  - UserID(uint): Unique ship identification number (MMSI)
	  - Spare(uint): Not used.  Should be set to zero. (field automatically set to "0")
	  - corner1_lon(decimal): north-east corner of area for assignment  longitude of corner
	  - corner1_lat(decimal): north-east corner of area for assignment  latitude of corner
	  - corner2_lon(decimal): south-west corner of area for assignment  longitude of corner
	  - corner2_lat(decimal): south-west corner of area for assignment  latitude of corner
	  - StationType(uint): TODO
	  - shipandcargo(uint): what
	  - Spare2(uint): Not used.  Should be set to zero. (field automatically set to "0")
	  - TxRxMode(uint): TODO
	  - ReportingInterval(uint): Command the stations to report as given in table 17
	  - QuietTime(uint): How long to be quiet
	  - Spare3(uint): Not used.  Should be set to zero. (field automatically set to "0")
	@type bv: BitVector
	@param bv: Bits defining a message
	@param validate: Set to true to cause checking to occur.  Runs slower.  FIX: not implemented.
	@rtype: dict
	@return: params
	'''

	#Would be nice to check the bit count here..
	#if validate:
	#	assert (len(bv)==FIX: SOME NUMBER)
	r = {}
	r['MessageID']=23
	r['RepeatIndicator']=int(bv[6:8])
	r['UserID']=int(bv[8:38])
	r['Spare']=0
	r['corner1_lon']=Decimal(binary.signedIntFromBV(bv[40:58]))/Decimal('600')
	r['corner1_lat']=Decimal(binary.signedIntFromBV(bv[58:75]))/Decimal('600')
	r['corner2_lon']=Decimal(binary.signedIntFromBV(bv[75:93]))/Decimal('600')
	r['corner2_lat']=Decimal(binary.signedIntFromBV(bv[93:110]))/Decimal('600')
	r['StationType']=int(bv[110:114])
	r['shipandcargo']=int(bv[114:122])
	r['Spare2']=0
	r['TxRxMode']=int(bv[144:148])
	r['ReportingInterval']=int(bv[148:152])
	r['QuietTime']=int(bv[152:174])
	r['Spare3']=0
	return r
示例#12
0
def decode(bv, validate=False):
	'''Unpack a whalenotice message 

	Fields in params:
	  - MessageID(uint): AIS message number.  Must be 8 (field automatically set to "8")
	  - RepeatIndicator(uint): Indicated how many times a message has been repeated
	  - UserID(uint): Unique ship identification number (MMSI)
	  - Spare(uint): Reserved for definition by a regional authority. (field automatically set to "0")
	  - dac(uint): Designated Area Code - 366 for the United States (field automatically set to "366")
	  - fid(uint): Functional IDentifier - 63 for the Whale Notice (field automatically set to "63")
	  - day(uint): Time of most recent whale detection.  UTC day of the month 1..31
	  - hour(uint): Time of most recent whale detection.  UTC hours 0..23
	  - min(uint): Time of most recent whale detection.  UTC minutes
	  - stationid(uint): Identifier of the station that recorded the whale.  Usually a number.
	  - longitude(decimal): Center of the detection zone.  East West location
	  - latitude(decimal): Center of the detection zone.  North South location
	  - timetoexpire(uint): Minutes from the detection time until the notice expires
	  - radius(uint): Distance from center of detection zone (lat/lon above)
	@type bv: BitVector
	@param bv: Bits defining a message
	@param validate: Set to true to cause checking to occur.  Runs slower.  FIX: not implemented.
	@rtype: dict
	@return: params
	'''

	#Would be nice to check the bit count here..
	#if validate:
	#	assert (len(bv)==FIX: SOME NUMBER)
	r = {}
	r['MessageID']=8
	r['RepeatIndicator']=int(bv[6:8])
	r['UserID']=int(bv[8:38])
	r['Spare']=0
	r['dac']=366
	r['fid']=63
	r['day']=int(bv[56:61])
	r['hour']=int(bv[61:66])
	r['min']=int(bv[66:72])
	r['stationid']=int(bv[72:80])
	r['longitude']=Decimal(binary.signedIntFromBV(bv[80:108]))/Decimal('600000')
	r['latitude']=Decimal(binary.signedIntFromBV(bv[108:135]))/Decimal('600000')
	r['timetoexpire']=int(bv[135:151])
	r['radius']=int(bv[151:167])
	return r
示例#13
0
def decode(bv, validate=False):
    r = {}
    r['MessageID']=int(bv[:6])
    r['RepeatIndicator']=int(bv[6:8])
    r['UserID']=int(bv[8:38])
    r['NavigationStatus']=int(bv[38:42])
    r['ROT']=binary.signedIntFromBV(bv[42:50])
    r['SOG']=Decimal(int(bv[50:60]))/Decimal('10')
    r['PositionAccuracy']=int(bv[60:61])
    r['longitude']=Decimal(binary.signedIntFromBV(bv[61:89]))/Decimal('600000')
    r['latitude']=Decimal(binary.signedIntFromBV(bv[89:116]))/Decimal('600000')
    r['COG']=Decimal(int(bv[116:128]))/Decimal('10')
    r['TrueHeading']=int(bv[128:137])
    r['TimeStamp']=int(bv[137:143])
    r['RegionalReserved']=0
    r['Spare']=0
    r['RAIM']=bool(int(bv[148:149]))
    r.update(commstate.sotdma_parse_bits(bv[-19:]))
    return r
示例#14
0
def decode(bv, validate=False):
	r = {}
	r['MessageID']=int(bv[:6])
	r['RepeatIndicator']=int(bv[6:8])
	r['UserID']=int(bv[8:38])
	r['NavigationStatus']=int(bv[38:42])
	r['ROT']=binary.signedIntFromBV(bv[42:50])
	r['SOG']=Decimal(int(bv[50:60]))/Decimal('10')
	r['PositionAccuracy']=int(bv[60:61])
	r['longitude']=Decimal(binary.signedIntFromBV(bv[61:89]))/Decimal('600000')
	r['latitude']=Decimal(binary.signedIntFromBV(bv[89:116]))/Decimal('600000')
	r['COG']=Decimal(int(bv[116:128]))/Decimal('10')
	r['TrueHeading']=int(bv[128:137])
	r['TimeStamp']=int(bv[137:143])
	r['RegionalReserved']=0
	r['Spare']=0
	r['RAIM']=bool(int(bv[148:149]))
	r.update(commstate.itdma_parse_bits(bv[-19:]))
	return r
示例#15
0
def decode(bv, validate=False):
	'''Unpack a alltypesmsg message.

	Fields in params:
	  - dac(uint): Designated Area Code (field automatically set to "366")
	  - reqDecimal(decimal): required decimal value... FIX: scale or no? (field automatically set to "122")
	  - unavail_uint(uint): Unavailable unsigned integer
	  - anUInt(uint): NO unavailable unsigned integer
	  - anInt(int): NO unavailable signed integer
	  - aBool(bool): Simple bool
	  - aStr(aisstr6): An ais string of 5 characters
	  - anUDecimal(udecimal): An unsigned decimal.  Allow smaller numbers
	  - aDecimal(decimal): A decimal
	  - aFloat(float): An IEEE floating point number
	@type bv: BitVector
	@param bv: Bits defining a message
	@param validate: Set to true to cause checking to occur.  Runs slower.  FIX: not implemented.
	@rtype: dict
	@return: params
	'''

	#Would be nice to check the bit count here..
	#if validate:
	#	assert (len(bv)==FIX: SOME NUMBER)
	r = {}
	r['dac']=366
	r['reqDecimal']=122/Decimal('1')
	r['unavail_uint']=int(bv[24:26])
	r['anUInt']=int(bv[26:28])
	r['anInt']=binary.signedIntFromBV(bv[28:31])
	r['aBool']=bool(int(bv[31:32]))
	r['aStr']=aisstring.decode(bv[32:62])
	r['anUDecimal']=Decimal(int(bv[62:78]))/Decimal('10')
	r['aDecimal']=Decimal(binary.signedIntFromBV(bv[78:94]))/Decimal('10')
	r['aFloat']=binary.bitvec2float(bv[94:126])
	return r
示例#16
0
def decode(bv, validate=False):
	'''Unpack a waterlevel message 

	Fields in params:
	  - MessageID(uint): AIS message number.  Must be 8 (field automatically set to "8")
	  - RepeatIndicator(uint): Indicated how many times a message has been repeated
	  - UserID(uint): Unique ship identification number (MMSI)
	  - Spare(uint): Reserved for definition by a regional authority. (field automatically set to "0")
	  - dac(uint): Designated Area Code (field automatically set to "366")
	  - fid(uint): Functional Identifier (field automatically set to "63")
	  - month(uint): Time the measurement represents  month 1..12
	  - day(uint): Time the measurement represents  day of the month 1..31
	  - hour(uint): Time the measurement represents  UTC hours 0..23
	  - min(uint): Time the measurement represents  minutes
	  - stationid(aisstr6): Character identifier of the station.  Usually a number.
	  - waterlevel(int): Water level in centimeters
	  - datum(uint): What reference datum applies to the value
	  - sigma(uint): Standard deviation of 1 second samples used to compute the water level height.  FIX: is this the correct description of sigma?
	  - source(uint): How the water level was derived
	@type bv: BitVector
	@param bv: Bits defining a message
	@param validate: Set to true to cause checking to occur.  Runs slower.  FIX: not implemented.
	@rtype: dict
	@return: params
	'''

	#Would be nice to check the bit count here..
	#if validate:
	#	assert (len(bv)==FIX: SOME NUMBER)
	r = {}
	r['MessageID']=8
	r['RepeatIndicator']=int(bv[6:8])
	r['UserID']=int(bv[8:38])
	r['Spare']=0
	r['dac']=366
	r['fid']=63
	r['month']=int(bv[56:60])
	r['day']=int(bv[60:65])
	r['hour']=int(bv[65:70])
	r['min']=int(bv[70:76])
	r['stationid']=aisstring.decode(bv[76:118])
	r['waterlevel']=binary.signedIntFromBV(bv[118:134])
	r['datum']=int(bv[134:139])
	r['sigma']=int(bv[139:146])
	r['source']=int(bv[146:149])
	return r
示例#17
0
def decodePosition_latitude(bv, validate=False):
	return Decimal(binary.signedIntFromBV(bv[107:134]))/Decimal('600000')
示例#18
0
def decodeaDecimal(bv, validate=False):
	return Decimal(binary.signedIntFromBV(bv[78:94]))/Decimal('10')
示例#19
0
def decodePosition_longitude(bv, validate=False):
	return Decimal(binary.signedIntFromBV(bv[79:107]))/Decimal('600000')
示例#20
0
def decodex(bv, validate=False):
	return Decimal(binary.signedIntFromBV(bv[40:58]))/Decimal('600')
示例#21
0
def decodeanInt(bv, validate=False):
	return binary.signedIntFromBV(bv[28:31])
示例#22
0
def decodelongitude(bv, validate=False):
	return Decimal(binary.signedIntFromBV(bv[80:108]))/Decimal('600000')
示例#23
0
def decodelatitude(bv, validate=False):
	return Decimal(binary.signedIntFromBV(bv[108:135]))/Decimal('600000')
示例#24
0
def float_dec(bv):
    '''@rtype: float'''
    return float(binary.signedIntFromBV(bv))
示例#25
0
def decimal_dec(bv):
    '''@rtype: Decimal'''
    return Decimal(binary.signedIntFromBV(bv))
示例#26
0
def decodeROT(bv, validate=False):
	return binary.signedIntFromBV(bv[42:50])
示例#27
0
def int_dec(bv):
    '''@rtype: int'''
    return int(binary.signedIntFromBV(bv))
示例#28
0
def decodecorner2_lat(bv, validate=False):
	return Decimal(binary.signedIntFromBV(bv[93:110]))/Decimal('600')
示例#29
0
def decodecorner2_lon(bv, validate=False):
	return Decimal(binary.signedIntFromBV(bv[75:93]))/Decimal('600')
示例#30
0
def decodecorner1_lat(bv, validate=False):
	return Decimal(binary.signedIntFromBV(bv[58:75]))/Decimal('600')
示例#31
0
 def GetSignedInt(self, length):
   end = self.pos + length
   value = binary.signedIntFromBV(self.bits[self.pos:end])
   self.pos += length
   return value
示例#32
0
def decodewaterlevel(bv, validate=False):
	return binary.signedIntFromBV(bv[118:134])