
export class PidDataProcess{

  //Default function
  private static defaultFunc(data, unit : string) : any{
    return (parseInt(data, 16)) + unit;
  }

  //Vehicle RPM
  private static _010C(data: string) : any {
    console.log("Called this method, data was: " + data);

    return (parseInt(data.replace(" ", ""), 16) / 4) + "rpm";
  }

  public static getData(pid: string, data: string, unit: string) : string{
    let func;
    switch(pid){
     case "010C": func = this._010C; break;
     default: func = this.defaultFunc; break;
    }
    return String(func(data.substring(6), unit));
  }
}

export class PidDataProcess{

  public static useImperialUnits: boolean;

  //Default function
  private static defaultFunc(data) : any{
    return (parseInt(data.replace(" ", ""), 16));
  }

  //Vehicle RPM
  private static _010C(data: string) : any {
    return (parseInt(data.replace(" ", ""), 16) / 4);
  }

  public static getData(pid: string, data: string, unit: string, iUnit?: string, iUnitConvert?: Function) : string{
    let func;
    switch(pid){
     case "010C": func = this._010C; break;
     default: func = this.defaultFunc; break;
    }

    if(PidDataProcess.useImperialUnits && iUnitConvert != null){
      return String(iUnitConvert(func(data.substring(6))) + iUnit);
    }else{
      return String(func(data.substring(6)) + unit);
    }
  }
}

Add support for Imperial Units aka dumb units
Add support for Imperial Units aka dumb units
