Initial commit

This commit is contained in:
2017-09-19 11:58:36 +02:00
commit 557bbb0eae
66 changed files with 12510 additions and 0 deletions

4
.gitignore vendored Normal file
View File

@@ -0,0 +1,4 @@
*~
*.bak
SL6-x86_64
felix-cache

59
MakefileWin/Makefile Normal file
View File

@@ -0,0 +1,59 @@
MATLAB_ROOT=C:\Program Files\MATLAB\R2016b_x64
MEXE=mexw64
empty:=
s? = $(subst $(empty) ,?,$1)
?s = $(subst ?, ,$1)
notdirx = $(call ?s,$(notdir $(call s?,$1)))
MATLAB_VERSION= $(call notdirx, $(MATLAB_ROOT))
$(info ****************)
$(info $(MATLAB_VERSION))
$(info ****************)
INCLUDES = -IC:\CAFE\cafe-1.0.0-beta-3\cpp\include -IC:\local\boost_1_63_0 \
-IC:\local\boost_1_63_0\boost -IC:\epics\base-3.14.12.5\include -IC:\epics\base-3.14.12.5\include\os\WIN32 \
-I"$(MATLAB_ROOT)"\extern\include \
-Ic:\Qt\qt-4.8.6-x64-msvc2010\include -Ic:\Qt\qt-4.8.6-x64-msvc2010\include\QtCore -Ic:\Qt\qt-4.8.6-msvc2010\include\QtXml
CXX=cl
CXXFLAGS = /W4 /EHsc
OUTPUT_OPTION = /o $@
LIB_CAFE=C:\CAFE\cafe-1.0.0-beta-3\cpp\lib\cafe\cafe.lib
LIB_BOOST =C:\local\boost_1_63_0\lib64-msvc-10.0\libboost_date_time-vc100-mt-1_63.lib
LIB_BOOST2=C:\local\boost_1_63_0\lib64-msvc-10.0\libboost_date_time-vc100-mt-s-1_63.lib \
C:\local\boost_1_63_0\lib64-msvc-10.0\libboost_thread-vc100-mt-s-1_63.lib \
C:\local\boost_1_63_0\lib64-msvc-10.0\libboost_system-vc100-mt-s-1_63.lib \
C:\local\boost_1_63_0\lib64-msvc-10.0\libboost_chrono-vc100-mt-s-1_63.lib
LIB_QT=C:\Qt\Qt-4.8.6-x64-msvc2010\lib\QtCore4.lib C:\Qt\qt-4.8.6-x64-msvc2010\lib\QtXml4.lib
LIB_EPICS=C:\epics\base-3.14.12.5\lib\windows-x64\Com.lib C:\epics\base-3.14.12.5\lib\windows-x64\ca.lib
LIB_MATLAB=-I"$(MATLAB_ROOT)"\extern\lib\win64\microsoft\libmat.lib \
-I"$(MATLAB_ROOT)"\extern\lib\win64\microsoft\libmex.lib \
-I"$(MATLAB_ROOT)"\extern\lib\win64\microsoft\libmx.lib
OBJ_DIR=$(MATLAB_VERSION)
$(OBJ_DIR)\mocha.$(MEXE): mocha.cpp $(OBJ_DIR)\macchinettaSwitch.obj
"$(MATLAB_ROOT)"\bin\win64\mex -v COMPFLAGS="$(COMPFLAGS) -Wall" mocha.cpp \
$(OBJ_DIR)/macchinettaSwitch.obj -DDB_TEXT_GLBLSOURCE -DMSCC -DWIN32 -DWIN64 -largeArrayDims \
$(INCLUDES) $(LIB_MATLAB) $(LIB_EPICS) $(LIB_CAFE) $(LIB_BOOST) $(LIB_BOOST2) $(LIB_QT) \
-outdir $(OBJ_DIR) -output mocha.$(MEXE)
$(OBJ_DIR)\macchinettaSwitch.obj: macchinettaSwitch.cpp macchinettaHelper.h \
macchinetta.h containerMochaccino.h
"$(MATLAB_ROOT)"\bin\win64\mex -largeArrayDims \
-c macchinettaSwitch.cpp $(INCLUDES) -outdir $(OBJ_DIR)
clean:
del $(OBJ_DIR)\macchinettaSwitch.obj $(OBJ_DIR)\mocha.$(MEXE)

63
MakefileWin/Makefile_noqt Normal file
View File

@@ -0,0 +1,63 @@
#
# Note LIB_CAFE=C:\CAFE\cafe-1.0.0-beta-3\cpp\lib\cafe-noqt\cafe.lib
#
MATLAB_ROOT=C:\Program Files\MATLAB\R2016b_x64
MEXE=mexw64
empty:=
s? = $(subst $(empty) ,?,$1)
?s = $(subst ?, ,$1)
notdirx = $(call ?s,$(notdir $(call s?,$1)))
MATLAB_VERSION= $(call notdirx, $(MATLAB_ROOT))
$(info ****************)
$(info $(MATLAB_VERSION))
$(info ****************)
INCLUDES = -IC:\CAFE\cafe-1.0.0-beta-3\cpp\include -IC:\local\boost_1_63_0 \
-IC:\local\boost_1_63_0\boost -IC:\epics\base-3.14.12.5\include -IC:\epics\base-3.14.12.5\include\os\WIN32 \
-I"$(MATLAB_ROOT)"\extern\include
#-Ic:\Qt\qt-4.8.6-x64-msvc2010\include -Ic:\Qt\qt-4.8.6-x64-msvc2010\include\QtCore -Ic:\Qt\qt-4.8.6-msvc2010\include\QtXml
CXX=cl
CXXFLAGS = /W4 /EHsc
OUTPUT_OPTION = /o $@
LIB_CAFE=C:\CAFE\cafe-1.0.0-beta-3\cpp\lib\cafe-noqt\cafe.lib
LIB_BOOST =C:\local\boost_1_63_0\lib64-msvc-10.0\libboost_date_time-vc100-mt-1_63.lib
LIB_BOOST2=C:\local\boost_1_63_0\lib64-msvc-10.0\libboost_date_time-vc100-mt-s-1_63.lib \
C:\local\boost_1_63_0\lib64-msvc-10.0\libboost_thread-vc100-mt-s-1_63.lib \
C:\local\boost_1_63_0\lib64-msvc-10.0\libboost_system-vc100-mt-s-1_63.lib \
C:\local\boost_1_63_0\lib64-msvc-10.0\libboost_chrono-vc100-mt-s-1_63.lib
LIB_QT=C:\Qt\Qt-4.8.6-x64-msvc2010\lib\QtCore4.lib C:\Qt\qt-4.8.6-x64-msvc2010\lib\QtXml4.lib
LIB_EPICS=C:\epics\base-3.14.12.5\lib\windows-x64\Com.lib C:\epics\base-3.14.12.5\lib\windows-x64\ca.lib
LIB_MATLAB=-I"$(MATLAB_ROOT)"\extern\lib\win64\microsoft\libmat.lib \
-I"$(MATLAB_ROOT)"\extern\lib\win64\microsoft\libmex.lib \
-I"$(MATLAB_ROOT)"\extern\lib\win64\microsoft\libmx.lib
OBJ_DIR=$(MATLAB_VERSION)
$(OBJ_DIR)\mocha.$(MEXE): mocha.cpp $(OBJ_DIR)\macchinettaSwitch.obj
"$(MATLAB_ROOT)"\bin\win64\mex -v COMPFLAGS="$(COMPFLAGS) -Wall" mocha.cpp \
$(OBJ_DIR)/macchinettaSwitch.obj -DDB_TEXT_GLBLSOURCE -DMSCC -DWIN32 -DWIN64 -largeArrayDims \
$(INCLUDES) $(LIB_MATLAB) $(LIB_EPICS) $(LIB_CAFE) $(LIB_BOOST) $(LIB_BOOST2) \
-outdir $(OBJ_DIR) -output mocha.$(MEXE)
$(OBJ_DIR)\macchinettaSwitch.obj: macchinettaSwitch.cpp macchinettaHelper.h \
macchinetta.h containerMochaccino.h
"$(MATLAB_ROOT)"\bin\win64\mex -largeArrayDims \
-c macchinettaSwitch.cpp $(INCLUDES) -outdir $(OBJ_DIR)
clean:
del $(OBJ_DIR)\macchinettaSwitch.obj $(OBJ_DIR)\mocha.$(MEXE)

