Matlab for MCC Users

Platforms

 

         VMS (Only versions 4 and 5 available)

         Solaris / Linux (Up to version 2007a)

         MCC Macs (Version 2006b)

         Windows (Up to version 2007a)

 

Matlab’s Initial Setup

These instructions include the scripts that need to be sourced to allow Matlab to perform EPICS Channel Access calls.

 

1.      modify your account’s .cshrc file to include the following lines:

setenv MATLAB_VER 2007a

source /afs/slac/g/cd/soft/dev/script/ENVS.csh

source /afs/slac/g/cd/soft/dev/script/epicsSetupPepii

(Note: Other Matlab versions include 13, 14, 2006a and 2006b)

2.      It is recommended that you start Matlab with the -nojvm (No Java Virtual Machine).  There is a flaw on Solaris that makes the full Matlab desktop run slow.  If you plan to use AIDA, then use the –nodesktop flag.  This allows Java to work, but does not start up the full desktop.

3.      Start Matlab: unixhost% Matlab –nodeskstop (or –nojvm).

 

Choosing Platform (some features)

 VMS

 

         No License is required to run Matlab.

         Matlab 4 is old yet powerful. Matlab 5 has been reported to be slow at times.

         Matlab 5 does have features not present in version 4; including cell arrays.

         Use MCC> matlab4; matlab5 to switch between the two versions.

         SCP can launch Matlab applications and pass data to Matlab via .COM files. (See for example the macro used to send PEPII spectrum analyzer waveform to E-Logs).

         VMS Database Gets.  No database Puts. No EPICS access.

         Useful Matlab functions include: dbget, dbget_asts, hstb_get, comf2mat, help slc

         Cautionary note:  VMS Matlab is not supported and it can stop working at any time (due to upgrades to the operating system).  Use at your own risk. 

Solaris and Linux

 

         Limited number of licenses available. (Use: flora% lmstat –f matlab for availability status).

         Running over ssh slows down Matlab’s full desktop. Full desktop includes debugger.

         Functions can be compiled.

         AIDA allows for EPICS and VMS database gets and puts.

         labCA - EPICS Channel Access on selected nodes.

Windows

 

         Uses same license servers as UNIX.

         Use Z:\> lmutil lmstat –f matlab for availability status. (Start -> Run…)

         Full desktop with debugger, editor, GUI development and documentation.

         AIDA provides for EPICS and VMS database gets and puts.

         Functions can be compiled.

Matlab Compiler

 

         Matlab functions written for Matlab 13 (aka Matlab 6.5) and higher can be compiled. 

         SLAC owns one compiler license that is checked out to the node-user combination for one hour after the compiler is used. 

         To check compiler license availability use: flora01% lmstat –f compiler

         Compiled programs are stand alone binaries and can be deployed to machines with no Matlab installation.

 

Compiling Instructions (UNIX/Linux):

 

Setup environment:

setenv MATLAB_VER 2006b

source /afs/slac/g/spear/epics/epicsSetup

Use Matlab C compiler command (MCC)

>> mcc -mv -nocache <matlabFunction>.m –a <otherMfunctions>.m

–d <dirDestination>

 

Note: Above line works on Windows and Macintosh as well.

Getting at your Data

 

         VMS-SCP can save .MAT file format.

         Striptool Data: /nfs/mccfs0/u1/pepii/strip/data/  (PEPII) /nfs/slac/g/lcls/tools/StripTool/config/ (LCLS)

         See how to get data from Striptool: http://www.slac.stanford.edu/grp/ad/op/getstripdata.html

         EPICS Archiver .MAT saved to mcclx01 at /a/surrey11/vol/vol0/g.esd.archiver/pepii/Matlab (PEPII) and lcls-prod02: /a/surrey10/vol/vol0/g.lcls/tools/ArchiveBrowser/data/ (LCLS).

File Transfer Tools

 

         Windows can access data in UNIX AFS/NFS ( \\slaccfs\group_ad\PEPII - NFS and \\slaccfs\slac_afs\u\ad\colocho - AFS).

         Use OpenAFS to get an AFS token and map drives to AFS.  This gives Read/write access to AFS apace.

         WinSCP3 can be used to secure copy files to and from UNIX/Linux.

         Copy/Paste: When everything else fails or for fast and small text files: One can drag to select and copy text.  Then middle mouse button pastes.

         For UNIX/Linux <-> VMS transfers see:

      http://www.slac.stanford.edu/grp/ad/op/unix_help/OPS_unix_help.shtml

         WEBMCC provides for a way to access VMS files from the web:

