#!../../bin/linux-x86/AerotechEnsembleMP

## You may have to change AerotechEnsembleMP to something else
## everywhere it appears in this file

< envPaths

cd ${TOP}

## --------------------------------------------------------------------------------

## Register all support components
dbLoadDatabase "dbd/AerotechEnsembleMP.dbd"
AerotechEnsembleMP_registerRecordDeviceDriver pdbbase

## --------------------------------------------------------------------------------

## Aerotech Ensemble MP controller configuration

# To properly configure controller read the README file in
#    $(EPICS_MODULES_TOP)/motor/$(MOTOR_MODULE_VERSION)/motorApp/AerotechSrc/

## Asyn IP port configuration
#     (1) ASYN port name
#     (2) server info (ipAddres:port)
#     (3) priority
#     (4) noAutoConnect
#     (5) noProcessEos
drvAsynIPPortConfigure("EnsemblePort","134.79.218.31:8000", 0, 0, 0)

## Aerotech Ensemble digital servo controller
#     (1) maximum number of controllers in system
EnsembleAsynSetup(1)

## The Ensemble driver does not set end of string (EOS).
asynOctetSetInputEos("EnsemblePort",0,"\n")
asynOctetSetOutputEos("EnsemblePort",0,"\n")

## Initialization of Aerotech Ensemble controller
#     (1) Controller number being configured
#     (2) ASYN port name
#     (3) ASYN address (GPIB only)
#     (4) Number of axes this controller supports
#     (5) Time to poll (msec) when an axis is in motion
#     (6) Time to poll (msec) when an axis is idle. 0 for no polling
EnsembleAsynConfig(0, "EnsemblePort", 0, 1, 100, 1000)

## Asyn-based Motor Record support
#   (1) Asyn port
#   (2) Driver name
#   (3) Controller index
#   (4) Max. number of axes
drvAsynMotorConfigure("AeroE1","motorEnsemble",0,1)

## --------------------------------------------------------------------------------

## Load record instances

dbLoadRecords(db/Aerotech_simple_motor.db)
dbLoadRecords(db/asynRecord.db, "P=AEROTECH:,R=MOTOR:ASYN,PORT=EnsemblePort,ADDR=0,IMAX=100,OMAX=100")


## --------------------------------------------------------------------------------

cd ${TOP}/iocBoot/${IOC}
iocInit

## --------------------------------------------------------------------------------

## Start any sequence programs
#seq sncxxx,"user=zovenHost"

## --------------------------------------------------------------------------------

## simple workaround to enable the controller automatically...
dbpf(AEROTECH:MOTOR:ASYN.AOUT,"ENABLE 0")
