ADS-B Version

    Args:
        msg (string): 28 bytes hexadecimal message string, TC = 31

    Returns:
        int: version number
15400
def version(msg):
    
    tc = typecode(msg)

    if tc != 31:
        raise RuntimeError("%s: Not a status operation message, expecting TC = 31" % msg)

    msgbin = common.hex2bin(msg)
    version = common.bin2int(msgbin[72:75])

    return version
447795
def _get_new_msg_id(self):
        
        now = time.time() + self.time_offset
        nanoseconds = int((now - int(now)) * 1e+9)
        new_msg_id = (int(now) << 32) | (nanoseconds << 2)

        if self._last_msg_id >= new_msg_id:
            new_msg_id = self._last_msg_id + 4

        self._last_msg_id = new_msg_id
        return new_msg_id
487271
def ic45(msg):
    
    d = hex2bin(data(msg))
    if d[9] == '0':
        return None

    ic = bin2int(d[10:12])
    return ic
962545
def hash256(msg_bytes):
    '''
    
    '''
    if 'decred' in riemann.get_current_network_name():
        return blake256(blake256(msg_bytes))
    return hashlib.sha256(hashlib.sha256(msg_bytes).digest()).digest()
636057
def fetch_plaintext(self, msg_nums):
        
        if not msg_nums:
            raise Exception("Invalid Message Number!")

        return self.__imap_fetch_content_type(msg_nums, self.PLAIN)
1236350
def sign(self, msg: Dict) -> Dict:
        
        ser = serialize_msg_for_signing(msg, topLevelKeysToIgnore=[f.SIG.nm])
        bsig = self.naclSigner.signature(ser)
        sig = base58.b58encode(bsig).decode("utf-8")
        return sig
369702
def parse(bin_payload):    
    
    
    message_hash = hexlify(bin_payload)
    if not is_hex( message_hash ):
        log.warning("Not a message hash")
        return None 

    if len(message_hash) != 40:
        log.warning("Not a 160-bit hash")
        return None 

    return {
       'opcode': 'ANNOUNCE',
       'message_hash': message_hash
    }
256951
def tas53(msg):
    
    d = hex2bin(data(msg))

    if d[33] == '0':
        return None

    tas = bin2int(d[34:46]) * 0.5   # kts
    return round(tas, 1)
184333
def icao(msg):
    

    DF = df(msg)

    if DF in (11, 17, 18):
        addr = msg[2:8]
    elif DF in (0, 4, 5, 16, 20, 21):
        c0 = bin2int(crc(msg, encode=True))
        c1 = hex2int(msg[-6:])
        addr = '%06X' % (c0 ^ c1)
    else:
        addr = None

    return addr
1199652
def board_msg(self):
        """"""
        board_str = "s\t\t"
        for i in xrange(self.board_width):
            board_str += str(i)+"\t"
        board_str = board_str.expandtabs(4)+"\n\n"

        for i in xrange(self.board_height):
            temp_line = str(i)+"\t\t"
            for j in xrange(self.board_width):
                if self.info_map[i, j] == 9:
                    temp_line += "@\t"
                elif self.info_map[i, j] == 10:
                    temp_line += "?\t"
                elif self.info_map[i, j] == 11:
                    temp_line += "*\t"
                elif self.info_map[i, j] == 12:
                    temp_line += "!\t"
                else:
                    temp_line += str(self.info_map[i, j])+"\t"
            board_str += temp_line.expandtabs(4)+"\n"

        return board_str
102853
def ias53(msg):
    
    d = hex2bin(data(msg))

    if d[12] == '0':
        return None

    ias = bin2int(d[13:23])    # knots
    return ias
347134
def mach53(msg):
    
    d = hex2bin(data(msg))

    if d[23] == '0':
        return None

    mach = bin2int(d[24:33]) * 0.008
    return round(mach, 3)
1015025
public static int extractFlagsFromType2Message(byte[] msg) {
        byte[] flagsBytes = new byte[4];

        System.arraycopy(msg, 20, flagsBytes, 0, 4);
        ByteUtilities.changeWordEndianess(flagsBytes, 0, 4);

        return ByteUtilities.makeIntFromByte4(flagsBytes);
    }
1063011
def is40(msg):
    

    if allzeros(msg):
        return False

    d = hex2bin(data(msg))

    # status bit 1, 14, and 27

    if wrongstatus(d, 1, 2, 13):
        return False

    if wrongstatus(d, 14, 15, 26):
        return False

    if wrongstatus(d, 27, 28, 39):
        return False

    if wrongstatus(d, 48, 49, 51):
        return False

    if wrongstatus(d, 54, 55, 56):
        return False

    # bits 40-47 and 52-53 shall all be zero

    if bin2int(d[39:47]) != 0:
        return False

    if bin2int(d[51:53]) != 0:
        return False

    return True
1285952
def turb45(msg):
    
    d = hex2bin(data(msg))
    if d[0] == '0':
        return None

    turb = bin2int(d[1:3])
    return turb
1338062
def nic_s(msg):
    
    tc = typecode(msg)

    if tc != 31:
        raise RuntimeError("%s: Not a status operation message, expecting TC = 31" % msg)

    msgbin = common.hex2bin(msg)
    nic_s = int(msgbin[75])

    return nic_s
951570
def handleMarketDepth(self, msg):
        

        # make sure symbol exists
        if msg.tickerId not in self.marketDepthData.keys():
            self.marketDepthData[msg.tickerId] = self.marketDepthData[0].copy()

        # bid
        if msg.side == 1:
            self.marketDepthData[msg.tickerId].loc[msg.position, "bid"] = msg.price
            self.marketDepthData[msg.tickerId].loc[msg.position, "bidsize"] = msg.size

        # ask
        elif msg.side == 0:
            self.marketDepthData[msg.tickerId].loc[msg.position, "ask"] = msg.price
            self.marketDepthData[msg.tickerId].loc[msg.position, "asksize"] = msg.size

        """
        # bid/ask spread / vol diff
        self.marketDepthData[msg.tickerId].loc[msg.position, "spread"] = \
            self.marketDepthData[msg.tickerId].loc[msg.position, "ask"]-\
            self.marketDepthData[msg.tickerId].loc[msg.position, "bid"]

        self.marketDepthData[msg.tickerId].loc[msg.position, "spreadsize"] = \
            self.marketDepthData[msg.tickerId].loc[msg.position, "asksize"]-\
            self.marketDepthData[msg.tickerId].loc[msg.position, "bidsize"]
        """

        self.ibCallback(caller="handleMarketDepth", msg=msg)