Home > mml > copybpmrespfile.m

copybpmrespfile

PURPOSE ^

COPYBPMRESPFILE - Copies a BPM response matrix file to the golden file

SYNOPSIS ^

function copybpmrespfile(DataFileName, ToFileName)

DESCRIPTION ^

COPYBPMRESPFILE - Copies a BPM response matrix file to the golden file 
  copybpmrespfile(DataFileName, ToFileName)

  INPUTS
  1. DataFileName
  2. toFileName - Default: Golden Filename 

  See Also copychrorespfile, copybpmsigmafile, copydispersionfile,
  copydisprespfile, copymachineconfigfile, copytunerespfile

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function copybpmrespfile(DataFileName, ToFileName)
0002 %COPYBPMRESPFILE - Copies a BPM response matrix file to the golden file
0003 %  copybpmrespfile(DataFileName, ToFileName)
0004 %
0005 %  INPUTS
0006 %  1. DataFileName
0007 %  2. toFileName - Default: Golden Filename
0008 %
0009 %  See Also copychrorespfile, copybpmsigmafile, copydispersionfile,
0010 %  copydisprespfile, copymachineconfigfile, copytunerespfile
0011 
0012 %
0013 %  Written by Gregory J. Portmann
0014 
0015 if nargin < 1
0016     DataFileName = '';
0017 end
0018 
0019 if nargin < 2
0020     ToFileName = 'Golden';
0021 end
0022 
0023 
0024 % Get the file
0025 if isempty(DataFileName)
0026     DataDirectoryName = getfamilydata('Directory','BPMResponse');
0027     if isempty(DataDirectoryName)
0028         DataDirectoryName = getfamilydata('Directory','DataRoot');
0029     end
0030     [DataFileName, DataDirectoryName, FilterIndex] = uigetfile('*.mat','Select the BPM Response Matrix File to Copy', DataDirectoryName);
0031     if FilterIndex == 0 
0032         fprintf('   File not copied (copybpmrespfile)\n');
0033         return;
0034     end
0035 else
0036     [DataDirectoryName, DataFileName, ExtName] = fileparts(DataFileName);
0037     DataDirectoryName = [DataDirectoryName, filesep];
0038     DataFileName = [DataFileName, ExtName];
0039 end
0040 
0041 
0042 % Where is it going
0043 if strcmpi(ToFileName, 'Golden')
0044     FileName = [getfamilydata('OpsData','BPMRespFile'),'.mat'];
0045     DirectoryName = getfamilydata('Directory','OpsData');
0046     
0047     if exist([DirectoryName FileName],'file')
0048         AnswerString = questdlg(strvcat(strvcat(strvcat('Are you sure you want to overwrite the default BPM response matrix file?',sprintf('%s',[DirectoryName FileName])),'With file:'),[DataDirectoryName, DataFileName]),'Default BPM Response','Yes','No','No');
0049     else
0050         AnswerString = 'Yes';
0051     end
0052 
0053     if strcmp(AnswerString,'Yes')
0054         DirStart = pwd;
0055         [DirectoryName, ErrorFlag] = gotodirectory(DirectoryName);
0056         cd(DirStart);
0057     else
0058         fprintf('   File not copied (copybpmrespfile)\n');
0059         return;
0060     end
0061 end
0062 
0063 
0064 % Backup first
0065 BackupDirectoryName = [getfamilydata('Directory','DataRoot') 'Backup' filesep];
0066 BackupDataFileName  = prependtimestamp(FileName);
0067 if exist([DirectoryName, FileName],'file')
0068     DirStart = pwd;
0069     [FinalDir, ErrorFlag] = gotodirectory(BackupDirectoryName);
0070     if ~ErrorFlag
0071         copyfile([DirectoryName, FileName], [BackupDirectoryName, BackupDataFileName], 'f');
0072         fprintf('   File %s backup to %s\n', [DirectoryName, FileName], [BackupDirectoryName, BackupDataFileName]);
0073     else
0074         fprintf('   Problem finding/creating backup directory, hence backup made to ops directory.\n');
0075         copyfile([DirectoryName, FileName], [DirectoryName, BackupDataFileName], 'f');
0076     end
0077     cd(DirStart);
0078 end
0079 
0080 
0081 % Do the copy
0082 copyfile([DataDirectoryName, DataFileName], [DirectoryName, FileName], 'f');
0083 fprintf('   File %s copied to %s\n', [DataDirectoryName, DataFileName], [DirectoryName, FileName]);

Generated on Mon 21-May-2007 15:29:18 by m2html © 2003