# Database for the records specific to the mar345 driver
# Mark Rivers
# October 31, 2008

# Status poll.  This can normally be Passive, except when ArrayCallbacks is 0 and Overlap is 1.
# In that case the state will appear to be busy when it is idle, and this polling should be
# turned on to avoid confusion

record(bo,"$(P)$(R)Abort") {
    field(DTYP,"asynInt32")
    field(OUT, "@asyn($(PORT),$(ADDR),$(TIMEOUT))MAR_ABORT")
    field(ZNAM,"Done")
    field(ONAM,"Abort")
    field(VAL, "1")
}

record(bi,"$(P)$(R)Abort_RBV") {
    field(DTYP,"asynInt32")
    field(INP, "@asyn($(PORT),$(ADDR),$(TIMEOUT))MAR_ABORT")
    field(ZNAM,"Done")
    field(ZSV, "NO_ALARM")
    field(ONAM,"Aborting")
    field(OSV, "MINOR")
    field(SCAN, "I/O Intr")
}

record(busy,"$(P)$(R)Erase") {
    field(DTYP,"asynInt32")
    field(OUT, "@asyn($(PORT),$(ADDR),$(TIMEOUT))MAR_ERASE")
    field(ZNAM,"Done")
    field(ONAM,"Erase")
}

record(bi,"$(P)$(R)Erase_RBV") {
    field(DTYP,"asynInt32")
    field(INP, "@asyn($(PORT),$(ADDR),$(TIMEOUT))MAR_ERASE")
    field(ZNAM,"Done")
    field(ZSV, "NO_ALARM")
    field(ONAM,"Erasing")
    field(OSV, "MINOR")
    field(SCAN, "I/O Intr")
}

record(longout, "$(P)$(R)NumErase")
{
   field(PINI, "YES")
   field(DTYP, "asynInt32")
   field(OUT,  "@asyn($(PORT),$(ADDR),$(TIMEOUT))MAR_NUM_ERASE")
   field(VAL, "1")
}

record(longin, "$(P)$(R)NumErase_RBV")
{
   field(DTYP, "asynInt32")
   field(INP,  "@asyn($(PORT),$(ADDR),$(TIMEOUT))MAR_NUM_ERASE")
   field(SCAN, "I/O Intr")
}

record(longin, "$(P)$(R)NumErased_RBV")
{
   field(DTYP, "asynInt32")
   field(INP,  "@asyn($(PORT),$(ADDR),$(TIMEOUT))MAR_NUM_ERASED")
   field(SCAN, "I/O Intr")
}

# Erase mode - none, before, after
record(mbbo,"$(P)$(R)EraseMode") {
    field(DTYP,"asynInt32")
    field(OUT, "@asyn($(PORT),$(ADDR),$(TIMEOUT))MAR_ERASE_MODE")
    field(PINI, "YES")
    field(ZRVL,"0")
    field(ZRST,"None")
    field(ONVL,"1")
    field(ONST,"Before expose")
    field(TWVL,"2")
    field(TWST,"After scan")
}
# Erase mode - none, before, after
record(mbbi,"$(P)$(R)EraseMode_RBV") {
    field(DTYP,"asynInt32")
    field(INP, "@asyn($(PORT),$(ADDR),$(TIMEOUT))MAR_ERASE_MODE")
    field(SCAN, "I/O Intr")
    field(ZRVL,"0")
    field(ZRST,"None")
    field(ONVL,"1")
    field(ONST,"Before expose")
    field(TWVL,"2")
    field(TWST,"After scan")
}

record(busy,"$(P)$(R)ChangeMode") {
    field(DTYP,"asynInt32")
    field(PINI, "YES")
    field(VAL, "1")
    field(OUT, "@asyn($(PORT),$(ADDR),$(TIMEOUT))MAR_CHANGE_MODE")
    field(ZNAM,"Done")
    field(ONAM,"Change")
}

