Skip to content
Snippets Groups Projects
Commit 50b2f1c4 authored by mwyman's avatar mwyman
Browse files

Updated README and template startup scripts

parent ff659714
No related branches found
No related tags found
No related merge requests found
# xxx # 100idPy
APS BCDA synApps module: xxx 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. The IOC is based off of the xxx template from APS BCDA synApps collection. For
It uses the various modules that comprise synApps and other support. more information on synAps, see
For more information, see
http://www.aps.anl.gov/bcda/synApps http://www.aps.anl.gov/bcda/synApps
converted from APS SVN repository: Fri Nov 20 18:04:37 CST 2015 More information on the PyDevice module can be found here:
https://github.com/klemenv/PyDevice
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)
* [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 ## Setting up
(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.
Edit iocBoot/iocxxx/Makefile to set the variable ARCH and correct targets ### Python Environment
Edit iocBoot/iocxxx/st.cmd.* to agree with your hardware. Need to create conda environment from which to build and run the IOC (should be kept external to IOC file structure)
Example code is provided in the iocBoot/iocxxx/examples folder. 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' New command files in iocBoot/ioc100idPyFilters/softioc/commands:
to whatever you want 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
...@@ -80,6 +80,14 @@ BEGIN ...@@ -80,6 +80,14 @@ BEGIN
$ENV{PROCSERV}="/APSshare/bin/procServ"; $ENV{PROCSERV}="/APSshare/bin/procServ";
$ENV{NETCAT}="nc"; $ENV{NETCAT}="nc";
$ENV{ECHO}="echo"; $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}";
} }
......
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;
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;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment