diff --git a/README.md b/README.md index cad13e630e8f82047e4a4f5cf744094929f2eb2f..fe9e689e7738ae500dc74fb69d1c2e056a73dd09 100644 --- a/README.md +++ b/README.md @@ -1,43 +1,51 @@ -# xxx -APS BCDA synApps module: xxx +# 100idPy +EPICS IOC using PyDevice module to integrate python code into PVs -XXX is a template to use when creating an EPICS IOC that provides beam line support. -It uses the various modules that comprise synApps and other support. - -For more information, see +The IOC is based off of the xxx template from APS BCDA synApps collection. For +more information on synAps, see http://www.aps.anl.gov/bcda/synApps -converted from APS SVN repository: Fri Nov 20 18:04:37 CST 2015 - -Regarding the license of tagged versions prior to synApps 4-5, -refer to http://www.aps.anl.gov/bcda/synApps/license.php - -[Report an issue with XXX](https://github.com/epics-modules/xxx/issues/new?title=%20ISSUE%20NAME%20HERE&body=**Describe%20the%20issue**%0A%0A**Steps%20to%20reproduce**%0A1.%20Step%20one%0A2.%20Step%20two%0A3.%20Step%20three%0A%0A**Expected%20behaivour**%0A%0A**Actual%20behaviour**%0A%0A**Build%20Environment**%0AArchitecture:%0AEpics%20Base%20Version:%0ADependent%20Module%20Versions:&labels=bug) -[Request a feature](https://github.com/epics-modules/xxx/issues/new?title=%20FEATURE%20SHORT%20DESCRIPTION&body=**Feature%20Long%20Description**%0A%0A**Why%20should%20this%20be%20added?**%0A&labels=enhancement) +More information on the PyDevice module can be found here: + https://github.com/klemenv/PyDevice -* [HTML documentation](https://epics-modules.github.io/xxx) +## Sub-IOCs +### 100idPyFilters +Integrates x-ray filter attenuation calculations with control of filter devices. +Uses xraylib python module. -### Usage +### 100idPyCRL +<upcoming...> -Edit configure/RELEASE to set the variable SUPPORT +### 100idPyBL +<upcoming...> -If you don't want to build all of the default target architectures -(see the variable CROSS_COMPILER_TARGET_ARCHS in -synApps/support/configure/CONFIG, or in base/configure/CONFIG_SITE), -then edit configure/CONFIG to set the variable CROSS_COMPILER_TARGET_ARCHS. +## Setting up -Edit iocBoot/iocxxx/Makefile to set the variable ARCH and correct targets +### Python Environment -Edit iocBoot/iocxxx/st.cmd.* to agree with your hardware. -Example code is provided in the iocBoot/iocxxx/examples folder. +Need to create conda environment from which to build and run the IOC (should be kept external to IOC file structure) +Create a source script for activating the environment (e.g. 100idPyFilter_startup_env) -Edit iocBoot/iocxxx/auto*.req to add any PV's that aren't saved by the -autobuild system. -chmod a+w,g+s iocBoot/iocxxx/autosave +### Startup script changes + +xxx.pl --> 100idPyFilters.pl +Added definitions: +PYDEV_STARTUP —> file to be sourced that includes conda activation and updates to LD_LIBRARY_PATH +PYDEV_IOC_CMD —> combined source and IOC_CMD for use in screen call -Run synApps/support/utils/changePrefix to change the prefix from 'xxx' -to whatever you want +New command files in iocBoot/ioc100idPyFilters/softioc/commands: +pyrun.pl — had to combine source command and IOC startup command into one line: +``` +system("source ${PYDEV_STARTUP} && ${IOC_CMD}"); +``` + +pystart.pl — And in 6-3 looks like: +``` +system("$SCREEN -dm -S $IOC_NAME -h 5000 -L -Logfile $LOG_FILE bash -c \"$PYDEV_IOC_CMD\""); +``` + +## Running +Should be able run like any other xxx-based (synApps) IOC i.e. by running the xxx.pl file (or as in one the new examples in this IOC 100idPyFilters.pl) -Run gnumake diff --git a/iocBoot/ioc100idPy/softioc/100idPy.pl b/iocBoot/ioc100idPy/softioc/100idPy.pl index 2c8e02d55835ab3e57dcdc55c1e486d66010c0e4..a300761f6a45eff787f1b5483b691fd26191716f 100644 --- a/iocBoot/ioc100idPy/softioc/100idPy.pl +++ b/iocBoot/ioc100idPy/softioc/100idPy.pl @@ -80,6 +80,14 @@ BEGIN $ENV{PROCSERV}="/APSshare/bin/procServ"; $ENV{NETCAT}="nc"; $ENV{ECHO}="echo"; + + ########################## + # Config for PyDeviece # + ########################## + + #If PyDevice is to be used, source script needs to be set here + $ENV{PYDEV_STARTUP}="/net/s100dserv/xorApps/epics/synApps_6_3/ioc/100idPy/100idPyFilter_startup_env"; + $ENV{PYDEV_IOC_CMD}="source $ENV{PYDEV_STARTUP}; $ENV{IOC_CMD}"; } diff --git a/iocBoot/ioc100idPy/softioc/commands/pyrun.pm b/iocBoot/ioc100idPy/softioc/commands/pyrun.pm new file mode 100644 index 0000000000000000000000000000000000000000..68961662f6dc20ac8df60bbb001d717c6185e26a --- /dev/null +++ b/iocBoot/ioc100idPy/softioc/commands/pyrun.pm @@ -0,0 +1,30 @@ +package commands::pyrun; + +use Env; +use lib "$IOC_COMMAND_DIR"; +use _info; + +use Cwd; + +sub _local +{ + if (_info::ioc_up()) { print("$IOC_NAME is already running\n"); } + elsif (_info::has_remote()) { print("IOC set up for remote commands\n"); } + else + { + _info::sanity_check(); + print("Starting $IOC_NAME\n"); + + my $currdir = getcwd(); + chdir "$IOC_STARTUP_DIR"; + + # Run IOC outside of a screen session, which is helpful for debugging + # Need to setup python environment before executing startup command + print("Sourcing environment file $PYDEV_STARTUP\n"); + system("source ${PYDEV_STARTUP} && ${IOC_CMD}"); + + chdir "$currdir"; + } +} + +1; diff --git a/iocBoot/ioc100idPy/softioc/commands/pystart.pm b/iocBoot/ioc100idPy/softioc/commands/pystart.pm new file mode 100644 index 0000000000000000000000000000000000000000..23937c913877908252f30aed89ceee1ca2ef1ead --- /dev/null +++ b/iocBoot/ioc100idPy/softioc/commands/pystart.pm @@ -0,0 +1,52 @@ +package commands::pystart; + +use Env; +use Cwd; +use FindBin; +use POSIX; +use lib "$IOC_COMMAND_DIR"; +use _info; + + +sub _local() +{ + if (_info::ioc_up()) { print ("IOC is already running\n"); } + elsif (_info::has_remote()) { _info::send_cmd("COMMAND", "start"); } + else + { + _info::sanity_check(); + print ("Starting $IOC_NAME\n"); + + my $prefix = _info::procserv("CONSOLE", "PREFIX"); + my $curr_time = strftime("%y%m%d-%H%M%S", localtime()); + my $LOG_FILE="$IOC_STARTUP_DIR/softioc/logs/iocConsole/${prefix}.log_${curr_time}"; + + my $currdir = getcwd(); + + chdir "${IOC_STARTUP_DIR}"; + + #system("$SCREEN -dm -S $IOC_NAME -h 5000 -L -Logfile $LOG_FILE $IOC_CMD"); + system("$SCREEN -dm -S $IOC_NAME -h 5000 -L -Logfile $LOG_FILE bash -c \"$PYDEV_IOC_CMD\""); + + chdir "$currdir"; + } +} + +sub _remote() +{ + if (_info::ioc_up()) { print("IOC is already running\n"); } + else + { + my $ip_addr = _info::my_ip(); + my $port = _info::get_port(); + + my $prefix = _info::procserv("CONSOLE", "PREFIX"); + my $curr_time = strftime("%y%m%d-%H%M%S", localtime()); + my $LOG_FILE="$IOC_STARTUP_DIR/softioc/logs/iocConsole/${prefix}.log_${curr_time}"; + + system("cd $FindBin::RealBin; $PROCSERV --allow --quiet --oneshot -L $LOG_FILE -c $IOC_STARTUP_DIR -i ^C --logoutcmd=^D -I $prefix.txt $ip_addr:$port $IOC_CMD"); + } +} + + +1;