Initial commit of the PSI version of motorMotorSim as a standalone

driver.
This commit is contained in:
2025-02-14 15:12:33 +01:00
commit b240341bfd
55 changed files with 4155 additions and 0 deletions

25
iocs/Makefile Normal file
View File

@ -0,0 +1,25 @@
TOP = ..
include $(TOP)/configure/CONFIG
DIRS += motorSimIOC
include $(TOP)/configure/RULES_TOP
uninstallTargets = $(foreach dir, $(DIRS), $(dir)$(DIVIDER)uninstall)
uninstall: $(uninstallTargets)
define UNINSTALL_template
$(1)$(DIVIDER)uninstall:
$(MAKE) -C $(1) uninstall
endef
$(foreach dir, $(DIRS), $(eval $(call UNINSTALL_template,$(dir))))
.PHONY: uninstall $(uninstallTargets)
realuninstallTargets = $(foreach dir, $(DIRS), $(dir)$(DIVIDER)realuninstall)
realuninstall: $(realuninstallTargets)
define REALUNINSTALL_template
$(1)$(DIVIDER)realuninstall:
$(MAKE) -C $(1) realuninstall
endef
$(foreach dir, $(DIRS), $(eval $(call REALUNINSTALL_template,$(dir))))
.PHONY: realuninstall $(realuninstallTargets)

31
iocs/motorSimIOC/Makefile Normal file
View File

@ -0,0 +1,31 @@
# Makefile at top of application tree
TOP = .
include $(TOP)/configure/CONFIG
# Directories to build, any order
DIRS += configure
DIRS += $(wildcard *Sup)
DIRS += $(wildcard *App)
DIRS += $(wildcard *Top)
DIRS += $(wildcard iocBoot)
# The build order is controlled by these dependency rules:
# All dirs except configure depend on configure
$(foreach dir, $(filter-out configure, $(DIRS)), \
$(eval $(dir)_DEPEND_DIRS += configure))
# Any *App dirs depend on all *Sup dirs
$(foreach dir, $(filter %App, $(DIRS)), \
$(eval $(dir)_DEPEND_DIRS += $(filter %Sup, $(DIRS))))
# Any *Top dirs depend on all *Sup and *App dirs
$(foreach dir, $(filter %Top, $(DIRS)), \
$(eval $(dir)_DEPEND_DIRS += $(filter %Sup %App, $(DIRS))))
# iocBoot depends on all *App dirs
iocBoot_DEPEND_DIRS += $(filter %App,$(DIRS))
# Add any additional dependency rules here:
include $(TOP)/configure/RULES_TOP

View File

@ -0,0 +1,29 @@
# CONFIG - Load build configuration data
#
# Do not make changes to this file!
# Allow user to override where the build rules come from
RULES = $(EPICS_BASE)
# RELEASE files point to other application tops
include $(TOP)/configure/RELEASE
-include $(TOP)/configure/RELEASE.$(EPICS_HOST_ARCH).Common
ifdef T_A
-include $(TOP)/configure/RELEASE.Common.$(T_A)
-include $(TOP)/configure/RELEASE.$(EPICS_HOST_ARCH).$(T_A)
endif
CONFIG = $(RULES)/configure
include $(CONFIG)/CONFIG
# Override the Base definition:
INSTALL_LOCATION = $(TOP)
# CONFIG_SITE files contain other build configuration settings
include $(TOP)/configure/CONFIG_SITE
-include $(TOP)/configure/CONFIG_SITE.$(EPICS_HOST_ARCH).Common
ifdef T_A
-include $(TOP)/configure/CONFIG_SITE.Common.$(T_A)
-include $(TOP)/configure/CONFIG_SITE.$(EPICS_HOST_ARCH).$(T_A)
endif

View File

@ -0,0 +1,44 @@
# CONFIG_SITE
# Make any application-specific changes to the EPICS build
# configuration variables in this file.
#
# Host/target specific settings can be specified in files named
# CONFIG_SITE.$(EPICS_HOST_ARCH).Common
# CONFIG_SITE.Common.$(T_A)
# CONFIG_SITE.$(EPICS_HOST_ARCH).$(T_A)
# CHECK_RELEASE controls the consistency checking of the support
# applications pointed to by the RELEASE* files.
# Normally CHECK_RELEASE should be set to YES.
# Set CHECK_RELEASE to NO to disable checking completely.
# Set CHECK_RELEASE to WARN to perform consistency checking but
# continue building even if conflicts are found.
CHECK_RELEASE = YES
# Set this when you only want to compile this application
# for a subset of the cross-compiled target architectures
# that Base is built for.
#CROSS_COMPILER_TARGET_ARCHS = vxWorks-ppc32
# To install files into a location other than $(TOP) define
# INSTALL_LOCATION here.
#INSTALL_LOCATION=</absolute/path/to/install/top>
# Set this when the IOC and build host use different paths
# to the install location. This may be needed to boot from
# a Microsoft FTP server say, or on some NFS configurations.
#IOCS_APPL_TOP = </IOC's/absolute/path/to/install/top>
# For application debugging purposes, override the HOST_OPT and/
# or CROSS_OPT settings from base/configure/CONFIG_SITE
#HOST_OPT = NO
#CROSS_OPT = NO
# Include motor's CONFIG_SITE.local when building inside motor
-include $(TOP)/../../../../configure/CONFIG_SITE.local
# Include motorMotorSim's CONFIG_SITE.local when building inside motorMotorSim
-include $(TOP)/../../configure/CONFIG_SITE.local
# Use motorSimIOC's CONFIG_SITE.local
-include $(TOP)/configure/CONFIG_SITE.local

View File

@ -0,0 +1,8 @@
TOP=..
include $(TOP)/configure/CONFIG
TARGETS = $(CONFIG_TARGETS)
CONFIGS += $(subst ../,,$(wildcard $(CONFIG_INSTALLS)))
include $(TOP)/configure/RULES

View File

@ -0,0 +1,8 @@
# RELEASE - Location of external support modules
# Use motor/module's generated release file when buidling inside motor
-include $(TOP)/../../../RELEASE.$(EPICS_HOST_ARCH).local
# Use motorMotorSim's release file when building inside motorMotorSim, but outside motor
-include $(TOP)/../../configure/RELEASE.local
# Use motorSimIOC's RELEASE.local when building outside motorMotorSim
-include $(TOP)/configure/RELEASE.local

View File

@ -0,0 +1,6 @@
# RULES
include $(CONFIG)/RULES
# Library should be rebuilt because LIBOBJS may have changed.
$(LIBNAME): ../Makefile

View File

@ -0,0 +1,2 @@
#RULES.ioc
include $(CONFIG)/RULES.ioc

View File

@ -0,0 +1,2 @@
#RULES_DIRS
include $(CONFIG)/RULES_DIRS

View File

@ -0,0 +1,3 @@
#RULES_TOP
include $(CONFIG)/RULES_TOP

View File

@ -0,0 +1,6 @@
TOP = ..
include $(TOP)/configure/CONFIG
DIRS += $(wildcard *ioc*)
DIRS += $(wildcard as*)
include $(CONFIG)/RULES_DIRS

View File

@ -0,0 +1,9 @@
TOP = ../..
include $(TOP)/configure/CONFIG
#ARCH = linux-x86_64
#ARCH = vxWorks-ppc32
ARCH = $(EPICS_HOST_ARCH)
TARGETS = cdCommands
TARGETS += envPaths
include $(TOP)/configure/RULES.ioc

View File

@ -0,0 +1,24 @@
To build any examples;
- in <motor>/configure/RELEASE: EPICS_BASE and MOTOR must be defined.
- in <motor>/Makefile: the following three lines must be uncommented;
#!DIRS += motorExApp iocBoot
#!motorExApp_DEPEND_DIRS = motorApp
#!iocBoot_DEPEND_DIRS = motorExApp
To build this simulation example;
- in <motor>/configure/RELEASE: ASYN must be defined.
- in <motor>/iocBoot/iocSim/Makefile set the target architecture
Finally, cd <motor>; gnumake clean uninstall; gnumake
To run this simulation example on a Unix OS;
- Set the EPICS_HOST_ARCH environment variable correctly.
- Edit the st.cmd.unix file for either sun or linux.
- Start the ioc from this directory by executing the following command.
../../bin/${EPICS_HOST_ARCH}/WithAsyn st.cmd.unix

