22 Commits

Author SHA1 Message Date
a4403b1c41 add new matlab versions and update cafe/epics version 2025-10-13 14:19:26 +02:00
d775d1e8c3 makefile v 1.22 2025-10-10 12:08:59 +02:00
ea43e6215a README 2025-10-01 12:12:11 +02:00
5aa35ce8d7 makfile for 1.20.1 for epics 7.0.7 2024-08-08 14:37:48 +02:00
Armborst Felix
bddcb4f9c7 Cafe 1.21 setup script and module template final 2024-07-14 10:29:29 +02:00
Armborst Felix
477d4ec821 Cafe 1.21 setup script updated 2024-07-14 09:59:27 +02:00
Armborst Felix
d59a6b9dae Cafe 1.21 setup script updated 2024-07-13 13:50:04 +02:00
Armborst Felix
8ea218717a Cafe 1.21 setup script updated 2024-07-13 13:32:50 +02:00
a8d745839b Cafe 1.21 setup script done 2024-07-13 13:28:04 +02:00
Armborst Felix
140e306c96 Cafe 1.21 almost done 2024-07-13 09:00:00 +02:00
0eb076c215 bash sh wrappers to makefiles 2024-07-10 17:41:32 +02:00
Armborst Felix
76c93d7b3f updated version in macchinettaSwitch.cpp 2024-07-10 16:26:07 +02:00
36401f6b9e epics 7.0.8 2024-07-10 16:00:26 +02:00
45e08c4b20 cafe-1.21.0 2024-07-04 15:24:20 +02:00
19d636477f RHEL8-x86_64 2024-02-08 14:30:57 +01:00
fb3854cf4d makefile uploaded 2022-08-22 17:28:19 +02:00
e8d4d6596e cafe-1.16.1 2022-08-04 10:19:32 +02:00
2170202fc9 version 1.15.0; added ca, epics4 version methods 2022-03-11 16:32:51 +01:00
9a18453b41 reset status in getCache following put with nowtaccess error 2021-10-14 19:37:59 +02:00
f97beb8edf 2020b LD_PRELOAD 2021-06-15 16:19:04 +02:00
32ed13125d cafe-1.13.0 2021-03-22 12:41:12 +01:00
90d82bec7a cafe-1.12.5 release 2021-03-16 09:35:10 +01:00
111 changed files with 8717 additions and 365 deletions

7
.gitignore vendored
View File

@@ -1,9 +1,14 @@
makefile-
scripts-
*~
*.bak
*.*-
RHEL7-x86_64
RHEL8-x86_64
SL6-x86_64
windows-x64
felix-cache
readme.txt
makefile_rel*
makefile_rel_1.1*
makefile_rel_1.3*
*.*.orig

233
.matlab7rc.sh-original Executable file
View File

@@ -0,0 +1,233 @@
#
# usage: .matlab7rc.sh
#
# abstract: This Bourne Shell script is sourced by the matlab script
# to obtain certain site/user dependent information
# as explained below. The first occurrence of this file
# in the directory list:
#
# . (current)
# $HOME (home)
# matlab/bin (default location)
#
# is used. Most of the time this file in the default location
# need not be modified at all and nothing needs to be done.
# However, if MATLAB does not work properly with the default
# values then this file may need to be modified and different
# values inserted.
#
# Currently, the following variables appear in the code below.
#
# ARCH (machine architecture)
# DISPLAY (DISPLAY variable for X Window System)
# LDPATH_PREFIX (path(s) that appear at the start of
# LD_LIBRARY_PATH)
# LDPATH_SUFFIX (path(s) that appear at the end of
# LD_LIBRARY_PATH)
# LD_LIBRARY_PATH (load library path - the name
# LD_LIBRARY_PATH is platform dependent)
# MATLAB (MATLAB root directory)
# MATLABPATH (MATLAB search path)
# SHELL (which shell to use for ! and unix
# command in MATLAB)
# TOOLBOX (toolbox path)
#
# NOTE: Run matlab -n to get the values used to run MATLAB.
# MATLAB is NOT executed.
#
# Additional variables are used in the MATLAB script, but
# to affect their behavior from this file requires an
# understanding first of how they are determined in the
# MATLAB script and then making code modifications to this
# file.
#
# The strategy behind the use of this file is to keep
# the site wide changes in the matlab/bin/.matlab7rc.sh version
# and have the individual user start with a copy in their
# $HOME directory and modify it for their special circumstances.
#
# IMPORTANT: Please understand that The MathWorks cannot
# anticipate every possible installation. If
# your situation does not fit into the current
# model of using this .matlab7rc.sh file then
# we would like to hear from you. Please
# contact The MathWorks Technical Support.
#
# note(s): 1. The default values are
#
# ARCH (machine architecture)
#
# This is the machine architecture determined by
# the arch utility script.
#
# DISPLAY (DISPLAY variable for X Window System)
#
# This is set to "$DISPLAY" where DISPLAY is
# taken from the environment.
#
# LDPATH_PREFIX (path(s) that appear at the
# start of LD_LIBRARY_PATH)
#
# Enclose in single quotes to defer evaluation
# to the MATLAB script.
#
# LDPATH_SUFFIX (path(s) that appear at the
# end of LD_LIBRARY_PATH)
#
# Enclose in single quotes to defer evaluation
# to the MATLAB script.
#
# LD_LIBRARY_PATH (load library path - the name
# LD_LIBRARY_PATH is platform
# dependent)
#
# TABLE:
#
# platform variable name
# -------- -------------
# glnxa64 LD_LIBRARY_PATH
# maci64 DYLD_LIBRARY_PATH
#
# NOTE: The final load library path determined
# in the MATLAB startup script is composed
# of:
#
# ------------------------------------------------------------
# LDPATH_PREFIX:<matlab_additions>:LD_LIBRARY_PATH:\
# <system_additions>:LDPATH_SUFFIX
# ------------------------------------------------------------
#
# This means to add paths between:
# 1. <matlab_additions> and LD_LIBRARY_PATH
# put them in front of LD_LIBRARY_PATH
# 2. LD_LIBRARY_PATH and <system_additions>
# put them at the end of LD_LIBRARY_PATH
#
# MATLAB (MATLAB root directory)
#
# MATLABPATH (MATLAB search path)
#
# This is set to "$MATLABPATH" where MATLABPATH is
# taken from the environment.
#
# SHELL (which shell to use for ! or
# unix command in MATLAB)
#
# This is set to "$SHELL" where SHELL is taken from
# the environment. If SHELL is empty or not defined
# then MATLAB uses /bin/sh internally.
#
# TOOLBOX (toolbox path)
#
# This is set to "$TOOLBOX" where TOOLBOX is
# taken from the environment.
#
# Copyright 1986-2016 The MathWorks, Inc.
#----------------------------------------------------------------------------
#
# Determine the arch.
#
# -------------------------------------------------------------
#
MATLAB_UTIL_DIR=
#
# -------------------------------------------------------------
#
if [ ! "$MATLAB_UTIL_DIR" ]; then
MATLAB_UTIL_DIR=$MATLAB_UTIL_DIRdefault
fi
#
MATLAB="$MATLABdefault"
#
. "$MATLAB_UTIL_DIR/arch.sh"
if [ "$ARCH" = "unknown" ]; then
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
echo ''
echo ' Sorry! We could not determine the machine architecture for your'
echo ' host. Please contact:'
echo ''
echo ' MathWorks Technical Support'
echo ''
echo ' for further assistance.'
echo ''
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
trap ""
exit 1
fi
#
# IMPORTANT! Modify ONLY if you don't like the defaults after running
# MATLAB.
#
case "$ARCH" in
glnx*)
#----------------------------------------------------------------------------
AUTOMOUNT_MAP=''
DISPLAY="$DISPLAY"
ARCH="$ARCH"
TOOLBOX="$TOOLBOX"
MATLABPATH="$MATLABPATH"
SHELL="$SHELL"
LDPATH_PREFIX=''
#
# To always use the OpenGL libraries shipped with MATLAB uncomment the next
# line.
#
# LDPATH_PREFIX='$MATLAB/sys/opengl/lib/$ARCH'
#
LDPATH_SUFFIX=''
#
if [ "$LD_LIBRARY_PATH" != "" ]; then
LD_LIBRARY_PATH=$LD_LIBRARY_PATH
else
LD_LIBRARY_PATH=
fi
#----------------------------------------------------------------------------
;;
mac*)
AUTOMOUNT_MAP=''
DISPLAY="$DISPLAY"
ARCH="$ARCH"
TOOLBOX="$TOOLBOX"
MATLABPATH="$MATLABPATH"
SHELL="$SHELL"
LDPATH_PREFIX=''
#
# To always use the OpenGL libraries shipped with MATLAB uncomment the next
# line.
#
# LDPATH_PREFIX='$MATLAB/sys/opengl/lib/$ARCH'
#
LDPATH_SUFFIX=''
#
if [ "$DYLD_LIBRARY_PATH" != "" ]; then
DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH
else
DYLD_LIBRARY_PATH=
fi
#----------------------------------------------------------------------------
;;
*)
#----------------------------------------------------------------------------
AUTOMOUNT_MAP=''
DISPLAY="$DISPLAY"
ARCH="$ARCH"
TOOLBOX="$TOOLBOX"
MATLABPATH="$MATLABPATH"
SHELL="$SHELL"
LDPATH_PREFIX=''
#
# To always use the OpenGL libraries shipped with MATLAB uncomment the next
# line.
#
# LDPATH_PREFIX='$MATLAB/sys/opengl/lib/$ARCH'
#
LDPATH_SUFFIX=''
#
if [ "$LD_LIBRARY_PATH" != "" ]; then
LD_LIBRARY_PATH=$LD_LIBRARY_PATH
else
LD_LIBRARY_PATH=
fi
#----------------------------------------------------------------------------
;;
esac

38
README
View File

@@ -1,19 +1,49 @@
## --------------------------------------------------------------------------
## makefile
##
make: installs mocha mex file and associated shared object file locally
into $OBJ_DIR=${EPICS_HOST_ARCH}/$(MATLAB_VERSION)
make install: installs mocha mex file and associated shared object file
into INSTALL_PATH?=$(INSTALL_MOCHA_LIBDIR) where:
INSTALL_MOCHA_LIBDIR= $(CAFE_BASE)/mocha/$(MOCHA_VERSION)/lib/${EPICS_HOST_ARCH}/$(MATLAB_VERSION)
make clean:
rm $(OBJ_DIR)/*.o $(OBJ_DIR)/*.so $(OBJ_DIR)/*.$(MEXE)
## --------------------------------------------------------------------------
#RHEL8
module load gcc/10.4.0
module load matlab/<version>
#Before compiling, update version number in macchinettaSwitch.cpp
#Find the following line and change version/date
#plhs[0]=mxCreateString((char *) "mocha-1.20.1 : 7 May 2024");
make -f makefile_rel_1.20-gcc-10.4.0
# installs mex file locally
# RHEL8-x86_64/><version>
make -f makefile_rel_1.20-gcc-10.4.0 install
# installs mex file centrally to
/opt/gfa/cafe/mocha/mocha-1.20.1-gcc-10.4.0/lib/RHEL8-x86_64/<version>
#Create AIT module instance
cd /opt/psi/Cafe/cafe-matlab
mdkir 2023a-RHEL8-gcc-10.4.0-cafe-1.20.1
cd 2023a-RHEL8-gcc-10.4.0-cafe-1.20.1
mkdir libexec
cd libexec
cp /opt/gfa/cafe/mocha/mocha-1.20.1-gcc-10.4.0/lib/RHEL8-x86_64/2023a/* .
#Declare new module, e.g., <new_matlab_version>
cd /opt/psi/Cafe/modulefiles/cafe-matlab
cp 2024a <new_matlab_version>
#in new module,
module load matlab/<new_matlab_version>
cp .release-2024a .release-<new_matlab_version>

Binary file not shown.

BIN
RHEL7-x86_64/2018a/mocha.mexa64 Executable file

Binary file not shown.

23
RHEL8-x86_64/2022b/cadelmon.m Executable file
View File

@@ -0,0 +1,23 @@
function cadelmon(channel)
% cadelmon('channel')
% Deletes monitor callback on EPICS channel
% translate pv name to handle
if ischar(channel)
pv = mcaisopen(channel);
if pv == 0
return;
end
elseif isnumeric(channel)
pv = channel;
else
error ('first argument must be channel name or handle');
end
% delete monitor
mcaclearmon(pv);
% if no monitor left then stop monitoring
if isempty(mcamon) && mcamontimer
mcamontimer('stop')
end

244
RHEL8-x86_64/2022b/cafe-matlab.sh Executable file
View File

@@ -0,0 +1,244 @@
#! /bin/bash
# User to set the default MATLAB version here
# This default is ONLY activated
# (1) in the absence of the relevant input argument, and
# (2) if matlab is not already pre-loaded on your system
MATLAB_DEFAULT=2016b
# cafe-matlab.sh script to enable use of the mocha mex-file
# The script executes the command: module load cafe-matlab/<matlab-version>
# which will pre-pend the $MATLABPATH environment variable with the location
# of the matching mocha mex-file
# Jan Chrin, 5 April 2017
#
# Usage: cafe-matlab.sh -v <matlab version> -d <default matlab version> -s <true/false>
# where the input key value pairs are **optional**
# Examples of usage:
# (1) Use mocha with MATLAB version 2016b but do not start matlab [-s false is default]
# cafe-matlab.sh -v 2016b
# (2) Use mocha with MATLAB version 2016b and start matlab
# cafe-matlab.sh -v 2016b -s true
# (3) Use mocha with MATLAB version given by MATLAB_DEFAULT in script
# cafe-matlab.sh -v default -s true
# cafe-matlab.sh --usedefault [equivalent -v default -s false]
# (4) Use mocha with preloaded matlab (else if none, then that given by -d option else MATLAB_DEFAULT )
# cafe-matlab.sh -d 2016b
# cafe-matlab.sh --preloaded [equivalent to -v preloaded -s false]
# If no instruction to the matlab version is given by the user then the procedure is:
# (1) If MATLAB is already loaded ($MATLAB has automatically been set),
# then the location of the corresponding mex-file will be pre-pended to $MATLABPATH
# (2) if MATLAB is **not** already loaded, then the script will use a default MATLAB
# version, as given by the -d option else that given by $MATLAB_DEFAULT in the above.
# and the location of the corresponding mex-file will be pre-pended to $MATLABPATH
PRINT_INFO=false
# Reset (required)
MATLAB_START=false
MATLAB_REQUESTED=
MATLAB_V=$MATLAB_VERSION
#For MATLAB version 2015a and earlier
if [ ! $MATLAB_VERSION ]
then
if [ ${MATLAB} ]
then
MATLAB_EXT=${MATLAB##*/}
#use IFS to split string into arrays with . being the delimeter
IFS='.' read -ra NAMES <<< $MATLAB_EXT
MATLAB_V=${NAMES[0]}
#echo $MATLAB_EXT
fi
fi
# Loop round input arguments
while [[ $# -gt 0 ]]
do
key="$1"
case $key in
-v|-V|--version|--Version)
c=$2
MATLAB_REQUESTED=${c##*/}
if [ $PRINT_INFO = true ]
then
echo MATLAB VERSION REQUESTED = "${MATLAB_REQUESTED}"
fi
shift
;;
-s|-S|--start|--Start)
MATLAB_START="$2"
if [ $PRINT_INFO = true ]
then
echo MATLAB START = "${MATLAB_START}"
fi
shift
;;
-d|-D|--default|--Default)
MATLAB_DEFAULT="$2"
if [ $PRINT_INFO = true ]
then
echo MATLAB DEFAULT = "${MATLAB_DEFAULT}"
fi
shift
;;
--preloaded)
MATLAB_REQUESTED="preloaded"
MATLAB_START=false
if [ $PRINT_INFO = true ]
then
echo MATLAB VERSION REQUESTED = "${MATLAB_REQUESTED}"
echo MATLAB START = "${MATLAB_START}"
fi
;;
--usedefault)
MATLAB_REQUESTED="default"
MATLAB_START=false
if [ $PRINT_INFO = true ]
then
echo MATLAB VERSION REQUESTED = "${MATLAB_REQUESTED}"
echo MATLAB START = "${MATLAB_START}"
fi
;;
-h|-H|--help|--Help)
echo '*********************************************************'
echo Usage: cafe-matlab.sh
echo '-v <matlabVersion> If omitted, uses pre-loaded matlab version, else default version'
echo '-d <matlabVersion> Override default version to be used if matlab module not already loaded'
echo '-s <true/false> Whether or not to start matlab; default is false '
echo '--show Shows matlab version currently loaded and the script default version'
echo '*********************************************************'
echo 'e.g. cafe-matlab.sh -v 2016b -s false % use matlab/2016b'
echo 'e.g. cafe-matlab.sh -d 2016b -s false % Use pre-loaded matlab module else matlab/2016b'
echo 'e.g. cafe-matlab.sh % Use pre-loaded matlab module, else that given in script'
return 2> /dev/null || exit
;;
--show)
echo '*********************************************************'
if [ $MATLAB_V ]
then
echo MATLAB VERSION CURRENTLY LOADED IS ${MATLAB_V}
else
echo 'MATLAB MODULE NOT CURRENTLY LOADED'
fi
echo THE SCRIPT DEFAULT IS $MATLAB_DEFAULT BUT WILL ONLY BE ACTIVATED IF MATLAB
echo 'IS NOT ALREADY LOADED OR OTHERWISE SPECIFIED BY THE -v OPTION'
echo '$MATLAB_DEFAULT CAN BE OVERRIDDEN USING THE -d OPTION'
echo '*********************************************************'
return 2> /dev/null || exit
;;
*)
echo Unknown input key: "$key"
echo Usage: 'cafe-matlab -v <matlab version> -s <true/false>'
echo where '-s true' will start matlab - default is false
echo Executing script with default options
# unknown option
;;
esac
shift #
done
if [ $MATLAB_REQUESTED ]
then
if [ $MATLAB_REQUESTED == 'default' ]
then
MATLAB_REQUESTED=$MATLAB_DEFAULT
fi
if [ $MATLAB_REQUESTED == 'preloaded' ]
then
MATLAB_REQUESTED= #leave empty
fi
fi
#echo $MATLAB_V
#echo $MATLAB_REQUESTED
#echo $MATLAB_DEFAULT
module use Cafe
#if -v is given then load MATLAB_REQUESTED
#if -v not given or if -v preloaded, then load MATLAB_V
#else load MATLAB_DEFAULT
if [ $MATLAB_REQUESTED ]
then
if test -f "/opt/psi/Cafe/modulefiles/cafe-matlab/${MATLAB_REQUESTED}"
then
#unload removes $MATLAB_VERSION
module unload matlab
module unload cafe-matlab
module load cafe-matlab/${MATLAB_REQUESTED}
if [ $PRINT_INFO = true ]
then
echo "Using requested version: matlab/$MATLAB_REQUESTED"
fi
else
echo "Unknown requested version: matlab/$MATLAB_REQUESTED"
echo "'module avail cafe-matlab' gives the possibilities:"
module avail cafe-matlab
fi
elif [ $MATLAB_V ]
then
if test -f "/opt/psi/Cafe/modulefiles/cafe-matlab/${MATLAB_V}"
then
#unload removes $MATLAB_VERSION
module unload matlab
module unload cafe-matlab
module load cafe-matlab/${MATLAB_V}
if [ $PRINT_INFO = true ]
then
echo "Using matlab/$MATLAB_V"
fi
else
module unload matlab
module unload cafe-matlab
module load cafe-matlab/$MATLAB_DEFAULT
if [ $PRINT_INFO = true ]
then
echo "Using matlab/$MATLAB_DEFAULT"
fi
fi
else
if test -f "/opt/psi/Cafe/modulefiles/cafe-matlab/${MATLAB_DEFAULT}"
then
module unload matlab
module unload cafe-matlab
module load cafe-matlab/$MATLAB_DEFAULT
if [ $PRINT_INFO = true ]
then
echo "Using matlab/$MATLAB_DEFAULT"
fi
else
echo "The default requested version: matlab/$MATLAB_DEFAULT within cafe-matlab.sh is invalid!"
echo "'module avail cafe-matlab' gives the possibilities:"
module avail cafe-matlab
fi
fi
if [ $MATLAB_START = true ]
then
matlab &
fi
## Or manually acticate cafe-matlab:
## module unload matlab
## module unload cafe-matlab
## module load cafe-matlab/2016b
## or module switch cafe-matlab/2016b cafe-matlab/2015a

108
RHEL8-x86_64/2022b/caget.m Executable file
View File

@@ -0,0 +1,108 @@
function value = caget(channel,cached)
% caget('channel') returns current value and additional infos
% of given EPICS channel.
% caget('channel',1) returns last value and additional infos
% of given EPICS channel.
%
% channel can be a channel name or a handle as returned from mcaopen
%
% return value elements:
% val: value (scalar, vector or string)
% sevr: severity as a number
% sevr_str: severity as a string
% stat: status as a number
% stat_str: status as a string
% time: timestamp as a date vector
% units: units string
persistent severity_str
persistent status_str
persistent zerotime
persistent units
if ischar(channel)
pv = mocha('open',channel);
if mocha('isConnected', channel) == false
mocha('openNowAndWait', 1.5)
end
if mocha('isConnected', channel) == false
error('EPICS channel %s not found', channel);
end
elseif isnumeric(channel)
pv = channel;
else
error ('first argument must be channel name or handle');
end
if isvector(pv)
pv=pv(1); % truncate
end
chInfo=mocha ('getChannelInfo',pv);
if nargin > 1 && cached
pvStruct = mocha('getPVCache',pv);
else
pvStruct = mocha('getPV', pv);
end
pvCtrl = mocha('getCtrlCache',pv);
%pvCtrl
% initialize severity and status enums
if isempty(severity_str)
severity_str = {'NO_ALARM';'MINOR';'MAJOR';'INVALID'};
status_str = {'NO_ALARM';'READ';'WRITE';'HIHI';'HIGH';'LOLO';'LOW';'STATE';'COS';'COMM';'TIMEOUT';'HWLIMIT';'CALC';'SCAN';'LINK';'SOFT';'BAD_SUB';'UDF';'DISABLE';'SIMM';'READ_ACCESS';'WRITE_ACCESS'};
end
value.val = pvStruct.val;
units = pvCtrl.units;
if (pvCtrl.noEnumStrings>0)
value.val_str = value.val;
value.val = mocha('getCache',pv,'int8');
end
value.units=units;
value.sevr = pvStruct.alarmSeverity;
indx=max(pvStruct.alarmSeverity, 0);
value.sevr_str = severity_str{indx+1};
value.stat = pvStruct.alarmStatus;
indx=max(pvStruct.alarmStatus, 0);
value.stat_str = status_str{ indx+1};
timestamp = mocha('getTimestamp',pv);
if (numel(timestamp) == 2)
% old mca version
% do not use mcatime here because 1. it is slow, 2. is returns UTC
% calculating zerotime only once is faster and takes localtime into account
% When daylight saving time begins or ends, restart the program!
if isempty(zerotime)
[status,timezone]=system('date +%z'); % get localtime offset
timeoffs=str2double(timezone);
houroffs=floor(timeoffs/100);
minoffs=(timeoffs-100*houroffs);
zerotime = datenum('1-Jan-1990') + (minoffs/60 + houroffs)/24;
end
time=timestamp(1)+timestamp(2)/1000000000;
if time
time = zerotime+time/24/3600;
end
value.time = datevec(time);
else
% new mca version
timestamp(6)=timestamp(6)+timestamp(7)/1000000000;
value.time = timestamp(1:6);
end

34
RHEL8-x86_64/2022b/cainfo.m Executable file
View File

@@ -0,0 +1,34 @@
function value = cainfo(pvname)
% cainfo('pvname') returns handle,element count, native type, state, ...
%
mcaNoConnection ={'unknown', 'disconnected','Disconnected due to server or network problem'};
mcaConnection ={'known', 'connected','Normal connection'};
mcaClosedConnection={'unknown', 'disconnected','Permanently disconnected (cleared)'};
value=struct('Handle',{}, 'PVName',{}, 'ElementCount',{},'NativeType',{},'State',{},'MCAMessage',{},'Host',{},'Units',{});
chInfo=mocha ('getChannelInfo', pvname);
pvCtrl=mocha ('getCtrlCache', pvname);
value(1).Handle= mocha('getHandleFromPV', pvname);
value(1).PVName= mocha('getPVFromHandle', value(1).Handle);
value(1).ElementCount=chInfo.nelem;
nativeType=strsplit(chInfo.dataType,'_');
value(1).NativeType=nativeType{2};
if (chInfo.connectFlag==1)
value(1).State=mcaConnection{2};
value(1).MCAMessage=mcaConnection{3};
else
value(1).State=mcaNoConnection{2};
value(1).MCAMessage=mcaNoConnection{3};
end
%value(1).MCAMessage=mocha('statusInfo', mocha('getStatus', pvname));
value(1).Host =chInfo.hostName;
value(1).Units=pvCtrl.units;
%value(1)=setfield(value(1),'Units',pvCtrl.units)

62
RHEL8-x86_64/2022b/camon.m Executable file
View File

@@ -0,0 +1,62 @@
function camon(channel,callback,userarg)
% camon('channel', 'callback')
% camon('channel', 'callback', userarg)
% camon('channel', @callback)
% camon('channel', @callback, userarg)
%
% Installs a callback function (given as string or handle)
% on an EPICS channel.
% Whenever the channel updates, the callback is called
% with a structure as defined below and an optional
% numeric, string, or matrix user argument
%
% callback argument structure elements:
% val: value (scalar, vector or string)
% sevr: severity as a number
% sevr_str: severity as a string
% stat: status as a number
% stat_str: status as a string
% time: timestamp as a date vector
%
% A monitor can be deleted with
% cadelmon ('channel')
% initialize monitoring the first time
if ~mcamontimer
mcamontimer('start');
end
% translate channel name to handle
if ischar(channel)
pv = mcacheckopen(channel);
if pv == 0
error('EPICS channel %s not found', channel);
end
elseif isnumeric(channel)
pv = channel;
else
error ('usage: camon(''channel'',@callback,userarg)');
end
% callback can be string or function handle -- we need string
if nargin>1
if isa(callback,'function_handle')
callback = func2str(callback);
elseif ~ischar(callback)
error ('usage: camon(''channel'',@callback,userarg)');
end
end
% install monitor
if nargin==1
mcamon(pv);
return
elseif nargin==2
cb=sprintf('%s(caget(%d,1))',callback,pv);
else
cb=sprintf('%s(caget(%d,1),''%s'')',callback,pv,mat2str(userarg));
end
disp(pv)
disp(cb)
mcamon(pv, cb);

30
RHEL8-x86_64/2022b/caput.m Executable file
View File

@@ -0,0 +1,30 @@
function sts = caput(pvname, value)
% sts=caput('pvname',value) sets the value of EPICS PV 'pvname'.
%
channel=pvname;
if ischar(channel)
pv = mocha('open',channel);
if mocha('isConnected', channel) == false
mocha('openNowAndWait', 1.5)
end
if mocha('isConnected', channel) == false
error('EPICS channel %s not found', channel);
end
elseif isnumeric(channel)
if mocha('isConnected', channel) == false
error('EPICS channel with handle %d not connected', channel);
end
pv = channel;
else
error ('First argument must be channel name or handle');
end
sts= mocha('set', pv, value);

View File

@@ -38,7 +38,7 @@
% To run this test script, first create 5 soft channels of the given class.
% pv(1:2) are scalar numerics, pv(3) is a wf, pv(4) is a mbbo record (enum),
% pv(5) is a dbr_string_t, pv(6) does not exist
pv={'ARIDI-BPM-01LE:X-AVG','ARIDI-BPM-01LE:Y-AVG','ARIDI-BPM-01LE:WF-INT-2','caget','ARIDI-BPM-01LE:SET-ENABLE.DESC','PV-JOKE'};
pv={'ARIDI-BPM-01LE:X-AVG','ARIDI-BPM-01LE:Y-AVG','ARIDI-BPM-01LE:WF-INT-2','ARIDI-BPM-01LE:SET-ENABLE','ARIDI-BPM-01LE:SET-ENABLE.DESC','PV-JOKE'};
%
% MATLAB's Run and Advance utility will run each of these 17 sections at the user's prompt.
@@ -92,10 +92,10 @@ disp('Section (1) Establishing connections to EPICS Process Variables (PVs) ');
disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%');
%returns an array of handles (object references)
hpv=mocha('open',pv);
%hpv=mocha('open',pv);
%When executing the 'open' message as above, the default behaviour
%is for each 'open' to wait for a fixed amount of time, given by:
%is for each 'open' to wait for a maximum amount of time, given by:
openTime = mocha ('getOpenWaitTime'); %currently 0.4s
%The 'open' wait time can, however, be configured by the user as follows:
mocha ('setOpenWaitTime', 0.2); %set to 0.2s
@@ -108,7 +108,7 @@ mocha ('setOpenWaitTime'); %reset to default (0.4s)
mocha('openPrepare');
hpv=mocha('open',pv);
% and more mocha 'open' messages would follow here...
% Finally send the messages and wait for 0.2s for connections to complete
% Finally send the messages and wait for a maximum of 0.2s for connections to complete
mocha('openNowAndWait', 0.2)
%There are a number of ways to extract information on the created handles
@@ -162,7 +162,7 @@ pvtable
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%(2) Simple single channel operations (and the PVData Object)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%');
@@ -245,6 +245,8 @@ pvStruct.epicsTS; %[secPastEpoch, nsec]
%END (2) Simple single channel operations
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%(3) Understanding the Status Error Code / MATLAB Exceptions
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -275,7 +277,7 @@ statusInfo = mocha ('statusInfo', status);
%statusArray[2] returns same data as statusInfo above
%Status code/name pairs can be listed as follows:
%disp('Listing all possible status code value/name pairs')
disp('Listing all possible status code value/name pairs')
[strVal, intVal] = mocha('statusList');
%Alarm conditions and alarm severities can be listed as follows:
@@ -467,6 +469,8 @@ disp('Section (8) Multiple Struct operations on several PVS returning PVData Obj
disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%');
%GET
%returns a sequence of pvData structs
%%
[pvData, isAllOK] = mocha ('getPVArray', pv)
disp('Display all pvData.val values and statuses:');
%pvData(i) corresponds to the data returned by pv(i)
@@ -482,41 +486,52 @@ disp('Display all pvData.val values and statuses:');
%returns a sequence of extended (x) pvData structs
[pvStruct, isAllOK] = mocha ('getStructArray', pv)
%%[pvStruct, isAllOK] = mocha ('getStructArray', pv)
%pvStruct(i) corresponds to the data returned by pv(i)
disp('Display all pvStruct as arrays:');
[pvStruct.handle]
{pvStruct.pv}
{pvStruct.val}
[pvStruct.status]
{pvStruct.status_str}
[pvStruct.alarmStatus]
[pvStruct.alarmStatus_str]
[pvStruct.alarmSeverity]
{pvStruct.alarmSeverity_str}
pvStruct.ts
pvStruct.epicsTS
[pvStruct.alarmSeverity]
{pvStruct.alarmSeverity_str}
%%disp('Display all pvStruct as arrays:');
%%[pvStruct.handle]
%%{pvStruct.pv}
%%{pvStruct.val}
%%[pvStruct.status]
%%{pvStruct.status_str}
%%[pvStruct.alarmStatus]
%%{pvStruct.alarmStatus_str}
%%[pvStruct.alarmSeverity]
%%{pvStruct.alarmSeverity_str}
%%pvStruct.ts
%%pvStruct.epicsTS
%%[pvStruct.alarmSeverity]
%%{pvStruct.alarmSeverity_str}
%pvStruct(1:6).ts %timestamps
%[pvStruct(1:6).alarmStatus]
%% %%%%
%Note: the following method is equivelent to the above
%as it will call getStructArray internally
[pvStruct, isAllOK] = mocha ('getStruct', pv);
%%%%%%%%
disp('Alternatively part data (values, statuses only) could also be retrieved with getCellArray:');
%% %%%%
[val, isAllOK, s] = mocha ('getCellArray', hpv)
%%%%%%%%%%%%%%
%SET
%SET -overwrite pvData
pvData(1).val =0.2345;
pvData(2).val =2.6789;
pvData(3).val =(256:512);
pvData(4).val = 'off';
%%%%%%
[isAllOK, s] = mocha ('set', hpv, pvData(1:6).val);
%%%%%%%%%%%%%%%%%%%
%Check values were set
[val, isAllOK, s] = mocha ('getCellArray', hpv)
%%%%%%%%%
disp('Recall we had previously set an offset for wf of value:');
offset=mocha('getOffset',hpv(3))
disp('Setting new offset/nelem for wf has value:');
@@ -543,6 +558,8 @@ pvData(3).val
%END (8) Multiple Struct operations on several PVS returning PVData Objects plus Multiple Sets for Scalars/Vectors
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%(9) Asynchronous interactions and retrieving data from Cache
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -708,7 +725,6 @@ disp('Show members of group gTest (as loaded from test.xml):');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%(11) Monitors, either with or without user supplied callbacks (in essence, matlab scripts)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -720,6 +736,8 @@ monitorID = mocha ('monitor', pv(1));
[monitorIDArray, isAllOK, statusArray] = mocha ('monitor', pv(1:6)); %start monitors for several pvs/handles
%Once the monitor is started, data may be retrieved via one of the cache methods
pause(0.1)
[val,s] = mocha('getCache', pv(1)); %Scalar or vector returned in native data type
[val,s] = mocha('getCache', pv(1), 'double'); %Scalar or vector returned as a MATLAB double
[val,s] = mocha('getCache', pv(1), 'uint8'); %Scalar or vector returned as a MATLAB uint8
@@ -758,14 +776,14 @@ mocha('monitorFlushEvent', pv(1)); %will execute the MATLAB script monitorAction
mocha('monitorFlushEvent'); %will execute all 'actions' for all 'handles' that have received new data
%The above command is used in conjunction with MATLAB timer (as for MCA's mcamontimer.m)
obj.t = timer('TimerFcn', 'mocha(''monitorFlushEvent'')', 'Period', 1.0, 'ExecutionMode', 'fixedSpacing');
obj.t = timer('TimerFcn', 'mocha(''monitorFlushEvent'')', 'Period', 2.0, 'ExecutionMode', 'fixedSpacing');
%Else if double quotes cannot be used in the above; here's a way around the problem:
%obj.t = timer('TimerFcn', 'mocha(402)', 'Period', 2.0, 'ExecutionMode', 'fixedSpacing');
start(obj.t);
disp ('Callback for monitors for 5 seconds')
for n=1:5
mocha('set', pv(1), n); %See the script be executed
pause(1);
pause(0.5);
end
stop(obj.t);
@@ -1040,8 +1058,7 @@ disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%');
%Stops all monitors (if any)
%Closes all channels
%Releases all CA resources
mocha ('close');
mocha ('close')
%
%END (17) Gracefully terminate CAFE
%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Binary file not shown.

View File

@@ -0,0 +1,36 @@
function varargout = mcaalarm(varargin)
%MCAALARM - read alarm status and severity for PVs previously read with MCAGET or MCAMON
%
% VALUE = MCAALARM(HANDLE)
% returns the status and severity of a PV specified by integer HANDLE:
%
% VALUE is a structure:
% 'status' : Status code
% 'severity': Severity code
%
% Refer to the EPICS header file "alarmString.h" for the code definitions.
%
% [VALUE1, ... VALUEN] = MCAALARM(HANDLE1, ... , HANDLEN)
% returns status and severity of multiple PVs of any type and length
% Number of outputs must match the number of inputs
%
% See also MCAGET, MCAMON.
%
if nargin<1
error('No arguments were specified in mcaalarm')
elseif nargin==1
result{1} = mocha('getAlarm',varargin{1}); %mca(61,varargin{1});
varargout{1}.status = result{1}(1,1);
varargout{1}.severity = result{1}(1,2);
elseif nargin>1
if nargin ~= nargout
error('Number of outputs must match the number of inputs')
end
%[result{1:nargin}] = mca(61,varargin{:});
for k = 1:nargin
[result{k}] = mocha('getAlarm',varargin{k});
varargout{k}.status=result{k}(1,1);
varargout{k}.severity=result{k}(1,2);
end
end

View File

@@ -0,0 +1,40 @@
function varargout = mcacache(varargin)
%MCACACHE - reads locally cached value of a PV.
% MCACACHE does NOT communicate with the server or use resources of CA library
%
% VALUE = MCACACHE(HANDLE) returns a value of a PV by integer HANDLE
% The type (EPICS strings are returned as MATLAB strings)
% All numeric EPICS types returned are as MATLAB double
% If a PV is is a waveform VALUE is a vector
%
% [ VALUE1 , ... VALUEN ] = MCACACHE(HANDLE1, ... , HANDLEN)
% returns values of multiple PV's.
% Number of outputs must match the number of inputs
%
% Notes: The cache value for a PV does not exist until the first use of a
% monitor on that PV
% See also: MCAMON
if nargin>1 && nargin~=nargout
error('Number of outputs must match the number of inputs')
end
for k = 1:nargin
[varargout{k}] = mocha('getCache',varargin{k});
end
%for k = 1:nargin
% scalarValues(k) = varargin{k};
%end
%[a,isAllOk,s]=mocha('getScalarArrayCache',scalarValues);
%for k = 1:nargin
% [varargout{k}]= a(k);
%end
%
%[varargout{1:nargin}] = mca(300,varargin{:});

View File

@@ -0,0 +1,20 @@
function varargout = mcacheck(varargin)
%MCACHECK - Same as MCASTATE
% See also MCAOPEN
if nargin > 0
%varargout{1} = mca(13,varargin{:});
for k = 1:nargin
if mocha('isConnected', varargin{k}) == true
isConnected(k) = uint16(1);
else
isConnected(k) = uint16(0);
end
end
varargout{1} = isConnected;
else
[h,pv,state] = mocha('getHandleStates');
%[varargout{1}, varargout{2}] = mca(12);
varargout{1} = h;
varargout{2} = state;
end

View File

@@ -0,0 +1,48 @@
function varargout = mcacheckopen(varargin)
%MCACHECKOPEN - returns handle(s) to PV(s)
% Returns existing handles for PVs already connected,
% opens new connections otherwise.
% Returns 0 for PVs that failed to connect.
%
% HANDLE = MCACHECKOPEN('NAME')
%
% [HANDLE1, ... , HANDLEN] = MCACHECKOPEN('PVNAME1', ... , 'PVNAMEN')
%
% HANDLES = MCACHECKOPEN(NAMES)
% When NAMES is a cell array of strings, HANDLES is a numeric array of
% handles
%
% Note:
% In principle, one should open, use, close PVs.
% But in some cases the bookkeeping of PV handles might
% be a bit too much for quick script hacks,
% in which case mcacheckopen can help with re-use of
% existing handles for PVs that were opened earlier yet
% their handles are lost.
%
% See also MCAOPEN, MCAISOPEN
if iscellstr(varargin{1})
varargout{1} = zeros(size(varargin{1}));
for i=1:length(varargin{1})
varargout{1}(i) = mcaisopen(varargin{1}{i});
if ~varargout{1}(i)
varargout{1}(i) = mcaopen(varargin{1}{i});
end
end
else
for i=1:nargin
varargout{i} = mcaisopen(varargin{i});
if ~varargout{i}
varargout{i} = mcaopen(varargin{i});
end
end
end

View File

@@ -0,0 +1,19 @@
function mcaclearmon(varargin)
%MCACLEARMON - uninstall monitors, previously installed with MCAMON
%
% MCACLEARMON(H1,H2,...,HN)
% H1,H2..,HN - integer channel handles
%
% Note: Monitors can be installed with MCAMON and cleared with
% MCACLEARMON any number of times.
%
% See also MCAMON, MCAMONTIMER, MCACACHE
if nargin <1
error('Must specify channel handles to close');
else
for i=1:nargin
%mca(200,varargin{i})
mocha('monitorStop',varargin{i})
end
end

View File

@@ -0,0 +1,22 @@
function mcaclose(varargin)
%MCACLOSE - permanently closes channels
% MCACLOSE(H1,H2,...,HN) closes the channels identified by their
% integer handles, previously opened with MCAOPEN.
% MCACLOSE(H) is the same for the case that H is an array of handles.
%
% Note: Once a channel is closed, it can not be used
% by MCAGET,MCAPUT or MCAMON. It can not be reopened.
% Use MCAOPEN again in order to connect to the same PV.
%
% See also MCAOPEN, MCASTATE, MCAINFO
if nargin <1
error('Must specify channel handles to close');
else
for i=1:nargin
pvs = varargin{i};
for j=1:length(pvs)
%mca(5, pvs(j))
mocha('close', pvs(j))
end
end
end

View File

@@ -0,0 +1,12 @@
function mcadebug(onoff)
%MCADEBUG - Enable/disable debugging
%
% Used only for development, not user-callable.
if onoff
%mca(9999, 1);
disp('Not relevant to mocha');
else
%mca(9999);
disp('Not relevant to mocha');
end

View File

@@ -0,0 +1,34 @@
function varargout = mcaegu(varargin)
%MCAEGU - read engineering units from PV's
%
% VALUES = MCAEGU(HANDLE) returns a string array of enum strings of the
% PV specified by integer HANDLE.
% The function does not handle arrays of PV handles, but only a single PV at at time.
%
%
% Error handling:
% An empty cell string array will be returned if the PV type is not ENUM.
% A matlab exception will be thrown when the PV handle is invalid,
% i.e. not the result of a successful MCAOPEN.
% Furthermore, an error can result from a 'get' timeout,
% configurable via MCATIMEOUT.
% In addition, an error can result from a network disconnect.
% In principle, one can check beforehand via MCASTATE, but since
% a disconnect might happen just between the sucessful MCASTATE call
% and the following MCAGET, the only safe thing might be to surround
% MCAGET calls with TRY....CATCH.
%
% See also TRY, CATCH, MCASTATE, MCATIMEOUT, MCAPUT
if nargin<1
error('No arguments were specified in mcaget')
elseif nargin==1
if length(varargin{1})>1
error('Only single PV can be handled at a time')
else
pvCtrl=mocha('getCtrlCache', varargin{1});
varargout{1} = {pvCtrl.units}; %mca(41,varargin{1});
end
elseif nargin>1
error('Only single PV can be handled at a time')
end

View File

@@ -0,0 +1,39 @@
function varargout = mcaenums(varargin)
%MCAENUMS - read enum strings from PV's
%
% VALUES = MCAENUMS(HANDLE) returns a string array of enum strings of the
% PV specified by integer HANDLE.
% The function does not handle arrays of PV handles, but only a single PV at at time.
%
%
% Error handling:
% An empty cell string array will be returned if the PV type is not ENUM.
% A matlab exception will be thrown when the PV handle is invalid,
% i.e. not the result of a successful MCAOPEN.
% Furthermore, an error can result from a 'get' timeout,
% configurable via MCATIMEOUT.
% In addition, an error can result from a network disconnect.
% In principle, one can check beforehand via MCASTATE, but since
% a disconnect might happen just between the sucessful MCASTATE call
% and the following MCAGET, the only safe thing might be to surround
% MCAGET calls with TRY....CATCH.
%
% See also TRY, CATCH, MCASTATE, MCATIMEOUT, MCAPUT
if nargin<1
error('No arguments were specified in mcaget')
elseif nargin==1
if length(varargin{1})>1
error('Only single PV can be handled at a time')
else
pvCtrl=mocha('getCtrlCache', varargin{1});
ens13=pvCtrl.enumStrings;
ens=cell(max(1,pvCtrl.noEnumStrings),1);
for k=1:pvCtrl.noEnumStrings
ens(k)=ens13(k);
end
varargout{1} = ens; %mca(40,varargin{1});
end
elseif nargin>1
error('Only single PV can be handled at a time')
end

View File

@@ -0,0 +1,5 @@
function mcaexit()
%MCAEXIT - Shut down channel access...
%
% Disconnects all PVs.
mocha('close') %mca(999)

View File

@@ -0,0 +1,71 @@
function varargout = mcaget(varargin)
%MCAGET - read values from PV's
%
% VALUE = MCAGET(HANDLE) returns a value of a PV specified by integer HANDLE.
% Type of return value depends on the native type and the number of elements
% in the EPICS record:
%
% EPICS strings are returned as MATLAB strings
% EPICS array of strings - MATLAB cell array of strings
% All numeric EPICS types are returned as MATLAB double arrays
%
% VALUES = MCAGET(HANDLES) an easy get for a group of scalar numeric PV's
% HANDLES - array of handles
% VALUES - numeric array of values.
% If any of the PVs is a waveform,
% only the first element is returned
%
% [VALUE1, ... VALUEN] = MCAGET(HANDLE1, ... , HANDLEN)
% returns values of multiple PV's of any type and length
% Number of outputs must match the number of inputs
%
% Error handling:
% A matlab exception will be thrown when any of the PVs are invalid,
% i.e. not the result of a successful MCAOPEN.
% Furthermore, an error can result from a 'get' timeout,
% configurable via MCATIMEOUT.
% In addition, an error can result from a network disconnect.
% In principle, one can check beforehand via MCASTATE, but since
% a disconnect might happen just between the sucessful MCASTATE call
% and the following MCAGET, the only safe thing might be to surround
% MCAGET calls with TRY....CATCH.
%
% See also TRY, CATCH, MCASTATE, MCATIMEOUT, MCAPUT
if nargin<1
error('No arguments were specified in mcaget')
elseif nargin==1
if length(varargin{1})>1
[a, isallOK]=mocha('getScalarArray', varargin{1}, 'double');
varargout{1} = [a]; %mocha('getScalarArray', varargin{1}); %mca(51,varargin{1});
else
chInfo=mocha('getInfo', varargin{1});
if( strcmp(chInfo.dataType,'DBR_ENUM') )
varargout{1} = mocha('get', varargin{1},'double');
else
varargout{1} = mocha('get', varargin{1}); %mca(50,varargin{1});
end
end
elseif nargin>1
if nargin ~= nargout
error('Number of outputs must match the number of inputs')
end
[a, isallOK]=mocha('getStructArray', [varargin{:}]);
for k=1:length(a)
chInfo=mocha('getInfo', varargin{k});
if( length(a(k).val) ==1 && strcmp(chInfo.dataType,'DBR_ENUM') )
varargout{k}=mocha('getCache', varargin{k}, 'double');
%if (length(a(k).val)==1 && iscell(a(k).val))
% varargout{k}=a(k).val{1};
else
if (length(a(k).val)==1 && iscell(a(k).val))
varargout{k}=a(k).val{1};
else
varargout{k}=a(k).val;
end
end
end
%[varargout{1:nargin}] mca(50,varargin{:});
end

View File

@@ -0,0 +1,76 @@
function varargout = mcagets(varargin)
%MCAGETS - read values from PV's, with string output for ENUMs
%
% VALUE = MCAGETS(HANDLE) returns a value of a PV specified by integer HANDLE.
% Type of return value depends on the native type and the number of elements
% in the EPICS record:
%
% EPICS strings are returned as MATLAB strings
% EPICS array of strings - MATLAB cell array of strings
% All numeric EPICS types are returned as MATLAB double arrays
% This routine returns the string value of ENUM types, when the input
% parameter is a single handle. Otherwise this routine behaves
% identically to MCAGET
%
% VALUES = MCAGETS(HANDLES) an easy get for a group of scalar numeric PV's
% HANDLES - array of handles
% VALUES - numeric array of values.
% If any of the PVs is a waveform,
% only the first element is returned
%
% [VALUE1, ... VALUEN] = MCAGETS(HANDLE1, ... , HANDLEN)
% returns values of multiple PV's of any type and length
% Number of outputs must match the number of inputs
%
% Error handling:
% A matlab exception will be thrown when any of the PVs are invalid,
% i.e. not the result of a successful MCAOPEN.
% Furthermore, an error can result from a 'get' timeout,
% configurable via MCATIMEOUT.
% In addition, an error can result from a network disconnect.
% In principle, one can check beforehand via MCASTATE, but since
% a disconnect might happen just between the sucessful MCASTATE call
% and the following MCAGET, the only safe thing might be to surround
% MCAGET calls with TRY....CATCH.
%
% See also TRY, CATCH, MCASTATE, MCATIMEOUT, MCAPUT
if nargin<1
error('No arguments were specified in mcaget')
elseif nargin==1
if length(varargin{1})>1
[a, isallOK]=mocha('getScalarArray', varargin{1}, 'double');
varargout{1} = [a]; %mca(51,varargin{1});
else
varargout{1} = mocha('get', varargin{1});
%if(strcmp(mca(43,varargin{1}),'ENUM'))
% enumvalues=mca(40,varargin{1});
% varargout{1}= enumvalues{mca(50,varargin{1})+1};
% else
% varargout{1} =mca(50,varargin{1});
% end
end
elseif nargin>1
if nargin ~= nargout
error('Number of outputs must match the number of inputs')
end
[a, isallOK]=mocha('getStructArray', [varargin{:}]);
for k=1:length(a)
chInfo=mocha('getInfo', varargin{k});
if( length(a(k).val) ==1 && strcmp(chInfo.dataType,'DBR_ENUM') )
varargout{k}=mocha('getCache', varargin{k}, 'double');
else
if (length(a(k).val)==1 && iscell(a(k).val))
varargout{k}=a(k).val{1};
else
varargout{k}=a(k).val;
end
end
end
%[varargout{1:nargin}] mca(50,varargin{:})
end

View File

@@ -0,0 +1,86 @@
function varargout = mcainfo(varargin);
%MCAINFO - get connection status and other information about a PV
% INFO = MCAINFO(PV) returns information on a single PV
% PV can be a string PV name or an integer handle
% Returns a 1-by-1 structure with fields:
%
% Handle
% PVName
% ElementCount:
% NativeType { STRING | INT | FLOAT | ENUM | CHAR | DOUBLE }
% State { connected | disconnected }
% MCAMessage
% Host
%
% [HANDLES, INFO] = MCAINFO with no argument returns information on
% all open channels in a structure array.
% HANDLES is a numeric array of handles
% INFO is a structure array of inoformation on the PV in the
% same format as above
%
% Note: A channel may become disconnected
% due to a server or network problem. This will be reflected in
% MCAMessage field. Any attempts to read, write or monitor this channel
% will return an error. CA library will periodically attempt to reestablish
% connection without any action required from the user.
% When the connection is closed by the user with MCACLOSE,
% that PV handle becomes invalid, and attempts to call MCAINFO
% will result in an error.
%
% See also: MCAOPEN MCACLOSE MCASTATE
value=struct('Handle',{}, 'PVName',{}, 'ElementCount',{},'NativeType',{},'State',{},'MCAMessage',{},'Host',{},'Units',{});
mcaNoConnection ={'unknown', 'disconnected','Disconnected due to server or network problem'};
mcaConnection ={'known', 'connected','Normal connection'};
mcaClosedConnection={'unknown', 'disconnected','Permanently disconnected (cleared)'};
if nargin>0
if ischar(varargin{1})
%[handles, names] = mca(3);
%matchfound = find(strcmp(varargin{1},names));
%if isempty(matchfound)
% error(['No open channels found for a PV: ',varargin{1}]);
%end
%h = handles(matchfound);
h(1)=mocha('getHandleFromPV',varargin{1});
if (h(1)==0)
error(['No open channels found for a PV: ',varargin{1}]);
end
elseif isnumeric(varargin{1})
h(1)=(varargin{1});
else
error('Argument must be a string PV Name or an integer handle');
end
%varargout{1} = mca(11,h);
else % Return info on all channels
%[varargout{1} varargout{2}] = mca(10);
[h,pv]=mocha('getHandles');
end
for k=1:length(h)
chInfo=mocha ('getChannelInfo', h(k));
pvCtrl=mocha ('getCtrlCache', h(k));
value(k).Handle=h(k);
value(k).PVName= mocha('getPVFromHandle', h(k));
value(k).ElementCount=chInfo.nelem;
nativeType=strsplit(chInfo.dataType,'_');
value(k).NativeType=nativeType{2};
if (chInfo.connectFlag==1)
value(k).State=mcaConnection{2};
value(k).MCAMessage=mcaConnection{3};
else
value(k).State=mcaNoConnection{2};
value(k).MCAMessage=mcaNoConnection{3};
end
%value(k).MCAMessage=mocha('statusInfo', mocha('getStatus', h(k)));
value(k).Host =chInfo.hostName;
value(k).Units=pvCtrl.units;
end
if (length(h)==1)
varargout{1} = value;
else
varargout{1} = h;
varargout{2} = value;
end

View File

@@ -0,0 +1,20 @@
function h = mcaisopen(PVNAMESTRING);
%MCAISOPEN - Check if a channel to a PV is open with MCAOPEN
%
% H = MCAISOPEN(PVNAMESTRING) returns an integer handle if open
% and 0 otherwise. If more than one channel is open to the
% same PV, an array of handles is returned.
%
% See also MCAINFO MCASTATE
if ~ischar(PVNAMESTRING)
error('Argument must be a string')
end
[handles, names] = mcaopen;
matchfound = find(strcmp(PVNAMESTRING,names));
if isempty(matchfound)
h = 0;
else
h = handles(matchfound);
end;

View File

@@ -0,0 +1,66 @@
function varargout = mcamon(handle,varargin)
%MCAMON - install or replace monitor on a PV
%
% STS = MCAMON(HANDLE) installs monitor with default callback.
% Default callback updates local copy of the channel data
% every time the data changes on the server.
% This cached data can be read at later time into MATLAB with MCACACHE.
% HANDLE - integer handle to a channel previously opened with MCAOPEN
% Returns 1 on success, 0 on failure
%
% STS = MCAMON(HANDLE,CALLBACKSTRING) installs a monitor and specifies
% a callback string for each. A callback string must be a MATLAB command,
% sequence of commands or a name of a script/function on the MATLAB path.
% It is executed in the 'base' workspace (AFTER the default callback) on
% the next poll of the queue by the MCAMONTIMER command.
% Returns 1 on success, 0 on failure
%
% [HANDLES, CALLBACKSTRINGS]=MCAMON with no arguments returns information
% on all currently installed monitors
%
% Note: Monitors can be installed with MCAMON and cleared with
% MCACLEARMON any number of times. Use MCAMONTIMER to initialise
% the MATLAB timer which polls and processes the outstanding MCA Monitor
% callback queue.
%
% Note: Use of asynchronous features of EPICS (such as monitors)
% with MATLAB requires special care - read MCA notes.
%
% 1.In CA client library (EPICS R3.13.4) asynchronous callbacks run one at a time
% to completion. This means that MATLAB callback string installed with MCAMON
% may not itself contain other MCA functions that call CA library such as MCAGET
% For example MCAMON(H1, 'X=MCAGET(H2);') will not work.
% MCAMON(H1, X='MCACACHE(H2);') is OK since MCACACHE does not use CA library.
%
% See also MCAMONTIMER, MCACACHE, MCAGET, MCACLEARMON.
if nargin ==1
%varargout{1}=mca(100,handle);
monID=mocha('monitor', handle); %return monitorID
status=0;
if (monID > 4095) %1st onid is 0xff (4096)
status=1;
end
varargout{1}=status;
elseif nargin==2
if ischar(varargin{1})
%varargout{1} = mca(100,handle,varargin{1});
monID=mocha('monitor', handle, varargin{1} )
status=0;
if (monID > 4095)
status=1;
end
else
error('Second argument must be a string');
end
elseif nargin == 0
if nargout == 2
%[varargout{1},varargout{2}]=mca(500);
[varargout{1},varargout{2}]=mocha ('getMonitorHandlesAndActions');
else
%varargout{1}=mca(500);
varargout{1}=mocha ('getMonitorHandles');
end
end

View File

@@ -0,0 +1,25 @@
function varargout = mcamonevents(varargin)
%MCAMONEVENTS - returns the number of monitor events which have
% occurred for channels since the last call to MCACACHE.
%
% [HANDLES, EVENTCOUNT] = MCAMONEVENTS
% Returns handles and event counts for all open channels
%
% EVENTCOUNT = MCAMONEVENTS(HANDLES)
% Returns event counts for specified channel(s)
%
% See also MCAMON, MCACACHE, MCAGET, MCACLEARMON
disp('not supported in mocha');
%[handles, count] = mca(510);
%if nargin == 0
% varargout{1} = handles;
% varargout{2} = count;
%elseif nargin > 0 && isnumeric(varargin{1})
% for i=1:length(varargin{1})
% ind(i)=find(handles==varargin{1}(i));
% end
% varargout{1} = count(ind);
%end

View File

@@ -0,0 +1,64 @@
function varargout = mcamontimer(varargin)
%MCAMONTIMER - Controls the initialisation and termination of the MATLAB
% timer used to poll the MCA monitor command queue.
%
% Started = mcamontimer - returns 1 if monitor polling has been started
% returns 0 if monitor polling has not been started
%
% mcamontimer('start') - starts the timer polling every 0.1 seconds
% mcamontimer('stop') - stops the timer
%
% Notes:
% (1) If monitors are installed using mcamon but mcaTimer has not been
% started, the monitor events will queue up indefinitely. There is
% no limit to the size of the queue, so eventually you will
% run out of memory and crash.
% (2) A polling period of 0.1 seconds is used. This may be varied if
% desired by modifying the 'Period' argument in the definition of
% mcaTimer.
% (3) Call mcamontimer('start') once.
%
% See also MCAMON, MCAMONEVENTS, MCACACHE, MCACLEARMON
%
persistent mcaTimer TimerStarted;
%mocha('test')
if (nargin == 0)
if (TimerStarted)
varargout{1} = 1;
else
varargout{1} = 0;
end
elseif (nargin == 1)
switch varargin{1}
case 'start'
if (TimerStarted)
error('MCA monitor polling is already started.');
end
mlock;
%mcaTimer = timer('TimerFcn', 'mca(600)', 'Period', 0.1, 'ExecutionMode', 'fixedSpacing');
mcaTimer = timer('TimerFcn', 'mocha(402)', 'Period', 10.1, 'ExecutionMode', 'fixedSpacing');
%%mcaTimer.TimerFcn= {@mocha, 'monitorflushevent'};
start (mcaTimer);
TimerStarted = 1;
case 'stop'
if (TimerStarted)
munlock;
stop (mcaTimer);
clear mcaTimer;
TimerStarted = 0;
else
error('MCA monitor polling has not been started.');
end
otherwise
error('Invalid parameter specified for mcamontimer. Use ''start'' or ''stop''.')
end
else
error('Invalid number of arguments in mcamontimer.')
end

View File

@@ -0,0 +1,61 @@
function varargout = mcaopen(varargin);
%MCAOPEN - open a Channel Access connection to an EPICS Process Variable
%
% H = MCAOPEN(PVNAME);
% If successful H is a unique nonzero integer handle associated with this PV.
% Returned handle is 0 if a connection could not be established
%
% [H1, ... ,Hn] = MCAOPEN(PVNAME1, ... ,PVNAMEn);
% Is equivalent to but more efficient than multiple single-argument calls
% H1 = MCAOPEN(PVNAME1);
% ...
% Hn = MCAOPEN(PVNAMEn);
%
% HANDLES = MCAOPEN(NAMES) is convenient when working with long lists of PV names
% HANDLES is a numeric array of assigned handles
% NAMES is a cell array of strings with PV names
%
% [HANDLES, NAMES] = MCAOPEN with no arguments returns a list of PV Names for all open connections.
% HANDLES is a numeric array of handles
% NAMES is a cell array of strings with PV names
%
% Note:
% When done, one should probably use MCACLOSE on the handle.
% When you use the same channel again "later", you might keep it open.
% See MCACHECKOPEN for a lazy person's bookkeeping helper.
%
% See also: MCACHECKOPEN, MCAISOPEN, MCACLOSE
if nargin>1 && nargin ~= nargout
error('Number of outputs must match the number of inputs')
end
if nargin==0
[varargout{1} varargout{2}] = mocha('getHandles'); %mca(3);
elseif iscellstr(varargin) && nargin ==1
varargout{1} = mocha('open', varargin{1} );
elseif iscellstr(varargin{1}) && nargin==1
if length(varargin{1}) > 1
mocha ('openPrepare');
varargout{1} = mocha('open', varargin{1} );
mocha ('openNow')
else
varargout{1} = mocha('open', varargin{1} ); % mca(2,varargin{1});
end
elseif iscellstr(varargin)
mocha('openPrepare');
%[varargout{1:nargin}] =
h1=mocha('openArray',{varargin{:}}) %mca(1,varargin{:});
for i = 1:length(h1)
[varargout{i}] = h1(i);
end
mocha('openNow');
else
error('All arguments must be strings')
end

View File

@@ -0,0 +1,4 @@
function mcapoll()
%MCAPOLL - poll channel access...
%mca(30)
mocha('capoll')

View File

@@ -0,0 +1,35 @@
function varargout = mcaprec(varargin)
%MCAPREC - read precision from PV's
%
% VALUES = MCAPREC(HANDLE) returns the precision field of a channel as a double
%
% The function does not handle arrays of PV handles, but only a single PV at at time.
%
%
% Error handling:
% An empty cell string array will be returned if the PV type is not ENUM.
% A matlab exception will be thrown when the PV handle is invalid,
% i.e. not the result of a successful MCAOPEN.
% Furthermore, an error can result from a 'get' timeout,
% configurable via MCATIMEOUT.
% In addition, an error can result from a network disconnect.
% In principle, one can check beforehand via MCASTATE, but since
% a disconnect might happen just between the successful MCASTATE call
% and the following MCAGET, the only safe thing might be to surround
% MCAGET calls with TRY....CATCH.
%
% See also TRY, CATCH, MCASTATE, MCATIMEOUT, MCAPUT
if nargin<1
error('No arguments were specified in mcaget')
elseif nargin==1
if length(varargin{1})>1
error('Only single PV can be handled at a time')
else
%varargout{1} = mca(42,varargin{1});
pvCtrl = mocha('getCtrl', varargin{1});
varargout{1} =pvCtrl.precision();
end
elseif nargin>1
error('Only single PV can be handled at a time')
end

109
RHEL8-x86_64/2022b/mcaput.m Normal file
View File

@@ -0,0 +1,109 @@
function sts = mcaput(varargin)
%MCAPUT - Write values to EPICS Process Variables
%
% MCAPUT(HANDLE1, VALUE1) - one handle, one value
% MCAPUT(HANDLE1, VALUE1, ... , HANDLE_N, VALUE_N) - handles and values in pairs
%
% EPICS STRING values are passed as MATLAB strings. For example:
% >> mcaput(H, 'MATLAB')
% >> mcaput(H1, 'MATLAB', H2, 'EPICS')
% or cell arrays of strings.
%
% MCAPUT(HANDLES_CELL_ARRAY, VALUES_CELL_ARRAY) - arguments are grouped
% in cell array of integer handles and a cell array of values
% of equal length.
%
% Returns an array of status values: 1 success, 0 failure, -1 timeout
%
% MCAPUT is implemented as a call to the ca_put_array_callback
% function in CA client library.
% MCAPUT returns 1 or 0 if we get an OK respectively error status within
% the timeout, or -1 if we don't get any response within the timeout.
%
% Note:
% The special case of MCAPUT([PV, PV, ...], [SCALAR, SCALAR, ...])
% will simply write the scalar values to the PVs without waiting for the
% callback.
%
% See also MCAGET, MCATIMEOUT.
if nargin==2
if iscell(varargin{1}) && iscell(varargin{2})
% {pv, pv, pv, ...}, {value, value, value, ...}
if length(varargin{1}) ~= length(varargin{2})
error('Cell array of MCA handles and cell array of values must be the same length')
end
HANDLES = varargin{1}; VALUES = varargin{2};
ARGS = reshape([HANDLES(:)';VALUES(:)'],1,2*length(varargin{1}));
%sts = mca(70,ARGS{:});
mocha('setputwait',HANDLES);
[gsts,sts]=mocha('setScalarArray', HANDLES, VALUES);
elseif isnumeric(varargin{1})
if length(varargin{1})>1
if length(varargin{1}) ~= length(varargin{2})
error('Array of handles and array of values must be the same length');
end
% [pv, pv, pv, ...], [value, value, value, ...]
%sts = mca(80,varargin{1},varargin{2});
mocha('setputwait', varargin{1});
[gsts,sts]=mocha('setScalarArray', varargin{1},varargin{2});
else
ARGS = varargin;
% (pv, value)
if (isnumeric(ARGS{2}(1)))
%if (isnumeric(ARGS(2)))
%sts = mca(70,ARGS{:});
mocha('setputwait',ARGS{1});
sts = mocha('set',ARGS(1), ARGS(2));
else
chInfo=mocha('getInfo', varargin{1});
if(strcmp(chInfo.dataType,'DBR_ENUM')&&~isnumeric(varargin{2}))
%if(strcmp(mca(43,varargin{1}),'ENUM')&&~isnumeric(varargin{2}))
pvCtrl=mocha('getCtrlCache', varargin{1});
enumvalues= pvCtrl.enumStrings; %mca(40,varargin{1});
%enumvalues=mca(40,varargin{1});
found = 0;
for ind = 1:numel(enumvalues)
if(strcmp(ARGS(2),enumvalues(ind)))
valueToPut=ind-1;
found=1;
end
end
if(found)
ARGS{2}=valueToPut;
mocha('setputwait',ARGS(1));
sts = mocha('set',ARGS(1), ARGS(2)); % mca(70,ARGS{:});
else
strings = sprintf(' "%s" ',enumvalues{:});
error('mcaput:enumCheck','Invalid value for this channel. Try one of: [%s]',strings);
end
else
%sts = mca(70,ARGS{:});
mocha('setputwait',ARGS(1));
sts = mocha('set',ARGS(1), ARGS(2));
end
end
end
else
error('Invalid mcaput args, need PV, VALUE');
end
elseif mod(nargin,2) == 0
% 'pv, value, pv, value, ...'
%sts = mca(70,varargin{:});
j=uint16(0);
for i=1:2:nargin
j=j+1;
handles(j)=varargin{i};
values{j}=varargin{i+1};
end
mocha('setputnowait',handles);
[gsts,sts]=mocha('setMany', handles, values{1:j});
else
error('Incorrect number of inputs, need a sequence of PV, VALUE')
end

View File

@@ -0,0 +1,118 @@
function sts = mcaputnowait(varargin)
%MCAPUT - Write values to EPICS Process Variables
%
% MCAPUT(HANDLE1, VALUE1) - one handle, one value
% MCAPUT(HANDLE1, VALUE1, ... , HANDLE_N, VALUE_N) - handles and values in pairs
%
% EPICS STRING values are passed as MATLAB strings. For example:
% >> mcaput(H, 'MATLAB')
% >> mcaput(H1, 'MATLAB', H2, 'EPICS')
% or cell arrays of strings.
%
% MCAPUT(HANDLES_CELL_ARRAY, VALUES_CELL_ARRAY) - arguments are grouped
% in cell array of integer handles and a cell array of values
% of equal length.
%
% Returns an array of status values: 1 success, 0 failure, -1 timeout
%
% MCAPUT is implemented as a call to the ca_put_array_callback
% function in CA client library.
% MCAPUT returns 1 or 0 if we get an OK respectively error status within
% the timeout, or -1 if we don't get any response within the timeout.
%
% Note:
% The special case of MCAPUT([PV, PV, ...], [SCALAR, SCALAR, ...])
% will simply write the scalar values to the PVs without waiting for the
% callback.
%
% See also MCAGET, MCATIMEOUT.
if nargin==2
if iscell(varargin{1}) && iscell(varargin{2})
% {pv, pv, pv, ...}, {value, value, value, ...}
if length(varargin{1}) ~= length(varargin{2})
error('Cell array of MCA handles and cell array of values must be the same length')
end
HANDLES = cell2mat(varargin{1}); VALUES = cell2mat(varargin{2});
disp('first call to mca 80')
%sts = mca(80,HANDLES,VALUES);
mocha('setputnowait',HANDLES);
[gsts,sts]=mocha('setScalarArray', HANDLES, VALUES);
elseif isnumeric(varargin{1})
if length(varargin{1})>1
if length(varargin{1}) ~= length(varargin{2})
error('Array of handles and array of values must be the same length');
end
% [pv, pv, pv, ...], [value, value, value, ...]
disp('call mca 80')
%sts = mca(80,varargin{1},varargin{2});
mocha('setputnowait', varargin{1});
[gsts,sts]=mocha('setScalarArray', varargin{1},varargin{2});
else
ARGS = varargin;
%a=ARGS{1};
%b=ARGS{2};
% (pv, value)
if (isnumeric(ARGS{2}(1))) %(ARGS(2)))
%sts = mca(80,ARGS{:});
mocha('setputnowait',ARGS{1});
sts = mocha('set',ARGS(1), ARGS(2));
else
chInfo=mocha('getInfo', varargin{1});
%if(strcmp(mca(43,varargin{1}),'ENUM')&&~isnumeric(varargin{2}))
if(strcmp(chInfo.dataType,'DBR_ENUM')&&~isnumeric(varargin{2}))
pvCtrl=mocha('getCtrlCache', varargin{1});
enumvalues= pvCtrl.enumStrings; %mca(40,varargin{1});
found = 0;
for ind = 1:numel(enumvalues)
if(strcmp(ARGS(2),enumvalues(ind)))
valueToPut=ind-1;
found=1;
end
end
if(found)
ARGS{2}=valueToPut;
mocha('setputnowait',ARGS(1));
sts = mocha('set',ARGS(1), ARGS(2)); % mca(70,ARGS{:});
else
strings = sprintf(' "%s" ',enumvalues{:});
error('mcaput:enumCheck','Invalid value for this channel. Try one of: [%s]',strings);
end
else
mocha('setputnowait',ARGS(1));
sts = mocha('set',ARGS(1), ARGS(2)); %mca(80,ARGS{:});
end
end
end
else
error('Invalid mcaput args, need PV, VALUE');
end
elseif mod(nargin,2) == 0
% 'pv, value, pv, value, ...'
% sts = mca(80,handles,values);
%for i=1:nargin
%params(i)=varargin{i};
%end
%nargin;
%data=reshape(params,2,nargin/2);
%handles=data(1,:);
%values=data(2,:);
j=uint16(0);
for i=1:2:nargin
j=j+1;
handles(j)=varargin{i};
values{j}=varargin{i+1};
end
disp(handles)
disp(values)
mocha('setputnowait',handles);
[gsts,sts]=mocha('setMany', handles, values{1:j});
%disp('pv,val,pv,val')
else
error('Incorrect number of inputs, need a sequence of PV, VALUE')
end

View File

@@ -0,0 +1,46 @@
function varargout = mcastate(varargin);
%MCASTATE - returns an array of connection states for open channels
% MCASTATE is used as diagnostics prior to issuing other
% MCA commands such as MCAGET, MCAPUT and MCAMON
%
% STATES = MCASTATE(H1,H2,...,HN) returns the states of
% the specified channels previously opened with MCAOPEN.
% STATES = an array of the states of the channels listed in the HANDLES
% array
%
% [HANDLES, STATES] = MCASTATE is an array of states of all
% currently open channels.
% HANDLES = an array of all the currently open channels
% STATES = an array of the states of the channels listed in the HANDLES
% array
%
% Possible values
% 1 - Connected: MCAGET, MCAPUT and MCAMON are valid
% 0 - Disconnected: MCAGET, MCAPUT and MCAMON will return invalid
% data or fail. This may be due to a server/network problem
%
% See also MCAINFO, MCAOPEN, MCACLOSE.
%if nargin > 0
% varargout{1} = mca(13,varargin{:});
%else
% [varargout{1}, varargout{2}] = mca(12);
%end
if nargin > 0
%varargout{1} = mca(13,varargin{:});
for k = 1:nargin
if mocha('isConnected', varargin{k}) == true
isConnected(k) = uint16(1);
else
isConnected(k) = uint16(0);
end
end
varargout{1} = isConnected;
else
[h,pv,state] = mocha('getHandleStates');
%[varargout{1}, varargout{2}] = mca(12);
varargout{1} = h;
varargout{2} = state;
end

View File

@@ -0,0 +1,44 @@
function varargout = mcatime(varargin)
%MCATIME - read timestamps for PVs previously read with MCAGET or MCAMON
%
% The timestamp is returned as a MATLAB serial date number suitable
% for use in the DATESTR function.
%
% The original time stamp is in the UTC timezone,
% but since Matlab doesn't handle timezones in datenum/datastr,
% it's converted to the 'local' timezone, so that
% datestr(mcatime(pv))
% should give a time that is close to the wall clock
% for channels that changed recently.
%
% VALUE = MCATIME(HANDLE)
% returns the timestamp of a PV specified by integer HANDLE.
%
% [VALUE1, ... VALUEN] = MCATIME(HANDLE1, ... , HANDLEN)
% returns timestamps of multiple PVs of any type and length
% Number of outputs must match the number of inputs
%
% See also MCAGET, MCAMON.
%
for i=1:nargin
% We get y/m/d H:M:S plus nanosecs...
%pieces = mca(60,varargin{i});
% but datenum doesn't handle nanosecs
%varargout{i} = datenum(pieces(1:6));
timestamp=mocha('getTimeStamp',varargin{i});
timestamp=double(timestamp);
timestamp(6)=timestamp(6)+timestamp(7)/double(1000000000);
%value.time(1)=double(timestamp(1));
%value.time(2)=(timestamp(2));
%value.time(3)=(timestamp(3));
%value.time(4)=(timestamp(4));
%value.time(5)=(timestamp(5));
%varargout{i}(1:5)=value.time(1:5);=
%varargout{i}(6)=double(timestamp6);
varargout{i}=timestamp(1:6);
%format longG;
end

View File

@@ -0,0 +1,64 @@
function varargout = mcatimeout(varargin)
%MCATIMEOUT - set or display MCA timeout setings
%
% MCATIMEOUT('open', t1)
% 'open' option sets the internal variable MCA_SEARCH_TIMEOUT to t1 (sec)
%
% MCATIMEOUT('get', t1)
% 'get' option sets the internal variable MCA_GET_TIMEOUT to t1 (sec)
%
% MCATIMEOUT('put', t1)
% 'put' option sets the internal variable MCA_PUT_TIMEOUT to t1 (sec)
%
% MCATIMEOUT('default') sets the default values
% MCA_SEARCH_TIMEOUT = 1.0 (sec)
% MCA_GET_TIMEOUT = 5.0 (sec)
% MCA_PUT_TIMEOUT = 0.01 (sec)
%
% TIMEOUTS = MCATIMEOUT with no arguments returns a vector of currently set timeouts
% in the format [MCA_SEARCH_TIMEOUT MCA_GET_TIMEOUT MCA_PUT_TIMEOUT]
%
% Notes:
% See also: MCA.cpp
%
switch nargin
case 0
a=mocha('getTimeout');
%a(1) Put %a(2)Get
b=mocha('getOpenWaitTime');
AB=[b(1); a(2); a(1)]; %search, get, put
varargout{1} = AB(1:3); %mca(1000);
case 1
if strcmp(varargin{1}, 'default')
a=mocha('setTimeOutDefault');
b=mocha('openWaitWithTimeDefault');
AB=[b(1); a(2); a(1)]; %search, get, put
varargout{1} = AB(1:3); %mca(1004);
else
error ('Invalid command option.')
end
case 2
if strcmp(varargin{1}, 'open')
if ~isnumeric(varargin{2}) || varargin{2} <= 0
error('Second argument must be numeric, positive seconds');
end
mocha('openWaitWithTime',varargin{2});
%mca(1001,varargin{2});
elseif strcmp(varargin{1}, 'get')
if ~isnumeric(varargin{2}) || varargin{2} <= 0
error('Second argument must be numeric, positive seconds');
end
mocha('setTimeoutGet',varargin{2});
%mca(1002,varargin{2});
elseif strcmp(varargin{1}, 'put')
if ~isnumeric(varargin{2}) || varargin{2} <= 0
error('Second argument must be numeric, positive seconds');
end
mocha('setTimeoutPut',varargin{2});
%mca(1003,varargin{2});
else
error('Invalid command option.')
end
otherwise
error ('Invalid number of arguments.')
end

View File

@@ -0,0 +1,11 @@
function mcaunlock;
%MCAUNLOCK - unlocks the MCAMAIN mex-file
% .. so that it can be cleared from memory with CLEAR
%
% MCAMAIN starts in a locked state
% to protect from it from being
% accidentally cleared and
% loosing channel access connections.
%mca(0);
mocha('mexUnlock');
%disp('mca mex-file is now UNLOCKED');

View File

@@ -0,0 +1,8 @@
function ver = mcaversion()
%MCAVERSION - get version info
% ver = mcaversion()
%
% returns the mca version as a string
%ver = mca(-1);
ver = mocha('version');

BIN
RHEL8-x86_64/2022b/mocha.mexa64 Executable file

Binary file not shown.

View File

@@ -0,0 +1,16 @@
function varargout = monActionLocal(varargin)
disp('monitorAction called for:');
pvName=mocha('getPVFromHandle', varargin{1});
disp(pvName);
X=['Handle =', num2str(varargin{1})];
disp(X);
%[varargout{1} varargout{2}] = mocha ('getCache', varargin{1});
[var1,var2]=mocha ('getCache', varargin{1});
[s,t]=mocha('getStatus', varargin{1});
%X=['Value=', num2str(varargout{1}), ' Status=', num2str(s), ' [',t(1), ' ', t(2),']'];
X=['Value =', num2str(var1)];
Y=['Status=', num2str(s)];
disp(X)
disp(Y)
disp([t(1),t(2)])

48
RHEL8-x86_64/2022b/pvtable.m Executable file
View File

@@ -0,0 +1,48 @@
function pvt = pvtable()
%
% pvt=pvtable()
% returns a table displaying all pvs and their status
%
[hpv,pvn,state] = mocha('getHandleStates');
pvt=[];
if (isempty(hpv))
disp('THERE ARE NO CHANNELS!');
return;
end
%If monitor then uses cache value
mocha('getAsyn', hpv);
mocha('sendNow'); %otherwise getPVCache will do the send!
dstruct = mocha('getPVCache', hpv);
%If NaN then following warning given from struct2table:
%Warning: Out of range or non-integer values truncated during
%conversion to character
%
t=struct2table(dstruct);
for n=1:length(hpv)
s1(n).handle=hpv(n);
s1(n).pv=pvn(n);
s1(n).cs=state(n);
s1(n).nmon=mocha('getNoMonitors', hpv(n));
end
t1=struct2table(s1);
if (string(class(t.val)) == string('char'))
t.val=string(t.val);
end
pvt=table(t1.handle,t1.pv, t.val, t.status, t1.cs, t1.nmon);
pvt.Properties.VariableNames={'h','pv', 'val', 'stat','c', 'm'};
%tNew.Properties.VariableNames{'Var1'}= 'handle';
%tNew.Properties.VariableNames{'Var2'}= 'pv';
%tNew.Properties.VariableNames{'Var3'}= 'val';
%2017a
%setColHeading(tNew, 1, 'handle');
%setColHeading(tNew, 2, 'pv');
%setColHeading(tNew, 3, 'val');

View File

@@ -0,0 +1,18 @@
<!--A simple, minimalistic TEST XML file-->
<cafe:config>
<cafe:group id="gTest">
<cafe:member> <cafe:name> ARIDI-BPM-01LE:X-AVG </cafe:name> </cafe:member>
<!--
<cafe:member> <cafe:name> ARIDI-BPM-01LB:X-AVG </cafe:name> </cafe:member>
<cafe:member> <cafe:name> ARIDI-BPM-01SE:X-AVG </cafe:name> </cafe:member>
<cafe:member> <cafe:name> ARIDI-BPM-01SB:X-AVG </cafe:name> </cafe:member>
-->
<cafe:member> <cafe:name> ARIDI-BPM-01LE:Y-AVG </cafe:name> </cafe:member>
<!--
<cafe:member> <cafe:name> ARIDI-BPM-01LB:X-AVG </cafe:name> </cafe:member>
<cafe:member> <cafe:name> ARIDI-BPM-01SE:X-AVG </cafe:name> </cafe:member>
<cafe:member> <cafe:name> ARIDI-BPM-01SB:X-AVG </cafe:name> </cafe:member>
-->
</cafe:group>
</cafe:config>

Binary file not shown.

BIN
RHEL8-x86_64/2023a/mocha.mexa64 Executable file

Binary file not shown.

53
bug2020b.txt Normal file
View File

@@ -0,0 +1,53 @@
Dear Jan,
Thank you for the feedback and your suggestion to use LD_PRELOAD to load the library before we then actually LD_PRELOAD the partial glibc 2.18 implementation. Then your library should still be able to load with pure glibc 2.17 as available on your system, in which this glibc bug does not exist. I had not thought of this. I have now added this approach to our knowledge base.
Thanks again and best regards,
Martijn
--------------- Original Message ---------------
From: Martijn Aben [support@mathworks.nl]
Sent: 6/3/2021 11:56 AM
To: jan.chrin@psi.ch
Subject: Re: mex file hangs in 2020b on Linux [ ref:_00Di0Ha1u._5003q1PWEEz:ref ]
Dear Jan Chrin,
I am writing in reference to your Technical Support Case 04900956 regarding 'mex file hangs in 2020b on Linux'.
I suspect that what is going on here is that this third-party library is using pthread_join() when loaded (i.e. it might call it its entry point or the constructor of a static class instance). Using pthread_join() at library load, will lead to deadlocks in glibc versions 2.18 2.22:
https://bugzilla.redhat.com/show_bug.cgi?id=1223055
Now it looks like you are on a Red Hat 7 (based) system. RHEL 7 by default includes glibc 2.17 and so in general, outside MATLAB, you would not run into this issue with that third-party library which you work with. As a matter of fact, even inside MATLAB you will not run into any issues related to this as long as you work with a MATLAB release before R2020b; those releases will simply work with your system's glibc 2.17.
Starting with MATLAB R2020b however, MATLAB is no longer compatible with glibc 2.17, we now require 2.18 at a minimum. To still allow MATLAB to run on RHEL 7 systems, which we did still want to support, we therefore have included a partial glibc 2.18 implementation with MATLAB R20208b which is loaded on top of the glibc 2.17 of your system (if needed, if you are on a system with newer glibc we will simply only use the newer system glibc). This glibc 2.18 implementation which we add, then also actually introduces that glibc 2.18 bug.
There is no direct/straightforward solution or workaround for this issue, you have to either:
1. Avoid the usage of pthread_join() during library load. Perhaps move the initialization code which normally occurs statically/automatically at library load to a function which can/must be be called after the library has loaded. You may be able to make this change by yourself or you might need to work with the developer of the third-party library to see whether they can/are willing to make this change. The issue is not necessarily MATLAB specific; it could occur with any application trying to work with their library on a Linux distribution with glibc versions 2.18 2.22, so it could really be worth making that change. Or,
2. Work with MATLAB releases prior to R2020b, or
3. Since upgrading glibc in an existing Linux distribution is not really an option, switch to version 8 of your Red Hat (based) Linux distribution, which includes glibc 2.28 which we can work with directly and which should not suffer from that glibc bug which exists in versions 2.18 2.22. Or switch to an entirely different Linux distribution/version altogether which includes glibc > 2.22.
Please preserve the Reference ID in further correspondence on this query. This allows our systems to automatically associate your reply to the appropriate Case.
If you have a new technical support question, please submit a new request here:
http://www.mathworks.com/support/servicerequests/create.html
Sincerely,
Martijn Aben
MathWorks Technical Support Department
Self-Service: http://www.mathworks.com/support
File Exchange and MATLAB Answers: http://www.mathworks.com/matlabcentral/
The MathWorks BV
Dr. Holtroplaan 5B
5652 XR Eindhoven
The Netherlands
Chamber of Commerce Eindhoven: 29046452

268
cafe-matlab.sh Executable file
View File

@@ -0,0 +1,268 @@
#! /bin/bash
# User to set the default MATLAB version here
# This default is ONLY activated
# (1) in the absence of the relevant input argument, and
# (2) if matlab is not already pre-loaded on your system
MATLAB_DEFAULT=2017b
# cafe-matlab.sh script to enable use of the mocha mex-file
# The script executes the command: module load cafe-matlab/<matlab-version>
# which will pre-pend the $MATLABPATH environment variable with the location
# of the matching mocha mex-file
# Jan Chrin, 5 April 2017
#
# Usage: cafe-matlab.sh -v <matlab version> -d <default matlab version> -s <true/false>
# where the input key value pairs are **optional**
# Examples of usage:
# (1) Use mocha with MATLAB version 2017b but do not start matlab [-s false is default]
# cafe-matlab.sh -v 2017b
# (2) Use mocha with MATLAB version 2017b and start matlab
# cafe-matlab.sh -v 2017b -s true
# (3) Use mocha with MATLAB version given by MATLAB_DEFAULT in script
# cafe-matlab.sh -v default -s true
# cafe-matlab.sh --usedefault [equivalent -v default -s true]
# (4) Use mocha with preloaded matlab (else if none, then that given by -d option else MATLAB_DEFAULT )
# cafe-matlab.sh -d 2017b
# cafe-matlab.sh --preloaded [equivalent to -v preloaded -s true]
# If no instruction to the matlab version is given by the user then the procedure is:
# (1) If MATLAB is already loaded ($MATLAB has automatically been set),
# then the location of the corresponding mex-file will be pre-pended to $MATLABPATH
# (2) if MATLAB is **not** already loaded, then the script will use a default MATLAB
# version, as given by the -d option else that given by $MATLAB_DEFAULT in the above.
# and the location of the corresponding mex-file will be pre-pended to $MATLABPATH
PRINT_INFO=false
# Reset (required)
MATLAB_START=false
MATLAB_REQUESTED=
MATLAB_V=$MATLAB_VERSION
#For MATLAB version 2015a and earlier
if [ ! $MATLAB_VERSION ]
then
if [ ${MATLAB} ]
then
MATLAB_EXT=${MATLAB##*/}
#use IFS to split string into arrays with . being the delimeter
IFS='.' read -ra NAMES <<< $MATLAB_EXT
MATLAB_V=${NAMES[0]}
#echo $MATLAB_EXT
fi
fi
# Loop round input arguments
while [[ $# -gt 0 ]]
do
key="$1"
case $key in
-v|-V|--version|--Version)
c=$2
MATLAB_REQUESTED=${c##*/}
if [ $PRINT_INFO = true ]
then
echo MATLAB VERSION REQUESTED = "${MATLAB_REQUESTED}"
fi
shift
;;
-s|-S|--start|--Start)
MATLAB_START="$2"
if [ $PRINT_INFO = true ]
then
echo MATLAB START = "${MATLAB_START}"
fi
shift
;;
-d|-D|--default|--Default)
MATLAB_DEFAULT="$2"
if [ $PRINT_INFO = true ]
then
echo MATLAB DEFAULT = "${MATLAB_DEFAULT}"
fi
shift
;;
--preloaded)
MATLAB_REQUESTED="preloaded"
MATLAB_START=false
if [ $PRINT_INFO = true ]
then
echo MATLAB VERSION REQUESTED = "${MATLAB_REQUESTED}"
echo MATLAB START = "${MATLAB_START}"
fi
;;
--usedefault)
MATLAB_REQUESTED="default"
MATLAB_START=false
if [ $PRINT_INFO = true ]
then
echo MATLAB VERSION REQUESTED = "${MATLAB_REQUESTED}"
echo MATLAB START = "${MATLAB_START}"
fi
;;
-h|-H|--help|--Help)
echo '*********************************************************'
echo Usage: cafe-matlab.sh
echo '-v <matlabVersion> If omitted, uses pre-loaded matlab version, else default version'
echo '-d <matlabVersion> Override default version to be used if matlab module not already loaded'
echo '-s <true/false> Whether or not to start matlab; default is false.'
echo ' Option is valid for matlab versions 2020a and earlier '
echo '--show Shows matlab version currently loaded and the script default version'
echo '*********************************************************'
echo 'e.g. cafe-matlab.sh -v 2019a -s false % use matlab/2019a'
echo 'e.g. cafe-matlab.sh -d 2019a -s false % Use pre-loaded matlab module else matlab/2019a'
echo 'e.g. cafe-matlab.sh % Use pre-loaded matlab module, else that given in script'
return 2> /dev/null || exit
;;
--show)
echo '*********************************************************'
if [ $MATLAB_V ]
then
echo MATLAB VERSION CURRENTLY LOADED IS ${MATLAB_V}
else
echo 'MATLAB MODULE NOT CURRENTLY LOADED'
fi
echo THE SCRIPT DEFAULT IS $MATLAB_DEFAULT BUT WILL ONLY BE ACTIVATED IF MATLAB
echo 'IS NOT ALREADY LOADED OR OTHERWISE SPECIFIED BY THE -v OPTION'
echo '$MATLAB_DEFAULT CAN BE OVERRIDDEN USING THE -d OPTION'
echo '*********************************************************'
return 2> /dev/null || exit
;;
*)
echo Unknown input key: "$key"
echo Usage: 'cafe-matlab -v <matlab version> -s <true/false>'
echo where '-s true' will start matlab - default is false
echo Executing script with default options
# unknown option
;;
esac
shift #
done
if [ $MATLAB_REQUESTED ]
then
if [ $MATLAB_REQUESTED == 'default' ]
then
MATLAB_REQUESTED=$MATLAB_DEFAULT
fi
if [ $MATLAB_REQUESTED == 'preloaded' ]
then
MATLAB_REQUESTED= #leave empty
fi
fi
#echo $MATLAB_V
#echo $MATLAB_REQUESTED
#echo $MATLAB_DEFAULT
module use Cafe
#if -v is given then load MATLAB_REQUESTED
#if -v not given or if -v preloaded, then load MATLAB_V
#else load MATLAB_DEFAULT
if [ $MATLAB_REQUESTED ]
then
if test -f "/opt/psi/Cafe/modulefiles/cafe-matlab/${MATLAB_REQUESTED}"
then
#unload removes $MATLAB_VERSION
module unload matlab
module unload cafe-matlab
module load cafe-matlab/${MATLAB_REQUESTED}
if [ $PRINT_INFO = true ]
then
echo "Using requested version: matlab/$MATLAB_REQUESTED"
fi
else
echo "Unknown requested version: matlab/$MATLAB_REQUESTED"
echo "'module avail cafe-matlab' gives the possibilities:"
module avail cafe-matlab
MATLAB_START=false
fi
elif [ $MATLAB_V ]
then
if test -f "/opt/psi/Cafe/modulefiles/cafe-matlab/${MATLAB_V}"
then
#unload removes $MATLAB_VERSION
module unload matlab
module unload cafe-matlab
module load cafe-matlab/${MATLAB_V}
if [ $PRINT_INFO = true ]
then
echo "Using matlab/$MATLAB_V"
fi
else
module unload matlab
module unload cafe-matlab
module load cafe-matlab/$MATLAB_DEFAULT
if [ $PRINT_INFO = true ]
then
echo "Using matlab/$MATLAB_DEFAULT"
fi
fi
else
if test -f "/opt/psi/Cafe/modulefiles/cafe-matlab/${MATLAB_DEFAULT}"
then
module unload matlab
module unload cafe-matlab
module load cafe-matlab/$MATLAB_DEFAULT
if [ $PRINT_INFO = true ]
then
echo "Using matlab/$MATLAB_DEFAULT"
fi
else
echo "The default requested version: matlab/$MATLAB_DEFAULT within cafe-matlab.sh is invalid!"
echo "'module avail cafe-matlab' gives the possibilities:"
module avail cafe-matlab
fi
fi
#safe versions
mvarray=("2015a" "2016a" "2016b" "2017a" "2017b" "2018a" "2019a" "2019b" "2020a")
if [[ ! " ${mvarray[*]} " =~ " ${MATLAB_REQUESTED} " ]]; then
#echo "Version is not in array"
#ld-preload for 2020b onwards on redhat7
if [[ -z "${LD_PRELOAD}" ]]; then
export LD_PRELOAD=$EPICS/base-7.0.6/lib/$EPICS_HOST_ARCH/libCom.so
else
LD_PRELOAD_TEMP=$LD_PRELOAD
export LD_PRELOAD=$EPICS/base-7.0.6/lib/$EPICS_HOST_ARCH/libCom.so:$LD_PRELOAD
fi
MATLAB_START=true
fi
if [ $MATLAB_START = true ]
then
matlab &
fi
## Or manually acticate cafe-matlab:
## module unload matlab
## module unload cafe-matlab
## module load cafe-matlab/2016b
## or module switch cafe-matlab/2016b cafe-matlab/2015a
if [[ ! " ${mvarray[*]} " =~ " ${MATLAB_REQUESTED} " ]]; then
if [[ -z "$LD_PRELOAD_TEMP" ]]; then
unset LD_PRELOAD
else
export LD_PRELOAD=$LD_PRELOAD_TEMP
unset LD_PRELOAD_TEMP
fi
module unload cafe-matlab
module unload matlab
fi

View File

@@ -1 +0,0 @@
exampleNew.m

1068
example.m Normal file

File diff suppressed because it is too large Load Diff

23
linux-x86_64/2024b/cadelmon.m Executable file
View File

@@ -0,0 +1,23 @@
function cadelmon(channel)
% cadelmon('channel')
% Deletes monitor callback on EPICS channel
% translate pv name to handle
if ischar(channel)
pv = mcaisopen(channel);
if pv == 0
return;
end
elseif isnumeric(channel)
pv = channel;
else
error ('first argument must be channel name or handle');
end
% delete monitor
mcaclearmon(pv);
% if no monitor left then stop monitoring
if isempty(mcamon) && mcamontimer
mcamontimer('stop')
end

108
linux-x86_64/2024b/caget.m Executable file
View File

@@ -0,0 +1,108 @@
function value = caget(channel,cached)
% caget('channel') returns current value and additional infos
% of given EPICS channel.
% caget('channel',1) returns last value and additional infos
% of given EPICS channel.
%
% channel can be a channel name or a handle as returned from mcaopen
%
% return value elements:
% val: value (scalar, vector or string)
% sevr: severity as a number
% sevr_str: severity as a string
% stat: status as a number
% stat_str: status as a string
% time: timestamp as a date vector
% units: units string
persistent severity_str
persistent status_str
persistent zerotime
persistent units
if ischar(channel)
pv = mocha('open',channel);
if mocha('isConnected', channel) == false
mocha('openNowAndWait', 1.5)
end
if mocha('isConnected', channel) == false
error('EPICS channel %s not found', channel);
end
elseif isnumeric(channel)
pv = channel;
else
error ('first argument must be channel name or handle');
end
if isvector(pv)
pv=pv(1); % truncate
end
chInfo=mocha ('getChannelInfo',pv);
if nargin > 1 && cached
pvStruct = mocha('getPVCache',pv);
else
pvStruct = mocha('getPV', pv);
end
pvCtrl = mocha('getCtrlCache',pv);
%pvCtrl
% initialize severity and status enums
if isempty(severity_str)
severity_str = {'NO_ALARM';'MINOR';'MAJOR';'INVALID'};
status_str = {'NO_ALARM';'READ';'WRITE';'HIHI';'HIGH';'LOLO';'LOW';'STATE';'COS';'COMM';'TIMEOUT';'HWLIMIT';'CALC';'SCAN';'LINK';'SOFT';'BAD_SUB';'UDF';'DISABLE';'SIMM';'READ_ACCESS';'WRITE_ACCESS'};
end
value.val = pvStruct.val;
units = pvCtrl.units;
if (pvCtrl.noEnumStrings>0)
value.val_str = value.val;
value.val = mocha('getCache',pv,'int8');
end
value.units=units;
value.sevr = pvStruct.alarmSeverity;
indx=max(pvStruct.alarmSeverity, 0);
value.sevr_str = severity_str{indx+1};
value.stat = pvStruct.alarmStatus;
indx=max(pvStruct.alarmStatus, 0);
value.stat_str = status_str{ indx+1};
timestamp = mocha('getTimestamp',pv);
if (numel(timestamp) == 2)
% old mca version
% do not use mcatime here because 1. it is slow, 2. is returns UTC
% calculating zerotime only once is faster and takes localtime into account
% When daylight saving time begins or ends, restart the program!
if isempty(zerotime)
[status,timezone]=system('date +%z'); % get localtime offset
timeoffs=str2double(timezone);
houroffs=floor(timeoffs/100);
minoffs=(timeoffs-100*houroffs);
zerotime = datenum('1-Jan-1990') + (minoffs/60 + houroffs)/24;
end
time=timestamp(1)+timestamp(2)/1000000000;
if time
time = zerotime+time/24/3600;
end
value.time = datevec(time);
else
% new mca version
timestamp(6)=timestamp(6)+timestamp(7)/1000000000;
value.time = timestamp(1:6);
end