View File

@@ -0,0 +1,146 @@
<?xml version="1.0" encoding="UTF-8" ?>
<config
Name="Microsoft Windows SDK 7.1 (C++)"
ShortName="MSSDK71CPP"
Manufacturer="Microsoft"
Version="7.1"
Language="C++"
Priority="H"
Location="$VSROOT" >
<Details
CompilerExecutable="$COMPILER"
CompilerDefines="$COMPDEFINES"
CompilerFlags="$COMPFLAGS"
OptimizationFlags="$OPTIMFLAGS"
DebugFlags="$DEBUGFLAGS"
IncludeFlags="$INCLUDE"
LinkerExecutable="$LINKER"
LinkerFlags="$LINKFLAGS"
LinkerLibraries="$LINKLIBS"
LinkerDebugFlags="$LINKDEBUGFLAGS"
LinkerOptimizationFlags="$LINKOPTIMFLAGS"
CommandLineShell="$SDKROOT\Bin\SetEnv.cmd"
CommandLineShellArg=""
CompilerDefineFormatter="/D%s"
LinkerLibrarySwitchFormatter="lib%s.lib;%s.lib"
LinkerPathFormatter="/LIBPATH:%s"
LibrarySearchPath="$$LIB;$$LIBPATH;$$PATH;$$INCLUDE;$MATLABROOT\extern\lib\$ARCH\microsoft"
/>
<!-- Switch guide: http://msdn.microsoft.com/en-us/library/fwkeyyhe(v=vs.71).aspx -->
<!-- LINKTYPE="/DLL /DEBUG /NODEFAULTLIB:LIBCMT /NODEFAULTLIB:MSVCRT /FORCE:MULTIPLE" -->
<vars
CMDLINE100="$COMPILER /c $COMPFLAGS $OPTIM $SRC /Fo$OBJ"
CMDLINE200="$LINKER $LINKFLAGS $LINKTYPE $LINKOPTIM $LINKEXPORTVER $OBJS $LINKLIBS /out:$EXE"
CMDLINE250="mt -outputresource:$EXE;2 -manifest $MANIFEST"
CMDLINE300="del $EXP $LIB $MANIFEST $ILK"
COMPILER="cl"
COMPFLAGS="/GR /W3 /EHs /nologo /MT $INCLUDE $COMPDEFINES"
COMPDEFINES="/D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /D_SECURE_SCL=0 $MATLABMEX"
MATLABMEX=" /DMATLAB_MEX_FILE"
OPTIMFLAGS="/O2 /Oy- /DNDEBUG"
INCLUDE="-I&quot;$MATLABROOT\extern\include&quot; -I&quot;$MATLABROOT\simulink\include&quot;"
DEBUGFLAGS="/Z7"
LINKER="link"
LINKFLAGS="/nologo /manifest"
LINKTYPE="/DLL"
LINKEXPORT=" /EXPORT:mexFunction"
LINKEXPORTVER=" /EXPORT:mexFunction /EXPORT:mexfilerequiredapiversion"
LINKLIBS="/LIBPATH:&quot;$MATLABROOT\extern\lib\$ARCH\microsoft&quot; libmx.lib libmex.lib libmat.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib"
LINKDEBUGFLAGS="/debug /PDB:&quot;$TEMPNAME$LDEXT.pdb&quot;"
LINKOPTIMFLAGS=""
OBJEXT=".obj"
LDEXT=".mexw64"
SETENV="set COMPILER=$COMPILER
set COMPFLAGS=/c $COMPFLAGS $COMPDEFINES $MATLABMEX
set OPTIMFLAGS=$OPTIMFLAGS
set DEBUGFLAGS=$DEBUGFLAGS
set LINKER=$LINKER
set LINKFLAGS=$LINKFLAGS /export:%ENTRYPOINT% $LINKTYPE $LINKLIBS $LINKEXPORT
set LINKDEBUGFLAGS=/debug /PDB:&quot;%OUTDIR%%MEX_NAME%$LDEXT.pdb&quot;
set NAME_OUTPUT=/out:&quot;%OUTDIR%%MEX_NAME%%MEX_EXT%&quot;"
/>
<client>
<engine
CMDLINE250="mt -outputresource:$EXE;1 -manifest $MANIFEST"
LINKLIBS="$LINKLIBS libeng.lib"
LINKEXPORT=""
LINKEXPORTVER=""
LDEXT=".exe"
LINKTYPE=""
MATLABMEX=""
/>
<mbuild
CMDLINE100="$COMPILER /c $COMPFLAGS $OPTIM $COMPDEFINES $INCLUDE $SRC /Fo$OBJ /UMX_COMPAT_SC"
CMDLINE200="$LINKER $LINKFLAGS $LINKTYPE $LINKOPTIM $LINKEXPORT $OBJS $LINKLIBS /out:$EXE"
CMDLINE250="mt -outputresource:$EXE;1 -manifest $MANIFEST"
CMDLINE300="del $MANIFEST &quot;$TEMPNAME.map&quot; "
LINKFLAGS="/nologo /manifest"
LINKLIBS="/MACHINE:AMD64 /LIBPATH:&quot;$MATLABROOT\extern\lib\$ARCH\microsoft&quot; mclmcrrt.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib"
INCLUDE="-I&quot;$MATLABROOT\extern\include&quot; -I&quot;$MATLABROOT\extern\include\$ARCH&quot;"
COMPFLAGS="-MT -Zp8 -GR -W3 -EHsc- -Zc:wchar_t- -nologo"
COMPDEFINES="-DMSVC -DIBMPC /D_CRT_SECURE_NO_DEPRECATE"
OPTIMFLAGS="-O2 -DNDEBUG"
LINKEXPORT=""
LINKEXPORTVER=""
LDEXT=".exe"
MATLABMEX=""
LINKTYPE=""
LINKDEBUGFLAGS="/debug /PDB:&quot;$TEMPNAME.pdb&quot;"
/>
<mbuild_com
CMDLINE000="copy &quot;$MATLABROOT\extern\include\$ARCH\mwcomutil.tlb&quot; &quot;$OUTDIR&quot;"
CMDLINE001="midl /nologo /$ARCH $COMPINCLUDE /D NDEBUG /out &quot;$OUTDIR&quot; mwcomtypes.idl"
CMDLINE002="midl /nologo /$ARCH $COMPINCLUDE /D NDEBUG /out &quot;$OUTDIR&quot; &quot;$COMIDL&quot;"
CMDLINE100="$COMPILER $COMPFLAGS $OPTIM $COMPDEFINES $INCLUDE $COMPINCLUDE $SRC /Fo$OBJ"
CMDLINE150="rc /fo &quot;$RESFILE&quot; &quot;$RCFILE&quot;"
CMDLINE250="mt -outputresource:$EXE;2 -manifest $MANIFEST"
CMDLINE275="&quot;$MATLABROOT\runtime\$ARCH\mwregsvr.exe&quot; $EXE"
CMDLINE300="del $MANIFEST &quot;$OUTDIR\mwcomutil.tlb&quot; &quot;$RESFILE&quot;"
OUTDIR="."
INCLUDE="$INCLUDE -I&quot;$OUTDIR&quot; -I&quot;$MATLABROOT\extern\include\$ARCH&quot;"
COMPFLAGS="/c /GR /W3 /EHsc- -Zc:wchar_t /nologo /MT"
COMPDEFINES="/DMSVC /DIBMPC /D_CRT_SECURE_NO_DEPRECATE /D_SECURE_SCL=0"
COMPINCLUDE="-I&quot;$MATLABROOT\extern\include&quot; -I&quot;$OUTDIR&quot;"
LINKEXPORT="/DLL /def:&quot;$DEFFILE&quot;"
LINKEXPORTVER="/DLL /def:&quot;$DEFFILE&quot;"
LINKLIBS="/MACHINE:AMD64 $LINKLIBS mclmcrrt.lib &quot;$RESFILE&quot;"
LDEXT=".dll"
USERONLY=""
LINKTYPE=""
MATLABMEX=""
/>
</client>
<locationFinder>
<SDKROOT>
<or>
<hklmExists path="SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.1" name="InstallationFolder" />
<hklmExists path="SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v7.1" name="InstallationFolder" />
</or>
</SDKROOT>
<VSROOT>
<and>
<or diagnostic="Windows SDK 7.1 appears to be installed, but its compiler was not found. Install .NET Framework 4.0, and then rerun the SDK installation to add the &quot;Visual C++ Compilers&quot; component. See http://www.mathworks.com/support/solutions/en/data/1-IB1G3Q/ for more information.">
<hklmExists path="SOFTWARE\Wow6432Node\Microsoft\VisualStudio\SxS\VC7" name="10.0"/>
<hklmExists path="SOFTWARE\Microsoft\VisualStudio\SxS\VC7" name="10.0" />
<hkcuExists path="SOFTWARE\Wow6432Node\Microsoft\VisualStudio\SxS\VC7" name="10.0" />
<hkcuExists path="SOFTWARE\Microsoft\VisualStudio\SxS\VC7" name="10.0" />
</or>
<fileExists name="$$\bin\amd64\cl.exe" />
<dirExists name="$$\..\..\.." />
</and>
</VSROOT>
</locationFinder>
<env
PATH="$VSROOT\Common7\IDE;$VSROOT\Common7\Tools;$VSROOT\VC\Bin\amd64;$VSROOT\VC\Bin\VCPackages;$SDKROOT\Bin\x64;$SDKROOT\Bin;"
INCLUDE="$VSROOT\VC\INCLUDE;$SDKROOT\INCLUDE;$SDKROOT\INCLUDE\gl;$MATLABROOT\extern\include;"
LIB="$VSROOT\VC\Lib\amd64;$SDKROOT\Lib\X64;$VSROOT\VC\ATLMFC\LIB\AMD64;$MATLABROOT\lib\$ARCH;$MATLABROOT\extern\lib\win64"
LIBPATH="$VSROOT\VC\Lib\amd64;$SDKROOT\LIB\X64;$VSROOT\VC\ATLMFC\LIB\AMD64;$MATLABROOT\extern\lib\win64"
/>
</config>