View File

@ -0,0 +1,14 @@
file "$(MOTOR)/db/basic_asyn_motor.db"
{
pattern
{P, N, M, DTYP, PORT, ADDR, DESC, EGU, DIR, VELO, VBAS, ACCL, BDST, BVEL, BACC, MRES, PREC, DHLM, DLLM, INIT}
{IOC:, 1, "m$(N)", "asynMotor", motorSim1, 0, "motor $(N)", degrees, Pos, 1, .1, .2, 0, 1, .2, 0.01, 5, 100, -100, ""}
{IOC:, 2, "m$(N)", "asynMotor", motorSim1, 1, "motor $(N)", degrees, Pos, 1, .1, .2, 0, 1, .2, 0.01, 5, 100, -100, ""}
{IOC:, 3, "m$(N)", "asynMotor", motorSim1, 2, "motor $(N)", degrees, Pos, 1, .1, .2, 0, 1, .2, 0.01, 5, 100, -100, ""}
{IOC:, 4, "m$(N)", "asynMotor", motorSim1, 3, "motor $(N)", degrees, Pos, 1, .1, .2, 0, 1, .2, 0.01, 5, 100, -100, ""}
{IOC:, 5, "m$(N)", "asynMotor", motorSim2, 0, "motor $(N)", degrees, Pos, 1, .1, .2, 0, 1, .2, 0.01, 5, 100, -100, ""}
{IOC:, 6, "m$(N)", "asynMotor", motorSim2, 1, "motor $(N)", degrees, Pos, 1, .1, .2, 0, 1, .2, 0.01, 5, 100, -100, ""}
{IOC:, 7, "m$(N)", "asynMotor", motorSim2, 2, "motor $(N)", degrees, Pos, 1, .1, .2, 0, 1, .2, 0.01, 5, 100, -100, ""}
{IOC:, 8, "m$(N)", "asynMotor", motorSim2, 3, "motor $(N)", degrees, Pos, 1, .1, .2, 0, 1, .2, 0.01, 5, 100, -100, ""}
}

View File

@ -0,0 +1,24 @@
#!../../bin/linux-x86_64/motorSim
< envPaths
cd "${TOP}"
## Register all support components
dbLoadDatabase "dbd/motorSim.dbd"
motorSim_registerRecordDeviceDriver pdbbase
cd "${TOP}/iocBoot/${IOC}"
## motorUtil (allstop & alldone)
dbLoadRecords("$(MOTOR)/db/motorUtil.db", "P=motorSim:")
##
iocInit
## motorUtil (allstop & alldone)
motorUtilInit("motorSim:")
# Boot complete

View File

@ -0,0 +1,29 @@
# The is the ASYN example for communication to 4 simulated motors
# "#!" marks lines that can be uncommented.
# The following must be added for many board support packages
#!cd "... IOC st.cmd complete directory path ... "
< cdCommands
#!< ../nfsCommands
cd topbin
# If the VxWorks kernel was built using the project facility, the following must
# be added before any C++ code is loaded (see SPR #28980).
sysCplusEnable=1
ld(0,0,"motorSim.munch")
cd startup
dbLoadDatabase("$(TOP)/dbd/motorSim.dbd")
WithAsynVx_registerRecordDeviceDriver(pdbbase)
dbLoadTemplate("motor.substitutions")
# Create simulated motors: ( start card , start axis , low limit, high limit, home posn, # cards, # axes to setup)
motorSimCreate( 0, 0, -32000, 32000, 0, 1, 4 )
# Setup the Asyn layer (portname, low-level driver drvet name, card, number of axes on card)
drvAsynMotorConfigure("motorSim1", "motorSim", 0, 4)
iocInit

View File