34
linux-x86_64/2024b/cainfo.m Executable file
View File

@@ -0,0 +1,34 @@
function value = cainfo(pvname)
% cainfo('pvname') returns handle,element count, native type, state, ...
%
mcaNoConnection ={'unknown', 'disconnected','Disconnected due to server or network problem'};
mcaConnection ={'known', 'connected','Normal connection'};
mcaClosedConnection={'unknown', 'disconnected','Permanently disconnected (cleared)'};
value=struct('Handle',{}, 'PVName',{}, 'ElementCount',{},'NativeType',{},'State',{},'MCAMessage',{},'Host',{},'Units',{});
chInfo=mocha ('getChannelInfo', pvname);
pvCtrl=mocha ('getCtrlCache', pvname);
value(1).Handle= mocha('getHandleFromPV', pvname);
value(1).PVName= mocha('getPVFromHandle', value(1).Handle);
value(1).ElementCount=chInfo.nelem;
nativeType=strsplit(chInfo.dataType,'_');
value(1).NativeType=nativeType{2};
if (chInfo.connectFlag==1)
value(1).State=mcaConnection{2};
value(1).MCAMessage=mcaConnection{3};
else
value(1).State=mcaNoConnection{2};
value(1).MCAMessage=mcaNoConnection{3};
end
%value(1).MCAMessage=mocha('statusInfo', mocha('getStatus', pvname));
value(1).Host =chInfo.hostName;
value(1).Units=pvCtrl.units;
%value(1)=setfield(value(1),'Units',pvCtrl.units)

62
linux-x86_64/2024b/camon.m Executable file
View File

@@ -0,0 +1,62 @@
function camon(channel,callback,userarg)
% camon('channel', 'callback')
% camon('channel', 'callback', userarg)
% camon('channel', @callback)
% camon('channel', @callback, userarg)
%
% Installs a callback function (given as string or handle)
% on an EPICS channel.
% Whenever the channel updates, the callback is called
% with a structure as defined below and an optional
% numeric, string, or matrix user argument
%
% callback argument structure elements:
% val: value (scalar, vector or string)
% sevr: severity as a number
% sevr_str: severity as a string
% stat: status as a number
% stat_str: status as a string
% time: timestamp as a date vector
%
% A monitor can be deleted with
% cadelmon ('channel')
% initialize monitoring the first time
if ~mcamontimer
mcamontimer('start');
end
% translate channel name to handle
if ischar(channel)
pv = mcacheckopen(channel);
if pv == 0
error('EPICS channel %s not found', channel);
end
elseif isnumeric(channel)
pv = channel;
else
error ('usage: camon(''channel'',@callback,userarg)');
end
% callback can be string or function handle -- we need string
if nargin>1
if isa(callback,'function_handle')
callback = func2str(callback);
elseif ~ischar(callback)
error ('usage: camon(''channel'',@callback,userarg)');
end
end
% install monitor
if nargin==1
mcamon(pv);
return
elseif nargin==2
cb=sprintf('%s(caget(%d,1))',callback,pv);
else
cb=sprintf('%s(caget(%d,1),''%s'')',callback,pv,mat2str(userarg));
end
disp(pv)
disp(cb)
mcamon(pv, cb);

30
linux-x86_64/2024b/caput.m Executable file
View File

@@ -0,0 +1,30 @@
function sts = caput(pvname, value)
% sts=caput('pvname',value) sets the value of EPICS PV 'pvname'.
%
channel=pvname;
if ischar(channel)
pv = mocha('open',channel);
if mocha('isConnected', channel) == false
mocha('openNowAndWait', 1.5)
end
if mocha('isConnected', channel) == false
error('EPICS channel %s not found', channel);
end
elseif isnumeric(channel)
if mocha('isConnected', channel) == false
error('EPICS channel with handle %d not connected', channel);
end
pv = channel;
else
error ('First argument must be channel name or handle');
end
sts= mocha('set', pv, value);

1068
linux-x86_64/2024b/example.m Normal file

File diff suppressed because it is too large Load Diff

Binary file not shown.

View File

@@ -0,0 +1,36 @@
function varargout = mcaalarm(varargin)
%MCAALARM - read alarm status and severity for PVs previously read with MCAGET or MCAMON
%
% VALUE = MCAALARM(HANDLE)
% returns the status and severity of a PV specified by integer HANDLE:
%
% VALUE is a structure:
% 'status' : Status code
% 'severity': Severity code
%
% Refer to the EPICS header file "alarmString.h" for the code definitions.
%
% [VALUE1, ... VALUEN] = MCAALARM(HANDLE1, ... , HANDLEN)
% returns status and severity of multiple PVs of any type and length
% Number of outputs must match the number of inputs
%
% See also MCAGET, MCAMON.
%
if nargin<1
error('No arguments were specified in mcaalarm')
elseif nargin==1
result{1} = mocha('getAlarm',varargin{1}); %mca(61,varargin{1});
varargout{1}.status = result{1}(1,1);
varargout{1}.severity = result{1}(1,2);
elseif nargin>1
if nargin ~= nargout
error('Number of outputs must match the number of inputs')
end
%[result{1:nargin}] = mca(61,varargin{:});
for k = 1:nargin
[result{k}] = mocha('getAlarm',varargin{k});
varargout{k}.status=result{k}(1,1);
varargout{k}.severity=result{k}(1,2);
end
end

View File

@@ -0,0 +1,40 @@
function varargout = mcacache(varargin)
%MCACACHE - reads locally cached value of a PV.
% MCACACHE does NOT communicate with the server or use resources of CA library
%
% VALUE = MCACACHE(HANDLE) returns a value of a PV by integer HANDLE
% The type (EPICS strings are returned as MATLAB strings)
% All numeric EPICS types returned are as MATLAB double
% If a PV is is a waveform VALUE is a vector
%
% [ VALUE1 , ... VALUEN ] = MCACACHE(HANDLE1, ... , HANDLEN)
% returns values of multiple PV's.
% Number of outputs must match the number of inputs
%
% Notes: The cache value for a PV does not exist until the first use of a
% monitor on that PV
% See also: MCAMON
if nargin>1 && nargin~=nargout
error('Number of outputs must match the number of inputs')
end
for k = 1:nargin
[varargout{k}] = mocha('getCache',varargin{k});
end
%for k = 1:nargin
% scalarValues(k) = varargin{k};
%end
%[a,isAllOk,s]=mocha('getScalarArrayCache',scalarValues);
%for k = 1:nargin
% [varargout{k}]= a(k);
%end
%
%[varargout{1:nargin}] = mca(300,varargin{:});

View File

@@ -0,0 +1,20 @@
function varargout = mcacheck(varargin)
%MCACHECK - Same as MCASTATE
% See also MCAOPEN
if nargin > 0
%varargout{1} = mca(13,varargin{:});
for k = 1:nargin
if mocha('isConnected', varargin{k}) == true
isConnected(k) = uint16(1);
else
isConnected(k) = uint16(0);
end
end
varargout{1} = isConnected;
else
[h,pv,state] = mocha('getHandleStates');
%[varargout{1}, varargout{2}] = mca(12);
varargout{1} = h;
varargout{2} = state;
end

View File

@@ -0,0 +1,48 @@
function varargout = mcacheckopen(varargin)
%MCACHECKOPEN - returns handle(s) to PV(s)
% Returns existing handles for PVs already connected,
% opens new connections otherwise.
% Returns 0 for PVs that failed to connect.
%
% HANDLE = MCACHECKOPEN('NAME')
%
% [HANDLE1, ... , HANDLEN] = MCACHECKOPEN('PVNAME1', ... , 'PVNAMEN')
%
% HANDLES = MCACHECKOPEN(NAMES)
% When NAMES is a cell array of strings, HANDLES is a numeric array of
% handles
%
% Note:
% In principle, one should open, use, close PVs.
% But in some cases the bookkeeping of PV handles might
% be a bit too much for quick script hacks,
% in which case mcacheckopen can help with re-use of
% existing handles for PVs that were opened earlier yet
% their handles are lost.
%
% See also MCAOPEN, MCAISOPEN
if iscellstr(varargin{1})
varargout{1} = zeros(size(varargin{1}));
for i=1:length(varargin{1})
varargout{1}(i) = mcaisopen(varargin{1}{i});
if ~varargout{1}(i)
varargout{1}(i) = mcaopen(varargin{1}{i});
end
end
else
for i=1:nargin
varargout{i} = mcaisopen(varargin{i});
if ~varargout{i}
varargout{i} = mcaopen(varargin{i});
end
end
end

View File

@@ -0,0 +1,19 @@
function mcaclearmon(varargin)
%MCACLEARMON - uninstall monitors, previously installed with MCAMON
%
% MCACLEARMON(H1,H2,...,HN)
% H1,H2..,HN - integer channel handles
%
% Note: Monitors can be installed with MCAMON and cleared with
% MCACLEARMON any number of times.
%
% See also MCAMON, MCAMONTIMER, MCACACHE
if nargin <1
error('Must specify channel handles to close');
else
for i=1:nargin
%mca(200,varargin{i})
mocha('monitorStop',varargin{i})
end
end

View File

@@ -0,0 +1,22 @@
function mcaclose(varargin)
%MCACLOSE - permanently closes channels
% MCACLOSE(H1,H2,...,HN) closes the channels identified by their
% integer handles, previously opened with MCAOPEN.
% MCACLOSE(H) is the same for the case that H is an array of handles.
%
% Note: Once a channel is closed, it can not be used
% by MCAGET,MCAPUT or MCAMON. It can not be reopened.
% Use MCAOPEN again in order to connect to the same PV.
%
% See also MCAOPEN, MCASTATE, MCAINFO
if nargin <1
error('Must specify channel handles to close');
else
for i=1:nargin
pvs = varargin{i};
for j=1:length(pvs)
%mca(5, pvs(j))
mocha('close', pvs(j))
end
end
end

View File

@@ -0,0 +1,12 @@
function mcadebug(onoff)
%MCADEBUG - Enable/disable debugging
%
% Used only for development, not user-callable.
if onoff
%mca(9999, 1);
disp('Not relevant to mocha');
else
%mca(9999);
disp('Not relevant to mocha');
end

View File

@@ -0,0 +1,34 @@
function varargout = mcaegu(varargin)
%MCAEGU - read engineering units from PV's
%
% VALUES = MCAEGU(HANDLE) returns a string array of enum strings of the
% PV specified by integer HANDLE.
% The function does not handle arrays of PV handles, but only a single PV at at time.
%
%
% Error handling:
% An empty cell string array will be returned if the PV type is not ENUM.
% A matlab exception will be thrown when the PV handle is invalid,
% i.e. not the result of a successful MCAOPEN.
% Furthermore, an error can result from a 'get' timeout,
% configurable via MCATIMEOUT.
% In addition, an error can result from a network disconnect.
% In principle, one can check beforehand via MCASTATE, but since
% a disconnect might happen just between the sucessful MCASTATE call
% and the following MCAGET, the only safe thing might be to surround
% MCAGET calls with TRY....CATCH.
%
% See also TRY, CATCH, MCASTATE, MCATIMEOUT, MCAPUT
if nargin<1
error('No arguments were specified in mcaget')
elseif nargin==1
if length(varargin{1})>1
error('Only single PV can be handled at a time')
else
pvCtrl=mocha('getCtrlCache', varargin{1});
varargout{1} = {pvCtrl.units}; %mca(41,varargin{1});
end
elseif nargin>1
error('Only single PV can be handled at a time')
end

View File

@@ -0,0 +1,39 @@
function varargout = mcaenums(varargin)
%MCAENUMS - read enum strings from PV's
%
% VALUES = MCAENUMS(HANDLE) returns a string array of enum strings of the
% PV specified by integer HANDLE.
% The function does not handle arrays of PV handles, but only a single PV at at time.
%
%
% Error handling:
% An empty cell string array will be returned if the PV type is not ENUM.
% A matlab exception will be thrown when the PV handle is invalid,
% i.e. not the result of a successful MCAOPEN.
% Furthermore, an error can result from a 'get' timeout,
% configurable via MCATIMEOUT.
% In addition, an error can result from a network disconnect.
% In principle, one can check beforehand via MCASTATE, but since
% a disconnect might happen just between the sucessful MCASTATE call
% and the following MCAGET, the only safe thing might be to surround
% MCAGET calls with TRY....CATCH.
%
% See also TRY, CATCH, MCASTATE, MCATIMEOUT, MCAPUT
if nargin<1
error('No arguments were specified in mcaget')
elseif nargin==1
if length(varargin{1})>1
error('Only single PV can be handled at a time')
else
pvCtrl=mocha('getCtrlCache', varargin{1});
ens13=pvCtrl.enumStrings;
ens=cell(max(1,pvCtrl.noEnumStrings),1);
for k=1:pvCtrl.noEnumStrings
ens(k)=ens13(k);
end
varargout{1} = ens; %mca(40,varargin{1});
end
elseif nargin>1
error('Only single PV can be handled at a time')
end

View File

@@ -0,0 +1,5 @@
function mcaexit()
%MCAEXIT - Shut down channel access...
%
% Disconnects all PVs.
mocha('close') %mca(999)

View File