21
README Normal file
View File

@@ -0,0 +1,21 @@
USE makefile_rel_2014_manual for release versio
## --------------------------------------------------------------------------
## 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)
## --------------------------------------------------------------------------

60
containerMochaccino.h Normal file
View File

@@ -0,0 +1,60 @@
struct mochaccino
{
long id;
std::string name;
mochaccino(long _id, std::string _name):id(_id),name(_name){};
friend std::ostream& operator<<(std::ostream& os, const mochaccino& m)
{
//os<<m.id << " " << m.name << std::endl;
os << m.name << std::endl;
return os;
}
};
struct id{};
struct name{};
typedef multi_index_container<
mochaccino,
indexed_by<
ordered_unique<
tag<name>, BOOST_MULTI_INDEX_MEMBER(mochaccino, std::string , name)>,
ordered_non_unique<
tag<id>, BOOST_MULTI_INDEX_MEMBER(mochaccino, long, id )> >
> mochaccino_set;
template<typename Tag,typename MultiIndexContainer>
void print_out_by(
const MultiIndexContainer& s,
Tag* =0
)
{
// obtain a reference to the index tagged by Tag
const typename boost::multi_index::index<MultiIndexContainer,Tag>::type& i=
get<Tag>(s);
typedef typename MultiIndexContainer::value_type value_type;
// dump the elements of the index to cout
std::cout << "--------------" << std::endl;
std::cout << " METHODS LIST " << std::endl;
std::cout << "--------------" << std::endl;
std::copy(i.begin(),i.end(),std::ostream_iterator<value_type>(std::cout));
std::cout << "--------------------" << std::endl;
}
typedef mochaccino_set::index<id>::type mochaccino_set_by_id;
typedef mochaccino_set::index<name>::type mochaccino_set_by_name;

1
example.m Symbolic link
View File

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

1055
exampleNew.m Normal file

File diff suppressed because it is too large Load Diff

10
macchinetta.h Normal file
View File

@@ -0,0 +1,10 @@
/* Header for the wrapper.
Contains the function signature of (wrapper) machinettaFunction such that we can use this header
in the MEX-file to call the function in the (wrapper) machinetta library.
*/
#include "mex.h"
#define MACCHINETTA_API extern
MACCHINETTA_API void macchinettaFunction(int nlhs,mxArray *[],int nrhs, const mxArray *prhs[]);

2052
macchinettaHelper.h Normal file

File diff suppressed because it is too large Load Diff

6267
macchinettaSwitch.cpp Normal file

File diff suppressed because it is too large Load Diff

1
makefile Symbolic link
View File

@@ -0,0 +1 @@
makefile_rel_2014_1.3

124
makefile_rel_2014_1.3 Normal file
View File

