#=================================================================#
# Template file: NDROI.template
# Database for ND ROIs
# Mark Rivers
# April 22, 2008

include "NDPluginBase.template"

###################################################################
#  These records control the label for the ROI                    #
###################################################################
record(stringout, "$(P)$(R)Name")
{
   field(PINI, "YES")
   field(DTYP, "asynOctetWrite")
   field(OUT,  "@asyn($(PORT),$(ADDR=0),$(TIMEOUT=1))NAME")
   info(autosaveFields, "VAL")
}

record(stringin, "$(P)$(R)Name_RBV")
{
   field(DTYP, "asynOctetRead")
   field(INP,  "@asyn($(PORT),$(ADDR=0),$(TIMEOUT=1))NAME")
   field(SCAN, "I/O Intr")
}

###################################################################
#  These records control the ROI definition                       #
#  including binning, region start and size                       # 
###################################################################

record(longout, "$(P)$(R)BinX")
{
   field(PINI, "YES")
   field(DTYP, "asynInt32")
   field(OUT,  "@asyn($(PORT),$(ADDR=0),$(TIMEOUT=1))DIM0_BIN")
   field(VAL,  "1")
   info(autosaveFields, "VAL")
}

record(longin, "$(P)$(R)BinX_RBV")
{
   field(DTYP, "asynInt32")
   field(INP,  "@asyn($(PORT),$(ADDR=0),$(TIMEOUT=1))DIM0_BIN")
   field(SCAN, "I/O Intr")
}

record(longout, "$(P)$(R)BinY")
{
   field(PINI, "YES")
   field(DTYP, "asynInt32")
   field(OUT,  "@asyn($(PORT),$(ADDR=0),$(TIMEOUT=1))DIM1_BIN")
   field(VAL,  "1")
   info(autosaveFields, "VAL")
}

record(longin, "$(P)$(R)BinY_RBV")
{
   field(DTYP, "asynInt32")
   field(INP,  "@asyn($(PORT),$(ADDR=0),$(TIMEOUT=1))DIM1_BIN")
   field(SCAN, "I/O Intr")
}

record(longout, "$(P)$(R)BinZ")
{
   field(PINI, "YES")
   field(DTYP, "asynInt32")
   field(OUT,  "@asyn($(PORT),$(ADDR=0),$(TIMEOUT=1))DIM2_BIN")
   field(VAL,  "1")
   info(autosaveFields, "VAL")
}

record(longin, "$(P)$(R)BinZ_RBV")
{
   field(DTYP, "asynInt32")
   field(INP,  "@asyn($(PORT),$(ADDR=0),$(TIMEOUT=1))DIM2_BIN")
   field(SCAN, "I/O Intr")
}

record(longout, "$(P)$(R)MinX")
{
   field(PINI, "YES")
   field(DTYP, "asynInt32")
   field(OUT,  "@asyn($(PORT),$(ADDR=0),$(TIMEOUT=1))DIM0_MIN")
   field(LOPR, "0")
   field(VAL,  "0")
   info(autosaveFields, "VAL")
}

record(longin, "$(P)$(R)MinX_RBV")
{
   field(DTYP, "asynInt32")
   field(INP,  "@asyn($(PORT),$(ADDR=0),$(TIMEOUT=1))DIM0_MIN")
   field(SCAN, "I/O Intr")
}

record(longout, "$(P)$(R)MinY")
{
   field(PINI, "YES")
   field(DTYP, "asynInt32")
   field(OUT,  "@asyn($(PORT),$(ADDR=0),$(TIMEOUT=1))DIM1_MIN")
   field(LOPR, "0")
   field(VAL,  "0")
   info(autosaveFields, "VAL")
}

record(longin, "$(P)$(R)MinY_RBV")
{
   field(DTYP, "asynInt32")
   field(INP,  "@asyn($(PORT),$(ADDR=0),$(TIMEOUT=1))DIM1_MIN")
   field(SCAN, "I/O Intr")
}

record(longout, "$(P)$(R)MinZ")
{
   field(PINI, "YES")
   field(DTYP, "asynInt32")
   field(OUT,  "@asyn($(PORT),$(ADDR=0),$(TIMEOUT=1))DIM2_MIN")
   field(LOPR, "1")
   field(VAL,  "0")
   info(autosaveFields, "VAL")
}

record(longin, "$(P)$(R)MinZ_RBV")
{
   field(DTYP, "asynInt32")
   field(INP,  "@asyn($(PORT),$(ADDR=0),$(TIMEOUT=1))DIM2_MIN")
   field(SCAN, "I/O Intr")
}

record(longout, "$(P)$(R)SizeX")
{
   field(PINI, "YES")
   field(DTYP, "asynInt32")
   field(OUT,  "@asyn($(PORT),$(ADDR=0),$(TIMEOUT=1))DIM0_SIZE")
   field(VAL,  "1000000")
   info(autosaveFields, "VAL")
}

