Commit 6fb091f8 authored by Hao, Hao's avatar Hao, Hao
Browse files

add README.md

parent a99480cc
__Install EDM and StripTool on MacOS__
- [Quick setup](#quick-setup)
- [EPICS base](#epics-base)
- [EPICS extensions](#epics-extensions)
- [edm](#edm)
- [Config Makefile](#config-makefile)
- [Tweak source code](#tweak-source-code)
- [Configure edm](#configure-edm)
- [OPI files](#opi-files)
- [Run edm](#run-edm)
- [StripTool](#striptool)
# Quick setup
To proceed, you have to
- have the `sudo` permission of the MacOS
- be a member of `ICS` group on `code-int.ornl.gov`
Run the following commands to install necessary libs,
```
xcode-select --install
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
brew install --cask xquartz
brew install giflib
brew install openmotif
brew install git
```
There may be more libs needed depending on the particular MacOS environment.
Run the following commands to donwnload the whole EDM package, which contains source code for
- `edm`,
- `StripTool`,
- EPICS base 7.0,
- the SNS OPI files, and
- `edm` config files for SNS.
```
cd
git clone --recurse-submodules https://code.ornl.gov/1h7/edm.git
```
The whole package must be downloaded to `~/edm`. The size is about 355 MB.
Next, compile the EPICS base:
```
cd ~/edm/epics-base-7.0
make
```
Depending on your computer hardware, the above `make` command will take from a few minutes to 40 minutes.
Then compile `edm` and `StripTool`, which are included in the `extensions` folder.
```
cd ~/edm/extensions
make
```
**All done!**
Open the SNS main screen by running command:
```
~/edm/edmRuntime/startmap
```
You can also double-click the `startmap.app` in `~/edm/edmRuntime` to run above script. If you use it frequently, drag this App to MacOS dock. In case you want to change the icon of this App, refer to [here](https://appleinsider.com/articles/21/01/06/how-to-change-app-icons-on-macos). There is an icon file `epics_icon.png` in `~/edm/edmRuntime`.
If you want to use the "old" `/ade` edm screens, run
```
~/edm/edmRuntime/startmap-web2
```
The drawback of using it is you may suffer delays (up to more than 10 seconds) from the network when you open a new screen. Another issue is that you must use VPN to access the `.edl` files (even when you are using ORNL wireless network).
`StripTool` is also included. It can be invoked by running
```
export EPICS_CA_ADDR_LIST="160.91.228.17"
~/edm/extensions/bin/darwin-x86/StripTool
```
or choosing `StripTool` from `navwogif.edl` --> `Misc Tools`.
The mid-click can be used to copy the PV name from `edm`, then paste it to `StripTool` or `edm`. But you cannot paste it to other MacOS software.
Run `edm` in editing mode
```
~/edm/edmRuntime/startmap -devel
```
Below is the detailed setup from scratch.
# EPICS base
Install libraries:
```
xcode-select --install
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
brew install --cask xquartz
brew install giflib
brew install openmotif
brew install git
```
Download EPICS base and compile:
```
mkdir ~/edm
cd ~/edm
git clone --recurse-submodules https://github.com/epics-base/epics-base.git
mv epics-base epics-base-7.0
cd epics-base-7.0
make
```
# EPICS extensions
Download EPICS extensions software:
```
cd ~/edm
wget https://epics.anl.gov/download/extensions/extensionsTop_20120904.tar.gz
tar zxf extensionsTop_20120904.tar.gz
cd ~/edm/extensions/configure
```
Edit `RELEASE` so that it looks like this:
```
...
EPICS_BASE=$(TOP)/../epics-base-7.0
...
```
Then compile it
```
cd ~/edm/extensions
make
```
# edm
Download `edm` to extensions folder:
```
cd ~/edm/extensions/src
git clone https://github.com/gnartohl/edm.git
```
## Config Makefile
```
cd ~/edm/extensions/configure/os
```
Modify `CONFIG_SITE.darwin-x86.darwin-x86`, so that following 4 entries look like this:
```
...
MOTIF_LIB=/usr/local/lib
MOTIF_INC=/usr/local/include
...
X11_LIB=/opt/X11/lib
X11_INC=/opt/X11/include
...
```
Next,
```
cd ~/edm/extensions/src
```
Modify `Makefile`, add
```
...
EDM = edm
...
DIRS += $(EDM)
...
```
Then
```
cd ~/edm/extensions/src/edm/edmMain
```
Modify `Makefile`, comment the line that contains `OP_SYS_LDFLAGS`
```
# OP_SYS_LDFLAGS = -z combreloc -z lazyload
```
Then,
```
cd ~/edm/extensions/src/edm/giflib
```
Modify `Makefile`, modify `GIF_LIB`, `GIF_INC`, and remove `ungif`.
```Makefile
...
GIF_LIB = /usr/local/lib
GIF_INC = /usr/local/include
...
USR_SYS_LIBS_Linux += pthread dl gif
...
USR_SYS_LIBS_Darwin += pthread dl gif
...
USR_SYS_LIBS_solaris += pthread dl rt gif
...
USR_SYS_LIBS_hpux11_11_mt = pthread gif
...
```
We want to use `CRUL` to visit web-based edm files:
```
cd ~/edm/extensions/src/edm/lib
```
Modify `Makefile`, change `USE_CURL`
```Makefile
USE_CURL=YES
```
## Tweak source code
We need to tweak the source code.
```
cd ~/edm/extensions/src/edm/edmMain
```
Modify `main.cc` so that following lines look like this:
```cpp
...
stat = ::bind( sockfd, (struct sockaddr*) &s, sizeof(s) );
...
void xtErrorHandler (
char *msg ) _X_NORETURN
{
...
}
...
```
Next,
```
cd ~/edm/extensions/src/edm/calcPv
```
Modify `calcPerform.c`, include `errorlog.h`
```c
#include <errlog.h>
```
Then,
```
cd ~/edm/extensions/src/edm/giflib
```
Modify `gif.cc`, include `gif_lib.h`
```c
#include <gif_lib.h>
```
Now we can compile the `edm`:
```
cd ~/edm/extensions
make
```
## Configure edm
`edm` needs some configuration to work at SNS. All the configurations are located in `~/edm/edmRuntime`.
```
mkdir ~/edm/edmRuntime
cd ~/edm/edmRuntime
```
Then
```
ln -s ../extensions/bin/darwin-x86/ bin
ln -s ../extensions/lib/darwin-x86/ lib
```
Create a file `startmap`, with following contents:
```shell
#!/bin/bash
# --------------------------------------------------
# EDM environment variables
edm_root=${HOME}/edm
export EDMLIBS=${edm_root}/edmRuntime/lib
export EDMHELPFILES=${edm_root}/edmRuntime/config/helpFiles
export EDMFILES=${edm_root}/edmRuntime/config
export EDMOBJECTS=${edm_root}/edmRuntime/config
export EDMPVOBJECTS=${edm_root}/edmRuntime/config
export EDMPRINTDEF=${edm_root}/edmRuntime/config/edmPrintDef
export EDMACTIONS=${edm_root}/edmRuntime/config
export EDMRELATIVEPATHS=yes
export EDMLIB_SUFFIX=dylib
# Centralized location for all EDM files
export EDMDATAFILES=${edm_root}/opi/edm
# --------------------------------------------------
# EPICS environment variables
export EPICS_CA_ADDR_LIST="160.91.228.17"
export PATH=${PATH}:${edm_root}/extensions/bin/darwin-x86/
# --------------------------------------------------
DEFAULT_FILE=navwogif.edl
devel=0
opt=""
for v in "$@"; do
if [[ $v == "-devel" ]]; then
devel=1
elif [[ $v == "-edit" ]]; then
devel=1
else
opt="$opt $v"
fi
done
if [[ $devel -eq 1 ]]; then
edm $opt &
else
if [[ $# -gt 0 ]]; then
edm -x -noedit "$@" &
else
edm -x -noedit $DEFAULT_FILE &
fi
fi
```
and a script `startmap-web2` with following contents:
```shell
#!/bin/bash
# --------------------------------------------------
# EDM environment variables
edm_root=${HOME}/edm
export EDMLIBS=${edm_root}/edmRuntime/lib
export EDMHELPFILES=${edm_root}/edmRuntime/config/helpFiles
export EDMFILES=${edm_root}/edmRuntime/config
export EDMOBJECTS=${edm_root}/edmRuntime/config
export EDMPVOBJECTS=${edm_root}/edmRuntime/config
export EDMPRINTDEF=${edm_root}/edmRuntime/config/edmPrintDef
export EDMACTIONS=${edm_root}/edmRuntime/config
export EDMRELATIVEPATHS=yes
export EDMLIB_SUFFIX=dylib
# Centralized location for all EDM files
export EDMDATAFILES=${edm_root}/opi/edm
# Remote config, overrides EDMDATAFILES, EDMFILES, and EDMHELPFILES
# defines EDMHTTPDOCROOT
export EDMHELPFILES=/ade/epics/supTop/edmDevel/R3.14.8.2/edmRuntime/config-1-12-105F/helpFiles
export EDMFILES=/ade/epics/supTop/edmDevel/R3.14.8.2/edmRuntime/config-1-12-105F
export EDMHTTPDOCROOT=https://ics-srv-web2.sns.ornl.gov
export EDMDATAFILES=@https://ics-srv-web2.sns.ornl.gov/ade/epics/site-setup/edm/edmdatafiles.txt
# --------------------------------------------------
# EPICS environment variables
export EPICS_CA_ADDR_LIST="160.91.228.17"
export PATH=${PATH}:${edm_root}/extensions/bin/darwin-x86/
# --------------------------------------------------
DEFAULT_FILE=navwogif.edl
devel=0
opt=""
edm -x -noedit $DEFAULT_FILE &
```
Then
```
chmod +x startmap startmap-web2
```
Copy the `config` folder from Linux server, e.g. `ics-srv-softioc8` or `dev-ics-rhel8`, to `~/edm/edmRuntime/config`. This folder is located at
```
/ics/tools/edm/config-1-12-105
```
Then edit files `edmPvObjects` and `edmObjects`, change the `.so` suffix to `.dylib` for all the entries.
## OPI files
All the edm files are located in a centralized folder in `/ics/opi/edm`. We need to copy this folder to `~/edm/opi` on Mac.
```
cd ~/edm
git clone https://code-int.ornl.gov/ics/opi.git
```
You will be asked for the username and password on `code-int.ornl.gov`. And you must be a member of `ICS` group on this git server to download this git repository.
## Run edm
Finally we can run the SNS main screen:
```
~/edm/edmRuntime/startmap
```
If you want to use the "old" `/ade` edm screens, you can run
```
~/edm/edmRuntime/startmap-web2
```
The drawback of using this scheme is you may suffer delays (up to 10s seconds) from the network when you open a new screen. Another issue is that you must use VPN to access the edm files (even when you are using ORNL wireless network).
You can also run `edm` in editing mode
```
~/edm/edmRuntime/startmap -devel
```
# StripTool
We can easily compile `StripTool`.
```
cd ~/edm/extensions/src
wget https://epics.anl.gov/download/extensions/StripTool2_5_17_0.tar.gz
tar zxf StripTool2_5_17_0.tar.gz
mv StripTool2_5_17_0 StripTool
cd ~/edm/extensions
make
```
Run `StripTool` using the following commands,
```
export EPICS_CA_ADDR_LIST="160.91.228.17"
~/edm/extensions/bin/darwin-x86/StripTool
```
or choose `StripTool` from `navwogif.edl` --> `Misc Tools`.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment