initial
This commit is contained in:
22
devsupApp/Db/Makefile
Normal file
22
devsupApp/Db/Makefile
Normal file
@ -0,0 +1,22 @@
|
||||
TOP=../..
|
||||
include $(TOP)/configure/CONFIG
|
||||
#----------------------------------------
|
||||
# ADD MACRO DEFINITIONS AFTER THIS LINE
|
||||
|
||||
#----------------------------------------------------
|
||||
# Optimization of db files using dbst (DEFAULT: NO)
|
||||
#DB_OPT = YES
|
||||
|
||||
#----------------------------------------------------
|
||||
# Create and install (or just install) into <top>/db
|
||||
# databases, templates, substitutions like this
|
||||
#DB += xxx.db
|
||||
|
||||
#----------------------------------------------------
|
||||
# If <anyname>.db template is not named <anyname>*.template add
|
||||
# <anyname>_template = <templatename>
|
||||
|
||||
include $(TOP)/configure/RULES
|
||||
#----------------------------------------
|
||||
# ADD RULES AFTER THIS LINE
|
||||
|
8
devsupApp/Makefile
Normal file
8
devsupApp/Makefile
Normal file
@ -0,0 +1,8 @@
|
||||
TOP = ..
|
||||
include $(TOP)/configure/CONFIG
|
||||
DIRS := $(DIRS) $(filter-out $(DIRS), $(wildcard *src*))
|
||||
DIRS := $(DIRS) $(filter-out $(DIRS), $(wildcard *Src*))
|
||||
DIRS := $(DIRS) $(filter-out $(DIRS), $(wildcard *db*))
|
||||
DIRS := $(DIRS) $(filter-out $(DIRS), $(wildcard *Db*))
|
||||
include $(TOP)/configure/RULES_DIRS
|
||||
|
52
devsupApp/src/Makefile
Normal file
52
devsupApp/src/Makefile
Normal file
@ -0,0 +1,52 @@
|
||||
TOP=../..
|
||||
|
||||
include $(TOP)/configure/CONFIG
|
||||
#----------------------------------------
|
||||
# ADD MACRO DEFINITIONS AFTER THIS LINE
|
||||
#=============================
|
||||
|
||||
PYTHON = python
|
||||
# EG 2.7
|
||||
PY_VER = $(shell $(PYTHON) -c 'from distutils.sysconfig import get_config_var; print get_config_var("VERSION")')
|
||||
# EG -I/usr/include/python2.7
|
||||
PY_CFLAGS := -I$(shell $(PYTHON) -c 'from distutils.sysconfig import get_python_inc; print get_python_inc()')
|
||||
# EG -L/usr/lib
|
||||
PY_LIBDIR := -L$(shell $(PYTHON) -c 'from distutils.sysconfig import get_config_var; print get_config_var("LIBDIR")')
|
||||
|
||||
USR_CPPFLAGS += $(PY_CFLAGS)
|
||||
USR_LDFLAGS += $(PY_LIBDIR)
|
||||
|
||||
#=============================
|
||||
# Build the IOC application
|
||||
|
||||
PROD_IOC = devsup
|
||||
# devsup.dbd will be created and installed
|
||||
DBD += devsup.dbd
|
||||
|
||||
# devsup.dbd will be made up from these files:
|
||||
devsup_DBD += base.dbd
|
||||
devsup_DBD += pyDevSup.dbd
|
||||
|
||||
devsup_SYS_LIBS += python$(PY_VER)
|
||||
|
||||
# devsup_registerRecordDeviceDriver.cpp derives from devsup.dbd
|
||||
devsup_SRCS += devsup_registerRecordDeviceDriver.cpp
|
||||
|
||||
# Build the main IOC entry point on workstation OSs.
|
||||
devsup_SRCS_DEFAULT += devsupMain.cpp
|
||||
devsup_SRCS_vxWorks += -nil-
|
||||
|
||||
devsup_SRCS += setup.c
|
||||
|
||||
# Add support from base/src/vxWorks if needed
|
||||
#devsup_OBJS_vxWorks += $(EPICS_BASE_BIN)/vxComLibrary
|
||||
|
||||
# Finally link to the EPICS Base libraries
|
||||
devsup_LIBS += $(EPICS_BASE_IOC_LIBS)
|
||||
|
||||
#===========================
|
||||
|
||||
include $(TOP)/configure/RULES
|
||||
#----------------------------------------
|
||||
# ADD RULES AFTER THIS LINE
|
||||
|
23
devsupApp/src/devsupMain.cpp
Normal file
23
devsupApp/src/devsupMain.cpp
Normal file
@ -0,0 +1,23 @@
|
||||
/* devsupMain.cpp */
|
||||
/* Author: Marty Kraimer Date: 17MAR2000 */
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "epicsExit.h"
|
||||
#include "epicsThread.h"
|
||||
#include "iocsh.h"
|
||||
|
||||
int main(int argc,char *argv[])
|
||||
{
|
||||
if(argc>=2) {
|
||||
iocsh(argv[1]);
|
||||
epicsThreadSleep(.2);
|
||||
}
|
||||
iocsh(NULL);
|
||||
epicsExit(0);
|
||||
return(0);
|
||||
}
|
1
devsupApp/src/pyDevSup.dbd
Normal file
1
devsupApp/src/pyDevSup.dbd
Normal file
@ -0,0 +1 @@
|
||||
registrar(pySetupReg)
|
88
devsupApp/src/setup.c
Normal file
88
devsupApp/src/setup.c
Normal file
@ -0,0 +1,88 @@
|
||||
/* python has its own ideas about which version to support */
|
||||
#undef _POSIX_C_SOURCE
|
||||
#undef _XOPEN_SOURCE
|
||||
|
||||
#include <Python.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <epicsThread.h>
|
||||
#include <epicsExit.h>
|
||||
#include <initHooks.h>
|
||||
|
||||
static PyThreadState *main_state;
|
||||
|
||||
static void cleanupPy(void *junk)
|
||||
{
|
||||
PyEval_RestoreThread(main_state);
|
||||
|
||||
Py_Finalize();
|
||||
}
|
||||
|
||||
/* Initialize the interpreter environment
|
||||
*/
|
||||
static void setupPyOnce(void *junk)
|
||||
{
|
||||
Py_Initialize();
|
||||
|
||||
PyEval_InitThreads();
|
||||
|
||||
epicsAtExit(&cleanupPy, NULL);
|
||||
|
||||
main_state = PyEval_SaveThread();
|
||||
}
|
||||
|
||||
static epicsThreadOnceId setupPyOnceId = EPICS_THREAD_ONCE_INIT;
|
||||
|
||||
void evalPy(const char* code)
|
||||
{
|
||||
PyEval_RestoreThread(main_state);
|
||||
|
||||
if(PyRun_SimpleStringFlags(code, NULL)!=0)
|
||||
PyErr_Print();
|
||||
|
||||
main_state = PyEval_SaveThread();
|
||||
}
|
||||
|
||||
void evalFilePy(const char* file)
|
||||
{
|
||||
FILE *fp;
|
||||
|
||||
PyEval_RestoreThread(main_state);
|
||||
|
||||
fp = fopen(file, "r");
|
||||
if(!fp) {
|
||||
fprintf(stderr, "Failed to open: %s\n", file);
|
||||
perror("open");
|
||||
} else {
|
||||
if(PyRun_SimpleFileExFlags(fp, file, 1, NULL)!=0)
|
||||
PyErr_Print();
|
||||
}
|
||||
/* fp closed by python */
|
||||
|
||||
main_state = PyEval_SaveThread();
|
||||
}
|
||||
|
||||
#include <iocsh.h>
|
||||
|
||||
static const iocshArg argCode = {"python code", iocshArgString};
|
||||
static const iocshArg argFile = {"file", iocshArgString};
|
||||
|
||||
static const iocshArg* const codeArgs[] = {&argCode};
|
||||
static const iocshArg* const fileArgs[] = {&argFile};
|
||||
|
||||
static const iocshFuncDef codeDef = {"evalPy", 1, codeArgs};
|
||||
static const iocshFuncDef fileDef = {"evalFilePy", 1, fileArgs};
|
||||
|
||||
static void codeRun(const iocshArgBuf *args){evalPy(args[0].sval);}
|
||||
static void fileRun(const iocshArgBuf *args){evalFilePy(args[0].sval);}
|
||||
|
||||
static void pySetupReg(void)
|
||||
{
|
||||
epicsThreadOnce(&setupPyOnceId, &setupPyOnce, NULL);
|
||||
iocshRegister(&codeDef, &codeRun);
|
||||
iocshRegister(&fileDef, &fileRun);
|
||||
}
|
||||
|
||||
#include <epicsExport.h>
|
||||
epicsExportRegistrar(pySetupReg);
|
Reference in New Issue
Block a user