src/utilities.js
function getNumFromThreeCSVADSRegisterQuery (str, regEx, offset) {
  let regExArr = str.match(regEx);
  if (regExArr) {
    const bit2 = parseInt(str.charAt(regExArr.index + offset));
    const bit1 = parseInt(str.charAt(regExArr.index + offset + 3));
    const bit0 = parseInt(str.charAt(regExArr.index + offset + 6));
    if (!Number.isNaN(bit2) && !Number.isNaN(bit1) && !Number.isNaN(bit0)) {
      return bit2 << 2 | bit1 << 1 | bit0;
    } else {
      throw new Error(k.OBCIErrorInvalidData);
    }
  } else {
    throw new Error(k.OBCIErrorMissingRegisterSetting);
  }
}
function getNumFromThreeCSVADSRegisterQuery (str, regEx, offset) {
  let regExArr = str.match(regEx);
  if (regExArr) {
    const bit2 = parseInt(str.charAt(regExArr.index + offset));
    const bit1 = parseInt(str.charAt(regExArr.index + offset + 3));
    const bit0 = parseInt(str.charAt(regExArr.index + offset + 6));
    if (!Number.isNaN(bit2) && !Number.isNaN(bit1) && !Number.isNaN(bit0)) {
      return bit2 << 2 | bit1 << 1 | bit0;
    } else {
      throw new Error(k.OBCIErrorInvalidData);
    }
  } else {
    throw new Error(k.OBCIErrorMissingRegisterSetting);
  }
}
function getNumFromThreeCSVADSRegisterQuery ( str , regEx , offset ) { let regExArr = str . match ( regEx ) ; if ( regExArr ) { const bit2 = parseInt ( str . charAt ( regExArr . index + offset ) ) ; const bit1 = parseInt ( str . charAt ( regExArr . index + offset + 3 ) ) ; const bit0 = parseInt ( str . charAt ( regExArr . index + offset + 6 ) ) ; if ( ! Number . isNaN ( bit2 ) && ! Number . isNaN ( bit1 ) && ! Number . isNaN ( bit0 ) ) { return bit2 << 2 | bit1 << 1 | bit0 ; } else { throw new Error ( k . OBCIErrorInvalidData ) ; } } else { throw new Error ( k . OBCIErrorMissingRegisterSetting ) ; } }
Used to get a number from the raw query data
@param str {String} - The raw query data
@param regEx {RegExp} - The regular expression to index off of
@param offset {Number} - The number of bytes offset from index to start
Used to get a number from the raw query data