1 | function copybpmrespfile(DataFileName, ToFileName) |
---|
2 | %COPYBPMRESPFILE - Copies a BPM response matrix file to the golden file |
---|
3 | % copybpmrespfile(DataFileName, ToFileName) |
---|
4 | % |
---|
5 | % INPUTS |
---|
6 | % 1. DataFileName |
---|
7 | % 2. toFileName - Default: Golden Filename |
---|
8 | % |
---|
9 | % See Also copychrorespfile, copybpmsigmafile, copydispersionfile, |
---|
10 | % copydisprespfile, copymachineconfigfile, copytunerespfile |
---|
11 | |
---|
12 | % |
---|
13 | % Written by Gregory J. Portmann |
---|
14 | |
---|
15 | if nargin < 1 |
---|
16 | DataFileName = ''; |
---|
17 | end |
---|
18 | |
---|
19 | if nargin < 2 |
---|
20 | ToFileName = 'Golden'; |
---|
21 | end |
---|
22 | |
---|
23 | |
---|
24 | % Get the file |
---|
25 | if isempty(DataFileName) |
---|
26 | DataDirectoryName = getfamilydata('Directory','BPMResponse'); |
---|
27 | if isempty(DataDirectoryName) |
---|
28 | DataDirectoryName = getfamilydata('Directory','DataRoot'); |
---|
29 | end |
---|
30 | [DataFileName, DataDirectoryName, FilterIndex] = uigetfile('*.mat','Select the BPM Response Matrix File to Copy', DataDirectoryName); |
---|
31 | if FilterIndex == 0 |
---|
32 | fprintf(' File not copied (copybpmrespfile)\n'); |
---|
33 | return; |
---|
34 | end |
---|
35 | else |
---|
36 | [DataDirectoryName, DataFileName, ExtName] = fileparts(DataFileName); |
---|
37 | DataDirectoryName = [DataDirectoryName, filesep]; |
---|
38 | DataFileName = [DataFileName, ExtName]; |
---|
39 | end |
---|
40 | |
---|
41 | |
---|
42 | % Where is it going |
---|
43 | if strcmpi(ToFileName, 'Golden') |
---|
44 | FileName = [getfamilydata('OpsData','BPMRespFile'),'.mat']; |
---|
45 | DirectoryName = getfamilydata('Directory','OpsData'); |
---|
46 | |
---|
47 | if exist([DirectoryName FileName],'file') |
---|
48 | 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'); |
---|
49 | else |
---|
50 | AnswerString = 'Yes'; |
---|
51 | end |
---|
52 | |
---|
53 | if strcmp(AnswerString,'Yes') |
---|
54 | DirStart = pwd; |
---|
55 | [DirectoryName, ErrorFlag] = gotodirectory(DirectoryName); |
---|
56 | cd(DirStart); |
---|
57 | else |
---|
58 | fprintf(' File not copied (copybpmrespfile)\n'); |
---|
59 | return; |
---|
60 | end |
---|
61 | end |
---|
62 | |
---|
63 | |
---|
64 | % Backup first |
---|
65 | BackupDirectoryName = [getfamilydata('Directory','DataRoot') 'Backup' filesep]; |
---|
66 | BackupDataFileName = prependtimestamp(FileName); |
---|
67 | if exist([DirectoryName, FileName],'file') |
---|
68 | DirStart = pwd; |
---|
69 | [FinalDir, ErrorFlag] = gotodirectory(BackupDirectoryName); |
---|
70 | if ~ErrorFlag |
---|
71 | copyfile([DirectoryName, FileName], [BackupDirectoryName, BackupDataFileName], 'f'); |
---|
72 | fprintf(' File %s backup to %s\n', [DirectoryName, FileName], [BackupDirectoryName, BackupDataFileName]); |
---|
73 | else |
---|
74 | fprintf(' Problem finding/creating backup directory, hence backup made to ops directory.\n'); |
---|
75 | copyfile([DirectoryName, FileName], [DirectoryName, BackupDataFileName], 'f'); |
---|
76 | end |
---|
77 | cd(DirStart); |
---|
78 | end |
---|
79 | |
---|
80 | |
---|
81 | % Do the copy |
---|
82 | copyfile([DataDirectoryName, DataFileName], [DirectoryName, FileName], 'f'); |
---|
83 | fprintf(' File %s copied to %s\n', [DataDirectoryName, DataFileName], [DirectoryName, FileName]); |
---|