function hrdat=get_hr(file_loc,ButtonName,chan)

%Where the java resides to parse the HS2
clean='java -cp C:\JavaJar\mbari.jar;C:\JavaJar\oasis.jar org.mbari.oasis.HRDataCleaner';
decode='java -cp C:\JavaJar\mbari.jar;C:\JavaJar\oasis.jar org.mbari.hobilabs.HRBinaryConverter';


   
if ButtonName== 'EP2'
    switch chan,
    case 1
    sn='HR020837_';
    hrcal='\\Hematite\oasisnt\oasis\cfg\hr1.hr020837.20020920';
    %hrcal='\\Tower\oasisnt\oasis\cfg\hr1.hr020837.20020920';
    pos = '1';
    inst_good = '0d0a4852312c';
    inst_bad = '0d0a485231452c';
    confile ='C:\Temp\hr1con';
    case 2
    sn='HR020836_';
    hrcal='\\Hematite\oasisnt\oasis\cfg\hr2.hr020836.20020920';
    %hrcal='\\Tower\oasisnt\oasis\cfg\hr2.hr020836.20020920';
    inst_good = '0d0a4852312c';
    inst_bad = '0d0a485231452c';
    pos = '2';
    confile ='C:\Temp\hr2con';
    case 3
    sn='HR020836_';
    hrcal='\\Hematite\oasisnt\oasis\cfg\hr2.hr020836.20020920';
    %hrcal='\\Tower\oasisnt\oasis\cfg\hr2.hr020836.20020920';
    inst_good = '0d0a4852312c';
    inst_bad = '0d0a485231452c';
    pos = '3';
    confile ='C:\Temp\hr3con';
    end;
    
elseif ButtonName== 'EP1'
    switch chan,
    case 1
    sn='HR020202_';
    hrcal='\\Tower\oasisnt\oasis\cfg\hr1.hr020202.20030413';
    %hrcal='\\Hematite\oasisnt\oasis\cfg\hr1.hr020202.20030413';
    pos = '1';
    inst_good = '4852312c48523032303230320';
    inst_bad = '5352312c53523032303230320';
    confile ='C:\Temp\hr1con';
    case 2
    sn='HR020231_';
    hrcal='\\Tower\oasisnt\oasis\cfg\hr2.hr020231.20030413';
    %hrcal='\\Hematite\oasisnt\oasis\cfg\hr2.hr020231.20030413';
    inst_good = '4852312c48523032303230320';
    inst_bad = '5352312c53523032303230320';
    pos = '2';
    confile ='C:\Temp\hr2con';
    case 3
    sn='HR020231_';
    hrcal='\\Tower\oasisnt\oasis\cfg\hr2.hr020231.20030413';
    %hrcal='\\Hematite\oasisnt\oasis\cfg\hr2.hr020231.20030413';
    inst_good = '4852312c48523032303230320';
    inst_bad = '5352312c53523032303230320';
    pos = '3';
    confile ='C:\Temp\hr3con';
    end;
end

    file_name=sprintf('%shr%g',file_loc,chan);%what file
    fid = fopen(file_name);
    Dat_Loc=rm_oasis_header(fid);%remove the header
    fseek(fid,(Dat_Loc),'bof');%start of the data
    fid2=fopen(confile,'wt');
    while ~feof(fid)
        X=fgetl(fid);
        tempdat=sscanf(X,'%s');
        rep=findstr(X,inst_bad);
        if ~isempty(rep)
            X=strrep(X,inst_bad,inst_good);
            fprintf(fid2,'%s\n',X);
        else
            fprintf(fid2,'%s\n',X);
        end   
     end;
     fclose(fid2);fclose(fid);
 
javacom=sprintf('%s %s C:\\Temp hr',clean,confile);
cd C:\;
dos(javacom);
javacom=sprintf('%s C:\\Temp\\%shr.bin %s C:\\Temp\\hrread %s',decode,sn,hrcal,pos);
dos(javacom);

fid=fopen('C:\Temp\hrread');
Dat_Loc=rm_oasis_header(fid);%remove the header
fseek(fid,(Dat_Loc),'bof');%start of the data
i=1;
while ~feof(fid) %read in the numbers
    X=fgetl(fid);
    if isempty(findstr(X,','))%crude error check for huge numbers
    hrdat(:,i)=sscanf(X,'%f');
    i=i+1;
    end
end;
hrdat(1,:)=utc2sdn(hrdat(1,:));
hrdat(1,find(hrdat(1,:)<datenum('1/1/2000')))=NaN;
fclose(fid);
delete('C:\Temp\hrread');

     
                
                
     
    
    

    