@@ -0,0 +1,124 @@
#
# 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-1.3.0-final-1
#CAFE version to link to
CAFE_VERSION=cafe-1.3.0-final-1
EPICS_BASE=${EPICS}/base
#CAFE project base
CAFE_BASE=/opt/gfa/cafe
CAFE_MOCHA_BASE=${CAFE_BASE}/mocha
#CAFE_CPP_BASE=/afs/psi.ch/project/cafe/gitlab/CAFE/cpp
CAFE_CPP_BASE=$(CAFE_BASE)/cpp/$(CAFE_VERSION)
BOOST_BASE=${CAFE_BASE}/boost/boost_1_61_0/include
BOOST_LIB=/afs/psi.ch/project/zeromq/devl/mate/deps/boost/lib
QT_LIB=/usr/lib64
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) \
-L$(CAFE_CPP_BASE) \
-Wl,-rpath,$(CAFE_CPP_BASE) \
-L$(QT_LIB) -Wl,-rpath,$(QT_LIB)
LIBS += -ldl -lca -lCom -lmx -lmex -lmat -lQtCore -lQtXml
LIB_INSTALL = $(LIB_DIR) -L$(INSTALL_PATH) -Wl,-rpath,$(INSTALL_PATH)
LIB_LOCAL = $(LIB_DIR)
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 GCC='/usr/bin/gcc' 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)/macchinettaSwitch.o: macchinettaSwitch.cpp macchinettaHelper.h \
macchinetta.h containerMochaccino.h
mex GCC='/usr/bin/g++' CXXFLAGS='-v -largeArrayDims -ansi -fexceptions -fPIC -fno-omit-frame-pointer -pthread' \
-largeArrayDims -c macchinettaSwitch.cpp $(INCLUDEPATH_MACHINETTA) -outdir $(OBJ_DIR)
install: $(OBJ_DIR)/mocha.$(MEXE)
mkdir -p $(INSTALL_PATH)
mex -largeArrayDims GCC='/usr/bin/gcc' 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/*.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,70 @@
MATLAB_ROOT=C:\'Program Files'\MATLAB\R2016b_x64
MEXE=mexw64
#c:\local\boost_1_62_0\
INCLUDES = -IC:\CAFE\CAFE\cpp\include -IC:\CAFE\CAFE\cpp -IC:\local\boost_1_62_0 \
-IC:\local\boost_1_62_0\boost -IC:\epics\base-3.14.12.5\include -IC:\epics\base-3.14.12.5\include\os\WIN32 \
-I"C:\Program Files\MATLAB\R2016b_x64\extern\include" \
-Ic:\Qt\qt-4.8.6-x64-msvc2010\include -Ic:\Qt\qt-4.8.6-x64-msvc2010\include\QtCore -Ic:\Qt\qt-4.8.6-msvc2010\include\QtXml
CXX=cl
CXXFLAGS = /W4 /EHsc
OUTPUT_OPTION = /o $@
LIB_LOCAL = C:\epics\base-3.14.12.5\lib\windows-x64\Com.lib C:\epics\base-3.14.12.5\lib\windows-x64\ca.lib \
C:\CAFE\CAFE\cpp\cafe.lib \
C:\local\boost_1_62_0\lib64-msvc-10.0\libboost_thread-vc100-mt-1_62.lib \
C:\local\boost_1_62_0\lib64-msvc-10.0\libboost_system-vc100-mt-1_62.lib \
C:\local\boost_1_62_0\lib64-msvc-10.0\libboost_chrono-vc100-mt-1_62.lib \
C:\local\boost_1_62_0\lib64-msvc-10.0\libboost_date_time-vc100-mt-1_62.lib \
C:\Qt\Qt-4.8.6-msvc2010\lib\QtCore4.lib C:\Qt\tq-4.8.6-msvc2010\lib\QtXml4.lib
#"C:\Program Files\MATLAB\R2016b_x64\extern\lib\win64\microsoft\libmat.lib" \
#"C:\Program Files\MATLAB\R2016b_x64\extern\lib\win64\microsoft\libmex.lib" \
#"C:\Program Files\MATLAB\R2016b_x64\extern\lib\win64\microsoft\libmx.lib"
LIB_CAFE=C:\CAFE\CAFE\cpp\cafe.lib
LIB_BOOST =C:\local\boost_1_62_0\lib64-msvc-10.0\libboost_date_time-vc100-mt-1_62.lib
LIB_BOOST2=C:\local\boost_1_62_0\lib64-msvc-10.0\libboost_date_time-vc100-mt-s-1_62.lib \
C:\local\boost_1_62_0\lib64-msvc-10.0\libboost_thread-vc100-mt-s-1_62.lib \
C:\local\boost_1_62_0\lib64-msvc-10.0\libboost_system-vc100-mt-s-1_62.lib \
C:\local\boost_1_62_0\lib64-msvc-10.0\libboost_chrono-vc100-mt-s-1_62.lib
#LIB_BOOST2=C:\local\boost_1_62_0\lib64-msvc-10.0\libboost_thread-vc100-mt-s-1_62.lib \
#C:\local\boost_1_62_0\lib64-msvc-10.0\libboost_system-vc100-mt-s-1_62.lib \
#C:\local\boost_1_62_0\lib64-msvc-10.0\libboost_date_time-vc100-mt-s-1_62.lib \
#C:\local\boost_1_62_0\lib64-msvc-10.0\libboost_chrono-vc100-mt-s-1_62.lib
#LIB_BOOST=C:\local\boost_1_62_0\lib64-msvc-10.0\libboost_thread-vc100-mt-1_62.lib \
#C:\local\boost_1_62_0\lib64-msvc-10.0\libboost_system-vc100-mt-1_62.lib \
#C:\local\boost_1_62_0\lib64-msvc-10.0\libboost_date_time-vc100-mt-1_62.lib \
#C:\local\boost_1_62_0\lib64-msvc-10.0\libboost_chrono-vc100-mt-1_62.lib
LIB_QT=C:\Qt\Qt-4.8.6-x64-msvc2010\lib\QtCore4.lib C:\Qt\qt-4.8.6-x64-msvc2010\lib\QtXml4.lib
LIB_EPICS=C:\epics\base-3.14.12.5\lib\windows-x64\Com.lib C:\epics\base-3.14.12.5\lib\windows-x64\ca.lib
OBJ_DIR=windows-x64
CAFE_OBJS = C:\CAFE\CAFE\cpp\src\cafeCache.obj C:\CAFE\CAFE\cpp\src\cafeGroup.obj C:\CAFE\CAFE\cpp\src\cafe.obj C:\CAFE\CAFE\cpp\src\cafeVectors.obj \
C:\CAFE\CAFE\cpp\src\cafeXML.obj C:\CAFE\CAFE\cpp\src\callbackHandlerCreate.obj C:\CAFE\CAFE\cpp\src\callbackHandlerMonitor.obj \
C:\CAFE\CAFE\cpp\src\conduitGroup.obj C:\CAFE\CAFE\cpp\src\conduit.obj \
C:\CAFE\CAFE\cpp\src\connectCallbacks.obj C:\CAFE\CAFE\cpp\src\connectGroup.obj \
C:\CAFE\CAFE\cpp\src\connect.obj C:\CAFE\CAFE\cpp\src\exceptionsHelper.obj C:\CAFE\CAFE\cpp\src\granules.obj C:\CAFE\CAFE\cpp\src\handleHelper.obj \
C:\CAFE\CAFE\cpp\src\helper.obj \
C:\CAFE\CAFE\cpp\src\loadCollectionXMLParser.obj C:\CAFE\CAFE\cpp\src\loadGroupXMLParser.obj C:\CAFE\CAFE\cpp\src\methodCallbacks.obj \
C:\CAFE\CAFE\cpp\src\policyHelper.obj \
C:\CAFE\CAFE\cpp\src\restorePVGroupXMLParser.obj C:\CAFE\CAFE\cpp\src\transpose.obj
#\NODEFAULTLIB
$(OBJ_DIR)\mocha.$(MEXE): mocha.cpp $(OBJ_DIR)\macchinettaSwitch.obj
"C:\Program Files\MATLAB\R2016b_x64\bin\win64\mex" -v COMPFLAGS="$(COMPFLAGS) -Wall" mocha.cpp $(OBJ_DIR)/macchinettaSwitch.obj -DDB_TEXT_GLBLSOURCE -DMSCC -DWIN32 -DWIN64 -largeArrayDims $(INCLUDES) $(LIB_EPICS) $(LIB_CAFE) $(LIB_BOOST) $(LIB_BOOST2) $(LIB_QT) \
-outdir $(OBJ_DIR) -output mocha.$(MEXE)
$(OBJ_DIR)\macchinettaSwitch.obj: macchinettaSwitch.cpp macchinettaHelper.h \
macchinetta.h containerMochaccino.h
"C:\Program Files\MATLAB\R2016b_x64\bin\win64\mex" -largeArrayDims \
-c macchinettaSwitch.cpp $(INCLUDES) -outdir $(OBJ_DIR)
clean:
rm -f $(OBJ_DIR)/*.obj $(OBJ_DIR)/*.$(MEXE)

2
matlab.sh Executable file
View File

@@ -0,0 +1,2 @@
/opt/psi/Cafe/cafe-matlab.sh -v 2015a
matlab &

146
mex_C++_win64.xml Normal file
View File

@@ -0,0 +1,146 @@
<?xml version="1.0" encoding="UTF-8" ?>
<config
Name="Microsoft Windows SDK 7.1 (C++)"
ShortName="MSSDK71CPP"
Manufacturer="Microsoft"
Version="7.1"
Language="C++"
Priority="H"
Location="$VSROOT" >
<Details
CompilerExecutable="$COMPILER"
CompilerDefines="$COMPDEFINES"
CompilerFlags="$COMPFLAGS"
OptimizationFlags="$OPTIMFLAGS"
DebugFlags="$DEBUGFLAGS"
IncludeFlags="$INCLUDE"
LinkerExecutable="$LINKER"
LinkerFlags="$LINKFLAGS"
LinkerLibraries="$LINKLIBS"
LinkerDebugFlags="$LINKDEBUGFLAGS"
LinkerOptimizationFlags="$LINKOPTIMFLAGS"
CommandLineShell="$SDKROOT\Bin\SetEnv.cmd"
CommandLineShellArg=""
CompilerDefineFormatter="/D%s"
LinkerLibrarySwitchFormatter="lib%s.lib;%s.lib"
LinkerPathFormatter="/LIBPATH:%s"
LibrarySearchPath="$$LIB;$$LIBPATH;$$PATH;$$INCLUDE;$MATLABROOT\extern\lib\$ARCH\microsoft"
/>
<!-- Switch guide: http://msdn.microsoft.com/en-us/library/fwkeyyhe(v=vs.71).aspx -->
<!-- LINKTYPE="/DLL /DEBUG /NODEFAULTLIB:LIBCMT /NODEFAULTLIB:MSVCRT /FORCE:MULTIPLE" -->
<vars
CMDLINE100="$COMPILER /c $COMPFLAGS $OPTIM $SRC /Fo$OBJ"
CMDLINE200="$LINKER $LINKFLAGS $LINKTYPE $LINKOPTIM $LINKEXPORTVER $OBJS $LINKLIBS /out:$EXE"
CMDLINE250="mt -outputresource:$EXE;2 -manifest $MANIFEST"
CMDLINE300="del $EXP $LIB $MANIFEST $ILK"
COMPILER="cl"
COMPFLAGS="/GR /W3 /EHs /nologo /MT $INCLUDE $COMPDEFINES"
COMPDEFINES="/D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /D_SECURE_SCL=0 $MATLABMEX"
MATLABMEX=" /DMATLAB_MEX_FILE"
OPTIMFLAGS="/O2 /Oy- /DNDEBUG"
INCLUDE="-I&quot;$MATLABROOT\extern\include&quot; -I&quot;$MATLABROOT\simulink\include&quot;"
DEBUGFLAGS="/Z7"
LINKER="link"
LINKFLAGS="/nologo /manifest"
LINKTYPE="/DLL"
LINKEXPORT=" /EXPORT:mexFunction"
LINKEXPORTVER=" /EXPORT:mexFunction /EXPORT:mexfilerequiredapiversion"
LINKLIBS="/LIBPATH:&quot;$MATLABROOT\extern\lib\$ARCH\microsoft&quot; libmx.lib libmex.lib libmat.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib"
LINKDEBUGFLAGS="/debug /PDB:&quot;$TEMPNAME$LDEXT.pdb&quot;"
LINKOPTIMFLAGS=""
OBJEXT=".obj"
LDEXT=".mexw64"
SETENV="set COMPILER=$COMPILER
set COMPFLAGS=/c $COMPFLAGS $COMPDEFINES $MATLABMEX
set OPTIMFLAGS=$OPTIMFLAGS
set DEBUGFLAGS=$DEBUGFLAGS
set LINKER=$LINKER
set LINKFLAGS=$LINKFLAGS /export:%ENTRYPOINT% $LINKTYPE $LINKLIBS $LINKEXPORT
set LINKDEBUGFLAGS=/debug /PDB:&quot;%OUTDIR%%MEX_NAME%$LDEXT.pdb&quot;
set NAME_OUTPUT=/out:&quot;%OUTDIR%%MEX_NAME%%MEX_EXT%&quot;"
/>
<client>
<engine
CMDLINE250="mt -outputresource:$EXE;1 -manifest $MANIFEST"
LINKLIBS="$LINKLIBS libeng.lib"
LINKEXPORT=""
LINKEXPORTVER=""
LDEXT=".exe"
LINKTYPE=""
MATLABMEX=""
/>
<mbuild
CMDLINE100="$COMPILER /c $COMPFLAGS $OPTIM $COMPDEFINES $INCLUDE $SRC /Fo$OBJ /UMX_COMPAT_SC"
CMDLINE200="$LINKER $LINKFLAGS $LINKTYPE $LINKOPTIM $LINKEXPORT $OBJS $LINKLIBS /out:$EXE"
CMDLINE250="mt -outputresource:$EXE;1 -manifest $MANIFEST"
CMDLINE300="del $MANIFEST &quot;$TEMPNAME.map&quot; "
LINKFLAGS="/nologo /manifest"
LINKLIBS="/MACHINE:AMD64 /LIBPATH:&quot;$MATLABROOT\extern\lib\$ARCH\microsoft&quot; mclmcrrt.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib"
INCLUDE="-I&quot;$MATLABROOT\extern\include&quot; -I&quot;$MATLABROOT\extern\include\$ARCH&quot;"
COMPFLAGS="-MT -Zp8 -GR -W3 -EHsc- -Zc:wchar_t- -nologo"
COMPDEFINES="-DMSVC -DIBMPC /D_CRT_SECURE_NO_DEPRECATE"
OPTIMFLAGS="-O2 -DNDEBUG"
LINKEXPORT=""
LINKEXPORTVER=""
LDEXT=".exe"
MATLABMEX=""
LINKTYPE=""
LINKDEBUGFLAGS="/debug /PDB:&quot;$TEMPNAME.pdb&quot;"
/>
<mbuild_com
CMDLINE000="copy &quot;$MATLABROOT\extern\include\$ARCH\mwcomutil.tlb&quot; &quot;$OUTDIR&quot;"
CMDLINE001="midl /nologo /$ARCH $COMPINCLUDE /D NDEBUG /out &quot;$OUTDIR&quot; mwcomtypes.idl"
CMDLINE002="midl /nologo /$ARCH $COMPINCLUDE /D NDEBUG /out &quot;$OUTDIR&quot; &quot;$COMIDL&quot;"
CMDLINE100="$COMPILER $COMPFLAGS $OPTIM $COMPDEFINES $INCLUDE $COMPINCLUDE $SRC /Fo$OBJ"
CMDLINE150="rc /fo &quot;$RESFILE&quot; &quot;$RCFILE&quot;"
CMDLINE250="mt -outputresource:$EXE;2 -manifest $MANIFEST"
CMDLINE275="&quot;$MATLABROOT\runtime\$ARCH\mwregsvr.exe&quot; $EXE"
CMDLINE300="del $MANIFEST &quot;$OUTDIR\mwcomutil.tlb&quot; &quot;$RESFILE&quot;"
OUTDIR="."
INCLUDE="$INCLUDE -I&quot;$OUTDIR&quot; -I&quot;$MATLABROOT\extern\include\$ARCH&quot;"
COMPFLAGS="/c /GR /W3 /EHsc- -Zc:wchar_t /nologo /MT"
COMPDEFINES="/DMSVC /DIBMPC /D_CRT_SECURE_NO_DEPRECATE /D_SECURE_SCL=0"
COMPINCLUDE="-I&quot;$MATLABROOT\extern\include&quot; -I&quot;$OUTDIR&quot;"
LINKEXPORT="/DLL /def:&quot;$DEFFILE&quot;"
LINKEXPORTVER="/DLL /def:&quot;$DEFFILE&quot;"
LINKLIBS="/MACHINE:AMD64 $LINKLIBS mclmcrrt.lib &quot;$RESFILE&quot;"
LDEXT=".dll"
USERONLY=""
LINKTYPE=""
MATLABMEX=""
/>
</client>
<locationFinder>
<SDKROOT>
<or>
<hklmExists path="SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.1" name="InstallationFolder" />
<hklmExists path="SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v7.1" name="InstallationFolder" />
</or>
</SDKROOT>
<VSROOT>
<and>
<or diagnostic="Windows SDK 7.1 appears to be installed, but its compiler was not found. Install .NET Framework 4.0, and then rerun the SDK installation to add the &quot;Visual C++ Compilers&quot; component. See http://www.mathworks.com/support/solutions/en/data/1-IB1G3Q/ for more information.">
<hklmExists path="SOFTWARE\Wow6432Node\Microsoft\VisualStudio\SxS\VC7" name="10.0"/>
<hklmExists path="SOFTWARE\Microsoft\VisualStudio\SxS\VC7" name="10.0" />
<hkcuExists path="SOFTWARE\Wow6432Node\Microsoft\VisualStudio\SxS\VC7" name="10.0" />
<hkcuExists path="SOFTWARE\Microsoft\VisualStudio\SxS\VC7" name="10.0" />
</or>
<fileExists name="$$\bin\amd64\cl.exe" />
<dirExists name="$$\..\..\.." />
</and>
</VSROOT>
</locationFinder>
<env
PATH="$VSROOT\Common7\IDE;$VSROOT\Common7\Tools;$VSROOT\VC\Bin\amd64;$VSROOT\VC\Bin\VCPackages;$SDKROOT\Bin\x64;$SDKROOT\Bin;"
INCLUDE="$VSROOT\VC\INCLUDE;$SDKROOT\INCLUDE;$SDKROOT\INCLUDE\gl;$MATLABROOT\extern\include;"
LIB="$VSROOT\VC\Lib\amd64;$SDKROOT\Lib\X64;$VSROOT\VC\ATLMFC\LIB\AMD64;$MATLABROOT\lib\$ARCH;$MATLABROOT\extern\lib\win64"
LIBPATH="$VSROOT\VC\Lib\amd64;$SDKROOT\LIB\X64;$VSROOT\VC\ATLMFC\LIB\AMD64;$MATLABROOT\extern\lib\win64"
/>
</config>

12
mocha.cpp Normal file
View File

@@ -0,0 +1,12 @@
/* Source of MEX-file which will call the wrapper shared library.
We moved the previous content of the mexFunction to the wrapper library and now
call the function in the wrapper library instead.
*/
#include "macchinetta.h"
extern void _main();
void mexFunction(int nlhs,mxArray *plhs[],int nrhs, const mxArray *prhs[])
{
macchinettaFunction(nlhs,plhs,nrhs,prhs);
}

16
monAction.m Normal file
View File

@@ -0,0 +1,16 @@
function varargout = monActionLocal(varargin)
disp('monActionLocal 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)])

1
monActionLocal.m Symbolic link
View File

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

1
monitorAction.m Symbolic link
View File

@@ -0,0 +1 @@
scripts/monitorAction.m

1
pvtable.m Symbolic link
View File

@@ -0,0 +1 @@
scripts/pvtable.m

115
readme.txt Normal file
View File

@@ -0,0 +1,115 @@
MATLAB Compiler
1. Prerequisites for Deployment
. Verify the MATLAB Runtime is installed and ensure you
have installed version 9.0.1 (R2016a).
. If the MATLAB Runtime is not installed, do the following:
(1) enter
>>mcrinstaller
at MATLAB prompt. The MCRINSTALLER command displays the
location of the MATLAB Runtime installer.
(2) run the MATLAB Runtime installer.
Or download the Linux 64-bit version of the MATLAB Runtime for R2016a
from the MathWorks Web site by navigating to
http://www.mathworks.com/products/compiler/mcr/index.html
For more information about the MATLAB Runtime and the MATLAB Runtime installer, see
Package and Distribute in the MATLAB Compiler documentation
in the MathWorks Documentation Center.
2. Files to Deploy and Package
Files to package for Standalone
================================
-exampleFcn
-run_exampleFcn.sh (shell script for temporarily setting environment variables and
executing the application)
-to run the shell script, type
./run_exampleFcn.sh <mcr_directory> <argument_list>
at Linux or Mac command prompt. <mcr_directory> is the directory
where version 9.0.1 of the MATLAB Runtime is installed or the directory where
MATLAB is installed on the machine. <argument_list> is all the
arguments you want to pass to your application. For example,
If you have version 9.0.1 of the MATLAB Runtime installed in
/mathworks/home/application/v901, run the shell script as:
./run_exampleFcn.sh /mathworks/home/application/v901
If you have MATLAB installed in /mathworks/devel/application/matlab,
run the shell script as:
./run_exampleFcn.sh /mathworks/devel/application/matlab
-MCRInstaller.zip
-if end users are unable to download the MATLAB Runtime using the above
link, include it when building your component by clicking
the "Runtime downloaded from web" link in the Deployment Tool
-This readme file
3. Definitions
For information on deployment terminology, go to
http://www.mathworks.com/help. Select MATLAB Compiler >
Getting Started > About Application Deployment >
Deployment Product Terms in the MathWorks Documentation
Center.
4. Appendix
A. Linux x86-64 systems:
In the following directions, replace MCR_ROOT by the directory where the MATLAB Runtime
is installed on the target machine.
(1) Set the environment variable XAPPLRESDIR to this value:
MCR_ROOT/v901/X11/app-defaults
(2) If the environment variable LD_LIBRARY_PATH is undefined, set it to the concatenation
of the following strings:
MCR_ROOT/v901/runtime/glnxa64:
MCR_ROOT/v901/bin/glnxa64:
MCR_ROOT/v901/sys/os/glnxa64:
MCR_ROOT/v901/sys/opengl/lib/glnxa64
If it is defined, set it to the concatenation of these strings:
${LD_LIBRARY_PATH}:
MCR_ROOT/v901/runtime/glnxa64:
MCR_ROOT/v901/bin/glnxa64:
MCR_ROOT/v901/sys/os/glnxa64:
MCR_ROOT/v901/sys/opengl/lib/glnxa64
For more detail information about setting the MATLAB Runtime paths, see Package and
Distribute in the MATLAB Compiler documentation in the MathWorks Documentation Center.
NOTE: To make these changes persistent after logout on Linux
or Mac machines, modify the .cshrc file to include this
setenv command.
NOTE: The environment variable syntax utilizes forward
slashes (/), delimited by colons (:).
NOTE: When deploying standalone applications, it is possible
to run the shell script file run_exampleFcn.sh
instead of setting environment variables. See
section 2 "Files to Deploy and Package".

33
run_example.sh Executable file
View File

@@ -0,0 +1,33 @@
#!/bin/sh
# script for execution of deployed applications
#
# Sets up the MATLAB Runtime environment for the current $ARCH and executes
# the specified command.
#
exe_name=$0
exe_dir=`dirname "$0"`
echo "------------------------------------------"
if [ "x$1" = "x" ]; then
echo Usage:
echo $0 \<deployedMCRroot\> args
else
echo Setting up environment variables
MCRROOT="$1"
echo ---
LD_LIBRARY_PATH=.:${MCRROOT}/runtime/glnxa64 ;
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${MCRROOT}/bin/glnxa64 ;
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${MCRROOT}/sys/os/glnxa64;
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${MCRROOT}/sys/opengl/lib/glnxa64;
export LD_LIBRARY_PATH;
echo LD_LIBRARY_PATH is ${LD_LIBRARY_PATH};
shift 1
args=
while [ $# -gt 0 ]; do
token=$1
args="${args} \"${token}\""
shift
done
eval "\"${exe_dir}/example\"" $args
fi
exit

23
scripts/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
scripts/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
scripts/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

109
scripts/caget.m- Executable file
View File

@@ -0,0 +1,109 @@
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', 0.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
if nargin > 1 && cached
pvStruct = mocha('getPVCache',pv);
else
pvStruct = mocha('getPV', pv);
end
val=pvStruct.val
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 = val;
units = pvCtrl.units;
string = pvCtrl.enumStrings;
if size(string) > 1
disp(size(string))
value.val_str = value.val;
value.val = mocha('getCache',pv,'int8');
end
%if ~isempty(units{1})
%value.units = units{1};
%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

118
scripts/cagetOld.m Executable file
View File

@@ -0,0 +1,118 @@
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', 0.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);
%dt='native'
%if (chInfo.dataType=='DBR_ENUM')
% dt='int8'
%end
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;
%string = pvCtrl.enumStrings;
if (pvCtrl.noEnumStrings>0)
%if size(string) > 1
%disp(size(string))
value.val_str = value.val;
value.val = mocha('getCache',pv,'int8');
end
%if ~isempty(units{1})
%value.units = units{1};
%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
scripts/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
scripts/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
scripts/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);

1
scripts/example.m Symbolic link
View File

@@ -0,0 +1 @@
../example.m

36
scripts/mcaalarm.m Normal file
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

40
scripts/mcacache.m Normal file
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{:});

20
scripts/mcacheck.m Normal file
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

48
scripts/mcacheckopen.m Normal file
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

19
scripts/mcaclearmon.m Normal file
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

22
scripts/mcaclose.m Normal file
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

12
scripts/mcadebug.m Normal file
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

34
scripts/mcaegu.m Normal file
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

39
scripts/mcaenums.m Normal file
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

5
scripts/mcaexit.m Normal file
View File

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

71
scripts/mcaget.m Normal file
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

76
scripts/mcagets.m Normal file
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

86
scripts/mcainfo.m Normal file
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

20
scripts/mcaisopen.m Normal file
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;

66
scripts/mcamon.m Normal file
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

25
scripts/mcamonevents.m Normal file
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

64
scripts/mcamontimer.m Normal file
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

61
scripts/mcaopen.m Normal file
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

4
scripts/mcapoll.m Normal file
View File

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

35
scripts/mcaprec.m Normal file
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
scripts/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

118
scripts/mcaputnowait.m Normal file
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

46
scripts/mcastate.m Normal file
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

44
scripts/mcatime.m Normal file
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

64
scripts/mcatimeout.m Normal file
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

11
scripts/mcaunlock.m Normal file
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');

8
scripts/mcaversion.m Normal file
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');

16
scripts/monitorAction.m Normal file
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)])

