export function subString (str, start, len) 
{
	start = parseInt(start);
	len = parseInt(len);
    return str.substring(start, len);
}

export function BitParse (str16) {
    let map = {
      '0': '0000',
      '1': '0001',
      '2': '0010',
      '3': '0011',
      '4': '0100',
      '5': '0101',
      '6': '0110',
      '7': '0111',
      '8': '1000',
      '9': '1001',
      'a': '1010',
      'b': '1011',
      'c': '1100',
      'd': '1101',
      'e': '1110',
      'f': '1111',
	  'A': '1010',
      'B': '1011',
      'C': '1100',
      'D': '1101',
      'E': '1110',
      'F': '1111'
    };
    let bit = [];
	
	for(let index = 0; index < str16.length; index++)
	{
		for (let key in map) {
			if (str16[index] === key) {
				bit[index] = map[key];
			}
		}
	} 
	
    return bit.join('');
 }
 
 export function getStrBitStr (str16) {
    let bit = BitParse(str16);
	let start = 8;
    let len = 1;
	
    return bit.substring(start, len);
 }

 export function getReplayStatus (str16, start) {
    let bit = BitParse(str16);
	
	if(bit.length > start)
	{
		let c = bit[start];
		let d = (c == "0") ? 0 : 1;
		return d;
	}
	
	return null;
 }


 export function getReplayStatus2 (str16, start) {
	let bit = BitParse(str16);
    if(bit.length > start)
	{
		let c = bit[start];
		let d = (c == "1") ? 0 : 1;
		return d;
	}
	
	return null;
 }