From cedfe49b40a5999b4b102e91b6f4d06950090238 Mon Sep 17 00:00:00 2001
From: Tejas Guruswamy <tguruswamy@anl.gov>
Date: Tue, 23 Jan 2024 18:37:24 -0600
Subject: [PATCH] Add better example of startup script to run at APS

---
 build_imagej+ad_plugins.sh |  3 +++
 start_imageJ               |  8 --------
 start_imagej_aps           | 29 +++++++++++++++++++++++++++++
 3 files changed, 32 insertions(+), 8 deletions(-)
 delete mode 100755 start_imageJ
 create mode 100755 start_imagej_aps

diff --git a/build_imagej+ad_plugins.sh b/build_imagej+ad_plugins.sh
index 1a70550..cb2be08 100644
--- a/build_imagej+ad_plugins.sh
+++ b/build_imagej+ad_plugins.sh
@@ -126,5 +126,8 @@ done
 
 popd
 
+# Copy example APS startup script into ImageJ folder
+cp -a "start_imagej_aps" ImageJ/
+
 # Make permissions consistent
 chmod -R ug=rwX,o=rX ImageJ
diff --git a/start_imageJ b/start_imageJ
deleted file mode 100755
index 0dabb96..0000000
--- a/start_imageJ
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/bin/bash
-# Example script to start ImageJ with compressed PVarray support from ADSupport. Adjust paths as necessary
-cd ${HOME}/ImageJ
-export EPICS_CA_MAX_ARRAY_BYTES=30000000
-export EPICS_CA_AUTO_ADDR_LIST=NO
-export EPICS_CA_ADDR_LIST=127.0.0.1
-export LD_LIBRARY_PATH=${HOME}/epics/synApps-6.2.1/support/areaDetector-R3-12-1/ADSupport/lib/linux-x86_64/
-./ImageJ -run "EPICS NTNDA Viewer" &
diff --git a/start_imagej_aps b/start_imagej_aps
new file mode 100755
index 0000000..ce201f3
--- /dev/null
+++ b/start_imagej_aps
@@ -0,0 +1,29 @@
+#!/bin/bash
+
+version=$( source /etc/os-release; echo $VERSION_ID | grep -oP '[0-9]+(?=\.)' )
+
+if [[($version == 9)]]
+then
+  export LD_LIBRARY_PATH=/APSshare/epics/synApps_6_2_1/support/areaDetector-R3-12-1/ADSupport/lib/rhel9-x86_64${LD_LIBRARY_PATH+:${LD_LIBRARY_PATH}}
+  echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH"
+elif [[($version == 8)]]
+then
+  export LD_LIBRARY_PATH=/APSshare/epics/synApps_6_2_1/support/areaDetector-R3-12-1/ADSupport/lib/rhel8-x86_64${LD_LIBRARY_PATH+:${LD_LIBRARY_PATH}}
+  echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH"
+elif [[($version == 7)]]
+then
+  export LD_LIBRARY_PATH=/APSshare/epics/synApps_6_2_1/support/areaDetector-R3-12-1/ADSupport/lib/rhel7-x86_64${LD_LIBRARY_PATH+:${LD_LIBRARY_PATH}}
+  echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH"
+else
+  export LD_LIBRARY_PATH=/APSshare/epics/synApps_6_2_1/support/areaDetector-R3-12-1/ADSupport/lib/linux-x86_64${LD_LIBRARY_PATH+:${LD_LIBRARY_PATH}}
+  echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH"
+fi
+
+export EPICS_CA_MAX_ARRAY_BYTES=72000000
+# Stop using the old imagej viewer. New one is faster and does not need EPICS_CA_MAX_ARRAY_BYTES
+#./ImageJ -run "EPICS AD Viewer" &
+# Please enable the PVA plugin and use that PV in the NTNDA version
+# https://areadetector.github.io/master/ADViewers/ad_viewers.html#areadetector-viewers
+# channelName will be something like this: 13SIM1:Pva1:Image
+./ImageJ -run "EPICS NTNDA Viewer" &
+
-- 
GitLab