source: MML/trunk/machine/SOLEIL/StorageRing/insertions/idUploadFFWDTableToDevice.m @ 4

Last change on this file since 4 was 4, checked in by zhangj, 10 years ago

Initial import--MML version from SOLEIL@2013

File size: 2.5 KB
Line 
1function UploadState=idUploadFFWDTableToDevice(FFWDTableWithArgs, idName, CorrectorName, idMode)
2%% Written by F.Briquez 25/04/2011
3% Creates the FFWD table text file (used by the Device Server) containing the matrix 'FFWDTableWithArgs'
4% - Backup the old file in /home/operateur/GrpGMI/.../Backup_Of_FFWD_Tables
5% - Backup the new file in /home/operateur/GrpGMI/.../Backup_Of_FFWD_Tables
6% - Deletes the old file in /usr/Local/configFiles/InsertionFFTables/...
7% - Creates the new file in /usr/Local/configFiles/InsertionFFTables/...
8% 1) Inputs : FFWDTableWithArgs : matrix containing the FFWD correction currents with headers (phase and gap values as first column and first row)
9%           : idName : such as 'HU36_SIRIUS'
10%           : CorrectorName : 'CHE', 'CHS', 'CVE' or 'CVS'
11%           : idMode : 'ii' or 'x' for parallel or anti-parallel modes.
12%               (Not case-sensitive)
13% 2) Output : -1 if failed. 1 if succeeded
14
15%%
16UploadState=-1;
17
18%% If existing, backup of old FFWD table used by the Device Server
19[UpdateFileFullName, BackupState]=idBackupFFWDTableFile(idName, CorrectorName, idMode);
20if (BackupState==-1)
21    fprintf('Error in ''idUploadFFWDTableToDevice'' : Backup of old FFWD table failed => New table was not uploaded\n');
22    return
23end
24TemporaryFFWDTableToCopyForBackupAndDeviceServer=FFWDTableWithArgs;
25
26%% Create backup of new FFWD table
27save (UpdateFileFullName, 'TemporaryFFWDTableToCopyForBackupAndDeviceServer', '-ascii');
28if (exist(UpdateFileFullName, 'file')~=2)
29    fprintf('Error in ''idUploadFFWDTableToDevice'' : could not create backup of new FFWD table file  ''%s'' => New table was not uploaded\n', UpdateFileFullName);
30    return
31end
32
33%% If existing, delete old FFWD table used by the Device Server
34FFWDTableFileName=idGetFFWDTableFullFileName(idName, CorrectorName, idMode);
35if (exist(FFWDTableFileName, 'file')==2)
36    delete(FFWDTableFileName);
37    if (exist(FFWDTableFileName, 'file')==2)
38        fprintf ('Error in ''idUploadFFWDTableToDevice'' : could not delete old FFWD table used by the Device Server => New table was not uploaded\n');
39        return
40    end
41end
42
43%% Create new FFWD table for Device Server
44
45save (FFWDTableFileName, 'TemporaryFFWDTableToCopyForBackupAndDeviceServer', '-ascii');
46if (exist(FFWDTableFileName, 'file')~=2)
47    fprintf('Error in ''idUploadFFWDTableToDevice'' : could not create new FFWD table file ''%s''\n', FFWDTableFileName);
48    return
49end
50clear('TemporaryFFWDTableToCopyForBackupAndDeviceServer');
51UploadState=1;
52end
Note: See TracBrowser for help on using the repository browser.