@@ -0,0 +1,71 @@
function varargout = mcaget(varargin)
%MCAGET - read values from PV's
%
% VALUE = MCAGET(HANDLE) returns a value of a PV specified by integer HANDLE.
% Type of return value depends on the native type and the number of elements
% in the EPICS record:
%
% EPICS strings are returned as MATLAB strings
% EPICS array of strings - MATLAB cell array of strings
% All numeric EPICS types are returned as MATLAB double arrays
%
% VALUES = MCAGET(HANDLES) an easy get for a group of scalar numeric PV's
% HANDLES - array of handles
% VALUES - numeric array of values.
% If any of the PVs is a waveform,
% only the first element is returned
%
% [VALUE1, ... VALUEN] = MCAGET(HANDLE1, ... , HANDLEN)
% returns values of multiple PV's of any type and length
% Number of outputs must match the number of inputs
%
% Error handling:
% A matlab exception will be thrown when any of the PVs are invalid,
% i.e. not the result of a successful MCAOPEN.
% Furthermore, an error can result from a 'get' timeout,
% configurable via MCATIMEOUT.
% In addition, an error can result from a network disconnect.
% In principle, one can check beforehand via MCASTATE, but since
% a disconnect might happen just between the sucessful MCASTATE call
% and the following MCAGET, the only safe thing might be to surround
% MCAGET calls with TRY....CATCH.
%
% See also TRY, CATCH, MCASTATE, MCATIMEOUT, MCAPUT
if nargin<1
error('No arguments were specified in mcaget')
elseif nargin==1
if length(varargin{1})>1
[a, isallOK]=mocha('getScalarArray', varargin{1}, 'double');
varargout{1} = [a]; %mocha('getScalarArray', varargin{1}); %mca(51,varargin{1});
else
chInfo=mocha('getInfo', varargin{1});
if( strcmp(chInfo.dataType,'DBR_ENUM') )
varargout{1} = mocha('get', varargin{1},'double');
else
varargout{1} = mocha('get', varargin{1}); %mca(50,varargin{1});
end
end
elseif nargin>1
if nargin ~= nargout
error('Number of outputs must match the number of inputs')
end
[a, isallOK]=mocha('getStructArray', [varargin{:}]);
for k=1:length(a)
chInfo=mocha('getInfo', varargin{k});
if( length(a(k).val) ==1 && strcmp(chInfo.dataType,'DBR_ENUM') )
varargout{k}=mocha('getCache', varargin{k}, 'double');
%if (length(a(k).val)==1 && iscell(a(k).val))
% varargout{k}=a(k).val{1};
else
if (length(a(k).val)==1 && iscell(a(k).val))
varargout{k}=a(k).val{1};
else
varargout{k}=a(k).val;
end
end
end
%[varargout{1:nargin}] mca(50,varargin{:});
end

View File

@@ -0,0 +1,76 @@
function varargout = mcagets(varargin)
%MCAGETS - read values from PV's, with string output for ENUMs
%
% VALUE = MCAGETS(HANDLE) returns a value of a PV specified by integer HANDLE.
% Type of return value depends on the native type and the number of elements
% in the EPICS record:
%
% EPICS strings are returned as MATLAB strings
% EPICS array of strings - MATLAB cell array of strings
% All numeric EPICS types are returned as MATLAB double arrays
% This routine returns the string value of ENUM types, when the input
% parameter is a single handle. Otherwise this routine behaves
% identically to MCAGET
%
% VALUES = MCAGETS(HANDLES) an easy get for a group of scalar numeric PV's
% HANDLES - array of handles
% VALUES - numeric array of values.
% If any of the PVs is a waveform,
% only the first element is returned
%
% [VALUE1, ... VALUEN] = MCAGETS(HANDLE1, ... , HANDLEN)
% returns values of multiple PV's of any type and length
% Number of outputs must match the number of inputs
%
% Error handling:
% A matlab exception will be thrown when any of the PVs are invalid,
% i.e. not the result of a successful MCAOPEN.
% Furthermore, an error can result from a 'get' timeout,
% configurable via MCATIMEOUT.
% In addition, an error can result from a network disconnect.
% In principle, one can check beforehand via MCASTATE, but since
% a disconnect might happen just between the sucessful MCASTATE call
% and the following MCAGET, the only safe thing might be to surround
% MCAGET calls with TRY....CATCH.
%
% See also TRY, CATCH, MCASTATE, MCATIMEOUT, MCAPUT
if nargin<1
error('No arguments were specified in mcaget')
elseif nargin==1
if length(varargin{1})>1
[a, isallOK]=mocha('getScalarArray', varargin{1}, 'double');
varargout{1} = [a]; %mca(51,varargin{1});
else
varargout{1} = mocha('get', varargin{1});
%if(strcmp(mca(43,varargin{1}),'ENUM'))
% enumvalues=mca(40,varargin{1});
% varargout{1}= enumvalues{mca(50,varargin{1})+1};
% else
% varargout{1} =mca(50,varargin{1});
% end
end
elseif nargin>1
if nargin ~= nargout
error('Number of outputs must match the number of inputs')
end
[a, isallOK]=mocha('getStructArray', [varargin{:}]);
for k=1:length(a)
chInfo=mocha('getInfo', varargin{k});
if( length(a(k).val) ==1 && strcmp(chInfo.dataType,'DBR_ENUM') )
varargout{k}=mocha('getCache', varargin{k}, 'double');
else
if (length(a(k).val)==1 && iscell(a(k).val))
varargout{k}=a(k).val{1};
else
varargout{k}=a(k).val;
end
end
end
%[varargout{1:nargin}] mca(50,varargin{:})
end

View File

@@ -0,0 +1,86 @@
function varargout = mcainfo(varargin);
%MCAINFO - get connection status and other information about a PV
% INFO = MCAINFO(PV) returns information on a single PV
% PV can be a string PV name or an integer handle
% Returns a 1-by-1 structure with fields:
%
% Handle
% PVName
% ElementCount:
% NativeType { STRING | INT | FLOAT | ENUM | CHAR | DOUBLE }
% State { connected | disconnected }
% MCAMessage
% Host
%
% [HANDLES, INFO] = MCAINFO with no argument returns information on
% all open channels in a structure array.
% HANDLES is a numeric array of handles
% INFO is a structure array of inoformation on the PV in the
% same format as above
%
% Note: A channel may become disconnected
% due to a server or network problem. This will be reflected in
% MCAMessage field. Any attempts to read, write or monitor this channel
% will return an error. CA library will periodically attempt to reestablish
% connection without any action required from the user.
% When the connection is closed by the user with MCACLOSE,
% that PV handle becomes invalid, and attempts to call MCAINFO
% will result in an error.
%
% See also: MCAOPEN MCACLOSE MCASTATE
value=struct('Handle',{}, 'PVName',{}, 'ElementCount',{},'NativeType',{},'State',{},'MCAMessage',{},'Host',{},'Units',{});
mcaNoConnection ={'unknown', 'disconnected','Disconnected due to server or network problem'};
mcaConnection ={'known', 'connected','Normal connection'};
mcaClosedConnection={'unknown', 'disconnected','Permanently disconnected (cleared)'};
if nargin>0
if ischar(varargin{1})
%[handles, names] = mca(3);
%matchfound = find(strcmp(varargin{1},names));
%if isempty(matchfound)
% error(['No open channels found for a PV: ',varargin{1}]);
%end
%h = handles(matchfound);
h(1)=mocha('getHandleFromPV',varargin{1});
if (h(1)==0)
error(['No open channels found for a PV: ',varargin{1}]);
end
elseif isnumeric(varargin{1})
h(1)=(varargin{1});
else
error('Argument must be a string PV Name or an integer handle');
end
%varargout{1} = mca(11,h);
else % Return info on all channels
%[varargout{1} varargout{2}] = mca(10);
[h,pv]=mocha('getHandles');
end
for k=1:length(h)
chInfo=mocha ('getChannelInfo', h(k));
pvCtrl=mocha ('getCtrlCache', h(k));
value(k).Handle=h(k);
value(k).PVName= mocha('getPVFromHandle', h(k));
value(k).ElementCount=chInfo.nelem;
nativeType=strsplit(chInfo.dataType,'_');
value(k).NativeType=nativeType{2};
if (chInfo.connectFlag==1)
value(k).State=mcaConnection{2};
value(k).MCAMessage=mcaConnection{3};
else
value(k).State=mcaNoConnection{2};
value(k).MCAMessage=mcaNoConnection{3};
end
%value(k).MCAMessage=mocha('statusInfo', mocha('getStatus', h(k)));
value(k).Host =chInfo.hostName;
value(k).Units=pvCtrl.units;
end
if (length(h)==1)
varargout{1} = value;
else
varargout{1} = h;
varargout{2} = value;
end

View File

@@ -0,0 +1,20 @@
function h = mcaisopen(PVNAMESTRING);
%MCAISOPEN - Check if a channel to a PV is open with MCAOPEN
%
% H = MCAISOPEN(PVNAMESTRING) returns an integer handle if open
% and 0 otherwise. If more than one channel is open to the
% same PV, an array of handles is returned.
%
% See also MCAINFO MCASTATE
if ~ischar(PVNAMESTRING)
error('Argument must be a string')
end
[handles, names] = mcaopen;
matchfound = find(strcmp(PVNAMESTRING,names));
if isempty(matchfound)
h = 0;
else
h = handles(matchfound);
end;

View File

@@ -0,0 +1,66 @@
function varargout = mcamon(handle,varargin)
%MCAMON - install or replace monitor on a PV
%
% STS = MCAMON(HANDLE) installs monitor with default callback.
% Default callback updates local copy of the channel data
% every time the data changes on the server.
% This cached data can be read at later time into MATLAB with MCACACHE.
% HANDLE - integer handle to a channel previously opened with MCAOPEN
% Returns 1 on success, 0 on failure
%
% STS = MCAMON(HANDLE,CALLBACKSTRING) installs a monitor and specifies
% a callback string for each. A callback string must be a MATLAB command,
% sequence of commands or a name of a script/function on the MATLAB path.
% It is executed in the 'base' workspace (AFTER the default callback) on
% the next poll of the queue by the MCAMONTIMER command.
% Returns 1 on success, 0 on failure
%
% [HANDLES, CALLBACKSTRINGS]=MCAMON with no arguments returns information
% on all currently installed monitors
%
% Note: Monitors can be installed with MCAMON and cleared with
% MCACLEARMON any number of times. Use MCAMONTIMER to initialise
% the MATLAB timer which polls and processes the outstanding MCA Monitor
% callback queue.
%
% Note: Use of asynchronous features of EPICS (such as monitors)
% with MATLAB requires special care - read MCA notes.
%
% 1.In CA client library (EPICS R3.13.4) asynchronous callbacks run one at a time
% to completion. This means that MATLAB callback string installed with MCAMON
% may not itself contain other MCA functions that call CA library such as MCAGET
% For example MCAMON(H1, 'X=MCAGET(H2);') will not work.
% MCAMON(H1, X='MCACACHE(H2);') is OK since MCACACHE does not use CA library.
%
% See also MCAMONTIMER, MCACACHE, MCAGET, MCACLEARMON.
if nargin ==1
%varargout{1}=mca(100,handle);
monID=mocha('monitor', handle); %return monitorID
status=0;
if (monID > 4095) %1st onid is 0xff (4096)
status=1;
end
varargout{1}=status;
elseif nargin==2
if ischar(varargin{1})
%varargout{1} = mca(100,handle,varargin{1});
monID=mocha('monitor', handle, varargin{1} )
status=0;
if (monID > 4095)
status=1;
end
else
error('Second argument must be a string');
end
elseif nargin == 0
if nargout == 2
%[varargout{1},varargout{2}]=mca(500);
[varargout{1},varargout{2}]=mocha ('getMonitorHandlesAndActions');
else
%varargout{1}=mca(500);
varargout{1}=mocha ('getMonitorHandles');
end
end

View File

@@ -0,0 +1,25 @@
function varargout = mcamonevents(varargin)
%MCAMONEVENTS - returns the number of monitor events which have
% occurred for channels since the last call to MCACACHE.
%
% [HANDLES, EVENTCOUNT] = MCAMONEVENTS
% Returns handles and event counts for all open channels
%
% EVENTCOUNT = MCAMONEVENTS(HANDLES)
% Returns event counts for specified channel(s)
%
% See also MCAMON, MCACACHE, MCAGET, MCACLEARMON
disp('not supported in mocha');
%[handles, count] = mca(510);
%if nargin == 0
% varargout{1} = handles;
% varargout{2} = count;
%elseif nargin > 0 && isnumeric(varargin{1})
% for i=1:length(varargin{1})
% ind(i)=find(handles==varargin{1}(i));
% end
% varargout{1} = count(ind);
%end

View File

@@ -0,0 +1,64 @@
function varargout = mcamontimer(varargin)
%MCAMONTIMER - Controls the initialisation and termination of the MATLAB
% timer used to poll the MCA monitor command queue.
%
% Started = mcamontimer - returns 1 if monitor polling has been started
% returns 0 if monitor polling has not been started
%
% mcamontimer('start') - starts the timer polling every 0.1 seconds
% mcamontimer('stop') - stops the timer
%
% Notes:
% (1) If monitors are installed using mcamon but mcaTimer has not been
% started, the monitor events will queue up indefinitely. There is
% no limit to the size of the queue, so eventually you will
% run out of memory and crash.
% (2) A polling period of 0.1 seconds is used. This may be varied if
% desired by modifying the 'Period' argument in the definition of
% mcaTimer.
% (3) Call mcamontimer('start') once.
%
% See also MCAMON, MCAMONEVENTS, MCACACHE, MCACLEARMON
%
persistent mcaTimer TimerStarted;
%mocha('test')
if (nargin == 0)
if (TimerStarted)
varargout{1} = 1;
else
varargout{1} = 0;
end
elseif (nargin == 1)
switch varargin{1}
case 'start'
if (TimerStarted)
error('MCA monitor polling is already started.');
end
mlock;
%mcaTimer = timer('TimerFcn', 'mca(600)', 'Period', 0.1, 'ExecutionMode', 'fixedSpacing');
mcaTimer = timer('TimerFcn', 'mocha(402)', 'Period', 10.1, 'ExecutionMode', 'fixedSpacing');
%%mcaTimer.TimerFcn= {@mocha, 'monitorflushevent'};
start (mcaTimer);
TimerStarted = 1;
case 'stop'
if (TimerStarted)
munlock;
stop (mcaTimer);
clear mcaTimer;
TimerStarted = 0;
else
error('MCA monitor polling has not been started.');
end
otherwise
error('Invalid parameter specified for mcamontimer. Use ''start'' or ''stop''.')
end
else
error('Invalid number of arguments in mcamontimer.')
end

View File

@@ -0,0 +1,61 @@
function varargout = mcaopen(varargin);
%MCAOPEN - open a Channel Access connection to an EPICS Process Variable
%
% H = MCAOPEN(PVNAME);
% If successful H is a unique nonzero integer handle associated with this PV.
% Returned handle is 0 if a connection could not be established
%
% [H1, ... ,Hn] = MCAOPEN(PVNAME1, ... ,PVNAMEn);
% Is equivalent to but more efficient than multiple single-argument calls
% H1 = MCAOPEN(PVNAME1);
% ...
% Hn = MCAOPEN(PVNAMEn);
%
% HANDLES = MCAOPEN(NAMES) is convenient when working with long lists of PV names
% HANDLES is a numeric array of assigned handles
% NAMES is a cell array of strings with PV names
%
% [HANDLES, NAMES] = MCAOPEN with no arguments returns a list of PV Names for all open connections.
% HANDLES is a numeric array of handles
% NAMES is a cell array of strings with PV names
%
% Note:
% When done, one should probably use MCACLOSE on the handle.
% When you use the same channel again "later", you might keep it open.
% See MCACHECKOPEN for a lazy person's bookkeeping helper.
%
% See also: MCACHECKOPEN, MCAISOPEN, MCACLOSE
if nargin>1 && nargin ~= nargout
error('Number of outputs must match the number of inputs')
end
if nargin==0
[varargout{1} varargout{2}] = mocha('getHandles'); %mca(3);
elseif iscellstr(varargin) && nargin ==1
varargout{1} = mocha('open', varargin{1} );
elseif iscellstr(varargin{1}) && nargin==1
if length(varargin{1}) > 1
mocha ('openPrepare');
varargout{1} = mocha('open', varargin{1} );
mocha ('openNow')
else
varargout{1} = mocha('open', varargin{1} ); % mca(2,varargin{1});
end
elseif iscellstr(varargin)
mocha('openPrepare');
%[varargout{1:nargin}] =
h1=mocha('openArray',{varargin{:}}) %mca(1,varargin{:});
for i = 1:length(h1)
[varargout{i}] = h1(i);
end
mocha('openNow');
else
error('All arguments must be strings')
end

View File

@@ -0,0 +1,4 @@
function mcapoll()
%MCAPOLL - poll channel access...
%mca(30)
mocha('capoll')

View File

@@ -0,0 +1,35 @@
function varargout = mcaprec(varargin)
%MCAPREC - read precision from PV's
%
% VALUES = MCAPREC(HANDLE) returns the precision field of a channel as a double
%
% The function does not handle arrays of PV handles, but only a single PV at at time.
%
%
% Error handling:
% An empty cell string array will be returned if the PV type is not ENUM.
% A matlab exception will be thrown when the PV handle is invalid,
% i.e. not the result of a successful MCAOPEN.
% Furthermore, an error can result from a 'get' timeout,
% configurable via MCATIMEOUT.
% In addition, an error can result from a network disconnect.
% In principle, one can check beforehand via MCASTATE, but since
% a disconnect might happen just between the successful MCASTATE call
% and the following MCAGET, the only safe thing might be to surround
% MCAGET calls with TRY....CATCH.
%
% See also TRY, CATCH, MCASTATE, MCATIMEOUT, MCAPUT
if nargin<1
error('No arguments were specified in mcaget')
elseif nargin==1
if length(varargin{1})>1
error('Only single PV can be handled at a time')
else
%varargout{1} = mca(42,varargin{1});
pvCtrl = mocha('getCtrl', varargin{1});
varargout{1} =pvCtrl.precision();
end
elseif nargin>1
error('Only single PV can be handled at a time')
end

109
linux-x86_64/2024b/mcaput.m Normal file
View File

@@ -0,0 +1,109 @@
function sts = mcaput(varargin)
%MCAPUT - Write values to EPICS Process Variables
%
% MCAPUT(HANDLE1, VALUE1) - one handle, one value
% MCAPUT(HANDLE1, VALUE1, ... , HANDLE_N, VALUE_N) - handles and values in pairs
%
% EPICS STRING values are passed as MATLAB strings. For example:
% >> mcaput(H, 'MATLAB')
% >> mcaput(H1, 'MATLAB', H2, 'EPICS')
% or cell arrays of strings.
%
% MCAPUT(HANDLES_CELL_ARRAY, VALUES_CELL_ARRAY) - arguments are grouped
% in cell array of integer handles and a cell array of values
% of equal length.
%
% Returns an array of status values: 1 success, 0 failure, -1 timeout
%
% MCAPUT is implemented as a call to the ca_put_array_callback
% function in CA client library.
% MCAPUT returns 1 or 0 if we get an OK respectively error status within
% the timeout, or -1 if we don't get any response within the timeout.
%
% Note:
% The special case of MCAPUT([PV, PV, ...], [SCALAR, SCALAR, ...])
% will simply write the scalar values to the PVs without waiting for the
% callback.
%
% See also MCAGET, MCATIMEOUT.
if nargin==2
if iscell(varargin{1}) && iscell(varargin{2})
% {pv, pv, pv, ...}, {value, value, value, ...}
if length(varargin{1}) ~= length(varargin{2})
error('Cell array of MCA handles and cell array of values must be the same length')
end
HANDLES = varargin{1}; VALUES = varargin{2};
ARGS = reshape([HANDLES(:)';VALUES(:)'],1,2*length(varargin{1}));
%sts = mca(70,ARGS{:});
mocha('setputwait',HANDLES);
[gsts,sts]=mocha('setScalarArray', HANDLES, VALUES);
elseif isnumeric(varargin{1})
if length(varargin{1})>1
if length(varargin{1}) ~= length(varargin{2})
error('Array of handles and array of values must be the same length');
end
% [pv, pv, pv, ...], [value, value, value, ...]
%sts = mca(80,varargin{1},varargin{2});
mocha('setputwait', varargin{1});
[gsts,sts]=mocha('setScalarArray', varargin{1},varargin{2});
else
ARGS = varargin;
% (pv, value)
if (isnumeric(ARGS{2}(1)))
%if (isnumeric(ARGS(2)))
%sts = mca(70,ARGS{:});
mocha('setputwait',ARGS{1});
sts = mocha('set',ARGS(1), ARGS(2));
else
chInfo=mocha('getInfo', varargin{1});
if(strcmp(chInfo.dataType,'DBR_ENUM')&&~isnumeric(varargin{2}))
%if(strcmp(mca(43,varargin{1}),'ENUM')&&~isnumeric(varargin{2}))
pvCtrl=mocha('getCtrlCache', varargin{1});
enumvalues= pvCtrl.enumStrings; %mca(40,varargin{1});
%enumvalues=mca(40,varargin{1});
found = 0;
for ind = 1:numel(enumvalues)
if(strcmp(ARGS(2),enumvalues(ind)))
valueToPut=ind-1;
found=1;
end
end
if(found)
ARGS{2}=valueToPut;
mocha('setputwait',ARGS(1));
sts = mocha('set',ARGS(1), ARGS(2)); % mca(70,ARGS{:});
else
strings = sprintf(' "%s" ',enumvalues{:});
error('mcaput:enumCheck','Invalid value for this channel. Try one of: [%s]',strings);
end
else
%sts = mca(70,ARGS{:});
mocha('setputwait',ARGS(1));
sts = mocha('set',ARGS(1), ARGS(2));
end
end
end
else
error('Invalid mcaput args, need PV, VALUE');
end
elseif mod(nargin,2) == 0
% 'pv, value, pv, value, ...'
%sts = mca(70,varargin{:});
j=uint16(0);
for i=1:2:nargin
j=j+1;
handles(j)=varargin{i};
values{j}=varargin{i+1};
end
mocha('setputnowait',handles);
[gsts,sts]=mocha('setMany', handles, values{1:j});
else
error('Incorrect number of inputs, need a sequence of PV, VALUE')
end

View File

@@ -0,0 +1,118 @@
function sts = mcaputnowait(varargin)
%MCAPUT - Write values to EPICS Process Variables
%
% MCAPUT(HANDLE1, VALUE1) - one handle, one value
% MCAPUT(HANDLE1, VALUE1, ... , HANDLE_N, VALUE_N) - handles and values in pairs
%
% EPICS STRING values are passed as MATLAB strings. For example:
% >> mcaput(H, 'MATLAB')
% >> mcaput(H1, 'MATLAB', H2, 'EPICS')
% or cell arrays of strings.
%
% MCAPUT(HANDLES_CELL_ARRAY, VALUES_CELL_ARRAY) - arguments are grouped
% in cell array of integer handles and a cell array of values
% of equal length.
%
% Returns an array of status values: 1 success, 0 failure, -1 timeout
%
% MCAPUT is implemented as a call to the ca_put_array_callback
% function in CA client library.
% MCAPUT returns 1 or 0 if we get an OK respectively error status within
% the timeout, or -1 if we don't get any response within the timeout.
%
% Note:
% The special case of MCAPUT([PV, PV, ...], [SCALAR, SCALAR, ...])
% will simply write the scalar values to the PVs without waiting for the
% callback.
%
% See also MCAGET, MCATIMEOUT.
if nargin==2
if iscell(varargin{1}) && iscell(varargin{2})
% {pv, pv, pv, ...}, {value, value, value, ...}
if length(varargin{1}) ~= length(varargin{2})
error('Cell array of MCA handles and cell array of values must be the same length')
end
HANDLES = cell2mat(varargin{1}); VALUES = cell2mat(varargin{2});
disp('first call to mca 80')
%sts = mca(80,HANDLES,VALUES);
mocha('setputnowait',HANDLES);
[gsts,sts]=mocha('setScalarArray', HANDLES, VALUES);
elseif isnumeric(varargin{1})
if length(varargin{1})>1
if length(varargin{1}) ~= length(varargin{2})
error('Array of handles and array of values must be the same length');
end
% [pv, pv, pv, ...], [value, value, value, ...]
disp('call mca 80')
%sts = mca(80,varargin{1},varargin{2});
mocha('setputnowait', varargin{1});
[gsts,sts]=mocha('setScalarArray', varargin{1},varargin{2});
else
ARGS = varargin;
%a=ARGS{1};
%b=ARGS{2};
% (pv, value)
if (isnumeric(ARGS{2}(1))) %(ARGS(2)))
%sts = mca(80,ARGS{:});
mocha('setputnowait',ARGS{1});
sts = mocha('set',ARGS(1), ARGS(2));
else
chInfo=mocha('getInfo', varargin{1});
%if(strcmp(mca(43,varargin{1}),'ENUM')&&~isnumeric(varargin{2}))
if(strcmp(chInfo.dataType,'DBR_ENUM')&&~isnumeric(varargin{2}))
pvCtrl=mocha('getCtrlCache', varargin{1});
enumvalues= pvCtrl.enumStrings; %mca(40,varargin{1});
found = 0;
for ind = 1:numel(enumvalues)
if(strcmp(ARGS(2),enumvalues(ind)))
valueToPut=ind-1;
found=1;
end
end
if(found)
ARGS{2}=valueToPut;
mocha('setputnowait',ARGS(1));
sts = mocha('set',ARGS(1), ARGS(2)); % mca(70,ARGS{:});
else
strings = sprintf(' "%s" ',enumvalues{:});
error('mcaput:enumCheck','Invalid value for this channel. Try one of: [%s]',strings);
end
else
mocha('setputnowait',ARGS(1));
sts = mocha('set',ARGS(1), ARGS(2)); %mca(80,ARGS{:});
end
end
end
else
error('Invalid mcaput args, need PV, VALUE');
end
elseif mod(nargin,2) == 0
% 'pv, value, pv, value, ...'
% sts = mca(80,handles,values);
%for i=1:nargin
%params(i)=varargin{i};
%end
%nargin;
%data=reshape(params,2,nargin/2);
%handles=data(1,:);
%values=data(2,:);
j=uint16(0);
for i=1:2:nargin
j=j+1;
handles(j)=varargin{i};
values{j}=varargin{i+1};
end
disp(handles)
disp(values)
mocha('setputnowait',handles);
[gsts,sts]=mocha('setMany', handles, values{1:j});
%disp('pv,val,pv,val')
else
error('Incorrect number of inputs, need a sequence of PV, VALUE')
end

View File

@@ -0,0 +1,46 @@
function varargout = mcastate(varargin);
%MCASTATE - returns an array of connection states for open channels
% MCASTATE is used as diagnostics prior to issuing other
% MCA commands such as MCAGET, MCAPUT and MCAMON
%
% STATES = MCASTATE(H1,H2,...,HN) returns the states of
% the specified channels previously opened with MCAOPEN.
% STATES = an array of the states of the channels listed in the HANDLES
% array
%
% [HANDLES, STATES] = MCASTATE is an array of states of all
% currently open channels.
% HANDLES = an array of all the currently open channels
% STATES = an array of the states of the channels listed in the HANDLES
% array
%
% Possible values
% 1 - Connected: MCAGET, MCAPUT and MCAMON are valid
% 0 - Disconnected: MCAGET, MCAPUT and MCAMON will return invalid
% data or fail. This may be due to a server/network problem
%
% See also MCAINFO, MCAOPEN, MCACLOSE.
%if nargin > 0
% varargout{1} = mca(13,varargin{:});
%else
% [varargout{1}, varargout{2}] = mca(12);
%end
if nargin > 0
%varargout{1} = mca(13,varargin{:});
for k = 1:nargin
if mocha('isConnected', varargin{k}) == true
isConnected(k) = uint16(1);
else
isConnected(k) = uint16(0);
end
end
varargout{1} = isConnected;
else
[h,pv,state] = mocha('getHandleStates');
%[varargout{1}, varargout{2}] = mca(12);
varargout{1} = h;
varargout{2} = state;
end

