# Database for the records specific to the ADSC detectors
# J. Lewis Muir (copied and modified prosilica.template by Mark Rivers)
# April 15, 2008

##############################################################################
#  Controls how frequently to read the condition of the detector             #
##############################################################################

record(longout, "$(P)$(R)ADSCReadConditn")
{
   field(DTYP, "asynInt32")
   field(OUT,  "@asyn($(PORT),$(ADDR),$(TIMEOUT))ADSC_READ_CONDITION")
   field(SCAN, "5 second")
}

##############################################################################
#  Detector condition properties                                             #
##############################################################################

record(mbbi, "$(P)$(R)ADSCState")
{
   field(DTYP, "asynInt32")
   field(INP,  "@asyn($(PORT),$(ADDR),$(TIMEOUT))ADSC_STATE")
   # These labels should match incl/detcon_state.h in ADSC control library
   field(ZRST, "IDLE")
   field(ZRVL, "0")
   field(ONST, "EXPOSING")
   field(ONVL, "1")
   field(TWST, "READING")
   field(TWVL, "2")
   field(THST, "ERROR")
   field(THVL, "3")
   field(FRST, "CONFIGDET")
   field(FRVL, "4")
   field(FVST, "RETRY")
   field(FVVL, "5")
   field(SXST, "TEMPCONTROL")
   field(SXVL, "6")
   field(SCAN, "I/O Intr")
}

record(waveform, "$(P)$(R)ADSCStatus")
{
   field(DTYP, "asynOctetRead")
   field(INP,  "@asyn($(PORT),$(ADDR),$(TIMEOUT))ADSC_STATUS")
   field(FTVL, "UCHAR")
   field(NELM, "256")
   field(SCAN, "I/O Intr")
}

record(waveform, "$(P)$(R)ADSCLastError")
{
   field(DTYP, "asynOctetRead")
   field(INP,  "@asyn($(PORT),$(ADDR),$(TIMEOUT))ADSC_LAST_ERROR")
   field(FTVL, "UCHAR")
   field(NELM, "256")
   field(SCAN, "I/O Intr")
}

##############################################################################
#  Detector error recovery parameters                                        #
##############################################################################

record(longout, "$(P)$(R)ADSCSoftReset")
{
   field(DTYP, "asynInt32")
   field(OUT,  "@asyn($(PORT),$(ADDR),$(TIMEOUT))ADSC_SOFTWARE_RESET")
}

##############################################################################
#  Detector continuous image mode parameters                                 #
##############################################################################

record(longout, "$(P)$(R)ADSCLastImage")
{
   field(DTYP, "asynInt32")
   field(OUT,  "@asyn($(PORT),$(ADDR),$(TIMEOUT))ADSC_LAST_IMAGE")
}

##############################################################################
#  Detector external trigger parameters                                      #
##############################################################################

record(bi, "$(P)$(R)ExSwTrOkToExp")
{
   field(DTYP, "asynInt32")
   field(INP,  "@asyn($(PORT),$(ADDR),$(TIMEOUT))ADSC_OK_TO_EXPOSE")
   field(SCAN, "I/O Intr")
   field(ZNAM, "No")
   field(ONAM, "Yes")
}

record(mbbo, "$(P)$(R)ExSwTrCtl")
{
   field(DTYP, "asynInt32")
   field(OUT,  "@asyn($(PORT),$(ADDR),$(TIMEOUT))ADSC_EXTERN_SW_TRIGGER_CTRL")
   field(ZRST, "Stop")
   field(ZRVL, "0")
   field(ONST, "Start")
   field(ONVL, "1")
}
record(mbbi, "$(P)$(R)ExSwTrCtlRsp")
{
   field(DTYP, "asynInt32")
   field(INP,  "@asyn($(PORT),$(ADDR),$(TIMEOUT))ADSC_EXTERN_SW_TRIGGER_CTRL")
   field(SCAN, "I/O Intr")
   field(ZRST, "Stop")
   field(ZRVL, "0")
   field(ONST, "Start")
   field(ONVL, "1")
   field(TWST, "OK")
   field(TWVL, "2")
   field(THST, "Again")
   field(THVL, "3")
}

##############################################################################
#  Driver parameters                                                         #
##############################################################################

record(mbbo, "$(P)$(R)ADSCReusDrk")
{
   field(PINI, "YES")
   field(DTYP, "asynInt32")
   field(OUT,  "@asyn($(PORT),$(ADDR),$(TIMEOUT))ADSC_REUSE_DARKS")
   field(ZRST, "No")
   field(ZRVL, "0")
   field(ONST, "Yes")
   field(ONVL, "1")
}

record(mbbi, "$(P)$(R)ADSCReusDrk_RBV")
{
   field(DTYP, "asynInt32")
   field(INP,  "@asyn($(PORT),$(ADDR),$(TIMEOUT))ADSC_REUSE_DARKS")
   field(SCAN, "I/O Intr")
   field(ZRST, "No")
   field(ZRVL, "0")
   field(ONST, "Yes")
   field(ONVL, "1")
}

record(mbbo, "$(P)$(R)ADSCDezingr")
{
   field(PINI, "YES")
   field(DTYP, "asynInt32")
   field(OUT,  "@asyn($(PORT),$(ADDR),$(TIMEOUT))ADSC_DEZINGER")
   field(ZRST, "No")
   field(ZRVL, "0")
   field(ONST, "Yes")
   field(ONVL, "1")
}

record(mbbi, "$(P)$(R)ADSCDezingr_RBV")
{
   field(DTYP, "asynInt32")
   field(INP,  "@asyn($(PORT),$(ADDR),$(TIMEOUT))ADSC_DEZINGER")
   field(SCAN, "I/O Intr")
   field(ZRST, "No")
   field(ZRVL, "0")
   field(ONST, "Yes")
   field(ONVL, "1")
}

##############################################################################
#  Detector hardware parameters                                              #
##############################################################################

record(mbbo, "$(P)$(R)ADSCAdc")
{
   field(PINI, "YES")
   field(DTYP, "asynInt32")
   field(OUT,  "@asyn($(PORT),$(ADDR),$(TIMEOUT))ADSC_ADC")
   field(ZRST, "Slow/Software")
   field(ZRVL, "0")
   field(ONST, "Fast/Hardware")
   field(ONVL, "1")
}

record(mbbi, "$(P)$(R)ADSCAdc_RBV")
{
   field(DTYP, "asynInt32")
   field(INP,  "@asyn($(PORT),$(ADDR),$(TIMEOUT))ADSC_ADC")
   field(SCAN, "I/O Intr")
   field(ZRST, "Slow/Software")
   field(ZRVL, "0")
   field(ONST, "Fast/Hardware")
   field(ONVL, "1")
}

record(mbbo, "$(P)$(R)ADSCRaw")
{
   field(PINI, "YES")
   field(DTYP, "asynInt32")
   field(OUT,  "@asyn($(PORT),$(ADDR),$(TIMEOUT))ADSC_RAW")
   field(ZRST, "No")
   field(ZRVL, "0")
   field(ONST, "Yes")
   field(ONVL, "1")
}

record(mbbi, "$(P)$(R)ADSCRaw_RBV")
{
   field(DTYP, "asynInt32")
   field(INP,  "@asyn($(PORT),$(ADDR),$(TIMEOUT))ADSC_RAW")
   field(SCAN, "I/O Intr")
   field(ZRST, "No")
   field(ZRVL, "0")
   field(ONST, "Yes")
   field(ONVL, "1")
}

record(mbbo, "$(P)$(R)ADSCImXform")
{
   field(PINI, "YES")
   field(DTYP, "asynInt32")
   field(OUT,  "@asyn($(PORT),$(ADDR),$(TIMEOUT))ADSC_IMAGE_TRANSFORM")
   field(ZRST, "No")
   field(ZRVL, "0")
   field(ONST, "Yes")
   field(ONVL, "1")
}

record(mbbi, "$(P)$(R)ADSCImXform_RBV")
{
   field(DTYP, "asynInt32")
   field(INP,  "@asyn($(PORT),$(ADDR),$(TIMEOUT))ADSC_IMAGE_TRANSFORM")
   field(SCAN, "I/O Intr")
   field(ZRST, "No")
   field(ZRVL, "0")
   field(ONST, "Yes")
   field(ONVL, "1")
}

record(mbbo, "$(P)$(R)ADSCStrDrks")
{
   field(PINI, "YES")
   field(DTYP, "asynInt32")
   field(OUT,  "@asyn($(PORT),$(ADDR),$(TIMEOUT))ADSC_STORED_DARKS")
   field(ZRST, "No")
   field(ZRVL, "0")
   field(ONST, "Yes")
   field(ONVL, "1")
}

record(mbbi, "$(P)$(R)ADSCStrDrks_RBV")
{
   field(DTYP, "asynInt32")
   field(INP,  "@asyn($(PORT),$(ADDR),$(TIMEOUT))ADSC_STORED_DARKS")
   field(SCAN, "I/O Intr")
   field(ZRST, "No")
   field(ZRVL, "0")
   field(ONST, "Yes")
   field(ONVL, "1")
}

##############################################################################
#  Detector file parameters                                                  #
##############################################################################

record(ao, "$(P)$(R)ADSCBeamX")
{
   field(PINI, "YES")
   field(DTYP, "asynFloat64")
   field(OUT,  "@asyn($(PORT),$(ADDR),$(TIMEOUT))ADSC_BEAM_CENTER_X")
   field(PREC, "3")
}

record(ai, "$(P)$(R)ADSCBeamX_RBV")
{
   field(DTYP, "asynFloat64")
   field(INP,  "@asyn($(PORT),$(ADDR),$(TIMEOUT))ADSC_BEAM_CENTER_X")
   field(PREC, "3")
   field(SCAN, "I/O Intr")
}

record(ao, "$(P)$(R)ADSCBeamY")
{
   field(PINI, "YES")
   field(DTYP, "asynFloat64")
   field(OUT,  "@asyn($(PORT),$(ADDR),$(TIMEOUT))ADSC_BEAM_CENTER_Y")
   field(PREC, "3")
}

record(ai, "$(P)$(R)ADSCBeamY_RBV")
{
   field(DTYP, "asynFloat64")
   field(INP,  "@asyn($(PORT),$(ADDR),$(TIMEOUT))ADSC_BEAM_CENTER_Y")
   field(PREC, "3")
   field(SCAN, "I/O Intr")
}

record(ao, "$(P)$(R)ADSCDistnce")
{
   field(PINI, "YES")
   field(DTYP, "asynFloat64")
   field(OUT,  "@asyn($(PORT),$(ADDR),$(TIMEOUT))ADSC_DISTANCE")
   field(PREC, "3")
}

record(ai, "$(P)$(R)ADSCDistnce_RBV")
{
   field(DTYP, "asynFloat64")
   field(INP,  "@asyn($(PORT),$(ADDR),$(TIMEOUT))ADSC_DISTANCE")
   field(PREC, "3")
   field(SCAN, "I/O Intr")
}

record(ao, "$(P)$(R)ADSC2Theta")
{
   field(PINI, "YES")
   field(DTYP, "asynFloat64")
   field(OUT,  "@asyn($(PORT),$(ADDR),$(TIMEOUT))ADSC_TWO_THETA")
   field(PREC, "3")
}

record(ai, "$(P)$(R)ADSC2Theta_RBV")
{
   field(DTYP, "asynFloat64")
   field(INP,  "@asyn($(PORT),$(ADDR),$(TIMEOUT))ADSC_TWO_THETA")
   field(PREC, "3")
   field(SCAN, "I/O Intr")
}

record(mbbo, "$(P)$(R)ADSCAxis")
{
   field(PINI, "YES")
   field(DTYP, "asynInt32")
   field(OUT,  "@asyn($(PORT),$(ADDR),$(TIMEOUT))ADSC_AXIS")
   field(ZRST, "Omega")
   field(ZRVL, "0")
   field(ONST, "Phi")
   field(ONVL, "1")
}

record(mbbi, "$(P)$(R)ADSCAxis_RBV")
{
   field(DTYP, "asynInt32")
   field(INP,  "@asyn($(PORT),$(ADDR),$(TIMEOUT))ADSC_AXIS")
   field(SCAN, "I/O Intr")
   field(ZRST, "Omega")
   field(ZRVL, "0")
   field(ONST, "Phi")
   field(ONVL, "1")
}

record(ao, "$(P)$(R)ADSCWavelen")
{
   field(PINI, "YES")
   field(DTYP, "asynFloat64")
   field(OUT,  "@asyn($(PORT),$(ADDR),$(TIMEOUT))ADSC_WAVELENGTH")
   field(PREC, "7")
}

record(ai, "$(P)$(R)ADSCWavelen_RBV")
{
   field(DTYP, "asynFloat64")
   field(INP,  "@asyn($(PORT),$(ADDR),$(TIMEOUT))ADSC_WAVELENGTH")
   field(PREC, "7")
   field(SCAN, "I/O Intr")
}

record(ao, "$(P)$(R)ADSCImWidth")
{
   field(PINI, "YES")
   field(DTYP, "asynFloat64")
   field(OUT,  "@asyn($(PORT),$(ADDR),$(TIMEOUT))ADSC_IMAGE_WIDTH")
   field(PREC, "3")
}

record(ai, "$(P)$(R)ADSCImWidth_RBV")
{
   field(DTYP, "asynFloat64")
   field(INP,  "@asyn($(PORT),$(ADDR),$(TIMEOUT))ADSC_IMAGE_WIDTH")
   field(PREC, "3")
   field(SCAN, "I/O Intr")
}

record(ao, "$(P)$(R)ADSCPhi")
{
   field(PINI, "YES")
   field(DTYP, "asynFloat64")
   field(OUT,  "@asyn($(PORT),$(ADDR),$(TIMEOUT))ADSC_PHI")
   field(PREC, "3")
}

record(ai, "$(P)$(R)ADSCPhi_RBV")
{
   field(DTYP, "asynFloat64")
   field(INP,  "@asyn($(PORT),$(ADDR),$(TIMEOUT))ADSC_PHI")
   field(PREC, "3")
   field(SCAN, "I/O Intr")
}

record(ao, "$(P)$(R)ADSCOmega")
{
   field(PINI, "YES")
   field(DTYP, "asynFloat64")
   field(OUT,  "@asyn($(PORT),$(ADDR),$(TIMEOUT))ADSC_OMEGA")
   field(PREC, "3")
}

record(ai, "$(P)$(R)ADSCOmega_RBV")
{
   field(DTYP, "asynFloat64")
   field(INP,  "@asyn($(PORT),$(ADDR),$(TIMEOUT))ADSC_OMEGA")
   field(PREC, "3")
   field(SCAN, "I/O Intr")
}

record(ao, "$(P)$(R)ADSCKappa")
{
   field(PINI, "YES")
   field(DTYP, "asynFloat64")
   field(OUT,  "@asyn($(PORT),$(ADDR),$(TIMEOUT))ADSC_KAPPA")
   field(PREC, "3")
}

record(ai, "$(P)$(R)ADSCKappa_RBV")
{
   field(DTYP, "asynFloat64")
   field(INP,  "@asyn($(PORT),$(ADDR),$(TIMEOUT))ADSC_KAPPA")
   field(PREC, "3")
   field(SCAN, "I/O Intr")
}

##############################################################################
#  Private parameters only for testing with simadsc
##############################################################################

record(longout, "$(P)$(R)ADSCStpExRtryCt")
{
   field(DTYP, "asynInt32")
   field(OUT,  "@asyn($(PORT),$(ADDR),$(TIMEOUT))ADSC_PRVT_STOP_EXP_RTRY_CNT")
}

##############################################################################
#  Note: The following are records defined in ADBase.template.               #
#        We are changing some of the fields here to reflect valid values and #
#        desired behavior for the ADSC driver.                               #
##############################################################################

record(mbbo, "$(P)$(R)TriggerMode")
{
   field(ZRST, "Internal")
   field(ZRVL, "0")
   field(ONST, "Ext. Software")
   field(ONVL, "1")
}

record(mbbi, "$(P)$(R)TriggerMode_RBV")
{
   field(ZRST, "Internal")
   field(ZRVL, "0")
   field(ONST, "Ext. Software")
   field(ONVL, "1")
}

record(longout, "$(P)$(R)BinX")
{
   field(FLNK,  "$(P)$(R)BinXChanged")
}

record(calcout, "$(P)$(R)BinXChanged")
{
   field(INPA, "$(P)$(R)BinX NPPNMS")
   field(INPB, "$(P)$(R)BinX.PACT NPPNMS")
   field(CALC, "B")
   field(OCAL, "A")
   field(OUT, "$(P)$(R)BinY PP MS")
   field(OOPT, "When Non-zero")
   field(DOPT, "Use OCAL")
   field(IVOA, "Don't drive outputs")
}

record(longout, "$(P)$(R)BinY")
{
   field(PINI, "NO")
   field(DTYP, "Soft Channel")
   field(OUT,  "$(P)$(R)BinYChanged.PROC PP MS")
}

record(calcout, "$(P)$(R)BinYChanged")
{
   field(INPA, "$(P)$(R)BinY NPPNMS")
   field(INPB, "$(P)$(R)BinX.PACT NPPNMS")
   field(CALC, "B")
   field(OCAL, "A")
   field(OUT, "$(P)$(R)BinX PP MS")
   field(OOPT, "When Zero")
   field(DOPT, "Use OCAL")
   field(IVOA, "Don't drive outputs")
}