record(longin, "$(P)$(R)SizeX_RBV")
{
   field(DTYP, "asynInt32")
   field(INP,  "@asyn($(PORT),$(ADDR=0),$(TIMEOUT=1))DIM0_SIZE")
   field(SCAN, "I/O Intr")
}

record(longout, "$(P)$(R)SizeY")
{
   field(PINI, "YES")
   field(DTYP, "asynInt32")
   field(OUT,  "@asyn($(PORT),$(ADDR=0),$(TIMEOUT=1))DIM1_SIZE")
   field(VAL,  "1000000")
   info(autosaveFields, "VAL")
}

record(longin, "$(P)$(R)SizeY_RBV")
{
   field(DTYP, "asynInt32")
   field(INP,  "@asyn($(PORT),$(ADDR=0),$(TIMEOUT=1))DIM1_SIZE")
   field(SCAN, "I/O Intr")
}

record(longout, "$(P)$(R)SizeZ")
{
   field(PINI, "YES")
   field(DTYP, "asynInt32")
   field(OUT,  "@asyn($(PORT),$(ADDR=0),$(TIMEOUT=1))DIM2_SIZE")
   field(VAL,  "1000000")
   info(autosaveFields, "VAL")
}

record(longin, "$(P)$(R)SizeZ_RBV")
{
   field(DTYP, "asynInt32")
   field(INP,  "@asyn($(PORT),$(ADDR=0),$(TIMEOUT=1))DIM2_SIZE")
   field(SCAN, "I/O Intr")
}

record(bo, "$(P)$(R)AutoSizeX")
{
   field(PINI, "YES")
   field(DTYP, "asynInt32")
   field(OUT,  "@asyn($(PORT),$(ADDR=0),$(TIMEOUT=1))DIM0_AUTO_SIZE")
   field(VAL,  "0")
   field(ZNAM, "No")
   field(ONAM, "Yes")
   info(autosaveFields, "VAL")
}

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

record(bo, "$(P)$(R)AutoSizeY")
{
   field(PINI, "YES")
   field(DTYP, "asynInt32")
   field(OUT,  "@asyn($(PORT),$(ADDR=0),$(TIMEOUT=1))DIM1_AUTO_SIZE")
   field(VAL,  "0")
   field(ZNAM, "No")
   field(ONAM, "Yes")
   info(autosaveFields, "VAL")
}

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

record(bo, "$(P)$(R)AutoSizeZ")
{
   field(PINI, "YES")
   field(DTYP, "asynInt32")
   field(OUT,  "@asyn($(PORT),$(ADDR=0),$(TIMEOUT=1))DIM2_AUTO_SIZE")
   field(VAL,  "0")
   field(ZNAM, "No")
   field(ONAM, "Yes")
   info(autosaveFields, "VAL")
}

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

record(longin, "$(P)$(R)MaxSizeX_RBV")
{
   field(DTYP, "asynInt32")
   field(INP,  "@asyn($(PORT),$(ADDR=0),$(TIMEOUT=1))DIM0_MAX_SIZE")
   field(SCAN, "I/O Intr")
}

record(longin, "$(P)$(R)MaxSizeY_RBV")
{
   field(DTYP, "asynInt32")
   field(INP,  "@asyn($(PORT),$(ADDR=0),$(TIMEOUT=1))DIM1_MAX_SIZE")
   field(SCAN, "I/O Intr")
}

record(longin, "$(P)$(R)MaxSizeZ_RBV")
{
   field(DTYP, "asynInt32")
   field(INP,  "@asyn($(PORT),$(ADDR=0),$(TIMEOUT=1))DIM2_MAX_SIZE")
   field(SCAN, "I/O Intr")
}

record(bo, "$(P)$(R)ReverseX")
{
   field(PINI, "YES")
   field(DTYP, "asynInt32")
   field(OUT,  "@asyn($(PORT),$(ADDR=0),$(TIMEOUT=1))DIM0_REVERSE")
   field(VAL,  "0")
   field(ZNAM, "No")
   field(ONAM, "Yes")
   info(autosaveFields, "VAL")
}

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

record(bo, "$(P)$(R)ReverseY")
{
   field(PINI, "YES")
   field(DTYP, "asynInt32")
   field(OUT,  "@asyn($(PORT),$(ADDR=0),$(TIMEOUT=1))DIM1_REVERSE")
   field(VAL,  "0")
   field(ZNAM, "No")
   field(ONAM, "Yes")
   info(autosaveFields, "VAL")
}

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

record(bo, "$(P)$(R)ReverseZ")
{
   field(PINI, "YES")
   field(DTYP, "asynInt32")
   field(OUT,  "@asyn($(PORT),$(ADDR=0),$(TIMEOUT=1))DIM2_REVERSE")
   field(VAL,  "0")
   field(ZNAM, "No")
   field(ONAM, "Yes")
   info(autosaveFields, "VAL")
}

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

