Move all under modules/database
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
##########################################################################
|
||||
# Copyright (c) 2011 UChicago Argonne LLC, as Operator of Argonne
|
||||
# National Laboratory.
|
||||
# EPICS BASE is distributed subject to a Software License Agreement found
|
||||
# in the file LICENSE that is included with this distribution.
|
||||
##########################################################################
|
||||
|
||||
# This is a Makefile fragment, see src/ioc/Makefile.
|
||||
|
||||
SRC_DIRS += $(STDDIR)/softIoc
|
||||
|
||||
PROD_IOC_DEFAULT = softIoc
|
||||
PROD_IOC_iOS = -nil-
|
||||
|
||||
DBD += base.dbd
|
||||
DBD += asSub.dbd
|
||||
DBD += softIoc.dbd
|
||||
|
||||
softIoc_DBD += base.dbd
|
||||
softIoc_DBD += dlload.dbd
|
||||
softIoc_DBD += system.dbd
|
||||
|
||||
softIoc_SRCS += softIoc_registerRecordDeviceDriver.cpp
|
||||
softIoc_SRCS_DEFAULT += softMain.cpp
|
||||
softIoc_SRCS_vxWorks = -nil-
|
||||
|
||||
softIoc_LIBS = $(EPICS_BASE_IOC_LIBS)
|
||||
|
||||
DB += softIocExit.db
|
||||
|
||||
FINAL_LOCATION ?= $(shell $(PERL) $(TOOLS)/fullPathName.pl $(INSTALL_LOCATION))
|
||||
|
||||
CLEANS += epicsInstallDir.h
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
##########################################################################
|
||||
# Copyright (c) 2011 UChicago Argonne LLC, as Operator of Argonne
|
||||
# National Laboratory.
|
||||
# EPICS BASE is distributed subject to a Software License Agreement found
|
||||
# in the file LICENSE that is included with this distribution.
|
||||
##########################################################################
|
||||
|
||||
# This is a Makefile fragment, see src/ioc/Makefile.
|
||||
|
||||
softIoc.dbd$(DEP): $(COMMON_DIR)/stdRecords.dbd
|
||||
softIoc.dbd$(DEP): $(COMMON_DIR)/filters.dbd
|
||||
softIoc.dbd$(DEP): $(COMMON_DIR)/links.dbd
|
||||
$(COMMON_DIR)/softIoc.dbd: $(COMMON_DIR)/stdRecords.dbd
|
||||
$(COMMON_DIR)/softIoc.dbd: $(COMMON_DIR)/filters.dbd
|
||||
$(COMMON_DIR)/softIoc.dbd: $(COMMON_DIR)/links.dbd
|
||||
$(COMMON_DIR)/softIoc.dbd: $(STDDIR)/softIoc/Makefile
|
||||
|
||||
softMain$(DEP): epicsInstallDir.h
|
||||
|
||||
epicsInstallDir.h: $(TOP)/configure/CONFIG_SITE*
|
||||
$(ECHO) "FINAL_LOCATION=$(FINAL_LOCATION)"
|
||||
$(PERL) $(STDDIR)/softIoc/makeInstallDir.pl "$(FINAL_LOCATION)" > $@
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
# Register access security subroutines
|
||||
registrar(asSub)
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
# This file includes the standard record types and device support
|
||||
# provided by Base and (usually) loaded into all IOCs.
|
||||
|
||||
# Fixed menus
|
||||
include "menuGlobal.dbd"
|
||||
|
||||
# Modifyable menus
|
||||
include "menuConvert.dbd"
|
||||
include "menuScan.dbd"
|
||||
|
||||
# Record types
|
||||
include "stdRecords.dbd"
|
||||
|
||||
# Channel filters & plugins
|
||||
include "filters.dbd"
|
||||
|
||||
# Link types
|
||||
include "links.dbd"
|
||||
|
||||
# Standard device support
|
||||
include "devSoft.dbd"
|
||||
|
||||
# Access security subroutines
|
||||
include "asSub.dbd"
|
||||
|
||||
# IOC Core variables
|
||||
include "dbCore.dbd"
|
||||
|
||||
# RSRV server
|
||||
include "rsrv.dbd"
|
||||
@@ -0,0 +1,28 @@
|
||||
eval 'exec perl -S $0 ${1+"$@"}' # -*- Mode: perl -*-
|
||||
if $running_under_some_shell;
|
||||
#*************************************************************************
|
||||
# Copyright (c) 2010 UChicago Argonne LLC, as Operator of Argonne
|
||||
# National Laboratory.
|
||||
# EPICS BASE is distributed subject to a Software License Agreement found
|
||||
# in file LICENSE that is included with this distribution.
|
||||
#*************************************************************************
|
||||
|
||||
use strict;
|
||||
|
||||
die "$0: Argument missing, INSTALL_LOCATION\n" if @ARGV == 0;
|
||||
die "$0: Too many arguments, expecting one\n" unless @ARGV == 1;
|
||||
|
||||
my $path = shift;
|
||||
|
||||
$path =~ s/\\/\\\\/gx;
|
||||
$path =~ s/^'//;
|
||||
$path =~ s/'$//;
|
||||
|
||||
print "/* THIS IS A GENERATED FILE. DO NOT EDIT! */\n",
|
||||
"\n",
|
||||
"#ifndef INC_epicsInstallDir_H\n",
|
||||
"#define INC_epicsInstallDir_H\n",
|
||||
"\n",
|
||||
"#define EPICS_BASE \"$path\"\n",
|
||||
"\n",
|
||||
"#endif /* INC_epicsInstallDir_H */\n";
|
||||
@@ -0,0 +1,15 @@
|
||||
# softIocExit.db
|
||||
|
||||
record(sub,"$(IOC):exit") {
|
||||
field(DESC,"Exit subroutine")
|
||||
field(SCAN,"Passive")
|
||||
field(SNAM,"exit")
|
||||
}
|
||||
|
||||
record(stringin,"$(IOC):BaseVersion") {
|
||||
field(DESC,"EPICS Base Version")
|
||||
field(DTYP,"getenv")
|
||||
field(INP,"@EPICS_VERSION_FULL")
|
||||
field(PINI,"YES")
|
||||
field(DISP,1)
|
||||
}
|
||||
@@ -0,0 +1,233 @@
|
||||
/*************************************************************************\
|
||||
* Copyright (c) 2008 UChicago Argonne LLC, as Operator of Argonne
|
||||
* National Laboratory.
|
||||
* Copyright (c) 2003 The Regents of the University of California, as
|
||||
* Operator of Los Alamos National Laboratory.
|
||||
* EPICS BASE is distributed subject to the Software License Agreement
|
||||
* found in the file LICENSE that is included with this distribution.
|
||||
\*************************************************************************/
|
||||
|
||||
/* Author: Andrew Johnson Date: 2003-04-08 */
|
||||
|
||||
/* Usage:
|
||||
* softIoc [-D softIoc.dbd] [-h] [-S] [-s] [-a ascf]
|
||||
* [-m macro=value,macro2=value2] [-d file.db]
|
||||
* [-x prefix] [st.cmd]
|
||||
*
|
||||
* If used the -D option must come first, and specify the
|
||||
* path to the softIoc.dbd file. The compile-time install
|
||||
* location is saved in the binary as a default.
|
||||
*
|
||||
* Usage information will be printed if -h is given, then
|
||||
* the program will exit normally.
|
||||
*
|
||||
* The -S option prevents an interactive shell being started
|
||||
* after all arguments have been processed.
|
||||
*
|
||||
* Previous versions accepted a -s option to cause a shell
|
||||
* to be started; this option is still accepted but ignored
|
||||
* since a command shell is now started by default.
|
||||
*
|
||||
* Access Security can be enabled with the -a option giving
|
||||
* the name of the configuration file; if any macros were
|
||||
* set with -m before the -a option was given, they will be
|
||||
* used as access security substitution macros.
|
||||
*
|
||||
* Any number of -m and -d arguments can be interspersed;
|
||||
* the macros are applied to the following .db files. Each
|
||||
* later -m option causes earlier macros to be discarded.
|
||||
*
|
||||
* The -x option loads the softIocExit.db with the macro
|
||||
* IOC set to the string provided. This database contains
|
||||
* a subroutine record named $(IOC):exit which has its field
|
||||
* SNAM set to "exit". When this record is processed, the
|
||||
* subroutine that runs will call epicsExit() with the value
|
||||
* of the field A determining whether the exit status is
|
||||
* EXIT_SUCCESS if (A == 0.0) or EXIT_FAILURE (A != 0.0).
|
||||
*
|
||||
* A st.cmd file is optional. If any databases were loaded
|
||||
* the st.cmd file will be run *after* iocInit. To perform
|
||||
* iocsh commands before iocInit, all database loading must
|
||||
* be performed by the script itself, or by the user from
|
||||
* the interactive IOC shell.
|
||||
*/
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "registryFunction.h"
|
||||
#include "epicsThread.h"
|
||||
#include "epicsExit.h"
|
||||
#include "epicsStdio.h"
|
||||
#include "dbStaticLib.h"
|
||||
#include "subRecord.h"
|
||||
#include "dbAccess.h"
|
||||
#include "asDbLib.h"
|
||||
#include "iocInit.h"
|
||||
#include "iocsh.h"
|
||||
#include "epicsInstallDir.h"
|
||||
|
||||
extern "C" int softIoc_registerRecordDeviceDriver(struct dbBase *pdbbase);
|
||||
|
||||
#define DBD_FILE EPICS_BASE "/dbd/softIoc.dbd"
|
||||
#define EXIT_FILE EPICS_BASE "/db/softIocExit.db"
|
||||
|
||||
const char *arg0;
|
||||
const char *base_dbd = DBD_FILE;
|
||||
const char *exit_db = EXIT_FILE;
|
||||
|
||||
|
||||
static void exitSubroutine(subRecord *precord) {
|
||||
epicsExitLater((precord->a == 0.0) ? EXIT_SUCCESS : EXIT_FAILURE);
|
||||
}
|
||||
|
||||
static void usage(int status) {
|
||||
printf("Usage: %s [-D softIoc.dbd] [-h] [-S] [-a ascf]\n", arg0);
|
||||
puts("\t[-m macro=value,macro2=value2] [-d file.db]");
|
||||
puts("\t[-x prefix] [st.cmd]");
|
||||
puts("Compiled-in path to softIoc.dbd is:");
|
||||
printf("\t%s\n", base_dbd);
|
||||
epicsExit(status);
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
char *dbd_file = const_cast<char*>(base_dbd);
|
||||
char *macros = NULL;
|
||||
char xmacro[PVNAME_STRINGSZ + 4];
|
||||
int startIocsh = 1; /* default = start shell */
|
||||
int loadedDb = 0;
|
||||
|
||||
arg0 = strrchr(*argv, '/');
|
||||
if (!arg0) {
|
||||
arg0 = *argv;
|
||||
} else {
|
||||
++arg0; /* skip the '/' */
|
||||
}
|
||||
|
||||
--argc, ++argv;
|
||||
|
||||
/* Do this here in case the dbd file not available */
|
||||
if (argc>0 && **argv=='-' && (*argv)[1]=='h') {
|
||||
usage(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
if (argc>1 && **argv=='-' && (*argv)[1]=='D') {
|
||||
dbd_file = *++argv;
|
||||
argc -= 2;
|
||||
++argv;
|
||||
}
|
||||
|
||||
if (dbLoadDatabase(dbd_file, NULL, NULL)) {
|
||||
epicsExit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
softIoc_registerRecordDeviceDriver(pdbbase);
|
||||
registryFunctionAdd("exit", (REGISTRYFUNCTION) exitSubroutine);
|
||||
|
||||
while (argc>1 && **argv == '-') {
|
||||
switch ((*argv)[1]) {
|
||||
case 'a':
|
||||
if (macros) asSetSubstitutions(macros);
|
||||
asSetFilename(*++argv);
|
||||
--argc;
|
||||
break;
|
||||
|
||||
case 'd':
|
||||
if (dbLoadRecords(*++argv, macros)) {
|
||||
epicsExit(EXIT_FAILURE);
|
||||
}
|
||||
loadedDb = 1;
|
||||
--argc;
|
||||
break;
|
||||
|
||||
case 'h':
|
||||
usage(EXIT_SUCCESS);
|
||||
|
||||
case 'm':
|
||||
macros = *++argv;
|
||||
--argc;
|
||||
break;
|
||||
|
||||
case 'S':
|
||||
startIocsh = 0;
|
||||
break;
|
||||
|
||||
case 's':
|
||||
break;
|
||||
|
||||
case 'x':
|
||||
epicsSnprintf(xmacro, sizeof xmacro, "IOC=%s", *++argv);
|
||||
if (dbLoadRecords(exit_db, xmacro)) {
|
||||
epicsExit(EXIT_FAILURE);
|
||||
}
|
||||
loadedDb = 1;
|
||||
--argc;
|
||||
break;
|
||||
|
||||
default:
|
||||
printf("%s: option '%s' not recognized\n", arg0, *argv);
|
||||
usage(EXIT_FAILURE);
|
||||
}
|
||||
--argc;
|
||||
++argv;
|
||||
}
|
||||
|
||||
if (argc>0 && **argv=='-') {
|
||||
switch((*argv)[1]) {
|
||||
case 'a':
|
||||
case 'd':
|
||||
case 'm':
|
||||
case 'x':
|
||||
printf("%s: missing argument to option '%s'\n", arg0, *argv);
|
||||
usage(EXIT_FAILURE);
|
||||
|
||||
case 'h':
|
||||
usage(EXIT_SUCCESS);
|
||||
|
||||
case 'S':
|
||||
startIocsh = 0;
|
||||
break;
|
||||
|
||||
case 's':
|
||||
break;
|
||||
|
||||
default:
|
||||
printf("%s: option '%s' not recognized\n", arg0, *argv);
|
||||
usage(EXIT_FAILURE);
|
||||
}
|
||||
--argc;
|
||||
++argv;
|
||||
}
|
||||
|
||||
if (loadedDb) {
|
||||
iocInit();
|
||||
epicsThreadSleep(0.2);
|
||||
}
|
||||
|
||||
/* run user's startup script */
|
||||
if (argc>0) {
|
||||
if (iocsh(*argv)) epicsExit(EXIT_FAILURE);
|
||||
epicsThreadSleep(0.2);
|
||||
loadedDb = 1; /* Give it the benefit of the doubt... */
|
||||
}
|
||||
|
||||
/* start an interactive shell if it was requested */
|
||||
if (startIocsh) {
|
||||
iocsh(NULL);
|
||||
} else {
|
||||
if (loadedDb) {
|
||||
epicsThreadExitMain();
|
||||
} else {
|
||||
printf("%s: Nothing to do!\n", arg0);
|
||||
usage(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
epicsExit(EXIT_SUCCESS);
|
||||
/*Note that the following statement will never be executed*/
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user