@ -0,0 +1,26 @@
# The is the ASYN example for communication to 4 simulated motors
# "#!" marks lines that can be uncommented.
< envPaths
dbLoadDatabase("$(TOP)/dbd/motorSim.dbd")
motorSim_registerRecordDeviceDriver(pdbbase)
dbLoadTemplate("motor.substitutions")
# Create simulated motors: ( start card , start axis , low limit, high limit, home posn, # cards, # axes to setup)
motorSimCreate( 0, 0, -32000, 32000, 0, 1, 4 )
# Setup the Asyn layer (portname, low-level driver drvet name, card, number of axes on card)
drvAsynMotorConfigure("motorSim1", "motorSim", 0, 4)
motorSimCreateController("motorSim2", 8)
#asynSetTraceIOMask("motorSim2", 0, 4)
#asynSetTraceMask("motorSim2", 0, 255)
# motorSimConfigAxis(port, axis, lowLimit, highLimit, home, start)
motorSimConfigAxis("motorSim2", 0, 20000, -20000, 500, 0)
motorSimConfigAxis("motorSim2", 1, 20000, -20000, 1500, 0)
motorSimConfigAxis("motorSim2", 2, 20000, -20000, 2500, 0)
motorSimConfigAxis("motorSim2", 3, 20000, -20000, 3000, 0)
iocInit

View File

@ -0,0 +1,16 @@
# The is the ASYN example for communication to 4 simulated motors
# "#!" marks lines that can be uncommented.
< envPaths
dbLoadDatabase("$(TOP)/dbd/motorSim.dbd")
motorSim_registerRecordDeviceDriver(pdbbase)
dbLoadTemplate("motor.substitutions")
# Create simulated motors: ( start card , start axis , low limit, high limit, home posn, # cards, # axes to setup)
motorSimCreate( 0, 0, -32000, 32000, 0, 1, 4 )
# Setup the Asyn layer (portname, low-level driver drvet name, card, number of axes on card)
drvAsynMotorConfigure("motorSim1", "motorSim", 0, 4)
iocInit

View File

@ -0,0 +1 @@
medm -x -macro "P=IOC:, M1=m1, M2=m2, M3=m3, M4=m4, M5=m5, M6=m6, M7=m7, M8=m8" motor8x.adl &

View 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

View 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

View File

@ -0,0 +1,56 @@
TOP=../..
include $(TOP)/configure/CONFIG
#----------------------------------------
# ADD MACRO DEFINITIONS AFTER THIS LINE
#=============================
# The following are used for debugging messages.
#!USR_CXXFLAGS += -DDEBUG
#=============================
# Build the IOC application
PROD_IOC = motorSim
# motorSim.dbd will be created and installed
DBD += motorSim.dbd
# motorSim.dbd will be made up from these files:
motorSim_DBD += base.dbd
# Include dbd files from all support applications:
#ifdef ASYN
motorSim_DBD += asyn.dbd
#endif
motorSim_DBD += motorSupport.dbd
motorSim_DBD += motorSimSupport.dbd
# Add all the support libraries needed by this IOC
motorSim_LIBS += motorSimSupport
motorSim_LIBS += motor
#ifdef ASYN
motorSim_LIBS += asyn
#endif
#ifdef SNCSEQ
motorSim_LIBS += seq pv
#endif
# motorSim_registerRecordDeviceDriver.cpp derives from motorSim.dbd
motorSim_SRCS += motorSim_registerRecordDeviceDriver.cpp
# Build the main IOC entry point on workstation OSs.
motorSim_SRCS_DEFAULT += motorSimMain.cpp
motorSim_SRCS_vxWorks += -nil-
# Add support from base/src/vxWorks if needed
#motorSim_OBJS_vxWorks += $(EPICS_BASE_BIN)/vxComLibrary
# Finally link to the EPICS Base libraries
motorSim_LIBS += $(EPICS_BASE_IOC_LIBS)
#===========================
include $(TOP)/configure/RULES
#----------------------------------------
# ADD RULES AFTER THIS LINE

View File

@ -0,0 +1,23 @@
/* motorSimMain.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);
}