src/utilities.js
function processImpedanceData (o) {
  const byteId = parseInt(o.rawDataPacket[0]);
  let channelNumber;
  switch (byteId) {
    case k.OBCIGanglionByteIdImpedanceChannel1:
      channelNumber = 1;
      break;
    case k.OBCIGanglionByteIdImpedanceChannel2:
      channelNumber = 2;
      break;
    case k.OBCIGanglionByteIdImpedanceChannel3:
      channelNumber = 3;
      break;
    case k.OBCIGanglionByteIdImpedanceChannel4:
      channelNumber = 4;
      break;
    case k.OBCIGanglionByteIdImpedanceChannelReference:
      channelNumber = 0;
      break;
  }

  let output = {
    channelNumber: channelNumber,
    impedanceValue: 0
  };

  let end = o.rawDataPacket.length;

  while (Number.isNaN(Number(o.rawDataPacket.slice(1, end))) && end !== 0) {
    end--;
  }

  if (end !== 0) {
    output.impedanceValue = Number(o.rawDataPacket.slice(1, end));
  }

  return output;
}
function processImpedanceData (o) {
  const byteId = parseInt(o.rawDataPacket[0]);
  let channelNumber;
  switch (byteId) {
    case k.OBCIGanglionByteIdImpedanceChannel1:
      channelNumber = 1;
      break;
    case k.OBCIGanglionByteIdImpedanceChannel2:
      channelNumber = 2;
      break;
    case k.OBCIGanglionByteIdImpedanceChannel3:
      channelNumber = 3;
      break;
    case k.OBCIGanglionByteIdImpedanceChannel4:
      channelNumber = 4;
      break;
    case k.OBCIGanglionByteIdImpedanceChannelReference:
      channelNumber = 0;
      break;
  }

  let output = {
    channelNumber: channelNumber,
    impedanceValue: 0
  };

  let end = o.rawDataPacket.length;

  while (Number.isNaN(Number(o.rawDataPacket.slice(1, end))) && end !== 0) {
    end--;
  }

  if (end !== 0) {
    output.impedanceValue = Number(o.rawDataPacket.slice(1, end));
  }

  return output;
}
function processImpedanceData ( o ) { const byteId = parseInt ( o . rawDataPacket [ 0 ] ) ; let channelNumber ; switch ( byteId ) { case k . OBCIGanglionByteIdImpedanceChannel1 : channelNumber = 1 ; break ; case k . OBCIGanglionByteIdImpedanceChannel2 : channelNumber = 2 ; break ; case k . OBCIGanglionByteIdImpedanceChannel3 : channelNumber = 3 ; break ; case k . OBCIGanglionByteIdImpedanceChannel4 : channelNumber = 4 ; break ; case k . OBCIGanglionByteIdImpedanceChannelReference : channelNumber = 0 ; break ; } let output = { channelNumber : channelNumber , impedanceValue : 0 } ; let end = o . rawDataPacket . length ; while ( Number . isNaN ( Number ( o . rawDataPacket . slice ( 1 , end ) ) ) && end !== 0 ) { end -- ; } if ( end !== 0 ) { output . impedanceValue = Number ( o . rawDataPacket . slice ( 1 , end ) ) ; } return output ; }
Process and emit an impedance value
@param o {RawDataToSample} - Used to hold data and configuration settings
@private
Process and emit an impedance value