Skip to content

Instantly share code, notes, and snippets.

@gioAlea
Last active August 27, 2018 09:18
Show Gist options
  • Save gioAlea/fb75f9f3c4ed5ef97990 to your computer and use it in GitHub Desktop.
Save gioAlea/fb75f9f3c4ed5ef97990 to your computer and use it in GitHub Desktop.
Cheatsheet for MatLab Middle Layer

MatLab Middle Layer cheatsheet

Data access modes

  • Online - r/w data from control system
  • Simulator - r/w data from AT model
  • Model - same as simulator (?)
  • Manual - read data from user input (matlab prompts user for input)
  • Special - when special functions, follows their format

Database access functions

  • get = read
  • set = write
  • step = write incrementally
  • pv (Process Variable): control system variable
  • am (Analog Monitor): device read channel value
  • sp (SetPoint): device write channel value

Function prefixes

  1. anal... analize dataset
  2. calc... calculate or converts
  3. get... read from (analog) monitor
  4. meas... measures
  5. mon... monitor a group of channels
  6. ramp... ramp variables (magnets)
  7. set... absolute change in setpoint value
  8. step... incremented change in setpoint value

Types of functions:

  1. Basic MML
  2. Database access
  3. Conversion
  4. Data retrieval
  5. Shortcut (aliases)
  6. Special
  7. Machine physics
  8. General
  9. Response matrix
  10. ID Compensation
  11. System Checkings
  12. Simulator Functions
  13. Miscellaneous

Data treatment functions

  1. getfamilydata returns the parameters of a family
  2. getphysdata returns physical data
  3. getdata enables to load data from a file

Fundamental objects

AO = Accelerator Object, despite the name is a struct variable, initialized in aoinit.m , must contain all of the families in the lattice and relative parameters

AO = getao;

AD = Accelerator Data, also a struct variable, initialized in setoperationalmode.m

AD = getad

Family creation in aoinit.m

% thisFam = 

% AO.(thisFam).FamilyName       = '';
% AO.(thisFam).MemberOf         = {'PlotFamily'; ''; };
% AO.(thisFam).CommonNames      = 'commonname';
% AO.(thisFam).Status           = 1/0;
% AO.(thisFam).ElemList         = n;
% AO.(thisFam).Position         = 'position along the ring in m'
% AO.(thisFam).AT               = optional structure for the AT simulator

% AO.(thisFam).Monitor.ChannelNames = '';
% AO.(thisFam).Monitor.DataType = 'Scalar'/'Vector';
% AO.(thisFam).Monitor.DataTypeIndex = only if vector;
% AO.(thisFam).Monitor.Mode = Mode;
% AO.(thisFam).Monitor.Units = 'Hardware'/'Physics';
% AO.(thisFam).Monitor.HWUnits = 'mm';
% AO.(thisFam).Monitor.PhysicsUnits = 'm';
% AO.(thisFam).Monitor.HW2PhysicsFcn = @;
% AO.(thisFam).Monitor.HW2PhysicsParams = 1e-3;

% AO.(thisFam).Monitor.SpecialFunctionGet
% AO.(thisFam).Monitor.Golden
% AO.(thisFam).Monitor.Offset
% AO.(thisFam).Monitor.Gain

% AO.(thisFam).Setpoint.ChannelNames = whatever;
% AO.(thisFam).Setpoint.DataType = 'Scalar'/'Vector';
% AO.(thisFam).Setpoint.DataTypeIndex = only if vector;
% AO.(thisFam).Setpoint.Mode = Mode;
% AO.(thisFam).Setpoint.Units = 'Hardware'/'Physics';
% AO.(thisFam).Setpoint.Physics2HWFcn = 'functionname';
% AO.(thisFam).Setpoint.Physics2HWParameters = whatever;
% AO.(thisFam).Setpoint.HWUnits = 'mm';
% AO.(thisFam).Setpoint.PhysicsUnits = 'm';
% AO.(thisFam).Setpoint.Range = [min max] in 2 columns in hardware units

% AO.(thisFam).Setpoint.SpecialFunctionSet
% AO.(thisFam).Setpoint.DeltaRespMat
% AO.(thisFam).Setpoint.RampRateFcn
% AO.(thisFam).Setpoint.RampRate
% AO.(thisFam).Setpoint.RunFlagFcn
% AO.(thisFam).Setpoint.Tolerance
% AO.(thisFam).Setpoint.Offset
% AO.(thisFam).Setpoint.Gain

Initialization of AD in setoperationalmode.m

AD.Machine = machine name e.g. 'ELINPGBS';
AD.Directory.DataRoot = root of the directories containing machine files;
AD.OpsData.RespFiles = where resp matrices are stored;
AD.ATModel = nome della maglia AT (?)
AD.BPMDelay = delay between 2 consecutive BPM measurements

Structure of the machine read data

Data: 
Data Vector:
FamilyName:
Field:
DeviceList:
Mode:
Status:
t:
tout:
TimeStamp:
DataTime:
GeV:
Units:
UnitsString:
DataDescriptor:
CreatedBy:

Experimental files path retrieval command: DataRoot = getfamily('Directory','DataRoot') Operational files path retrieval command: OpsRoot = getfamily('Directory','OpsRoot')

Setup Files

  • aoinit
  • setoperationalmode
  • srinit
  • srcycle
  • getbpmaverages
  • bend2gev/gev2bend
  • setorbitdefault
  • buildlocoinput/setlocogains
  • setquad/getquad/quadplotall/quadcenterall
  • updateatindex

8 data files:

  1. Machine save: getmachineconfig GoldenConfig_User
  2. Injection save: getmachineconfig InjectionConfig_User
  3. BPM Sigma: monbpm GoldenBPMSigma_User
  4. Dispersion Function: measdisp GoldenDisp_User
  5. Corrector-to-BPM response matrix: measbpmresp GoldenBPMResp_User
  6. Quad-to-TUNE response matrix: meastuneresp GoldenChroResp_User
  7. Sext-to-Chromaticity response matrix: measchroresp GoldenChroResp_User
  8. Corrector-to-Dispersion response matrix: measdispresp GoldenDispResp_User

Mode setup variables (setoperationalmode.m)

Mode setup variables (mostly path and file names)

  • AD.OperationalMode - String used in titles
  • MachineName - string used to build directory structure off DataRoot
  • ModeName - string used for mode directory name off DataRoot/MachineName
  • OpsFileExtension - string add to default file names

Archiving scripts and data structure

* MACHINENAME
  * Common/Applications
    * Configurations/Lattices
    * ...
  * <MainMachineType>
  * <MainMachineType>OpsData
  * <NthSubmachineName>
  * <NthSubmachineName>OpsData
  * ...

Setup files for each machine go into: MACHINENAME/<MainMachineType/NthSubmachineName>

References

  1. G. Portmann, MML Manual
  2. L. Nadolski, MatLab Middle Layer a SOLEIL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment