XAL Setup HOWTO for MacOS

 

1.      J2SE 1.5 ( Apple J2SE download) This is not the default for MacOS 10.4 Tiger – more on that below.

2.      Apache Ant 1.6.1 or later

3.      XAL from either the SNS CVS server (CVS access permission required) or web site. See XAL installation below for detail.

4.       JCA 2.1.6. See JCA setup below.

5.      EPICS base library R3.14.x. See EPICS library setup below.

 

1.   get a copy of my .bashrc fileand place it in your home directory. Edit to reflect your directory setup. Then in .bash_login add the line“source .bashrc” .

 2.    JAVA_HOME – points to the home directory of  Java 1.5 (see the.bashrc file)

2.      XAL_HOME – this is the root directory of xaldev.

3.      ANT_HOME – the ANT installation root directory.  For MacOS, set the ant alias in the .bashrc file (see Ant setup below)

4.      LD_LIBRARY_PATH – add the path to the epicsOS-specific lib directory. Mine is ~dfairley/Development/epics/lib/darwin-ppc

5.   LD_ASSUME_KERNEL=2.4.1

    IGNORED THIS FOR MAC OS  -required if using JCA 2.1.2 and Linux kernel 2.4.1 or later (this is to avoid pthread_cancel() crash when exiting an application with Channel Access running).

    

1.       Download and unpack Ant from ant.apache.org. I placed Apache Ant 1.6.5 in the  /Applications/apache-ant-1.6.5/ folder.

2.       I set the ant alias in the ~/.bashrc file to: alias ant=”/Applications/apache-ant-1.6.5/bin/ant"

 

1.      EPICS 3.14.xrequires gcc 3.x to build. Defaults on MacOS Tiger work.

2.      Download and unpack the EPICS base package.  I placed mine in ~dfairley/Development/epics/base-3.14.7

3.    I had to edit ~dfairley/Development/epics/base-3.14.7/src/libCom/osi/os/Darwin/osdSock.h, changed

             typedef int osiSocklen_t;   to

             typedef socklen_t osiSocklen_t;

4.    From an X-11 Terminal window, source ~/.bashrc if you haven’t already

5.      Type ‘make’ (it will take a few minutes)

6.      After it’s done, set the JCALibrary.properties properly as described below.

 

1.      JCA 2.1.6 requires EPICS 3.14.x. It has support to build for MacOS.

2.   download and unpack the JCA package. I placed mine in ~dfairley/Development/epics/jca-2.1.6

3.      Build from source: edit the file jca-2.1.6/config/config.darwin-ppc.properties(mine was empty) and add the line:java.include=${java.home}/include

4.   edit jca-2.1.6/src/core/gov/aps/jca/jni/JNI.cpp and add the line  #include <stdlib.h>

5.   then type ‘ant’from the JCA root directory;

6.   after it’s done, copy the resulting …/jca-2.1.6/O.darwin-ppc/libjca.jnilib to /System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Libraries/libjca.jnilib

To do this you will need to be a root user: start a terminal, and type:

            >sudo su “your user id”  (eg >sudo su dfairley)   you will have to enter your password

            >cp …/jca-2.1.6/O.darwin-ppc/libjca.jnilib /System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Libraries/.

            >exit

7.   set the $LD_LIBRARY_PATH properly.

8.      Set up JCALibrary.properties.

 

1.      Download, unpack, and move xaldev into an Eclipse workspace directory.  Mine is in/Users/dfairley/Development/workspace/xaldev.

2.      From xaldev root directory, type ‘ant jar-ext’to re-pack all the external JAR files used by XAL; creates xal.jar.

3.      Type ‘ant’ to build XAL frame work.

4.      Type ‘ant build-services’ to build all XAL service modules.

5.      Type ‘ant build-apps’ to build all applications (alternatively, you can build each application from its own directorywith ant). There are errors in several applications so it is necessary to build each app separately - I have only built the virtual accelerator at this point

6.      Ready to run applications.

 

Note: You can type ‘ant help’ from the xaldev root dir to get a quick on-line help for many other available options.

 

·        Installing the SNS_CAS portable channel access server for the Virtual Accelerator application

1.      Get the SNS_PCAS package from me – email to request it

2.      I placed it in /Users/dfairley/Development/epics/SNS_PCAS/

3.      I had to edit the Makefile in order to build on MacOS – you have the edited Makefile in the package from me. Edit the path or comment out the EPICS_BASE line in Makefile (this is duplicated in your .bashrc file).

4.      Make clean at the top level SNS_PCAS; then build  (make);  this should create an executable file …SNS_PCAS/bin/sns_cas. You may have to change the permission to writeable on the Makefile, obj and bin dirs.

5.      this executable is run programmatically by the XAL virtualaccelerator application using the sns_cas.exe script in its own directory (xaldev/gov/sns/apps/virtualaccelerator).  The virtualaccelerator java source uses the following command line:  sns_cas.exe start “filename” where the “filename” is the file created by the virtualaccelerator applications after the user has chosen an accelerator sequence. The file is a list of PVs the sns_cas must create .

6.       The sns_cas.exe script contains the commands as follows (these will change for MacOS):

 

#!/bin/bash

if[ $1 = 'start' ]

then

            $PCAS_HOME/bin/sns_cas-d2 -s0 -f=$2 -fout=pv_name.out

fi

 

if[ $1 = 'kill' ]

then

            pkill-u $USER sns_cas

fi

 

In order to use JCA, you must first install a JCALibrary.properties file to specify information about your EPICS setup and JCA configuration. Here we will provide a quick start setup that should be sufficient (for more details on JCA and setting up the properties file, please see Eric Boucher's JCA Documentation). The properties file should be placed either in the".JCALibrary" folder within your local user folder (e.g. /home/tom/.JCALibrary/JCALibrary.properties)or in your java library folder (e.g. /usr/java/jre/lib/JCALibrary.properties).Below is an example of the text that should appear in yourJCALibrary.properties file and be modified appropriately for yourconfiguration.  For MacOS, I placed the file in my home directory, ~dfairley/.JCALibrary/JCALibrary.properties.  The following is a copy of my file:

# define the location of the epics sharedlibraries and caRepeater executable
# replace these values with thepath to the appropriate epics resources.
gov.aps.jca.jni.epics.darwin-ppc.library.path= /Users/dfairley/Development/epics/base-3.14.7/lib/darwin-ppc
gov.aps.jca.jni.epics.darwin-ppc.caRepeater.path= /Users/dfairley/Development/epics/base-3.14.7/bin/darwin-ppc

# replace the values below with thoseappropriate for your EPICS setup.
# the addr_list is likely to bethe only property that needs to be customized.
gov.aps.jca.jni.JNIContext.addr_list=127.0.0.1
gov.aps.jca.jni.JNIContext.preemptive_callback=true
gov.aps.jca.jni.JNIContext.auto_addr_list=true
gov.aps.jca.jni.JNIContext.connection_timeout=27.3
gov.aps.jca.jni.JNIContext.beacon_period=15.0
gov.aps.jca.jni.JNIContext.repeater_port=5065
gov.aps.jca.jni.JNIContext.server_port=5064
gov.aps.jca.jni.JNIContext.max_array_bytes=16384

# ------------ the values belowshould not need to be changed ------------

# define default values only forJNI_SINGLE_THREADED context
gov.aps.jca.jni.SingleThreadedContext.event_dispatcher=gov.aps.jca.event.DirectEventDispatcher

# define default values only forJNI_THREAD_SAFE context
gov.aps.jca.jni.ThreadSafeContext.event_dispatcher=gov.aps.jca.event.QueuedEventDispatcher
gov.aps.jca.jni.ThreadSafeContext.priority=5

# define default values forQueuedEventDispatcher components
gov.aps.jca.event.QueuedEventDispatcher=5

 

·        Running XAL application:

·        1.   First you need to set your default version of java to Java 1.5 by becoming the root user and resetting a symlink.  See 1.5 as default Java in Tiger for instructions.

2.      To run an application such as orbit display, type ‘java –jar$XAL_HOME/build/jar/apps/orbitdisplay.jar’.

3.   Some applications don’t have $CLASSPATH properly set in their JAR manifest.  If this is the case, set $CLASSPATH to include the xal.jar and the application’s JAR file, and launch the application in the regular Java fashion (java gov.sns.apps…).

4.   For SNS virtualaccelerator, the machine configuration and on-line model initialization files are located in the xaldev/xal_xmls directory.

5.   To set up the default accelerator (for a user account), one can run the optics switcher application ‘java –jar $XAL_HOME/build/jar/apps/opticsswitcher.jar’.

 

Note: Need to allocate more memory (~100MB) for Java VM of running on-line model with hundreds of devices (e.g. ‘java –Xmx120m –jar …’ for 120MB of VM memory).