# Database for profile moves with asynMotor
# This is the database for the controller itself, profileMoveAxis is the file
# for each axis.
#
#    Mark Rivers
#    April 3, 2011
#
#
# Macro paramters:
#   $(P)        - PV name prefix
#   $(R)        - PV base record name
#   $(PORT)     - asyn port for this controller
#   $(NAXES)    - Number of axes to be used.
#   $(NPOINTS)  - Maximum profile points
#   $(NPULSES)  - Maximum number of output pulses
#   $(TIMEOUT)  - asyn timeout

#
# PVs controlling the number of profile elements and the number of output
# pulses
#
record(longout,"$(P)$(R)NumAxes") {
    field(DESC, "# of axes being used")
    field(PINI, "YES")
    field(DTYP, "asynInt32")
    field(OUT,  "@asyn($(PORT),0,$(TIMEOUT))PROFILE_NUM_AXES")
    field(VAL,  "$(NAXES)")
}
record(longout,"$(P)$(R)NumPoints") {
    field(DESC, "# of points in profile")
    field(PINI, "YES")
    field(DTYP, "asynInt32")
    field(OUT,  "@asyn($(PORT),0,$(TIMEOUT))PROFILE_NUM_POINTS")
    field(VAL,  "$(NPOINTS)")
}
record(longin, "$(P)$(R)CurrentPoint") {
    field(DESC, "Current point in profile")
    field(DTYP, "asynInt32")
    field(INP,  "@asyn($(PORT),0,$(TIMEOUT))PROFILE_CURRENT_POINT")
    field(SCAN, "I/O Intr")
}
record(longout,"$(P)$(R)NumPulses") {
    field(DESC, "Number of output pulses")
    field(PINI, "YES")
    field(DTYP, "asynInt32")
    field(OUT,  "@asyn($(PORT),0,$(TIMEOUT))PROFILE_NUM_PULSES")
    field(VAL,  "$(NPULSES)")
}
record(longin,"$(P)$(R)NumActualPulses") {
    field(DESC, "Actual # of output pulses")
    field(DTYP, "asynInt32")
    field(INP,  "@asyn($(PORT),0,$(TIMEOUT))PROFILE_ACTUAL_PULSES")
    field(SCAN, "I/O Intr")
}
record(longout, "$(P)$(R)StartPulses") {
    field(DESC, "Point # to start pulses")
    field(PINI, "YES")
    field(DTYP, "asynInt32")
    field(OUT,  "@asyn($(PORT),0,$(TIMEOUT))PROFILE_START_PULSES")
    field(VAL, "1")
}
record(longout,"$(P)$(R)EndPulses") {
    field(DESC, "Point # to end pulses")
    field(PINI, "YES")
    field(DTYP, "asynInt32")
    field(OUT,  "@asyn($(PORT),0,$(TIMEOUT))PROFILE_END_PULSES")
    field(VAL,  "$(NPOINTS)")
}

#
# PVs controlling the profile speed and acceleration
#
grecord(bo,"$(P)$(R)TimeMode") {
    field(DESC, "Profile time mode")
    field(PINI, "YES")
    field(DTYP, "asynInt32")
    field(OUT,  "@asyn($(PORT),0,$(TIMEOUT))PROFILE_TIME_MODE")
    field(ZNAM, "Fixed")
    field(ONAM, "Array")
}
grecord(ao,"$(P)$(R)FixedTime") {
    field(DESC, "Profile fixed time per point")
    field(PINI, "YES")
    field(DTYP, "asynFloat64")
    field(OUT,  "@asyn($(PORT),0,$(TIMEOUT))PROFILE_FIXED_TIME")
    field(VAL,  "1.")
    field(PREC, "3")
}
record(waveform,"$(P)$(R)Times") {
    field(DESC, "Profile time at each point")
    field(DTYP, "asynFloat64ArrayOut")
    field(INP,  "@asyn($(PORT),0,$(TIMEOUT))PROFILE_TIME_ARRAY")
    field(NELM, "$(NPOINTS)")
    field(FTVL, "DOUBLE")
    field(PREC, "3")
}
record(ao,"$(P)$(R)Acceleration") {
    field(DESC, "Profile Acceleration")
    field(PINI, "YES")
    field(DTYP, "asynFloat64")
    field(OUT,  "@asyn($(PORT),0,$(TIMEOUT))PROFILE_ACCELERATION")
    field(VAL,  "0.5")
    field(PREC, "3")
}

#
# PV for absolute/relative mode
#
grecord(bo,"$(P)$(R)MoveMode") {
    field(DESC, "Profile move mode")
    field(PINI, "YES")
    field(DTYP, "asynInt32")
    field(OUT,  "@asyn($(PORT),0,$(TIMEOUT))PROFILE_MOVE_MODE")
    field(ZNAM, "Absolute")
    field(ONAM, "Relative")
}