record(longin, "$(P)$(R)ArraySizeX_RBV")
{
   field(DTYP, "asynInt32")
   field(INP,  "@asyn($(PORT),$(ADDR=0),$(TIMEOUT=1))ARRAY_SIZE_X")
   field(SCAN, "I/O Intr")
}

record(longin, "$(P)$(R)ArraySizeY_RBV")
{
   field(DTYP, "asynInt32")
   field(INP,  "@asyn($(PORT),$(ADDR=0),$(TIMEOUT=1))ARRAY_SIZE_Y")
   field(SCAN, "I/O Intr")
}

record(longin, "$(P)$(R)ArraySizeZ_RBV")
{
   field(DTYP, "asynInt32")
   field(INP,  "@asyn($(PORT),$(ADDR=0),$(TIMEOUT=1))ARRAY_SIZE_Z")
   field(SCAN, "I/O Intr")
}

record(bo, "$(P)$(R)EnableX")
{
   field(PINI, "YES")
   field(DTYP, "asynInt32")
   field(OUT,  "@asyn($(PORT),$(ADDR=0),$(TIMEOUT=1))DIM0_ENABLE")
   field(VAL,  "1")
   field(ZNAM, "Disable")
   field(ONAM, "Enable")
   info(autosaveFields, "VAL")
}

record(bi, "$(P)$(R)EnableX_RBV")
{
   field(DTYP, "asynInt32")
   field(INP,  "@asyn($(PORT),$(ADDR=0),$(TIMEOUT=1))DIM0_ENABLE")
   field(ZNAM, "Disable")
   field(ONAM, "Enable")
   field(ZSV,  "NO_ALARM")
   field(OSV,  "MINOR")
   field(SCAN, "I/O Intr")
}

record(bo, "$(P)$(R)EnableY")
{
   field(PINI, "YES")
   field(DTYP, "asynInt32")
   field(OUT,  "@asyn($(PORT),$(ADDR=0),$(TIMEOUT=1))DIM1_ENABLE")
   field(VAL,  "1")
   field(ZNAM, "Disable")
   field(ONAM, "Enable")
   info(autosaveFields, "VAL")
}

record(bi, "$(P)$(R)EnableY_RBV")
{
   field(DTYP, "asynInt32")
   field(INP,  "@asyn($(PORT),$(ADDR=0),$(TIMEOUT=1))DIM1_ENABLE")
   field(ZNAM, "Disable")
   field(ONAM, "Enable")
   field(ZSV,  "NO_ALARM")
   field(OSV,  "MINOR")
   field(SCAN, "I/O Intr")
}

record(bo, "$(P)$(R)EnableZ")
{
   field(PINI, "YES")
   field(DTYP, "asynInt32")
   field(OUT,  "@asyn($(PORT),$(ADDR=0),$(TIMEOUT=1))DIM2_ENABLE")
   field(VAL,  "1")
   field(ZNAM, "Disable")
   field(ONAM, "Enable")
   info(autosaveFields, "VAL")
}

record(bi, "$(P)$(R)EnableZ_RBV")
{
   field(DTYP, "asynInt32")
   field(INP,  "@asyn($(PORT),$(ADDR=0),$(TIMEOUT=1))DIM2_ENABLE")
   field(ZNAM, "Disable")
   field(ONAM, "Enable")
   field(ZSV,  "NO_ALARM")
   field(OSV,  "MINOR")
   field(SCAN, "I/O Intr")
}


###################################################################
#  These records control the scaling of the data.  Useful when    #
#  binning or converting data types                               # 
###################################################################

record(bo, "$(P)$(R)EnableScale")
{
   field(PINI, "YES")
   field(DTYP, "asynInt32")
   field(OUT,  "@asyn($(PORT),$(ADDR=0),$(TIMEOUT=1))ENABLE_SCALE")
   field(VAL,  "0")
   field(ZNAM, "Disable")
   field(ONAM, "Enable")
   info(autosaveFields, "VAL")
}

record(bi, "$(P)$(R)EnableScale_RBV")
{
   field(DTYP, "asynInt32")
   field(INP,  "@asyn($(PORT),$(ADDR=0),$(TIMEOUT=1))ENABLE_SCALE")
   field(ZNAM, "Disable")
   field(ONAM, "Enable")
   field(ZSV,  "NO_ALARM")
   field(OSV,  "MINOR")
   field(SCAN, "I/O Intr")
}

record(ao, "$(P)$(R)Scale")
{
   field(PINI, "YES")
   field(DTYP, "asynFloat64")
   field(OUT,  "@asyn($(PORT),$(ADDR=0),$(TIMEOUT=1))SCALE_VALUE")
   field(VAL,  "1")
   info(autosaveFields, "VAL")
}