44
scripts/pvtable.m Executable file
View File

@@ -0,0 +1,44 @@
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);
end
t1=struct2table(s1);
pvt=table(t1.handle,t1.pv,t.val, t.status, t1.cs);
pvt.Properties.VariableNames={'h','pv', 'val', 'stat','c'};
%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');

18
scripts/test.xml Normal file
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>

260
windows-x64/example.m Normal file
View File

@@ -0,0 +1,260 @@
mocha('openNoWait')
h1=mocha('open','ARIDI-BPM-01LE:X-AVG')
h2=mocha('open','ARIDI-BPM-01LB:X-AVG')
h3=mocha('open','ARIDI-BPM-01LE:Y-AVG')
h4=mocha('open','ARIDI-BPM-01LB:Y-AVG')
h5=mocha('open','ARIDI-BPM-01SE:X-AVG')
h6=mocha('open','ARIDI-BPM-01SE:Y-AVG')
h7=mocha('open','ARIDI-BPM-01SE:WF-INT-2')
h8=mocha('open','ARIDI-BPM-01SE:GET-ENABLE')
mocha('openNow')
hAll=[h1,h2,h3,h4,h5,h6,h7,h8];
kkl= 1.1;
clock
for mm=1:2
[s, allOK] = mocha('setScalarArray',[h5,h6],[kkl,kkl]); % all in one
s, allOK
[a]=mocha('getStructArray', [h1,h2,h7,h4]);
a
a(1).val
a(2).val
a(3).val
a(4).val
[a, allOK]=mocha('getScalarArray', [h1,h2,h7,h4]);
[r]=mocha('getCtrl',h5);
[r]=mocha('get',h1);
pause(0.05);
[r]=mocha('getCtrlCache',h5,'string');
end
clock
for mm=1:10
[bret1]=mocha('getStructArrayCache', {'ARIDI-BPM-01LE:X-AVG','ARIDI-BPM-01LB:X-AVG','ARIDI-BPM-01SE:WF-INT-2','ARIDI-BPM-01LB:Y-AVG'});
[bret2]=mocha('getStructArrayCache',[h1,h2,h7,h4]);
pause(0.05);
end
clock
%[ST,I]=dbstack('-completenames')
[ST,I]=dbstack()
ST.file
ST.line
pause(5)
for mm=1:10
[r]=mocha('get', [h1]);
[r]=mocha('get', [h2]);
[r]=mocha('get', [h7]);
[r]=mocha('get', [h4]);
r
end
clock
[monID1,s]=mocha('monitor',h1);
[monID2,s]=mocha('monitor',h2);
[monID3,s]=mocha('monitor',h3);
[monID4,s]=mocha('monitor',h4);
s=mocha('defineGroup','gTest8',{'ARIDI-BPM-01LE:X-AVG','ARIDI-BPM-01LB:X-AVG','ARIDI-BPM-01LE:Y-AVG','ARIDI-BPM-01LB:Y-AVG','ARIDI-BPM-01SE:X-AVG','ARIDI-BPM-01SE:Y-AVG','ARIDI-BPM-01SE:WF-INT-2','ARIDI-BPM-01SE:GET-ENABLE'})
s=mocha('defineGroup','gTest', {'ARIDI-BPM-01LE:X-AVG','ARIDI-BPM-01LE:Y-AVG'})
g8=mocha('openGroup','gTest8');
%% pause to reduce growth in MATLAB memory
for mm =1:10
[r]=mocha('getStructArray', [h1,h2,h3,h4]); %byhandle
pause(0.05);
end
s=mocha('getAsyn',h5);
[r,s]=mocha('getCache',h5);
pause(0.1);
s=mocha('set','ARIDI-BPM-01LE:X-AVG',1.234); %bypvname
pause(0.1);
[r,s]=mocha('get', h1); %byhandle
pause(0.1);
s=mocha('set','ARIDI-BPM-01LE:X-AVG',1.234); %byhandle
pause(0.1);
[r,s]=mocha('getCache', h1); %byhandle
pause(0.1);
[r]=mocha('getStruct', h1); %byhandle
pause(0.1);
[r]=mocha('getStructArray', [h1,h2,h3,h4]); %byhandle
pause(0.1);
[r,s]=mocha('get', h1); %byhandle
pause(0.1);
%[r,s, allOK]=mocha('getScalarArray', [h1,h2,h3,h4]); %byhandle
%pause(0.1);
s=mocha('getAsyn',h5);
[r,s]=mocha('getCache',h5);
%why not combine the getNoWait and getNoWaitArray?
[s,allOK]=mocha('getAsyn',[h1,h2,h3]);
disp('s')
disp('allOK')
disp (s)
disp (allOK)
pause(10);
[r,allOK]=mocha('getStructArrayCache', [h1,h2,h3,h4]); %byhandle
r(1).val
r(2).val
r(3).val
r(4).val
%pause(0.1);
[r,s]=mocha('getCache',h5);
%pause(0.1);
s=mocha('set',h5,1.134);
pause(0.1);
s=mocha('set',h5,0.134);
pause(0.1);
s=mocha('getAsyn',h5);
[r,s]=mocha('getCache',h5);
pause(0.1);
%disp 'r should be 0.134'
for kkj =1:10
s=mocha('set',h5,mm);
[s, allOK] = mocha('setStructArray',[h5,h6],[1],[kkj]); %{'on'},[kk]);
[s, allOK] = mocha('setScalarArray',[h5,h6],[mm,mm]); % all in one
pause(0.01);
end
%tic;
%ts=tic;
for kk =1:10
mocha('isConnected',h1);
mocha('isConnected','ARIDI-BPM-01LE:X-AVG');
[s, allOK] = mocha('get',h1);
[r, allOK] = mocha('getScalarArray',[h1,h2,h3,h4,h5,h6,h7,h8]); %sequential gets
pause(0.01);
s
allOK
end
%te=toc(ts)
%tic;
%ts=tic;
for kk =1:10
[r, allOK] = mocha('getStructArray',[h1,h2,h3,h4,h5,h6,h7,h8]); %sequential gets
pause(0.01);
end
%te=toc(ts)
%tic;
%ts=tic
for kk =1:10
[r, allOK] = mocha('getGroup',g8); %sequential gets
pause(0.01);
end
%te=toc(ts)
%r(2).val
%pause(2.1);
%end;
%disp 'getStructArray h8,h7'
[r, allOK] = mocha('getStructArray',[h8,h7]);
%r.val
pause(0.01);
[s, allOK] = mocha('setScalarArray',[h5,h6],{'0.112','1.13'});
pause(0.01);
%disp(mm)
%disp 'getArrayNoWait h5,h6'
[s, allOK] = mocha('getArrayAsyn',[h5,h6]);
disp('getArrayAsyn')
pause(10);
%disp 'getScalarArrayCache h5,h6'
[r, s, allOK]=mocha('getScalarArrayCache',[h5,h6]);
pause(0.01);
%disp 'r should be 0.112'
s=mocha('set',h5,1.1345);
pause(0.01);
%disp 'getScalarArrayCache h5,h6'
[r, s, allOK]=mocha('getScalarArrayCache',[h5,h6]);
%disp 'r should be 0.112 not 1.1345'
%[s]=mocha('getAsyn',h1)
%[s]=mocha('getAsyn',h2)
%s=mocha('set',h1,int32(7))
%s=mocha('set',h1,single(8))
[a,s]=mocha('getCache',h1);
pause(0.01);
[a,s]=mocha('getCache',h2);
pause(0.01);
disp ('getArrayAsyn h5,h6')
[s, allOK]=mocha('getArrayAsyn',[h5,h6]);
pause(10);
s=mocha('set',h6,0.115);
pause(0.01);
[r, allOK]=mocha('getStructArrayCache',[h5,h6]);
%disp 'r should be 0.1345 and 0.115'
%pause(0.1);
%disp 'getCtrl h5'
[r]=mocha('getCtrl',h5);
pause(0.01);
[r]=mocha('getCtrlCache',h5,'string');
pause(0.01);
[res, allOK] = mocha('getGroup', 'gTest');
[res, allOK] = mocha('getGroup', 'gTest');
mocha('loadXMLCollections','Collections/collection_swissfel.xml');
mocha('loadXMLGroups','Groups/group_swissfel.xml');
pause(0.01);
lgr=mocha('listgroups');
lgr
g1=mocha('openGroup','gWF');
pause(0.01);
pause(0.01);
[a,allOK]=mocha('getGroup', 'gWF'); %bygroupName
a
[b,allOK]=mocha('getGroup', g1); %bygrouphandle
b
pause(0.01);
[a,allOK]=mocha('setGroup', g1, b.val); %bygroupName
pause(0.01);
l=mocha('listgroupmembers','gWF');
i=mocha('idxgrpmem', 'gWF', 'ARIDI-BPM-01LE:GET-ENABLE');
pause(0.01);
%end
r=mocha('monitorstop',h1, monID1);
r=mocha('monitorstop'); % stops all monitors
%mocha('closeGroup','gTest');

Binary file not shown.

BIN
windows-x64/mocha.mexw64 Normal file

Binary file not shown.

BIN
windows-x64/mocha.pdb Normal file

Binary file not shown.