record(bi,"$(P)$(R)ChangeMode_RBV") {
	field(DTYP,"asynInt32")
    field(INP, "@asyn($(PORT),$(ADDR),$(TIMEOUT))MAR_CHANGE_MODE")
    field(ZNAM,"Done")
    field(ZSV, "NO_ALARM")
    field(ONAM,"Changing")
    field(OSV, "MINOR")
    field(SCAN, "I/O Intr")
}

# Readout size
record(mbbo,"$(P)$(R)ScanSize") {
    field(DTYP,"asynInt32")
    field(OUT, "@asyn($(PORT),$(ADDR),$(TIMEOUT))MAR_SIZE")
    field(PINI, "YES")
    field(ZRVL,"0")
    field(ZRST,"180 mm")
    field(ONVL,"1")
    field(ONST,"240 mm")
    field(TWVL,"2")
    field(TWST,"300 mm")
    field(THVL,"3")
    field(THST,"345 mm")
}

record(mbbi,"$(P)$(R)ScanSize_RBV") {
    field(DTYP,"asynInt32")
    field(INP, "@asyn($(PORT),$(ADDR),$(TIMEOUT))MAR_SIZE")
    field(SCAN, "I/O Intr")
    field(ZRVL,"0")
    field(ZRST,"180 mm")
    field(ONVL,"1")
    field(ONST,"240 mm")
    field(TWVL,"2")
    field(TWST,"300 mm")
    field(THVL,"3")
    field(THST,"345 mm")
}

# Readout resolution
record(mbbo,"$(P)$(R)ScanResolution") {
    field(DTYP,"asynInt32")
    field(OUT, "@asyn($(PORT),$(ADDR),$(TIMEOUT))MAR_RESOLUTION")
    field(PINI, "YES")
    field(ZRVL,"0")
    field(ZRST,"0.10 mm")
    field(ONVL,"1")
    field(ONST,"0.15 mm")
}

record(mbbi,"$(P)$(R)ScanResolution_RBV") {
    field(DTYP,"asynInt32")
    field(INP, "@asyn($(PORT),$(ADDR),$(TIMEOUT))MAR_RESOLUTION")
    field(SCAN, "I/O Intr")
    field(ZRVL,"0")
    field(ZRST,"0.10 mm")
    field(ONVL,"1")
    field(ONST,"0.15 mm")
}


# We replace the file format choices from ADBase.template
record(mbbo, "$(P)$(R)FileFormat")
{
    field(ZRST, "MAR345")
    field(ZRVL, "0")
    field(ONST, "Invalid")
    field(ONVL, "1")
}

record(mbbi, "$(P)$(R)FileFormat_RBV")
{
    field(ZRST, "MAR345")
    field(ZRVL, "0")
    field(ONST, "Invalid")
    field(ONVL, "1")
    field(SCAN, "I/O Intr")
}

# asyn record for interactive communication with marServer
record(asyn, "$(P)$(R)marServerAsyn")
{
    field(PORT,  "$(MARSERVER_PORT)")
    field(IMAX, "64")
    field(OMAX, "64")
}

# We replace the states for DetectorState_RBV
record(mbbi, "$(P)$(R)DetectorState_RBV")
{
    field(DTYP, "asynInt32")
    field(INP,  "@asyn($(PORT),$(ADDR),$(TIMEOUT))STATUS")
    field(ZRST, "Idle")
    field(ZRVL, "0")
    field(ZRSV, "NO_ALARM")
    field(ONST, "Exposing")
    field(ONVL, "1")
    field(ONSV, "MINOR")
    field(TWST, "Scanning")
    field(TWVL, "2")
    field(TWSV, "MINOR")
    field(THST, "Erasing")
    field(THVL, "3")
    field(THSV, "MINOR")
    field(FRST, "Changing mode")
    field(FRVL, "4")
    field(FRSV, "MINOR")
    field(FVST, "Aborting")
    field(FVVL, "5")
    field(FVSV, "MINOR")
    field(SXST, "Error")
    field(SXVL, "6")
    field(SXSV, "MAJOR")
    field(SVST, "Waiting")
    field(SVVL, "7")
    field(SVSV, "MINOR")
    field(SCAN, "I/O Intr")
}