View File

@@ -0,0 +1,44 @@
function varargout = mcatime(varargin)
%MCATIME - read timestamps for PVs previously read with MCAGET or MCAMON
%
% The timestamp is returned as a MATLAB serial date number suitable
% for use in the DATESTR function.
%
% The original time stamp is in the UTC timezone,
% but since Matlab doesn't handle timezones in datenum/datastr,
% it's converted to the 'local' timezone, so that
% datestr(mcatime(pv))
% should give a time that is close to the wall clock
% for channels that changed recently.
%
% VALUE = MCATIME(HANDLE)
% returns the timestamp of a PV specified by integer HANDLE.
%
% [VALUE1, ... VALUEN] = MCATIME(HANDLE1, ... , HANDLEN)
% returns timestamps of multiple PVs of any type and length
% Number of outputs must match the number of inputs
%
% See also MCAGET, MCAMON.
%
for i=1:nargin
% We get y/m/d H:M:S plus nanosecs...
%pieces = mca(60,varargin{i});
% but datenum doesn't handle nanosecs
%varargout{i} = datenum(pieces(1:6));
timestamp=mocha('getTimeStamp',varargin{i});
timestamp=double(timestamp);
timestamp(6)=timestamp(6)+timestamp(7)/double(1000000000);
%value.time(1)=double(timestamp(1));
%value.time(2)=(timestamp(2));
%value.time(3)=(timestamp(3));
%value.time(4)=(timestamp(4));
%value.time(5)=(timestamp(5));
%varargout{i}(1:5)=value.time(1:5);=
%varargout{i}(6)=double(timestamp6);
varargout{i}=timestamp(1:6);
%format longG;
end

View File

@@ -0,0 +1,64 @@
function varargout = mcatimeout(varargin)
%MCATIMEOUT - set or display MCA timeout setings
%
% MCATIMEOUT('open', t1)
% 'open' option sets the internal variable MCA_SEARCH_TIMEOUT to t1 (sec)
%
% MCATIMEOUT('get', t1)
% 'get' option sets the internal variable MCA_GET_TIMEOUT to t1 (sec)
%
% MCATIMEOUT('put', t1)
% 'put' option sets the internal variable MCA_PUT_TIMEOUT to t1 (sec)
%
% MCATIMEOUT('default') sets the default values
% MCA_SEARCH_TIMEOUT = 1.0 (sec)
% MCA_GET_TIMEOUT = 5.0 (sec)
% MCA_PUT_TIMEOUT = 0.01 (sec)
%
% TIMEOUTS = MCATIMEOUT with no arguments returns a vector of currently set timeouts
% in the format [MCA_SEARCH_TIMEOUT MCA_GET_TIMEOUT MCA_PUT_TIMEOUT]
%
% Notes:
% See also: MCA.cpp
%
switch nargin
case 0
a=mocha('getTimeout');
%a(1) Put %a(2)Get
b=mocha('getOpenWaitTime');
AB=[b(1); a(2); a(1)]; %search, get, put
varargout{1} = AB(1:3); %mca(1000);
case 1
if strcmp(varargin{1}, 'default')
a=mocha('setTimeOutDefault');
b=mocha('openWaitWithTimeDefault');
AB=[b(1); a(2); a(1)]; %search, get, put
varargout{1} = AB(1:3); %mca(1004);
else
error ('Invalid command option.')
end
case 2
if strcmp(varargin{1}, 'open')
if ~isnumeric(varargin{2}) || varargin{2} <= 0
error('Second argument must be numeric, positive seconds');
end
mocha('openWaitWithTime',varargin{2});
%mca(1001,varargin{2});
elseif strcmp(varargin{1}, 'get')
if ~isnumeric(varargin{2}) || varargin{2} <= 0
error('Second argument must be numeric, positive seconds');
end
mocha('setTimeoutGet',varargin{2});
%mca(1002,varargin{2});
elseif strcmp(varargin{1}, 'put')
if ~isnumeric(varargin{2}) || varargin{2} <= 0
error('Second argument must be numeric, positive seconds');
end
mocha('setTimeoutPut',varargin{2});
%mca(1003,varargin{2});
else
error('Invalid command option.')
end
otherwise
error ('Invalid number of arguments.')
end

View File

@@ -0,0 +1,11 @@
function mcaunlock;
%MCAUNLOCK - unlocks the MCAMAIN mex-file
% .. so that it can be cleared from memory with CLEAR
%
% MCAMAIN starts in a locked state
% to protect from it from being
% accidentally cleared and
% loosing channel access connections.
%mca(0);
mocha('mexUnlock');
%disp('mca mex-file is now UNLOCKED');

View File

@@ -0,0 +1,8 @@
function ver = mcaversion()
%MCAVERSION - get version info
% ver = mcaversion()
%
% returns the mca version as a string
%ver = mca(-1);
ver = mocha('version');

View File

@@ -0,0 +1,16 @@
function varargout = monActionLocal(varargin)
disp('monitorAction called for:');
pvName=mocha('getPVFromHandle', varargin{1});
disp(pvName);
X=['Handle =', num2str(varargin{1})];
disp(X);
%[varargout{1} varargout{2}] = mocha ('getCache', varargin{1});
[var1,var2]=mocha ('getCache', varargin{1});
[s,t]=mocha('getStatus', varargin{1});
%X=['Value=', num2str(varargout{1}), ' Status=', num2str(s), ' [',t(1), ' ', t(2),']'];
X=['Value =', num2str(var1)];
Y=['Status=', num2str(s)];
disp(X)
disp(Y)
disp([t(1),t(2)])

48
linux-x86_64/2024b/pvtable.m Executable file
View File

@@ -0,0 +1,48 @@
function pvt = pvtable()
%
% pvt=pvtable()
% returns a table displaying all pvs and their status
%
[hpv,pvn,state] = mocha('getHandleStates');
pvt=[];
if (isempty(hpv))
disp('THERE ARE NO CHANNELS!');
return;
end
%If monitor then uses cache value
mocha('getAsyn', hpv);
mocha('sendNow'); %otherwise getPVCache will do the send!
dstruct = mocha('getPVCache', hpv);
%If NaN then following warning given from struct2table:
%Warning: Out of range or non-integer values truncated during
%conversion to character
%
t=struct2table(dstruct);
for n=1:length(hpv)
s1(n).handle=hpv(n);
s1(n).pv=pvn(n);
s1(n).cs=state(n);
s1(n).nmon=mocha('getNoMonitors', hpv(n));
end
t1=struct2table(s1);
if (string(class(t.val)) == string('char'))
t.val=string(t.val);
end
pvt=table(t1.handle,t1.pv, t.val, t.status, t1.cs, t1.nmon);
pvt.Properties.VariableNames={'h','pv', 'val', 'stat','c', 'm'};
%tNew.Properties.VariableNames{'Var1'}= 'handle';
%tNew.Properties.VariableNames{'Var2'}= 'pv';
%tNew.Properties.VariableNames{'Var3'}= 'val';
%2017a
%setColHeading(tNew, 1, 'handle');
%setColHeading(tNew, 2, 'pv');
%setColHeading(tNew, 3, 'val');

View File

@@ -0,0 +1,18 @@
<!--A simple, minimalistic TEST XML file-->
<cafe:config>
<cafe:group id="gTest">
<cafe:member> <cafe:name> ARIDI-BPM-01LE:X-AVG </cafe:name> </cafe:member>
<!--
<cafe:member> <cafe:name> ARIDI-BPM-01LB:X-AVG </cafe:name> </cafe:member>
<cafe:member> <cafe:name> ARIDI-BPM-01SE:X-AVG </cafe:name> </cafe:member>
<cafe:member> <cafe:name> ARIDI-BPM-01SB:X-AVG </cafe:name> </cafe:member>
-->
<cafe:member> <cafe:name> ARIDI-BPM-01LE:Y-AVG </cafe:name> </cafe:member>
<!--
<cafe:member> <cafe:name> ARIDI-BPM-01LB:X-AVG </cafe:name> </cafe:member>
<cafe:member> <cafe:name> ARIDI-BPM-01SE:X-AVG </cafe:name> </cafe:member>
<cafe:member> <cafe:name> ARIDI-BPM-01SB:X-AVG </cafe:name> </cafe:member>
-->
</cafe:group>
</cafe:config>

Binary file not shown.

View File

@@ -1,4 +1,5 @@
#include <cafe.h>
//include <hashConduit.h>
#include "macchinetta.h"
#include "containerMochaccino.h"
@@ -11,6 +12,7 @@ using namespace std;
const unsigned short METHOD_NAME_MAX_SIZE=80;
const unsigned short PVNAME_MAX_SIZE=80;
const unsigned short DBR_STRING_MAX_SIZE=40;
const unsigned short MONITOR_ACTION_MAX_SIZE=255;
const unsigned short ME_MESSAGE_MAX_SIZE=255;
@@ -182,7 +184,8 @@ enum mdtIndex {MOCHA_NATIVE=0, MOCHA_CHAR, MOCHA_UCHAR, MOCHA_SHORT, MOCHA_USH
enum mochaIndex {SHOW=1, OPEN, OPEN_ARRAY, OPEN_WAIT, GET_OPEN_WAIT_TIME,
OPEN_WAIT_WITH_TIME,OPEN_WAIT_TIME_TO_DEFAULT,
OPEN_NOWAIT, OPEN_NOW, OPEN_NOW_AND_WAIT, OPEN_GROUP,
CLOSE, CLOSE_ARRAY, CLOSE_GROUP, CA_POLL, MEX_UNLOCK, MOCHA_VERSION,
CLOSE, CLOSE_ARRAY, CLOSE_GROUP, CA_POLL, MEX_UNLOCK,
MOCHA_VERSION, EPICS_V_STRING, CA_V_STRING,
WITH_EXCEPTIONS, HAVE_EXCEPTIONS, SEND_NOW,
GET=100, GET_INT8, GET_INT16, GET_INT32, GET_INT64, GET_UINT8,
GET_UINT16, GET_UINT32, GET_UINT64, GET_FLOAT, GET_DOUBLE,
@@ -213,8 +216,8 @@ enum mochaIndex {SHOW=1, OPEN, OPEN_ARRAY, OPEN_WAIT, GET_OPEN_WAIT_TIME,
SET_NELEM, SET_NELEM_CACHE, SET_OFFSET,
GET_NELEM_CLIENT, GET_NELEM_NATIVE, GET_NELEM_REQUEST,
GET_NELEM, GET_NELEM_CACHE, GET_OFFSET,
MONITOR=400, MONITOR_STOP, MONITOR_FLUSH_EVENT,
GET_MONITOR_HANDLES, GET_MONITOR_HANDLES_AND_ACTIONS,
MONITOR=400, MONITOR_STOP, MONITOR_FLUSH_EVENT,
GET_MONITOR_HANDLES, GET_MONITOR_HANDLES_AND_ACTIONS, GET_NO_MONITORS,
IS_CONNECTED=500, ALL_CONNECTED,
PRINT_STATUS=600, PRINT_MONITORS, PRINT_HANDLE, PRINT_HANDLES,
PRINT_DISCONNECTED_HANDLES,GET_HANDLES,GET_HANDLE_STATES,
@@ -252,7 +255,8 @@ void msInsert()
ms.insert(mochaccino(CA_POLL, "capoll"));
ms.insert(mochaccino(MEX_UNLOCK, "mexunlock"));
ms.insert(mochaccino(MOCHA_VERSION, "version"));
ms.insert(mochaccino(EPICS_V_STRING, "epicsversion"));
ms.insert(mochaccino(CA_V_STRING, "caversion"));
ms.insert(mochaccino(WITH_EXCEPTIONS, "withexceptions"));
ms.insert(mochaccino(WITH_EXCEPTIONS, "setexceptions"));
ms.insert(mochaccino(HAVE_EXCEPTIONS, "haveexceptions"));
@@ -397,10 +401,12 @@ void msInsert()
ms.insert(mochaccino(GET_OFFSET, "getoffset"));
ms.insert(mochaccino(MONITOR, "monitorstart"));
ms.insert(mochaccino(MONITOR, "monitor"));
ms.insert(mochaccino(MONITOR_STOP, "monitorstop"));
ms.insert(mochaccino(MONITOR_FLUSH_EVENT, "monitorflushevent"));
ms.insert(mochaccino(GET_NO_MONITORS, "getnomonitors"));
ms.insert(mochaccino(GET_MONITOR_HANDLES, "getmonitorhandles"));
ms.insert(mochaccino(GET_MONITOR_HANDLES_AND_ACTIONS, "getmonitorhandlesandactions"));
@@ -456,6 +462,15 @@ void printStatus(int status )
}
void printStringInputError()
{
mexPrintf("Error in intepreting pv in input argument:\n");
mexPrintf("PV name does not have a char value \n");
mexPrintf("MATLAB mx library does not support string/mxSTRING_CLASS as input\n");
mexPrintf("Please use char/mxCHAR_CLASS as data type instead\n");
mexPrintf("i.e., use single quotes instead of double quotes in input argument!\n");
}
std::string prepareExceptionID(int status )
{
std::string exID="CAFE_";
@@ -771,6 +786,56 @@ unsigned int getNObjectsFromDataCell(const mxArray * thisCell)
}
char getEscapeSequence(char cNext, bool & recognizedFlag) {
char wfChar = cNext;
recognizedFlag = true;
switch (cNext) {
case '0':
wfChar = '\0';
break;
case '\'':
wfChar = '\'';
break;
case '"':
wfChar = '\"';
break;
case '?':
wfChar = '\?';
break;
case '\\':
wfChar = '\\';
break;
case 'a':
wfChar = '\a';
break;
case 'b':
wfChar = '\b';
break;
case 'f':
wfChar = '\f';
break;
case 'n':
wfChar = '\n';
break;
case 'r':
wfChar = '\r';
break;
case 't':
wfChar = '\t';
break;
case 'v':
wfChar = '\v';
break;
default:
// Unrecognized escape sequence; print slash
wfChar = '\\';
recognizedFlag = false;
break;
}
return wfChar;
}
/*
@@ -910,15 +975,93 @@ void cellToString(const mxArray * thisCell)
break;
case mxCHAR_CLASS:
ne=1;
dbr_string_t * strBuffer = new dbr_string_t[ne];
mxGetString(newCell, *strBuffer, sizeof(dbr_string_t)*ne);
for (mwIndex j=0; j< ne; ++j )
{
strcpy(inputStringCell[iWithinAllCells],strBuffer[j]);
unsigned int neLocal=1;
if (ne > (DBR_STRING_MAX_SIZE-1)) {
mexPrintf("Exceeded (with %d) max limit of %d chars. Ignoring this element of cell\n",
ne, (DBR_STRING_MAX_SIZE-1));
break;
}
dbr_string_t * strBuffer = new dbr_string_t[neLocal];
mxGetString(newCell, *strBuffer, sizeof(dbr_string_t)*neLocal);
//mexPrintf("ne %d\n", ne);
//mexPrintf("strBuffer %d\n", *strBuffer[0]);
//mexPrintf("strBuffer %c \n", *strBuffer[0]);
char c = strBuffer[0][0];
char cNext;
if (c == '\\' && ne > neLocal) {
cNext = strBuffer[0][1];
//mexPrintf("char cNext %c\n", cNext);
bool recognizedFlag = true;
char cNew = NS_MOCHA::getEscapeSequence(cNext, recognizedFlag);
//Must loop over all ne!
for (unsigned int i=0; i < ne; ++i) {
strBuffer[0][i] = cNew;
}
/* Must loop over all ne
switch (cNext) {
case '0':
strBuffer[0][0] = '\0';
break;
case '\'':
strBuffer[0][1] = '\'';
break;
case '"':
strBuffer[0][1] = '\"';
break;
case '?':
strBuffer[0][1] = '\?';
break;
case '\\':
strBuffer[0][1] = '\\';
break;
case 'a':
strBuffer[0][1] = '\a';
break;
case 'b':
strBuffer[0][1] = '\b';
break;
case 'f':
strBuffer[0][1] = '\f';
break;
case 'n':
//strBuffer[0][0] = '\n';
for (unsigned int i=0; i < ne; ++i) {
strBuffer[0][i] = '\n';
}
break;
case 'r':
strBuffer[0][1] = '\r';
break;
case 't':
//strBuffer[0][0] = '\t';
for (unsigned int i=0; i < ne; ++i) {
strBuffer[0][i] = '\t';
}
break;
case 'v':
strBuffer[0][1] = '\v';
break;
default:
// Unrecognized escape sequence; print slAH
strBuffer[0][1] = '\\';
break;
}
*/
}
for (mwIndex j=0; j< neLocal; ++j )
{
strcpy(inputStringCell[iWithinAllCells], strBuffer[j]);
++iWithinAllCells;
}
delete [] strBuffer;
break;
}
@@ -1188,6 +1331,7 @@ unsigned int checkForHandleNoOpen(const mxArray * inputValue)
if (mxIsNumeric(inputValue) )
{
_handle = (uint32_T) mxGetScalar(inputValue);
}
else if (mxIsChar(inputValue) )
@@ -1206,6 +1350,8 @@ unsigned int checkForHandleNoOpen(const mxArray * inputValue)
}
}
else if (mxIsCell(inputValue) )
{
@@ -1231,8 +1377,21 @@ unsigned int checkForHandleNoOpen(const mxArray * inputValue)
mexPrintf("PV=%s has not yet been opened by user!\n", pv );
}
}
else if (strcmp (mxGetClassName(newCell),"string") ==0 ) {
printStringInputError();
return _handle;;
}
}
else if (strcmp (mxGetClassName(inputValue),"string") ==0 ) {
printStringInputError();
return _handle;;
}
else
{
mexPrintf("Error in checkForHandleNoOpen:\n");
@@ -1248,6 +1407,8 @@ unsigned int checkForHandle(const mxArray * inputValue)
{
unsigned int _handle=0;
if (mxIsNumeric(inputValue) )
{
@@ -1297,7 +1458,20 @@ unsigned int checkForHandle(const mxArray * inputValue)
_handle=open(pv);
}
}
else if (strcmp (mxGetClassName(newCell),"string") ==0 ) {
printStringInputError();
return _handle;;
}
}
else if (strcmp (mxGetClassName(inputValue),"string") ==0 ) {
printStringInputError();
return _handle;;
}
else
{
mexPrintf("Error in checkForHandle:\n");
@@ -1305,9 +1479,11 @@ unsigned int checkForHandle(const mxArray * inputValue)
mexPrintf("or PV name does not have a char value \n");
return _handle;
}
if (_handle==0)
if (_handle<1)
{
mexPrintf("Handle in input argument not given! \n");
mexPrintf("Handle should be a positive integer. \n");
mexPrintf("Alternatively enter the pv name in single quotes\n");
}
return _handle;
}

View File

