Index: /trunk/LOGFILE_thomx.m
===================================================================
--- /trunk/LOGFILE_thomx.m	(revision 7)
+++ /trunk/LOGFILE_thomx.m	(revision 8)
@@ -159,2 +159,4 @@
 
 
+   
+ 
Index: /trunk/machine/THOMX/StorageRing/Lattices/CDR_017_064_r56_02_sx_Dff_corrSX_BPMIP.m
===================================================================
--- /trunk/machine/THOMX/StorageRing/Lattices/CDR_017_064_r56_02_sx_Dff_corrSX_BPMIP.m	(revision 8)
+++ /trunk/machine/THOMX/StorageRing/Lattices/CDR_017_064_r56_02_sx_Dff_corrSX_BPMIP.m	(revision 8)
@@ -0,0 +1,189 @@
+function varargout = CDR_017_064_r56_02_sx_Dff_corrSX_BPMIP 
+%!!****************************************************        }
+%! Nominal lattice of Thom-X for AT, with zero dispersion }
+%! in the straight sections.                                   }
+%!                                                             }
+%! Based on                                                    }
+%! BETA-LNS v7.70 /26/09/08/  3-Jan-12 14:43:44                }
+%! *** AUTHOR ***                                              }
+%!              Jianfeng Zhang @ LAL  14/02/2012               }
+%!****************************************************         }
+
+global FAMLIST  THERING  GLOBVAL
+
+GLOBVAL.E0 = 50E6;
+GLOBVAL.LatticeFile  = mfilename;
+FAMLIST = cell(0);
+
+disp(['** Loading THOMX ring lattice ',mfilename]);
+
+L0 = 16.8; 
+C0 = 2.99792458e8; % speed of light [m/s]
+% HarmNumber = 28.0899; % RF harmonic number
+ HarmNumber = 28; % RF harmonic number
+
+ %% ======================
+%  RF Cavity
+% =======================
+%              NAME   L     U[V]       f[Hz]          h        method
+RF = rfcavity('RF', 0.0,  300e3, HarmNumber*C0/L0, HarmNumber, ...
+               'CavityPass');
+
+
+
+%!------------------------------------}
+%! DRIFT                              }
+%!------------------------------------}
+ SD0        = drift('SD0',0.1000000E+00,'DriftPass');
+ SD1        = drift('SD1',0.1300000E+00,'DriftPass');
+ SD1S1      = drift('SD1S1',0.2000000E+00,'DriftPass');
+ SD1S       = drift('SD1S',0.6000000E-01,'DriftPass');
+
+ SD2        = drift('SD2',0.2000000E+00,'DriftPass');
+ SD3        = drift('SD3',0.2000000E+00,'DriftPass');
+ SD31       = drift('SD31',0.6000000E+00,'DriftPass');
+
+ SD4        = drift('SD4',0.1500000E+00,'DriftPass');
+ SD5        = drift('SD5',0.7871000E+00,'DriftPass');
+ SD3S       = drift('SD3S',0.6000000E-01,'DriftPass');
+SD3S1      = drift('SD3S1',0.1400000E+00,'DriftPass');
+
+% half length of SD3
+SD2S = drift('SD2S', 0.1000000E+00, 'DriftPass');
+%!------------------------------------}
+%! DIPOLE                             }
+%!------------------------------------}
+%****** For Thom-X lattice ******}
+beta_gap=0.04;
+%tracy_gap=beta_gap*2*1/6;}
+%Due to the Tanh-like fringe field, K1=0.2, and tracy_gap = gap * FINT (K brown para.)}
+tracy_gap = beta_gap*2*0.348;
+
+
+ COE    = drift('COE', 0.0000000E+00, 'DriftPass'); 
+ BEND    = rbend3('BEND',0.27646,0.785398, 0.0, 0.0,0.0,tracy_gap,1,1,'BndMPoleSymplecticNew4Pass');
+ COS    = drift('COS', 0.0000000E+00, 'DriftPass'); 
+
+%!------------------------------------}
+%! QUADRUPOLE                         }
+%!------------------------------------}
+QPassMethod = 'StrMPoleSymplectic4Pass';
+ QP1       = quadrupole('QP1', 0.15, -0.4742248E+01, QPassMethod);
+
+ QP2       = quadrupole('QP2', 0.15, 0.1027936E+02, QPassMethod); 
+
+ QP3       = quadrupole('QP3', 0.15, -0.1835696E+02, QPassMethod);
+
+ QP4       = quadrupole('QP4', 0.15, 0.1526965E+02, QPassMethod); 
+
+ QP31       = quadrupole('QP31', 0.15, -0.1304719E+02, QPassMethod);
+
+ QP41       = quadrupole('QP41', 0.15, 0.9634002E+01, QPassMethod); 
+
+%!---------------------------------------------------------------------}
+%! SEXTUPOLE                                                           }
+%!                                                                     }
+%!---------------------------------------------------------------------}
+
+sx_on=1;
+SPassMethod = 'StrMPoleSymplectic4Pass';
+
+ % SX1        = sextupole('SX1', 0.06e-10, -3.91653e+12/2, SPassMethod);
+ % SX2        = sextupole('SX2', 0.06e-10, 7.19423e+11/2, SPassMethod);
+ % SX3        = sextupole('SX3', 0.06e-10, -0.1903113E+07*sx_on*0, SPassMethod);
+
+ SX1       = sextupole('SX1', 0.1000000E-05, -0.8375307E+07*1, SPassMethod);
+ SX2       = sextupole('SX2', 0.1000000E-05,  0.2405303E+07*sx_on, SPassMethod);
+ SX3       = sextupole('SX3', 0.1000000E-05, -0.1903113E+07*sx_on, SPassMethod);
+
+%% =======================
+% BPM
+%========================
+% horizontal
+BPMx = marker('BPMx', 'IdentityPass');
+% vertical
+BPMz = marker('BPMz', 'IdentityPass');
+ 
+%% =======================
+% correctors
+%=========================
+%
+ HCOR = corrector('HCOR',1.0e-6,[0.0, 0],'CorrectorPass');
+ 
+ VCOR = corrector('VCOR',1.0e-6,[0, 0.0],'CorrectorPass');
+
+%=====================================
+% !MARKER                 
+%=====================================
+DEBUT =  marker('DEBUT','IdentityPass');
+FIN   =  marker('FIN','IdentityPass');
+
+
+%!=====================================}
+%! RING LATTICE                        }  
+%!=====================================}
+ELIST = [DEBUT,...
+         SD5,    BPMx,   BPMz,... 
+         QP1,    SD2,    QP2,    SD31,    COE, ...
+         BEND,   COS,    SD3S1,...  
+         SX1,     HCOR,  VCOR, ...
+         SD3S,...
+         QP31,...
+         SD3S,   SX3,    HCOR,   VCOR,... 
+         SD3S1,  QP41,   BPMx,   BPMz,...
+         SD1S1,  SX2,    HCOR,   VCOR,...
+         SD1S,   QP4,    SD2,    QP3,    SD2S,...    
+         BPMx,   BPMz,   SD2S,...
+         COE,...
+         BEND,   COS,    SD0,    SD0,     COE,...
+         BEND,...  
+         COS,    SD2S,   BPMx,   BPMz,    SD2S,...
+         QP3,    SD2,    QP4,     SD1S,...
+         SX2,    HCOR,   VCOR,...
+         SD1S1,  BPMx,   BPMz,...
+         QP41,   SD3S1,  SX3,   HCOR,   VCOR,...     
+         SD3S,...   
+         QP31,   SD3S,   SX1,   HCOR,   VCOR,...    
+         SD3S1,  COE,     BEND,...       
+         COS,    SD31,   QP2,    SD2,    QP1,...
+         BPMx,   BPMz,...
+         SD5,...
+         SD5,    BPMx,   BPMz,...   
+         QP1,    SD2,    QP2,    SD31,    COE,...
+         BEND,   COS,    SD3S1,  ...
+         SX1,    HCOR,   VCOR,...
+         SD3S,...
+         QP31,...    
+         SD3S,   SX3,    HCOR,   VCOR,...
+         SD3S1,  QP41,   BPMx,   BPMz,...
+         SD1S1,  SX2,    HCOR,   VCOR,...
+         SD1S,   QP4,    SD2,    QP3,    SD2S,...
+         BPMx,   BPMz,   SD2S,   COE,...
+         BEND,   COS,    SD0,    SD0,     COE,...
+         BEND,...       
+         COS,    SD2S,    BPMx,  BPMz,    SD2S...
+         QP3,    SD2,    QP4,     SD1S,...
+         SX2,    HCOR,   VCOR,...
+         SD1S1,  BPMx,   BPMz,...
+         QP41,   SD3S1,  SX3,   HCOR,   VCOR,...  
+         SD3S,...
+         QP31,   SD3S,   SX1,   HCOR,   VCOR,... 
+         SD3S1,  COE,     BEND,...   
+         COS,    SD31,   QP2,    SD2,    QP1, BPMx, BPMz,...    
+         SD5,...
+         RF,     FIN];
+ 
+
+buildlat(ELIST);
+      
+THERING = setcellstruct(THERING,'Energy',1:length(THERING), ...
+                                GLOBVAL.E0);
+evalin('caller','global THERING FAMLIST GLOBVAL');
+
+atsummary;
+
+if nargout
+  varargout{1} = THERING;
+end
+
+
Index: /trunk/machine/THOMX/StorageRing/Lattices/CDR_017_072_r56_02_sx_Dff_corrSX_BPMIP.m
===================================================================
--- /trunk/machine/THOMX/StorageRing/Lattices/CDR_017_072_r56_02_sx_Dff_corrSX_BPMIP.m	(revision 7)
+++ /trunk/machine/THOMX/StorageRing/Lattices/CDR_017_072_r56_02_sx_Dff_corrSX_BPMIP.m	(revision 8)
@@ -36,5 +36,5 @@
  %% ======================
 %  RF Cavity