#
# PVs to build the profile
#
record(busy,"$(P)$(R)Build") {
    field(DESC,"Build and check profile")
    field(DTYP, "asynInt32")
    field(OUT,  "@asyn($(PORT),0,$(TIMEOUT))PROFILE_BUILD")
    field(ZNAM, "Done")
    field(ONAM, "Build")
}
record(mbbi,"$(P)$(R)BuildState") {
    field(DESC,"Profile build state")
    field(DTYP, "asynInt32")
    field(INP,  "@asyn($(PORT),0,$(TIMEOUT))PROFILE_BUILD_STATE")
    field(ZRVL, "0")
    field(ZRST, "Done")
    field(ZRSV, "NO_ALARM")
    field(ONVL, "1")
    field(ONST, "Busy")
    field(ONSV, "MINOR")
    field(SCAN, "I/O Intr")
}
record(mbbi,"$(P)$(R)BuildStatus") {
    field(DESC,"Profile build status")
    field(DTYP, "asynInt32")
    field(INP,  "@asyn($(PORT),0,$(TIMEOUT))PROFILE_BUILD_STATUS")
    field(ZRVL, "0")
    field(ZRST, "Undefined")
    field(ZRSV, "INVALID")
    field(ONVL, "1")
    field(ONST, "Success")
    field(ONSV, "NO_ALARM")
    field(TWVL, "2")
    field(TWST, "Failure")
    field(TWSV, "MAJOR")
    field(SCAN, "I/O Intr")
}
record(waveform,"$(P)$(R)BuildMessage") {
    field(DESC, "Profile build message")
    field(DTYP, "asynOctetRead")
    field(INP,  "@asyn($(PORT),0,$(TIMEOUT))PROFILE_BUILD_MESSAGE")
    field(FTVL, "CHAR")
    field(NELM, "256")
    field(SCAN, "I/O Intr")
}
#
# PVs to execute and abort the profile
#
record(busy,"$(P)$(R)Execute") {
    field(DESC,"Execute profile motion")
    field(DTYP, "asynInt32")
    field(OUT,  "@asyn($(PORT),0,$(TIMEOUT))PROFILE_EXECUTE")
    field(ZNAM, "Done")
    field(ONAM, "Execute")
}
record(mbbi,"$(P)$(R)ExecuteState") {
    field(DESC,"Profile execute state")
    field(DTYP, "asynInt32")
    field(INP,  "@asyn($(PORT),0,$(TIMEOUT))PROFILE_EXECUTE_STATE")
    field(ZRVL, "0")
    field(ZRST, "Done")
    field(ZRSV, "NO_ALARM")
    field(ONVL, "1")
    field(ONST, "Move start")
    field(ONSV, "MINOR")
    field(TWVL, "2")
    field(TWST, "Executing")
    field(TWSV, "MINOR")
    field(THVL, "3")
    field(THST, "Flyback")
    field(THSV, "MINOR")
    field(SCAN, "I/O Intr")
}
record(mbbi,"$(P)$(R)ExecuteStatus") {
    field(DESC, "Profile execute status")
    field(DTYP, "asynInt32")
    field(INP,  "@asyn($(PORT),0,$(TIMEOUT))PROFILE_EXECUTE_STATUS")
    field(ZRVL, "0")
    field(ZRST, "Undefined")
    field(ZRSV, "INVALID")
    field(ONVL, "1")
    field(ONST, "Success")
    field(ONSV, "NO_ALARM")
    field(TWVL, "2")
    field(TWST, "Failure")
    field(TWSV, "MAJOR")
    field(THVL, "3")
    field(THST, "Abort")
    field(THSV, "MAJOR")
    field(FRVL, "4")
    field(FRST, "Timeout")
    field(FRSV, "MAJOR")
    field(SCAN, "I/O Intr")
}
record(waveform,"$(P)$(R)ExecuteMessage") {
    field(DESC, "Profile execute message")
    field(DTYP, "asynOctetRead")
    field(INP,  "@asyn($(PORT),0,$(TIMEOUT))PROFILE_EXECUTE_MESSAGE")
    field(FTVL, "CHAR")
    field(NELM, "256")
    field(SCAN, "I/O Intr")
}
record(bo,"$(P)$(R)Abort") {
    field(DESC, "Abort profile motion")
    field(DTYP, "asynInt32")
    field(OUT,  "@asyn($(PORT),0,$(TIMEOUT))PROFILE_ABORT")
    field(ZNAM, "Done")
    field(ONAM, "Abort")
}

#
# PVs for readback of actual positions and errors
#
record(busy,"$(P)$(R)Readback") {
    field(DESC, "Read back actual positions")
    field(DTYP, "asynInt32")
    field(OUT,  "@asyn($(PORT),0,$(TIMEOUT))PROFILE_READBACK")
    field(ZNAM, "Done")
    field(ONAM, "Readback")
}
record(mbbi,"$(P)$(R)ReadbackState") {
    field(DESC, "Readback state")
    field(DTYP, "asynInt32")
    field(INP,  "@asyn($(PORT),0,$(TIMEOUT))PROFILE_READBACK_STATE")
    field(ZRVL, "0")
    field(ZRST, "Done")
    field(ZRSV, "NO_ALARM")
    field(ONVL, "1")
    field(ONST, "Busy")
    field(ONSV, "MINOR")
    field(SCAN, "I/O Intr")
}
record(mbbi,"$(P)$(R)ReadbackStatus") {
    field(DESC, "Readback status")
    field(DTYP, "asynInt32")
    field(INP,  "@asyn($(PORT),0,$(TIMEOUT))PROFILE_READBACK_STATUS")
    field(ZRVL, "0")
    field(ZRST, "Undefined")
    field(ZRSV, "INVALID")
    field(ONVL, "1")
    field(ONST, "Success")
    field(ONSV, "NO_ALARM")
    field(TWVL, "2")
    field(TWST, "Failure")
    field(TWSV, "MAJOR")
    field(SCAN, "I/O Intr")
}
record(waveform,"$(P)$(R)ReadbackMessage") {
    field(DESC, "Profile readback message")
    field(DTYP, "asynOctetRead")
    field(INP,  "@asyn($(PORT),0,$(TIMEOUT))PROFILE_READBACK_MESSAGE")
    field(FTVL, "CHAR")
    field(NELM, "256")
    field(SCAN, "I/O Intr")
}

