README.md 9.81 KB
Newer Older
Hao, Hao's avatar
Hao, Hao committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
__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`.