-% =======================
+% ========================
 %              NAME   L     U[V]       f[Hz]          h        method
 RF = rfcavity('RF', 0.0,  300e3, HarmNumber*C0/L0, HarmNumber, ...
@@ -113,4 +113,5 @@
 %% =======================
 % BPM
+% installed before or after quadrupole
 %========================
 % horizontal
@@ -121,4 +122,5 @@
 %% =======================
 % correctors
+% the same location as sextupole
 %========================
 %
@@ -132,5 +134,5 @@
  
  DEBUT = drift('DEBUT',0.0,'DriftPass');
-FIN = drift('FIN',0.0,'DriftPass');
+ FIN   = drift('FIN',0.0,'DriftPass');
 
 
@@ -146,6 +148,6 @@
   SD1S1         SX2           HCOR          VCOR          SD1S          QP4 ...         
   SD2           QP3           SD2S          BPMx          BPMz          SD2S...         
-  COE           BEND           COS           SD0           BPMx ...
-  BPMz          SD0           COE           ...
+  COE           BEND           COS           SD0            ...
+  SD0           COE           ...
   BEND           COS           SD2S          BPMx          BPMz          SD2S  ...       
   QP3           SD2           QP4           SD1S          SX2           HCOR  ...       
@@ -153,5 +155,5 @@
   SX3           HCOR          VCOR          SD3S          QP31          SD3S ...        
   SX1           HCOR          VCOR          SD3S1         COE           BEND ...         
-  COS           SD31          QP2           SD2           QP1                ....        
+  COS           SD31          QP2           SD2           QP1         BPMx         BPMz      ....        
                 SD5           SD5           BPMx          BPMz          QP1 ...         
   SD2           QP2           SD31          COE           BEND           COS ...         
Index: /trunk/machine/THOMX/StorageRing/setoperationalmode.m
===================================================================
--- /trunk/machine/THOMX/StorageRing/setoperationalmode.m	(revision 7)
+++ /trunk/machine/THOMX/StorageRing/setoperationalmode.m	(revision 8)
@@ -117,31 +117,32 @@
     %AO = local_setmagnetcoefficient(AO, @magnetcoefficients);
     %setao(AO);
-% else if ModeNumber == 2
+ elseif ModeNumber == 2
 %     % User mode - nominal lattice 2010 until installation of S11 and S12
-%     AD.OperationalMode = '50e-3 GeV, 3.175 1.64';
-%     AD.Energy = 50e-3; % Make sure this is the same as bend2gev at the production lattice!
-%     ModeName = 'CDR_017_064_r56_02_sx_Dff';
-%     OpsFileExtension = '_CDR_017_064_r56_02_sx_Dff';
-% 
-%     % AT lattice
-%     AD.ATModel = 'CDR_017_064_r56_02_sx_Dff';
-%     eval(AD.ATModel);  %run model for compiler;
-% 
-%     % Golden TUNE is with the TUNE family
-%     AO = getao;
-%     AO.TUNE.Monitor.Golden = [
-%         0.175
-%         0.640
-%         NaN];
-% 
-%     % Golden chromaticity is in the AD (Physics units)
-%     AD.Chromaticity.Golden = [0; 0];
-% 
-%     % Status factory
-%     % don't need for ThomX ?????
-%     %local_set_config_mode('normalconfig120'); d
-%     %AO = local_setmagnetcoefficient(AO, @magnetcoefficients);
-%     %setao(AO);
-
+     AD.OperationalMode = '50e-3 GeV, 3.175 1.64';
+      AD.Energy = 50e-3; % Make sure this is the same as bend2gev at the production lattice!
+      ModeName = 'CDR_017_064_r56_02_sx_Dff_corrSX_BPMIP';
+     OpsFileExtension = '_CDR_017_064_r56_02_sx_Dff_corrSX_BPMIP';
+
+    % AT lattice
+    AD.ATModel = 'CDR_017_064_r56_02_sx_Dff_corrSX_BPMIP';
+    eval(AD.ATModel);  %run model for compiler;
+
+    % Golden TUNE is with the TUNE family
+    AO = getao;
+    AO.TUNE.Monitor.Golden = [
+        0.175
+        0.640
+        NaN];
+
+    % Golden chromaticity is in the AD (Physics units)
+    AD.Chromaticity.Golden = [0; 0];
+
+    % Status factory
+    % don't need for ThomX ?????
+    %local_set_config_mode('normalconfig120'); d
+    %AO = local_setmagnetcoefficient(AO, @magnetcoefficients);
+    %setao(AO);
+
+        
  else
     error('Operational mode unknown');
Index: /trunk/machine/THOMX/TL/TLinit.m
===================================================================
--- /trunk/machine/THOMX/TL/TLinit.m	(revision 7)
+++ /trunk/machine/THOMX/TL/TLinit.m	(revision 8)
@@ -83,11 +83,13 @@
 
 
+% AD already been defined in setpathmml.m. Modified by Jianfeng Zhang @ LAL,
+% 17/12/2013
 %Mode             = 'online';
-setad([]);       %clear AcceleratorData memory
-AD.SubMachine    = 'TL'; % Machine Name
-AD.Energy        = 0.05 ; % Energy in GeV
-
-
-setad(AD);   %load AcceleratorData
+%setad([]);       %clear AcceleratorData memory
+%AD.SubMachine    = 'TL'; % Machine Name
+%AD.Energy        = 0.05 ; % Energy in GeV
+
+
+%setad(AD);   %load AcceleratorData
 
 %%%%%%%%%%%%%%%%%%%%
Index: /trunk/machine/THOMX/TL/aoinit.m
===================================================================
--- /trunk/machine/THOMX/TL/aoinit.m	(revision 7)
+++ /trunk/machine/THOMX/TL/aoinit.m	(revision 8)
@@ -3,7 +3,8 @@
 %
 %
-%  See Also soleilinit, setpathsoleil 
+%  See Also TLinit, setpaththomx 
 
 % Written by Laurent S. Nadolski
+% Modified by Jianfeng Zhang for ThomX 
 
 
Index: /trunk/machine/THOMX/TL/setoperationalmode.m
===================================================================
--- /trunk/machine/THOMX/TL/setoperationalmode.m	(revision 7)
+++ /trunk/machine/THOMX/TL/setoperationalmode.m	(revision 8)
@@ -42,8 +42,16 @@
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 AD = getad;
-AD.Machine = 'THOMX';            % Will already be defined if setpathmml was used
-AD.MachineType = 'StorageRing';   % Will already be defined if setpathmml was used
-AD.SubMachine  = 'TL';           % Will already be defined if setpathmml was used
-AD.OperationalMode = '';          % Gets filled in later
+% Modified by Jianfeng Zhang @ LAL, 17/12/2013
+if(isempty(AD.Machine))
+    AD.Machine = 'THOMX';            % Will already be defined if setpathmml was used
+end
+if(isempty(AD.Machine))
+    AD.MachineType = 'Transport';   % Will already be defined if setpathmml was used
+end
+if(isempty(AD.SubMachine))
+    AD.SubMachine  = 'TL';           % Will already be defined if setpathmml was used
+end
+
+
 
 
Index: /trunk/machine/THOMX/readme
===================================================================
--- /trunk/machine/THOMX/readme	(revision 8)
+++ /trunk/machine/THOMX/readme	(revision 8)
@@ -0,0 +1,15 @@
+
+(1) Files need to update with the real machine:
+
+ --15/11/2013 
+
+  âŠ/common/cycling/*
+   Thomxinit.m; setoperationmode.m;
+   Magnetcoefficients.m; k2amp.m; amp2k.m; bend2gev.m; gev2bend.m
+
+(2) 17/12/2013
+ .../mml/setpathmml.m
+
+correct with the Tango of ThomX...
+
+case 'TANGO'
Index: /trunk/mml/plotcm.m
===================================================================
--- /trunk/mml/plotcm.m	(revision 7)
+++ /trunk/mml/plotcm.m	(revision 8)
@@ -113,10 +113,5 @@
     end
 
-    % Sector 11
-    %                    Off    1.9 GeV   1.5 GeV
-    % HCMCHICANEM(11,1)  80.0    40.5      52.0
-    % HCMCHICANEM(11,1)  80.0    40.5      52.0
-    % HCM(10,8)           0.0   -17.0     -14.0
-    % HCM(11,1)           0.0   -17.0     -14.0
+    
     ihcm = findrowindex([10 8], x.DeviceList);
     if length(ihcm) == 1
Index: /trunk/mml/setpaththomx.m
===================================================================
--- /trunk/mml/setpaththomx.m	(revision 7)
+++ /trunk/mml/setpaththomx.m	(revision 8)
@@ -7,5 +7,5 @@
 % INPUTS
 %  varargin(1):
-%       SubMachineName - 'StorageRing', 'LT','LE'
+%       SubMachineName - 'StorageRing', 'TL','EL'
 %  varagin(2):  
 %       hardware control system: LAbCA, MCA, Tango, 
@@ -110,8 +110,6 @@
     %         need to be customized for THOMX
          addpath(fullfile(MMLROOT, 'machine', 'THOMX', 'common', 'plotfamily'));
-%        addpath(fullfile(MMLROOT, 'machine', 'SOLEIL', 'common', 'plotfamily'));
  addpath(fullfile(MMLROOT, 'machine', 'THOMX', 'common', 'configurations'));
-%        addpath(fullfile(MMLROOT, 'machine', 'SOLEIL', 'common', 'configurations'));
-%        addpath(fullfile(MMLROOT, 'machine', 'SOLEIL', 'common', 'cycling'));
+ addpath(fullfile(MMLROOT, 'machine', 'THOMX', 'common', 'cycling'));
 %        addpath(fullfile(MMLROOT, 'machine', 'SOLEIL', 'common', 'diag', 'DserverBPM'));
         addpath(fullfile(MMLROOT, 'applications', 'mmlviewer'));