@@ -12,7 +12,6 @@
//#include <Python.h>
//#endif
extern void _main();
using namespace NS_MOCHA;
@@ -43,33 +42,23 @@ void macchinettaFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prh
mexPrintf("Please use the method name (MATLAB char) as input to the first argument. \n");
mexPrintf("The command: mocha \'show\' will display the methods available. \n");
mexPrintf("1st input argument Class Name: %s\n", mxGetClassName(prhs[0]));
mexPrintf("1st input argument Class ID: %d\n", mxGetClassID(prhs[0]));
mexPrintf("1st input argument to mocha must be of type char/mxCHAR_CLASS\n");
//mexPrintf("1st input argument given has Class Name: %s\n", mxGetClassName(prhs[0]));
//mexPrintf("1st input argument given has Class ID: %d\n", mxGetClassID(prhs[0]));
//mexPrintf("1st input argument to mocha must be of type char/mxCHAR_CLASS\n");
return;
}
}
/*
if (strcmp (mxGetClassName(prhs[0]),"string") ==0 ) {
mxChar * mess2 = static_cast<mxChar*>(mxGetData(prhs[0]));
mData = (mxArray *) mess2;
messLength = METHOD_NAME_MAX_SIZE+1;
if ( mxGetString(mData, mess, messLength) == 1) {
mexPrintf ("mxGetString has failed; input is not of mxChar type\n");
}
mexPrintf ("mocha does not support string/mxSTRING_CLASS as input\n");
mexPrintf ("Please use char/mxCHAR_CLASS as data type for input\n");
mexPrintf ("MATLAB mx library does not support string/mxSTRING_CLASS as input\n");
mexPrintf ("Please use char/mxCHAR_CLASS as data type instead\n");
mexPrintf("i.e., use single quotes instead of double quotes in input argument!\n");
return;
}
else {
*/
}
//message
//Trick to handle mocha(402) input from monitor Action
@@ -77,14 +66,32 @@ void macchinettaFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prh
messLength = METHOD_NAME_MAX_SIZE+1;
if (mxIsChar(prhs[0]) )
{
mData = (mxArray *) prhs[0];
mData = (mxArray *) prhs[0];
mxGetString(mData, mess, messLength);
}
else if (!strcmp(mxGetClassName(prhs[0]), "string") )
{
mexPrintf("1st input argument given has Class Name: %s\n", mxGetClassName(prhs[0]));
mexPrintf("1st input argument given has Class ID: %d\n", mxGetClassID(prhs[0]));
mexPrintf("1st input argument to mocha must be of type char/mxCHAR_CLASS\n");
mexPrintf("Please use single quotes instead of double quotes in input argument!\n");
return;
}
else if (mochaIndex ==MONITOR_FLUSH_EVENT)
{
strcpy(mess,"monitorflushevent");
}
else
{
mexPrintf("1st input argument given has Class Name: %s\n", mxGetClassName(prhs[0]));
mexPrintf("1st input argument given has Class ID: %d\n", mxGetClassID(prhs[0]));
mexPrintf("1st input argument to mocha must be of type char/mxCHAR_CLASS\n");
return;
}
char messOriginal[METHOD_NAME_MAX_SIZE+1];
strcpy(messOriginal,mess);
@@ -167,6 +174,7 @@ void macchinettaFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prh
//mexPrintf("message %s\n", mess);
//mexPrintf("message %s\n", messString.c_str());
it_name = name_index.find(mess);
@@ -325,14 +333,12 @@ void macchinettaFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prh
case SET:
if (nrhs<3)
{
mexPrintf("Invalid Number of argument %d. Input: 'set', handle/pv, data \n", nrhs);
return;
}
if (mxIsChar(prhs[1]))
{
nh=1;
@@ -421,9 +427,7 @@ void macchinettaFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prh
}
else
{
nh=mxGetNumberOfElements (prhs[1]);
}
///mexPrintf("nh=%d, nargin=%d\n", nh, nrhs);
@@ -488,8 +492,16 @@ void macchinettaFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prh
mexPrintf("mocha mex file is active\n");
break;
case EPICS_V_STRING:
plhs[0]=mxCreateString((char *) (cafe._epics_version()).c_str());
break;
case CA_V_STRING:
plhs[0]=mxCreateString((char *) (cafe._ca_version()).c_str());
break;
case MOCHA_VERSION:
plhs[0]=mxCreateString((char *) "mocha-1.8.0 : 14 December 2018");
plhs[0]=mxCreateString((char *) "mocha-1.22.0 : 6 October 2025; Contact: Felix.Armborst@psi.ch");
break;
case SHOW:
@@ -514,23 +526,18 @@ void macchinettaFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prh
case SET_PUT_PREPARE:
{
if (nrhs<2)
{
mexPrintf("Invalid Number of argument(s) %d. Input: setPutPrepare, handle(s) or handleArray \n", nrhs);
return;
}
size_t numberOfHandles=0;
for (size_t j=1; j<nrhs; ++j)
{
numberOfHandles=mxGetNumberOfElements (prhs[j]);
neWithinAllCells=0; // filled by checkHandleArray
//What is dataType?
@@ -1044,8 +1051,9 @@ void macchinettaFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prh
xData = (mxArray *) prhs[1];
pvLength = PVNAME_MAX_SIZE+1;
mxGetString(xData, pv, pvLength);
handle=NS_MOCHA::open(pv);
//return handle
//plhs[0] = mxCreateDoubleScalar(handle);
@@ -1351,7 +1359,6 @@ void macchinettaFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prh
(du[j].getPVName(),pvgroup.getGroupHandle());
//Match INPUT to CAFE DATATYPE
if (mdtIndexOriginal==MOCHA_NATIVE)
{
@@ -2599,19 +2606,14 @@ void macchinettaFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prh
case GET:
{
if (nrhs<2)
{
mexPrintf("Invalid Number of argument %d. Input: message, handle/pv \n", nrhs);
return;
}
handle=checkForHandle(prhs[1]);
if(handle==0)
{
mexPrintf("Handle does not exist!\n");
@@ -2640,11 +2642,8 @@ void macchinettaFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prh
if (mdtIndex==MOCHA_NATIVE)
{
status=cafe.getHandleHelper().getDataTypeRequest(handle, rdt);
if (status!=ICAFE_NORMAL)
{
mexPrintf("Error for handle input= %d \n", (uint32_T) mxGetScalar(prhs[1]) );
@@ -2657,14 +2656,11 @@ void macchinettaFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prh
CAFE_DATATYPE cdt = (CAFE_DATATYPE) rdt;
mdtIndex=getMdtIndexFromCafeDataType(cdt);
if (cafe.getHandleHelper().isEnum(handle))
{
mdtIndex=MOCHA_STRING;
}
}
@@ -2672,7 +2668,6 @@ void macchinettaFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prh
nelem = cafe.getHandleHelper().getNelemClient(handle); //Change Request to Client
if (cafe.getHandleHelper().getOffset(handle) > 0 )
{
@@ -2697,12 +2692,10 @@ void macchinettaFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prh
//mexPrintf("get Cache: nelem = %d \n", nelem);
if ( (cafe.getHandleHelper().getOffsetLast(handle) > 0) ||
(cafe.getHandleHelper().getNelemToRetrieveFromCache(handle) > cafe.getHandleHelper().getNelemRequest(handle)))
{
//if (nelem > cafe.getHandleHelper().getNelemRequest(handle) ) {
nelemPrevious=cafe.getHandleHelper().getNelemToRetrieveFromCache(handle);
nelem = min( (unsigned int) nelem, cafe.getHandleHelper().getNelemRequest(handle)-cafe.getHandleHelper().getOffsetLast(handle));
@@ -2716,6 +2709,14 @@ void macchinettaFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prh
}
//special case for wf with dbr_char_t
ChannelRegalia channelInfo;
status=cafe.getChannelInfo(handle, channelInfo);
unsigned int WFWithString = 0;
if (channelInfo.getClassNameAsString().compare("waveform") ==0) {
WFWithString = 1;
}
switch (mdtIndex)
{
case MOCHA_DOUBLE:
@@ -2786,57 +2787,91 @@ void macchinettaFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prh
break;
case MOCHA_UCHAR:
plhs[0] = mxCreateNumericMatrix(1,nelem,mxUINT8_CLASS, mxREAL);
ucharArray = (uint8_T *) mxGetData (plhs[0]);
if(cacheFlag)
{
status=cafe.getCache(handle,ucharArray);
}
else
{
status=cafe.get(handle,ucharArray);
}
//special case for wf with dbr_char_t
/*
if (WFWithString == 1) {
string wfStr;
if (cacheFlag)
{
status=cafe.getWFAsStringCache(handle,wfStr);
}
else
{
status=cafe.getWFAsString(handle,wfStr);
}
plhs[0] = mxCreateString( wfStr.c_str() );
}
else {
*/
plhs[0] = mxCreateNumericMatrix(1,nelem,mxUINT8_CLASS, mxREAL);
ucharArray = (uint8_T *) mxGetData (plhs[0]);
if(cacheFlag)
{
status=cafe.getCache(handle,ucharArray);
}
else
{
status=cafe.get(handle,ucharArray);
}
//}
break;
case MOCHA_STRING:
{
dbr_string_t * stringArrayc = new dbr_string_t[nelem];
if(cacheFlag)
{
status=cafe.getCache(handle,stringArrayc);
}
else
{
status=cafe.get(handle,stringArrayc);
}
if (WFWithString ==1) {
//char *test[40];
//test[0]="test";
//test[1]="again";
//mxChar *pr;
//char *ptr_to_seed_data;
//int c;
string wfStr;
if (status==ICAFE_NORMAL)
{
if (nelem==1)
if (cacheFlag)
{
plhs[0]=mxCreateString( stringArrayc[0] );
status=cafe.getWFAsStringCache(handle,wfStr);
}
else
{
plhs[0] = mxCreateCellMatrix(1,nelem);
for (mwSignedIndex i=0; i <nelem; ++i)
{
mxSetCell (plhs[0], i, mxCreateString( stringArrayc[i] ));
}
status=cafe.getWFAsString(handle,wfStr);
}
}
delete [] stringArrayc;
plhs[0] = mxCreateString( wfStr.c_str() );
}
else {
dbr_string_t * stringArrayc = new dbr_string_t[nelem];
if(cacheFlag)
{
status=cafe.getCache(handle,stringArrayc);
}
else
{
status=cafe.get(handle,stringArrayc);
}
if (status==ICAFE_NORMAL)
{
if (nelem==1)
{
plhs[0]=mxCreateString( stringArrayc[0] );
}
else
{
plhs[0] = mxCreateCellMatrix(1,nelem);
for (mwSignedIndex i=0; i <nelem; ++i)
{
mxSetCell (plhs[0], i, mxCreateString( stringArrayc[i] ));
}
}
}
delete [] stringArrayc;
}
break;
}
// Non DBR_TYPES
@@ -2997,11 +3032,11 @@ void macchinettaFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prh
if (cacheFlag)
{
status=cafe.getWFAsString(handle,wfStr);
status=cafe.getWFAsStringCache(handle,wfStr);
}
else
{
status=cafe.getWFAsStringCache(handle,wfStr);
status=cafe.getWFAsString(handle,wfStr);
}
//plhs[0] = mxCreateCellMatrix(1,2);
@@ -4236,7 +4271,7 @@ void macchinettaFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prh
size_t ne = mxGetNumberOfElements ( prhs[2]);
if(ne==0)
if (ne==0)
{
mexPrintf("Empty Data Array in Input \n");
return;
@@ -4246,21 +4281,34 @@ void macchinettaFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prh
neWithinAllCells=0;
iWithinAllCells=0;
mxClassID mxid =mxGetClassID( prhs[2]);
mxClassID mxid =mxGetClassID(prhs[2]);
//This line is important for a string as the Number of Elements
//is interpreted as the number of characters!!!
//Hence for ne to be 1
//Unless we have the special case of wf and DBR_CHAR
//So let us first check if this is a waveform
unsigned short isWFWithString=0;
if (mxid==mxCHAR_CLASS)
{
ne=1;
ChannelRegalia channelInfo;
status=cafe.getChannelInfo(handle, channelInfo);
//mexPrintf(channelInfo.getClassNameAsString().c_str());
if (channelInfo.getClassNameAsString().compare("waveform") !=0) {
ne=1;
}
else {
isWFWithString = 1;
}
}
nelem = cafe.getHandleHelper().getNelemClient(handle);
//handle does not exist
if(nelem==0)
if (nelem==0)
{
//status
plhs[0] = mxCreateNumericMatrix(1,1,mxINT32_CLASS,mxREAL);
@@ -4275,11 +4323,12 @@ void macchinettaFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prh
return;
}
if(nelem!=ne)
if (nelem!=ne)
{
cafe.getHandleHelper().setNelem(handle,ne);
}
mxArray *fout;
switch(mxid)
{
@@ -4360,11 +4409,13 @@ void macchinettaFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prh
scanCell(prhs[2]);
//Is it a waveform??
//If neWithinAllCells =1 and wf and class is mx_char
inputStringCell = new dbr_string_t[neWithinAllCells];
cellToString(prhs[2]);
if(neWithinAllCells!=ne)
{
cafe.getHandleHelper().setNelem(handle,neWithinAllCells);
@@ -4377,17 +4428,132 @@ void macchinettaFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prh
}
// Single String
case mxCHAR_CLASS:
dbr_string_t inputString;;
mxGetString(prhs[2], inputString, sizeof(dbr_string_t));
status=cafe.set(handle, inputString);
char *buf;
size_t buflen;
buflen = mxGetN(prhs[2]) + 1;
/*
buf = (char *) mxMalloc(buflen);
break;
long mexStatus;
mexStatus = mxGetString(prhs[2], buf, (mwSize) buflen+10);
if (mexStatus != 0) {
mexWarnMsgIdAndTxt( "MATLAB:mxmalloc:mxGetString",
"Failed to copy input string into allocated memory.");
status = ECAFE_BADSTR;
}
*/
buf=mxArrayToString(prhs[2]);
if (isWFWithString == 1) {
//std::string tempStr = inputString;
dbr_char_t * wfChar = new dbr_char_t [buflen+1];
//dbr_char_t * setStrValues = (dbr_char_t *) mxMalloc(buflen+40); // new dbr_char_t [buflen];
std::string wfStr = buf;
unsigned short iCount = 0;
for (std::string::size_type i=0; i < wfStr.size(); ++i) {
char c = wfStr[i];
char cNext;
if (c == '\\' && i < (wfStr.size()-1)) {
cNext = wfStr[i+1];
bool recognizedFlag = true;
wfChar[iCount] = NS_MOCHA::getEscapeSequence(cNext, recognizedFlag);
//mexPrintf ("wf %d", wfChar[iCount]);
/*
switch (cNext) {
case '0':
wfChar[iCount] = '\0';
break;
case '\'':
wfChar[iCount] = '\'';
break;
case '"':
wfChar[iCount] = '\"';
break;
case '?':
wfChar[iCount] = '\?';
break;
case '\\':
wfChar[iCount] = '\\';
break;
case 'a':
wfChar[iCount] = '\a';
break;
case 'b':
wfChar[iCount] = '\b';
break;
case 'f':
wfChar[iCount] = '\f';
break;
case 'n':
wfChar[iCount] = '\n';
break;
case 'r':
wfChar[iCount] = '\r';
break;
case 't':
mexPrintf ("wf %c", wfChar[iCount]);
wfChar[iCount] = '\t';
mexPrintf ("wf %c", wfChar[iCount]);
break;
case 'v':
wfChar[iCount] = '\v';
break;
default:
// Unrecognized escape sequence; print slash and subsequent letter
wfChar[iCount] = '\\';
--i;
break;
}
*/
//if (wfChar[iCount] != '\\') {
if (recognizedFlag) {
++i;
// mexPrintf ("wfplus i %d %d", wfChar[iCount], i);
}
}
else {
wfChar[iCount] = c;
}
++iCount;
//setStrValues[i] = buf[i];
}
cafe.getHandleHelper().setNelem(handle, iCount);
//std::string tb = buf;
//strcpy( (char*)(setStrValues), (const char*) buf); //"Hello \nWorld\0" );
//setStrValues =(dbr_char_t *) tb.c_str(); //"Hello\tWorld\nA\0"; //(dbr_char_t *) buf; //
status = cafe.set(handle, wfChar); // ) (dbr_char_t *) buf);
delete [] wfChar;
// mxFree(setStrValues);
}
else {
status=cafe.set(handle, buf);
}
mxFree(buf);
break;
default:
mexPrintf("mxClassID=%s (enum %d) is not supported; set not instigated!\n",
mxGetClassName(prhs[2]), mxid);
mexPrintf("mxClassID=%s (enum %d) is supported; i.e., use single instead of double quotes!\n",
"char", mxCHAR_CLASS);
break;
status = ECAFE_INVALID_SWITCH_CASE;
break;
}
if(nelem!=ne) cafe.getHandleHelper().setNelem(handle,nelem); //back to old value
//status
@@ -4408,9 +4574,6 @@ void macchinettaFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prh
}
case SET_AND_GET:
{
if (nrhs<3)
@@ -5361,6 +5524,39 @@ void macchinettaFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prh
break;
}
case GET_NO_MONITORS:
{
if (nrhs<2)
{
mexPrintf("Invalid Number of argument %d. Input: 'getNoMonitors', handle/pv \n", nrhs);
return;
}
else if (nrhs>2)
{
mexPrintf("Ignoring arguments after the 2nd from the %d entered. Input: 'getNoMonitors', handle/pv \n", nrhs);
}
handle=checkForHandle(prhs[1]);
if(handle==0)
{
return;
}
unsigned int nm;
nm=cafe.getHandleHelper().getNmonitor(handle);
//number of monitors for this handle
plhs[0] = mxCreateNumericMatrix(1,1,mxUINT32_CLASS,mxREAL);
ulongArray = (uint32_T *) mxGetData(plhs[0]);
ulongArray[0]=nm;
break;
}
case PRINT_MONITORS:
{

135
makefile
View File

@@ -1,135 +0,0 @@
#
# Jan Chrin
# New Version: June 2016
#
# makefile to build mocha mex file
# printenv | grep MATLAB to reveal your MATLAB Directory
#
# e.g. on sf-lc we have
# MATLAB=/afs/psi.ch/sys/linux/opt/matlab/2015a.x86_64
#
# local executables are built in ./${EPICS_HOST_ARCH}/$(MVER)
# where the MATLAB version is grepped from $(MATLAB)
MATLAB_ROOT=${MATLAB}
MATLAB_VERSION=$(notdir $(MATLAB_ROOT))
##### CHANGE AS APPROPRIATE #################
#Mocha Version to install
MOCHA_VERSION=mocha-noqt-1.8.0-gcc-6.3.0
#CAFE version to link to
CAFE_VERSION=cafe-noqt-1.8.0-gcc-6.3.0
EPICS_BASE=${EPICS}/base
#CAFE project base
CAFE_BASE=/opt/gfa/cafe
CAFE_MOCHA_BASE=${CAFE_BASE}/mocha
CAFE_CPP_BASE=$(CAFE_BASE)/cpp/$(CAFE_VERSION)
BOOST_BASE=${CAFE_BASE}/boost/boost_1_61_0/include
INSTALL_MOCHA_LIBDIR= $(CAFE_MOCHA_BASE)/$(MOCHA_VERSION)/lib/$(MATLAB_VERSION)
#############################################
#First deteremine if we are on a 32/64 bit machine
#as mex file extensions are named differently
pattern64=x86_64
pattern32=i386
PWD=$(shell pwd)
#hardware platform
HW=$(shell uname -i)
ifeq ($(pattern64),$(findstring $(pattern64), $(HW)))
MEXE=mexa64
MATLAB_LIB = $(MATLAB_ROOT)/bin/glnxa64
else
ifeq ($(pattern32),$(findstring $(pattern32), $(HW)))
MEXE=mexglx
MATLAB_LIB = $(MATLAB_ROOT)/bin/glnxa86
endif
endif
INSTALL_PATH?=$(INSTALL_MOCHA_LIBDIR)
OBJ_DIR= ${EPICS_HOST_ARCH}/$(MATLAB_VERSION)
INCLUDEPATH_MOCHA += -I$(MATLAB_ROOT)/extern/include \
-I$(CAFE_CPP_BASE)/include -I./ \
-I$(EPICS_BASE)/include -I$(EPICS_BASE)/include/os/Linux
INCLUDEPATH_MACHINETTA += $(INCLUDEPATH_MOCHA) -I$(BOOST_BASE) -I$(BOOST_BASE)/boost
LIB_DIR += \
-L$(EPICS_BASE)/lib/${EPICS_HOST_ARCH} \
-Wl,-rpath,$(EPICS_BASE)/lib/${EPICS_HOST_ARCH} \
-L$(MATLAB_LIB) -Wl,-rpath,$(MATLAB_LIB)
#-lboost_system -lboost_thread-mt
LIBS += -ldl -lca -lCom -lmx -lmex -lmat
LIB_INSTALL = $(LIB_DIR) -L$(INSTALL_PATH) -Wl,-rpath,$(INSTALL_PATH)
LIB_LOCAL = $(LIB_DIR)
CPP_OBJS=../cpp/src/libs/cafe/$(CAFE_VERSION_M)
#CAFE_OBJS_DIR = $(CPP_OBJS)/cafe.o $(CPP_OBJS)/cafeCache.o $(CPP_OBJS)/cafeGroup.o $(CPP_OBJS)/cafeVectors.o \
# $(CPP_OBJS)/cafeXML.o $(CPP_OBJS)/callbackHandlerCreate.o $(CPP_OBJS)/callbackHandlerMonitor.o \
# $(CPP_OBJS)/conduitGroup.o $(CPP_OBJS)/conduit.o \
# $(CPP_OBJS)/connectCallbacks.o $(CPP_OBJS)/connectGroup.o \
# $(CPP_OBJS)/connect.o $(CPP_OBJS)/exceptionsHelper.o $(CPP_OBJS)/granules.o $(CPP_OBJS)/handleHelper.o \
# $(CPP_OBJS)/helper.o \
# $(CPP_OBJS)/loadCollectionXMLParser.o $(CPP_OBJS)/loadGroupXMLParser.o $(CPP_OBJS)/methodCallbacks.o \
# $(CPP_OBJS)/policyHelper.o \
# $(CPP_OBJS)/restorePVGroupXMLParser.o $(CPP_OBJS)/transpose.o
CAFE_OBJS_DIR = $(CAFE_BASE)/cpp/$(CAFE_VERSION)/lib/libcafe.a
# MATLAB Versions 2014 onwards, use
# LDFLAGS='$(LIB_LOCAL) $(LIBS) instead of $(LIB_LOCAL) $(LIBS)
# LDFLAGS='$(LIB_LOCAL) $(LIBS) instead of $(LIB_INSTALL) $(LIBS)
$(OBJ_DIR)/mocha.$(MEXE): mocha.cpp $(OBJ_DIR)/macchinettaSwitch.o
mex -largeArrayDims CXXFLAGS='-v -largeArrayDims -ansi -fexceptions -fPIC -fno-omit-frame-pointer -pthread' \
mocha.cpp $(OBJ_DIR)/macchinettaSwitch.o $(CAFE_OBJS_DIR) -outdir $(OBJ_DIR) -output mocha.$(MEXE) \
$(INCLUDEPATH_MOCHA) \
LDFLAGS='$(LIB_LOCAL) $(LIBS)'
#$(OBJ_DIR)/libmacchinetta.so: $(OBJ_DIR)/macchinettaSwitch.o
# g++ -shared -Wl,-soname,libmacchinetta.so \
# $(OBJ_DIR)/macchinettaSwitch.o -o $(OBJ_DIR)/libmacchinetta.so
$(OBJ_DIR)/macchinettaSwitch.o: macchinettaSwitch.cpp macchinettaHelper.h \
macchinetta.h containerMochaccino.h
mex CXXFLAGS='-v -largeArrayDims -ansi -fexceptions -fPIC -fno-omit-frame-pointer -pthread' \
-c macchinettaSwitch.cpp $(INCLUDEPATH_MACHINETTA) -outdir $(OBJ_DIR)
install: $(OBJ_DIR)/mocha.$(MEXE)
mkdir -p $(INSTALL_PATH)
mex CXXFLAGS='-v -largeArrayDims -ansi -fexceptions -fPIC -fno-omit-frame-pointer -pthread' \
mocha.cpp $(OBJ_DIR)/macchinettaSwitch.o $(CAFE_OBJS_DIR) -outdir $(INSTALL_PATH) -output mocha.$(MEXE) \
$(INCLUDEPATH_MOCHA) \
LDFLAGS='$(LIB_INSTALL) $(LIBS)'
cp example.m $(INSTALL_PATH)
cp scripts/monitorAction.m $(INSTALL_PATH)
cp scripts/pvtable.m $(INSTALL_PATH)
cp scripts/test.xml $(INSTALL_PATH)
install_lib: $(OBJ_DIR)/libmacchinetta.so
mkdir -p $(INSTALL_PATH)
cp $(OBJ_DIR)/libmacchinetta.so $(INSTALL_PATH)
clean:
rm -f $(OBJ_DIR)/*.o $(OBJ_DIR)/*.so $(OBJ_DIR)/*.$(MEXE)

View File

@@ -0,0 +1,105 @@
#
# Jan Chrin
# Version: July 2019 - Qt5
#
# makefile to build mocha mex file
# printenv | grep MATLAB to reveal your MATLAB Directory
#
#
# local executables are built in ./${EPICS_HOST_ARCH}/$(MVER)
# where the MATLAB version is grepped from $(MATLAB)
MATLAB_ROOT=${MATLAB}
MATLAB_VERSION=$(notdir $(MATLAB_ROOT))
##### CHANGE AS APPROPRIATE #################
#Mocha Version to install
MOCHA_VERSION=mocha-1.20.1-gcc-10.4.0
#CAFE version to link to
CAFE_VERSION=cafe-1.20.1-gcc-10.4.0
EPICS_BASE=${EPICS}/base-7.0.7
#CAFE project base
CAFE_BASE=/opt/gfa/cafe
CAFE_MOCHA_BASE=${CAFE_BASE}/mocha
CAFE_CPP_BASE=$(CAFE_BASE)/cpp/$(CAFE_VERSION)
BOOST_BASE=${CAFE_BASE}/boost/boost_1_61_0/include
CAFE_OBJS_DIR = $(CAFE_BASE)/cpp/$(CAFE_VERSION)/lib/$(EPICS_HOST_ARCH)/libcafe.a
#if qt5 has libQt5Core.so link
#QT5_DIR= /opt/psi/Cafe/cafe-matlab/${MATLAB_VERSION}/libexec
QT5_DIR= ${MATLAB_ROOT}/bin/glnxa64
INSTALL_MOCHA_LIBDIR= $(CAFE_MOCHA_BASE)/$(MOCHA_VERSION)/lib/$(EPICS_HOST_ARCH)/$(MATLAB_VERSION)
#############################################
#First deteremine if we are on a 32/64 bit machine
#as mex file extensions are named differently
pattern64=x86_64
pattern32=i386
PWD=$(shell pwd)
#hardware platform
HW=$(shell uname -i)
ifeq ($(pattern64),$(findstring $(pattern64), $(HW)))
MEXE=mexa64
MATLAB_LIB = $(MATLAB_ROOT)/bin/glnxa64
else
ifeq ($(pattern32),$(findstring $(pattern32), $(HW)))
MEXE=mexglx
MATLAB_LIB = $(MATLAB_ROOT)/bin/glnxa86
endif
endif
INSTALL_PATH?=$(INSTALL_MOCHA_LIBDIR)
OBJ_DIR= ${EPICS_HOST_ARCH}/$(MATLAB_VERSION)
INCLUDEPATH_MOCHA += -I$(MATLAB_ROOT)/extern/include \
-I$(CAFE_CPP_BASE)/include -I./ \
-I$(EPICS_BASE)/include -I$(EPICS_BASE)/include/os/Linux \
-I$(EPICS_BASE)/include/compiler/gcc
INCLUDEPATH_MACHINETTA += $(INCLUDEPATH_MOCHA) -I$(BOOST_BASE) -I$(BOOST_BASE)/boost
# linkage to qt5 required if cafe built with Qt5
#-lboost_system -lboost_thread-mt
LIBS += -ldl -lca -lCom -lmx -lmex -lmat -lQt5Core -lQt5Xml
#LIBS += -lmx -lmex -lmat
$(OBJ_DIR)/mocha.$(MEXE): mocha.cpp $(OBJ_DIR)/macchinettaSwitch.o
mex CXXFLAGS='$(CXXFLAGS) -v -largeArrayDims -ansi -fexceptions -fPIC -fno-omit-frame-pointer -pthread -std=c++1z' \
'LDFLAGS=-L$(EPICS_BASE)/lib/${EPICS_HOST_ARCH} -Wl,-rpath,$(EPICS_BASE)/lib/${EPICS_HOST_ARCH} -L${QT5_DIR} -Wl,-rpath,${QT5_DIR} -L$(MATLAB_LIB) -Wl,-rpath,$(MATLAB_LIB) $(LIBS)' \
mocha.cpp $(OBJ_DIR)/macchinettaSwitch.o $(CAFE_OBJS_DIR) \
-outdir $(OBJ_DIR) -output mocha.$(MEXE) \
$(INCLUDEPATH_MOCHA)
cp example.m $(OBJ_DIR)
cp scripts/*.m $(OBJ_DIR)
cp scripts/test.xml $(OBJ_DIR)
$(OBJ_DIR)/macchinettaSwitch.o: macchinettaSwitch.cpp macchinettaHelper.h \
macchinetta.h containerMochaccino.h
mex CXXFLAGS='-v -largeArrayDims -ansi -fexceptions -fPIC -fno-omit-frame-pointer -pthread -std=c++1z' \
-c macchinettaSwitch.cpp $(INCLUDEPATH_MACHINETTA) 'LDFLAGS=-L$(EPICS_BASE)/lib/${EPICS_HOST_ARCH} -Wl,-rpath,$(EPICS_BASE)/lib/${EPICS_HOST_ARCH} -L$(MATLAB_LIB) -Wl,-rpath,$(MATLAB_LIB) $(LIBS)' -outdir $(OBJ_DIR)
install: $(OBJ_DIR)/mocha.$(MEXE)
mkdir -p $(INSTALL_PATH)
mex CXXFLAGS='-v -largeArrayDims -ansi -fexceptions -fPIC -fno-omit-frame-pointer -pthread -std=c++1z' \
mocha.cpp $(OBJ_DIR)/macchinettaSwitch.o $(CAFE_OBJS_DIR) -outdir $(INSTALL_PATH) -output mocha.$(MEXE) $(INCLUDEPATH_MOCHA) \
'LDFLAGS=-L$(EPICS_BASE)/lib/${EPICS_HOST_ARCH} -Wl,-rpath,$(EPICS_BASE)/lib/${EPICS_HOST_ARCH} -L$(MATLAB_LIB) -Wl,-rpath,$(MATLAB_LIB) $(LIBS)'
cp example.m $(INSTALL_PATH)
cp scripts/*.m $(INSTALL_PATH)
cp scripts/test.xml $(INSTALL_PATH)
install_lib: $(OBJ_DIR)/libmacchinetta.so
mkdir -p $(INSTALL_PATH)
cp $(OBJ_DIR)/libmacchinetta.so $(INSTALL_PATH)
clean:
rm -f $(OBJ_DIR)/*.o $(OBJ_DIR)/*.so $(OBJ_DIR)/*.$(MEXE)
print-% : ; @echo $* = $($*)

104
makefile_rel_1.20-gcc-4.7.4 Normal file
View File

@@ -0,0 +1,104 @@
#
# Jan Chrin
# Version: July 2019 - Qt5
#
# makefile to build mocha mex file
# printenv | grep MATLAB to reveal your MATLAB Directory
#
#
# local executables are built in ./${EPICS_HOST_ARCH}/$(MVER)
# where the MATLAB version is grepped from $(MATLAB)
MATLAB_ROOT=${MATLAB}
MATLAB_VERSION=$(notdir $(MATLAB_ROOT))
##### CHANGE AS APPROPRIATE #################
#Mocha Version to install
MOCHA_VERSION=mocha-1.20.1-gcc-4.7.4
#CAFE version to link to
CAFE_VERSION=cafe-1.20.1-gcc-7.3.0
EPICS_BASE=${EPICS}/base-7.0.7
#CAFE project base
CAFE_BASE=/opt/gfa/cafe
CAFE_MOCHA_BASE=${CAFE_BASE}/mocha
CAFE_CPP_BASE=$(CAFE_BASE)/cpp/$(CAFE_VERSION)
BOOST_BASE=${CAFE_BASE}/boost/boost_1_61_0/include
CAFE_OBJS_DIR = $(CAFE_BASE)/cpp/$(CAFE_VERSION)/lib/$(EPICS_HOST_ARCH)/libcafe.a
#if qt5 has libQt5Core.so link
#QT5_DIR= /opt/psi/Cafe/cafe-matlab/${MATLAB_VERSION}/libexec
QT5_DIR= ${MATLAB_ROOT}/bin/glnxa64
INSTALL_MOCHA_LIBDIR= $(CAFE_MOCHA_BASE)/$(MOCHA_VERSION)/lib/$(EPICS_HOST_ARCH)/$(MATLAB_VERSION)
#############################################
#First deteremine if we are on a 32/64 bit machine
#as mex file extensions are named differently
pattern64=x86_64
pattern32=i386
PWD=$(shell pwd)
#hardware platform
HW=$(shell uname -i)
ifeq ($(pattern64),$(findstring $(pattern64), $(HW)))
MEXE=mexa64
MATLAB_LIB = $(MATLAB_ROOT)/bin/glnxa64
else
ifeq ($(pattern32),$(findstring $(pattern32), $(HW)))
MEXE=mexglx
MATLAB_LIB = $(MATLAB_ROOT)/bin/glnxa86
endif
endif
INSTALL_PATH?=$(INSTALL_MOCHA_LIBDIR)
OBJ_DIR= ${EPICS_HOST_ARCH}/$(MATLAB_VERSION)
INCLUDEPATH_MOCHA += -I$(MATLAB_ROOT)/extern/include \
-I$(CAFE_CPP_BASE)/include -I./ \
-I$(EPICS_BASE)/include -I$(EPICS_BASE)/include/os/Linux \
-I$(EPICS_BASE)/include/compiler/gcc
INCLUDEPATH_MACHINETTA += $(INCLUDEPATH_MOCHA) -I$(BOOST_BASE) -I$(BOOST_BASE)/boost
# linkage to qt5 required if cafe built with Qt5
#-lboost_system -lboost_thread-mt
LIBS += -ldl -lca -lCom -lmx -lmex -lmat -lQt5Core -lQt5Xml
#LIBS += -lmx -lmex -lmat
$(OBJ_DIR)/mocha.$(MEXE): mocha.cpp $(OBJ_DIR)/macchinettaSwitch.o
mex CXXFLAGS='$(CXXFLAGS) -v -largeArrayDims -ansi -fexceptions -fPIC -fno-omit-frame-pointer -pthread -std=c++1z' \
'LDFLAGS=-L$(EPICS_BASE)/lib/${EPICS_HOST_ARCH} -Wl,-rpath,$(EPICS_BASE)/lib/${EPICS_HOST_ARCH} -L${QT5_DIR} -Wl,-rpath,${QT5_DIR} -L$(MATLAB_LIB) -Wl,-rpath,$(MATLAB_LIB) $(LIBS)' \
mocha.cpp $(OBJ_DIR)/macchinettaSwitch.o $(CAFE_OBJS_DIR) \
-outdir $(OBJ_DIR) -output mocha.$(MEXE) \
$(INCLUDEPATH_MOCHA)
$(OBJ_DIR)/macchinettaSwitch.o: macchinettaSwitch.cpp macchinettaHelper.h \
macchinetta.h containerMochaccino.h
mex CXXFLAGS='-v -largeArrayDims -ansi -fexceptions -fPIC -fno-omit-frame-pointer -pthread -std=c++1z' \
-c macchinettaSwitch.cpp $(INCLUDEPATH_MACHINETTA) 'LDFLAGS=-L$(EPICS_BASE)/lib/${EPICS_HOST_ARCH} -Wl,-rpath,$(EPICS_BASE)/lib/${EPICS_HOST_ARCH} -L$(MATLAB_LIB) -Wl,-rpath,$(MATLAB_LIB) $(LIBS)' -outdir $(OBJ_DIR)
install: $(OBJ_DIR)/mocha.$(MEXE)
mkdir -p $(INSTALL_PATH)
mex CXXFLAGS='-v -largeArrayDims -ansi -fexceptions -fPIC -fno-omit-frame-pointer -pthread -std=c++1z' \
mocha.cpp $(OBJ_DIR)/macchinettaSwitch.o $(CAFE_OBJS_DIR) -outdir $(INSTALL_PATH) -output mocha.$(MEXE) $(INCLUDEPATH_MOCHA) \
'LDFLAGS=-L$(EPICS_BASE)/lib/${EPICS_HOST_ARCH} -Wl,-rpath,$(EPICS_BASE)/lib/${EPICS_HOST_ARCH} -L$(MATLAB_LIB) -Wl,-rpath,$(MATLAB_LIB) $(LIBS)'
cp example.m $(INSTALL_PATH)
cp scripts/monitorAction.m $(INSTALL_PATH)
cp scripts/pvtable.m $(INSTALL_PATH)
cp scripts/test.xml $(INSTALL_PATH)
install_lib: $(OBJ_DIR)/libmacchinetta.so
mkdir -p $(INSTALL_PATH)
cp $(OBJ_DIR)/libmacchinetta.so $(INSTALL_PATH)
clean:
rm -f $(OBJ_DIR)/*.o $(OBJ_DIR)/*.so $(OBJ_DIR)/*.$(MEXE)
print-% : ; @echo $* = $($*)

103
makefile_rel_1.20-gcc-7.3.0 Normal file
View File

@@ -0,0 +1,103 @@
#
# Jan Chrin
# Version: July 2019 - Qt5
#
# makefile to build mocha mex file
# printenv | grep MATLAB to reveal your MATLAB Directory
#
#
# local executables are built in ./${EPICS_HOST_ARCH}/$(MVER)
# where the MATLAB version is grepped from $(MATLAB)
MATLAB_ROOT=${MATLAB}
MATLAB_VERSION=$(notdir $(MATLAB_ROOT))
##### CHANGE AS APPROPRIATE #################
#Mocha Version to install
MOCHA_VERSION=mocha-1.20.1-gcc-7.3.0
#CAFE version to link to
CAFE_VERSION=cafe-1.20.1-gcc-7.3.0
EPICS_BASE=${EPICS}/base-7.0.7
#CAFE project base
CAFE_BASE=/opt/gfa/cafe
CAFE_MOCHA_BASE=${CAFE_BASE}/mocha
CAFE_CPP_BASE=$(CAFE_BASE)/cpp/$(CAFE_VERSION)
BOOST_BASE=${CAFE_BASE}/boost/boost_1_61_0/include
CAFE_OBJS_DIR = $(CAFE_BASE)/cpp/$(CAFE_VERSION)/lib/$(EPICS_HOST_ARCH)/libcafe.a
#if qt5 has libQt5Core.so link
#QT5_DIR= /opt/psi/Cafe/cafe-matlab/${MATLAB_VERSION}/libexec
QT5_DIR= ${MATLAB_ROOT}/bin/glnxa64
INSTALL_MOCHA_LIBDIR= $(CAFE_MOCHA_BASE)/$(MOCHA_VERSION)/lib/$(EPICS_HOST_ARCH)/$(MATLAB_VERSION)
#############################################
#First deteremine if we are on a 32/64 bit machine
#as mex file extensions are named differently
pattern64=x86_64
pattern32=i386
PWD=$(shell pwd)
#hardware platform
HW=$(shell uname -i)
ifeq ($(pattern64),$(findstring $(pattern64), $(HW)))
MEXE=mexa64
MATLAB_LIB = $(MATLAB_ROOT)/bin/glnxa64
else
ifeq ($(pattern32),$(findstring $(pattern32), $(HW)))
MEXE=mexglx
MATLAB_LIB = $(MATLAB_ROOT)/bin/glnxa86
endif
endif
INSTALL_PATH?=$(INSTALL_MOCHA_LIBDIR)
OBJ_DIR= ${EPICS_HOST_ARCH}/$(MATLAB_VERSION)
INCLUDEPATH_MOCHA += -I$(MATLAB_ROOT)/extern/include \
-I$(CAFE_CPP_BASE)/include -I./ \
-I$(EPICS_BASE)/include -I$(EPICS_BASE)/include/os/Linux \
-I$(EPICS_BASE)/include/compiler/gcc
INCLUDEPATH_MACHINETTA += $(INCLUDEPATH_MOCHA) -I$(BOOST_BASE) -I$(BOOST_BASE)/boost
# linkage to qt5 required if cafe built with Qt5
#-lboost_system -lboost_thread-mt
LIBS += -ldl -lca -lCom -lmx -lmex -lmat -lQt5Core -lQt5Xml
#LIBS += -lmx -lmex -lmat
$(OBJ_DIR)/mocha.$(MEXE): mocha.cpp $(OBJ_DIR)/macchinettaSwitch.o
mex CXXFLAGS='$(CXXFLAGS) -v -largeArrayDims -ansi -fexceptions -fPIC -fno-omit-frame-pointer -pthread -std=c++1z' \
'LDFLAGS=-L$(EPICS_BASE)/lib/${EPICS_HOST_ARCH} -Wl,-rpath,$(EPICS_BASE)/lib/${EPICS_HOST_ARCH} -L${QT5_DIR} -Wl,-rpath,${QT5_DIR} -L$(MATLAB_LIB) -Wl,-rpath,$(MATLAB_LIB) $(LIBS)' \
mocha.cpp $(OBJ_DIR)/macchinettaSwitch.o $(CAFE_OBJS_DIR) \
-outdir $(OBJ_DIR) -output mocha.$(MEXE) \
$(INCLUDEPATH_MOCHA)
$(OBJ_DIR)/macchinettaSwitch.o: macchinettaSwitch.cpp macchinettaHelper.h \
macchinetta.h containerMochaccino.h
mex CXXFLAGS='-v -largeArrayDims -ansi -fexceptions -fPIC -fno-omit-frame-pointer -pthread -std=c++1z' \
-c macchinettaSwitch.cpp $(INCLUDEPATH_MACHINETTA) 'LDFLAGS=-L$(EPICS_BASE)/lib/${EPICS_HOST_ARCH} -Wl,-rpath,$(EPICS_BASE)/lib/${EPICS_HOST_ARCH} -L$(MATLAB_LIB) -Wl,-rpath,$(MATLAB_LIB) $(LIBS)' -outdir $(OBJ_DIR)
install: $(OBJ_DIR)/mocha.$(MEXE)
mkdir -p $(INSTALL_PATH)
mex CXXFLAGS='-v -largeArrayDims -ansi -fexceptions -fPIC -fno-omit-frame-pointer -pthread -std=c++1z' \
mocha.cpp $(OBJ_DIR)/macchinettaSwitch.o $(CAFE_OBJS_DIR) -outdir $(INSTALL_PATH) -output mocha.$(MEXE) $(INCLUDEPATH_MOCHA) \
'LDFLAGS=-L$(EPICS_BASE)/lib/${EPICS_HOST_ARCH} -Wl,-rpath,$(EPICS_BASE)/lib/${EPICS_HOST_ARCH} -L$(MATLAB_LIB) -Wl,-rpath,$(MATLAB_LIB) $(LIBS)'
cp example.m $(INSTALL_PATH)
cp scripts/*.m $(INSTALL_PATH)
cp scripts/test.xml $(INSTALL_PATH)
install_lib: $(OBJ_DIR)/libmacchinetta.so
mkdir -p $(INSTALL_PATH)
cp $(OBJ_DIR)/libmacchinetta.so $(INSTALL_PATH)
clean:
rm -f $(OBJ_DIR)/*.o $(OBJ_DIR)/*.so $(OBJ_DIR)/*.$(MEXE)
print-% : ; @echo $* = $($*)

View File

@@ -0,0 +1,105 @@
#
# Jan Chrin
# Version: July 2019 - Qt5
#
# makefile to build mocha mex file
# printenv | grep MATLAB to reveal your MATLAB Directory
#
#
# local executables are built in ./${EPICS_HOST_ARCH}/$(MVER)
# where the MATLAB version is grepped from $(MATLAB)
MATLAB_ROOT=${MATLAB}
MATLAB_VERSION=$(notdir $(MATLAB_ROOT))
##### CHANGE AS APPROPRIATE #################
#Mocha Version to install
MOCHA_VERSION=mocha-1.21.0-gcc-10.4.0
#CAFE version to link to
CAFE_VERSION=cafe-1.21.0-gcc-10.4.0
EPICS_BASE=${EPICS}/base-7.0.8
#CAFE project base
CAFE_BASE=/opt/gfa/cafe
CAFE_MOCHA_BASE=${CAFE_BASE}/mocha
CAFE_CPP_BASE=$(CAFE_BASE)/cpp/$(CAFE_VERSION)
BOOST_BASE=${CAFE_BASE}/boost/boost_1_61_0/include
CAFE_OBJS_DIR = $(CAFE_BASE)/cpp/$(CAFE_VERSION)/lib/$(EPICS_HOST_ARCH)/libcafe.a
#if qt5 has libQt5Core.so link
#QT5_DIR= /opt/psi/Cafe/cafe-matlab/${MATLAB_VERSION}/libexec
QT5_DIR= ${MATLAB_ROOT}/bin/glnxa64
INSTALL_MOCHA_LIBDIR= $(CAFE_MOCHA_BASE)/$(MOCHA_VERSION)/lib/$(EPICS_HOST_ARCH)/$(MATLAB_VERSION)
#############################################
#First deteremine if we are on a 32/64 bit machine
#as mex file extensions are named differently
pattern64=x86_64
pattern32=i386
PWD=$(shell pwd)
#hardware platform
HW=$(shell uname -i)
ifeq ($(pattern64),$(findstring $(pattern64), $(HW)))
MEXE=mexa64
MATLAB_LIB = $(MATLAB_ROOT)/bin/glnxa64
else
ifeq ($(pattern32),$(findstring $(pattern32), $(HW)))
MEXE=mexglx
MATLAB_LIB = $(MATLAB_ROOT)/bin/glnxa86
endif
endif
INSTALL_PATH?=$(INSTALL_MOCHA_LIBDIR)
OBJ_DIR= ${EPICS_HOST_ARCH}/$(MATLAB_VERSION)
INCLUDEPATH_MOCHA += -I$(MATLAB_ROOT)/extern/include \
-I$(CAFE_CPP_BASE)/include -I./ \
-I$(EPICS_BASE)/include -I$(EPICS_BASE)/include/os/Linux \
-I$(EPICS_BASE)/include/compiler/gcc
INCLUDEPATH_MACHINETTA += $(INCLUDEPATH_MOCHA) -I$(BOOST_BASE) -I$(BOOST_BASE)/boost
# linkage to qt5 required if cafe built with Qt5
#-lboost_system -lboost_thread-mt
LIBS += -ldl -lca -lCom -lmx -lmex -lmat -lQt5Core -lQt5Xml
#LIBS += -lmx -lmex -lmat
$(OBJ_DIR)/mocha.$(MEXE): mocha.cpp $(OBJ_DIR)/macchinettaSwitch.o
mex CXXFLAGS='$(CXXFLAGS) -v -largeArrayDims -ansi -fexceptions -fPIC -fno-omit-frame-pointer -pthread -std=c++1z' \
'LDFLAGS=-L$(EPICS_BASE)/lib/${EPICS_HOST_ARCH} -Wl,-rpath,$(EPICS_BASE)/lib/${EPICS_HOST_ARCH} -L${QT5_DIR} -Wl,-rpath,${QT5_DIR} -L$(MATLAB_LIB) -Wl,-rpath,$(MATLAB_LIB) $(LIBS)' \
mocha.cpp $(OBJ_DIR)/macchinettaSwitch.o $(CAFE_OBJS_DIR) \
-outdir $(OBJ_DIR) -output mocha.$(MEXE) \
$(INCLUDEPATH_MOCHA)
cp example.m $(OBJ_DIR)
cp scripts/*.m $(OBJ_DIR)
cp scripts/test.xml $(OBJ_DIR)
$(OBJ_DIR)/macchinettaSwitch.o: macchinettaSwitch.cpp macchinettaHelper.h \
macchinetta.h containerMochaccino.h
mex CXXFLAGS='-v -largeArrayDims -ansi -fexceptions -fPIC -fno-omit-frame-pointer -pthread -std=c++1z' \
-c macchinettaSwitch.cpp $(INCLUDEPATH_MACHINETTA) 'LDFLAGS=-L$(EPICS_BASE)/lib/${EPICS_HOST_ARCH} -Wl,-rpath,$(EPICS_BASE)/lib/${EPICS_HOST_ARCH} -L$(MATLAB_LIB) -Wl,-rpath,$(MATLAB_LIB) $(LIBS)' -outdir $(OBJ_DIR)
install: $(OBJ_DIR)/mocha.$(MEXE)
mkdir -p $(INSTALL_PATH)
mex CXXFLAGS='-v -largeArrayDims -ansi -fexceptions -fPIC -fno-omit-frame-pointer -pthread -std=c++1z' \
mocha.cpp $(OBJ_DIR)/macchinettaSwitch.o $(CAFE_OBJS_DIR) -outdir $(INSTALL_PATH) -output mocha.$(MEXE) $(INCLUDEPATH_MOCHA) \
'LDFLAGS=-L$(EPICS_BASE)/lib/${EPICS_HOST_ARCH} -Wl,-rpath,$(EPICS_BASE)/lib/${EPICS_HOST_ARCH} -L$(MATLAB_LIB) -Wl,-rpath,$(MATLAB_LIB) $(LIBS)'
cp example.m $(INSTALL_PATH)
cp scripts/*.m $(INSTALL_PATH)
cp scripts/test.xml $(INSTALL_PATH)
install_lib: $(OBJ_DIR)/libmacchinetta.so
mkdir -p $(INSTALL_PATH)
cp $(OBJ_DIR)/libmacchinetta.so $(INSTALL_PATH)
clean:
rm -f $(OBJ_DIR)/*.o $(OBJ_DIR)/*.so $(OBJ_DIR)/*.$(MEXE)
print-% : ; @echo $* = $($*)

View File

@@ -0,0 +1,5 @@
module unload gcc
module load gcc/10.4.0
echo "$1"
action=$1
make -f makefile_rel_1.21-gcc-10.4.0 -s $action

105
makefile_rel_1.21-gcc-6.3.0 Normal file
View File

@@ -0,0 +1,105 @@
#
# Jan Chrin
# Version: July 2019 - Qt5
#
# makefile to build mocha mex file
# printenv | grep MATLAB to reveal your MATLAB Directory
#
#
# local executables are built in ./${EPICS_HOST_ARCH}/$(MVER)
# where the MATLAB version is grepped from $(MATLAB)
MATLAB_ROOT=${MATLAB}
MATLAB_VERSION=$(notdir $(MATLAB_ROOT))
##### CHANGE AS APPROPRIATE #################
#Mocha Version to install
MOCHA_VERSION=mocha-1.21.0-gcc-6.3.0
#CAFE version to link to
CAFE_VERSION=cafe-1.21.0-gcc-6.3.0
EPICS_BASE=${EPICS}/base-7.0.8
#CAFE project base
CAFE_BASE=/opt/gfa/cafe
CAFE_MOCHA_BASE=${CAFE_BASE}/mocha
CAFE_CPP_BASE=$(CAFE_BASE)/cpp/$(CAFE_VERSION)
BOOST_BASE=${CAFE_BASE}/boost/boost_1_61_0/include
CAFE_OBJS_DIR = $(CAFE_BASE)/cpp/$(CAFE_VERSION)/lib/$(EPICS_HOST_ARCH)/libcafe.a
#if qt5 has libQt5Core.so link
#QT5_DIR= /opt/psi/Cafe/cafe-matlab/${MATLAB_VERSION}/libexec
QT5_DIR= ${MATLAB_ROOT}/bin/glnxa64
INSTALL_MOCHA_LIBDIR= $(CAFE_MOCHA_BASE)/$(MOCHA_VERSION)/lib/$(EPICS_HOST_ARCH)/$(MATLAB_VERSION)
#############################################
#First deteremine if we are on a 32/64 bit machine
#as mex file extensions are named differently
pattern64=x86_64
pattern32=i386
PWD=$(shell pwd)
#hardware platform
HW=$(shell uname -i)
ifeq ($(pattern64),$(findstring $(pattern64), $(HW)))
MEXE=mexa64
MATLAB_LIB = $(MATLAB_ROOT)/bin/glnxa64
else
ifeq ($(pattern32),$(findstring $(pattern32), $(HW)))
MEXE=mexglx
MATLAB_LIB = $(MATLAB_ROOT)/bin/glnxa86
endif
endif
INSTALL_PATH?=$(INSTALL_MOCHA_LIBDIR)
OBJ_DIR= ${EPICS_HOST_ARCH}/$(MATLAB_VERSION)
INCLUDEPATH_MOCHA += -I$(MATLAB_ROOT)/extern/include \
-I$(CAFE_CPP_BASE)/include -I./ \
-I$(EPICS_BASE)/include -I$(EPICS_BASE)/include/os/Linux \
-I$(EPICS_BASE)/include/compiler/gcc
INCLUDEPATH_MACHINETTA += $(INCLUDEPATH_MOCHA) -I$(BOOST_BASE) -I$(BOOST_BASE)/boost
# linkage to qt5 required if cafe built with Qt5
#-lboost_system -lboost_thread-mt
LIBS += -ldl -lca -lCom -lmx -lmex -lmat -lQt5Core -lQt5Xml
#LIBS += -lmx -lmex -lmat
$(OBJ_DIR)/mocha.$(MEXE): mocha.cpp $(OBJ_DIR)/macchinettaSwitch.o
mex CXXFLAGS='$(CXXFLAGS) -v -largeArrayDims -ansi -fexceptions -fPIC -fno-omit-frame-pointer -pthread -std=c++1z' \
'LDFLAGS=-L$(EPICS_BASE)/lib/${EPICS_HOST_ARCH} -Wl,-rpath,$(EPICS_BASE)/lib/${EPICS_HOST_ARCH} -L${QT5_DIR} -Wl,-rpath,${QT5_DIR} -L$(MATLAB_LIB) -Wl,-rpath,$(MATLAB_LIB) $(LIBS)' \
mocha.cpp $(OBJ_DIR)/macchinettaSwitch.o $(CAFE_OBJS_DIR) \
-outdir $(OBJ_DIR) -output mocha.$(MEXE) \
$(INCLUDEPATH_MOCHA)
cp example.m $(OBJ_DIR)
cp scripts/*.m $(OBJ_DIR)
cp scripts/test.xml $(OBJ_DIR)
$(OBJ_DIR)/macchinettaSwitch.o: macchinettaSwitch.cpp macchinettaHelper.h \
macchinetta.h containerMochaccino.h
mex CXXFLAGS='-v -largeArrayDims -ansi -fexceptions -fPIC -fno-omit-frame-pointer -pthread -std=c++1z' \
-c macchinettaSwitch.cpp $(INCLUDEPATH_MACHINETTA) 'LDFLAGS=-L$(EPICS_BASE)/lib/${EPICS_HOST_ARCH} -Wl,-rpath,$(EPICS_BASE)/lib/${EPICS_HOST_ARCH} -L$(MATLAB_LIB) -Wl,-rpath,$(MATLAB_LIB) $(LIBS)' -outdir $(OBJ_DIR)
install: $(OBJ_DIR)/mocha.$(MEXE)
mkdir -p $(INSTALL_PATH)
mex CXXFLAGS='-v -largeArrayDims -ansi -fexceptions -fPIC -fno-omit-frame-pointer -pthread -std=c++1z' \
mocha.cpp $(OBJ_DIR)/macchinettaSwitch.o $(CAFE_OBJS_DIR) -outdir $(INSTALL_PATH) -output mocha.$(MEXE) $(INCLUDEPATH_MOCHA) \
'LDFLAGS=-L$(EPICS_BASE)/lib/${EPICS_HOST_ARCH} -Wl,-rpath,$(EPICS_BASE)/lib/${EPICS_HOST_ARCH} -L$(MATLAB_LIB) -Wl,-rpath,$(MATLAB_LIB) $(LIBS)'
cp example.m $(INSTALL_PATH)
cp scripts/*.m $(INSTALL_PATH)
cp scripts/test.xml $(INSTALL_PATH)
install_lib: $(OBJ_DIR)/libmacchinetta.so
mkdir -p $(INSTALL_PATH)
cp $(OBJ_DIR)/libmacchinetta.so $(INSTALL_PATH)
clean:
rm -f $(OBJ_DIR)/*.o $(OBJ_DIR)/*.so $(OBJ_DIR)/*.$(MEXE)
print-% : ; @echo $* = $($*)

View File

@@ -0,0 +1,5 @@
module unload gcc
module load gcc/6.3.0
echo "$1"
action=$1
make -f makefile_rel_1.21-gcc-6.3.0 -s $action

105
makefile_rel_1.21-gcc-6.4.0 Normal file
View File

@@ -0,0 +1,105 @@
#
# Jan Chrin
# Version: July 2019 - Qt5
#
# makefile to build mocha mex file
# printenv | grep MATLAB to reveal your MATLAB Directory
#
#
# local executables are built in ./${EPICS_HOST_ARCH}/$(MVER)
# where the MATLAB version is grepped from $(MATLAB)
MATLAB_ROOT=${MATLAB}
MATLAB_VERSION=$(notdir $(MATLAB_ROOT))
##### CHANGE AS APPROPRIATE #################
#Mocha Version to install
MOCHA_VERSION=mocha-1.21.0-gcc-6.3.0
#CAFE version to link to
CAFE_VERSION=cafe-1.21.0-gcc-6.3.0
EPICS_BASE=${EPICS}/base-7.0.8
#CAFE project base
CAFE_BASE=/opt/gfa/cafe
CAFE_MOCHA_BASE=${CAFE_BASE}/mocha
CAFE_CPP_BASE=$(CAFE_BASE)/cpp/$(CAFE_VERSION)
BOOST_BASE=${CAFE_BASE}/boost/boost_1_61_0/include
CAFE_OBJS_DIR = $(CAFE_BASE)/cpp/$(CAFE_VERSION)/lib/$(EPICS_HOST_ARCH)/libcafe.a
#if qt5 has libQt5Core.so link
#QT5_DIR= /opt/psi/Cafe/cafe-matlab/${MATLAB_VERSION}/libexec
QT5_DIR= ${MATLAB_ROOT}/bin/glnxa64
INSTALL_MOCHA_LIBDIR= $(CAFE_MOCHA_BASE)/$(MOCHA_VERSION)/lib/$(EPICS_HOST_ARCH)/$(MATLAB_VERSION)
#############################################
#First deteremine if we are on a 32/64 bit machine
#as mex file extensions are named differently
pattern64=x86_64
pattern32=i386
PWD=$(shell pwd)
#hardware platform
HW=$(shell uname -i)
ifeq ($(pattern64),$(findstring $(pattern64), $(HW)))
MEXE=mexa64
MATLAB_LIB = $(MATLAB_ROOT)/bin/glnxa64
else
ifeq ($(pattern32),$(findstring $(pattern32), $(HW)))
MEXE=mexglx
MATLAB_LIB = $(MATLAB_ROOT)/bin/glnxa86
endif
endif
INSTALL_PATH?=$(INSTALL_MOCHA_LIBDIR)
OBJ_DIR= ${EPICS_HOST_ARCH}/$(MATLAB_VERSION)
INCLUDEPATH_MOCHA += -I$(MATLAB_ROOT)/extern/include \
-I$(CAFE_CPP_BASE)/include -I./ \
-I$(EPICS_BASE)/include -I$(EPICS_BASE)/include/os/Linux \
-I$(EPICS_BASE)/include/compiler/gcc
INCLUDEPATH_MACHINETTA += $(INCLUDEPATH_MOCHA) -I$(BOOST_BASE) -I$(BOOST_BASE)/boost
# linkage to qt5 required if cafe built with Qt5
#-lboost_system -lboost_thread-mt
LIBS += -ldl -lca -lCom -lmx -lmex -lmat -lQt5Core -lQt5Xml
#LIBS += -lmx -lmex -lmat
$(OBJ_DIR)/mocha.$(MEXE): mocha.cpp $(OBJ_DIR)/macchinettaSwitch.o
mex CXXFLAGS='$(CXXFLAGS) -v -largeArrayDims -ansi -fexceptions -fPIC -fno-omit-frame-pointer -pthread -std=c++1z' \
'LDFLAGS=-L$(EPICS_BASE)/lib/${EPICS_HOST_ARCH} -Wl,-rpath,$(EPICS_BASE)/lib/${EPICS_HOST_ARCH} -L${QT5_DIR} -Wl,-rpath,${QT5_DIR} -L$(MATLAB_LIB) -Wl,-rpath,$(MATLAB_LIB) $(LIBS)' \
mocha.cpp $(OBJ_DIR)/macchinettaSwitch.o $(CAFE_OBJS_DIR) \
-outdir $(OBJ_DIR) -output mocha.$(MEXE) \
$(INCLUDEPATH_MOCHA)
cp example.m $(OBJ_DIR)
cp scripts/*.m $(OBJ_DIR)
cp scripts/test.xml $(OBJ_DIR)
$(OBJ_DIR)/macchinettaSwitch.o: macchinettaSwitch.cpp macchinettaHelper.h \
macchinetta.h containerMochaccino.h
mex CXXFLAGS='-v -largeArrayDims -ansi -fexceptions -fPIC -fno-omit-frame-pointer -pthread -std=c++1z' \
-c macchinettaSwitch.cpp $(INCLUDEPATH_MACHINETTA) 'LDFLAGS=-L$(EPICS_BASE)/lib/${EPICS_HOST_ARCH} -Wl,-rpath,$(EPICS_BASE)/lib/${EPICS_HOST_ARCH} -L$(MATLAB_LIB) -Wl,-rpath,$(MATLAB_LIB) $(LIBS)' -outdir $(OBJ_DIR)
install: $(OBJ_DIR)/mocha.$(MEXE)
mkdir -p $(INSTALL_PATH)
mex CXXFLAGS='-v -largeArrayDims -ansi -fexceptions -fPIC -fno-omit-frame-pointer -pthread -std=c++1z' \
mocha.cpp $(OBJ_DIR)/macchinettaSwitch.o $(CAFE_OBJS_DIR) -outdir $(INSTALL_PATH) -output mocha.$(MEXE) $(INCLUDEPATH_MOCHA) \
'LDFLAGS=-L$(EPICS_BASE)/lib/${EPICS_HOST_ARCH} -Wl,-rpath,$(EPICS_BASE)/lib/${EPICS_HOST_ARCH} -L$(MATLAB_LIB) -Wl,-rpath,$(MATLAB_LIB) $(LIBS)'
cp example.m $(INSTALL_PATH)
cp scripts/*.m $(INSTALL_PATH)
cp scripts/test.xml $(INSTALL_PATH)
install_lib: $(OBJ_DIR)/libmacchinetta.so
mkdir -p $(INSTALL_PATH)
cp $(OBJ_DIR)/libmacchinetta.so $(INSTALL_PATH)
clean:
rm -f $(OBJ_DIR)/*.o $(OBJ_DIR)/*.so $(OBJ_DIR)/*.$(MEXE)
print-% : ; @echo $* = $($*)

Some files were not shown because too many files have changed in this diff Show More