record(ai, "$(P)$(R)Scale_RBV")
{
   field(DTYP, "asynFloat64")
   field(INP,  "@asyn($(PORT),$(ADDR=0),$(TIMEOUT=1))SCALE_VALUE")
   field(SCAN, "I/O Intr")
}


###################################################################
#  These records control the data type of the array data          # 
#  The last entry is "Automatic" meaning preserve the data type   #
#  of the input array.                                            # 
###################################################################

record(mbbo, "$(P)$(R)DataTypeOut")
{
   field(PINI, "YES")
   field(DTYP, "asynInt32")
   field(OUT,  "@asyn($(PORT),$(ADDR=0),$(TIMEOUT=1))ROI_DATA_TYPE")
   field(ZRST, "Int8")
   field(ZRVL, "0")
   field(ONST, "UInt8")
   field(ONVL, "1")
   field(TWST, "Int16")
   field(TWVL, "2")
   field(THST, "UInt16")
   field(THVL, "3")
   field(FRST, "Int32")
   field(FRVL, "4")
   field(FVST, "UInt32")
   field(FVVL, "5")
   field(SXST, "Int64")
   field(SXVL, "6")
   field(SVST, "UInt64")
   field(SVVL, "7")
   field(EIST, "Float32")
   field(EIVL, "8")
   field(NIST, "Float64")
   field(NIVL, "9")
   field(TEST, "Automatic")
   field(TEVL, "-1")
   field(VAL,  "10")
   info(autosaveFields, "VAL")
}

record(mbbi, "$(P)$(R)DataTypeOut_RBV")
{
   field(DTYP, "asynInt32")
   field(INP,  "@asyn($(PORT),$(ADDR=0),$(TIMEOUT=1))ROI_DATA_TYPE")
   field(ZRST, "Int8")
   field(ZRVL, "0")
   field(ONST, "UInt8")
   field(ONVL, "1")
   field(TWST, "Int16")
   field(TWVL, "2")
   field(THST, "UInt16")
   field(THVL, "3")
   field(FRST, "Int32")
   field(FRVL, "4")
   field(FVST, "UInt32")
   field(FVVL, "5")
   field(SXST, "Int64")
   field(SXVL, "6")
   field(SVST, "UInt64")
   field(SVVL, "7")
   field(EIST, "Float32")
   field(EIVL, "8")
   field(NIST, "Float64")
   field(NIVL, "9")
   field(TEST, "Automatic")
   field(TEVL, "-1")
   field(SCAN, "I/O Intr")
}

###################################################################
#  These records set the HOPR and LOPR values for the position    #
#  and size to the maximum for the input array                    #
###################################################################

record(longin, "$(P)$(R)MaxX")
{
    field(INP,  "$(P)$(R)MaxSizeX_RBV CP")
    field(FLNK, "$(P)$(R)SetXHOPR.PROC PP")
}

record(dfanout, "$(P)$(R)SetXHOPR")
{
    field(DOL,  "$(P)$(R)MaxX NPP")
    field(OMSL, "closed_loop")
    field(OUTA, "$(P)$(R)MinX.HOPR NPP")
    field(OUTB, "$(P)$(R)SizeX.HOPR NPP")
}

record(longin, "$(P)$(R)MaxY")
{
    field(INP,  "$(P)$(R)MaxSizeY_RBV CP")
    field(FLNK, "$(P)$(R)SetYHOPR.PROC PP")
}

record(dfanout, "$(P)$(R)SetYHOPR")
{
    field(DOL,  "$(P)$(R)MaxY NPP")
    field(OMSL, "closed_loop")
    field(OUTA, "$(P)$(R)MinY.HOPR NPP")
    field(OUTB, "$(P)$(R)SizeY.HOPR NPP")
}

###################################################################
#  These records whether dimensions of 1 are collapsed (removed)  #                               # 
###################################################################

record(bo, "$(P)$(R)CollapseDims")
{
   field(PINI, "YES")
   field(DTYP, "asynInt32")
   field(OUT,  "@asyn($(PORT),$(ADDR=0),$(TIMEOUT=1))COLLAPSE_DIMS")
   field(VAL,  "0")
   field(ZNAM, "Disable")
   field(ONAM, "Enable")
   info(autosaveFields, "VAL")
}

record(bi, "$(P)$(R)CollapseDims_RBV")
{
   field(DTYP, "asynInt32")
   field(INP,  "@asyn($(PORT),$(ADDR=0),$(TIMEOUT=1))COLLAPSE_DIMS")
   field(ZNAM, "Disable")
   field(ONAM, "Enable")
   field(ZSV,  "NO_ALARM")
   field(OSV,  "MINOR")
   field(SCAN, "I/O Intr")
}