http://www-mcc.slac.stanford.edu/

         For example, to access PEPII LER BPMS orbit data on the web, go to:

http://www-mcc.slac.stanford.edu/PROD2_SYS$ROOT /CONFIG/PEP2LERX/

         WGET can be used to get these files:

Flora01% wget -nv 'http://www-mcc.slac.stanford.edu/prod2_sys$root/config_SCRATCH/BPM_P2BPMHER/BPM_P2BPMHER$100.CNF' -O BPMHERN100.cnf  (the –O flag is used to rename the file.  The “$” character is not handled well as part of UNIX filenames.)

 

UNIX Environments Setup

 

A good way to have different UNIX environments on different machines is to have a switch statement on your account .cshrc file. (C shell start up file that gets executed each time a new shell is created.)

 

For example, one could modify the .cshrc file as follows:

 

setenv  HOSTNAME   `/bin/hostname`

switch ( $HOSTNAME )

  case slcs2:

     source /afs/slac/g/cd/soft/dev/script/ENVS.csh

     source /afs/slac/g/pepii/ctrl/prod/bin/solaris/epicsSetupPepii

  breaksw

  case lcls-prod02:

     source /afs/slac/g/lcls/tools/script/ENVS.csh

     source /afs/slac/g/lcls/epics/config/epicsSetup.csh

  breaksw

endsw

 

This allows for PEPII EPICS setup on slcs2 and LCLS EPICS setup on lcls-prod02.

 

labCA

 

         labCA’s help page can be found at: http://www.slac.stanford.edu/grp/cd/soft/epics/extensions/labca/manual/node2.html

         Once the EPICS environment has been setup so that Channel Access calls can be made; the lcaGet command can be used to get EPICS Process Variables (VP’s):

 

[value, timestamp] = lcaGet(pvs, nmax, type)

pvs - Column vector (in matlab: m x 1 cell- matrix) of m strings.

 

         lcaPut works on nodes where EPICS CA put permissions have been set. (For example opi00gtw01 for PEP and lcls-prod02 for LCLS).

 

labCA sample code

 

>> lerDCCT = lcaGet({'LB60:DCCT:SUMY'});

See also code found on the following directories:

 

/afs/slac.stanford.edu/u/ad/colocho/matlab/BIC_Data

         CVSWEB for some PEPII Code:

 

http://www.slac.stanford.edu/cgi-wrap/cvsweb/matlab/RFfaultFile/?cvsroot=LLRF-Matlab

         CVSWEB for LCLS Code:

http://www.slac.stanford.edu/cgi-wrap/cvsweb/matlab/toolbox/?cvsroot=LCLS

 

AIDA

The Accelerator Integrated Data Access middleware framework can be used from inside Matlab.  It allows Matlab functions to gain access to multiple databases.

 

         To set up AIDA for Matlab go to: http://www.slac.stanford.edu/grp/cd/soft/aida/aida_matlab.html

         Once setup, AIDA’s gets and puts work from many platforms (PC, UNIX, Linux, MACs).

         AIDA-Matlab code can be compiled (See compiler information on this document).

         Users may prefer to use: “matlab –nodesktop” on Unix/Linux nodes since the full Matlab desktop performance is slow on these platforms.

 

aidalist

The aidalist shell script provides a list of AIDA names that can be acquired.  These include EPICS and VMS database items as well as history buffer data and EPICS archived data.

 

get help for aidalist with:

flora% more `which aidalist`

 

Sample code

Sample code can be found under each individual data provider users’ guides.

http://www.slac.stanford.edu/grp/cd/soft/aida/

 

For a quick note on Object Oriented Programming go to:

http://en.wikipedia.org/wiki/Object-oriented_programming (Note that “Methods” are the things that one can do to “Objects”. So lassie.bark() is similar to da.getDaValue())

 

For other sample get functions see:

~colocho/matlab/aida/getHistory.m or

/nfs/slac/g/ad/PEPII/archiverPlots/aidaGetHstb.m (used by LastAbortHer.m - program to plot archiver data.)

 

Note: We need an AIDA toolbox! (i.e. Hide most/all java manipulations from most users).  This work is in progress.

 

Owner: Colocho