##########################################################################
# Description:
# This database gets the digital input status from the Aerotech controller
# and splits it into two MBBI records.
# This database also gets axis specifc status and fault pv`s
# Disableallpvs PV can be used to disable all the pv`s for the device
#
# Macros:
# U 	- Device prefix
# PORT 	- Aerotech asyn port
# AXIS 	- Aerotech axis identifier
# SCAN 	- Desired scan rate
# MAD   - mad device name
##########################################################################
record(ai, "$(U):DISTAT") {
  field(DESC, "digital inputs")
  field(PINI, "YES")
  field(DTYP, "stream")
  field(INP, "@aerotech.proto getDINall($(AERO_AXIS)) $(ASYN)")
  field(SCAN, "1 second")
}

record(mbbiDirect, "$(U):DISTATS1") {
  field(DESC, "Digital input lower bits")
  field(DTYP, "Raw Soft Channel")
  field(INP, "$(U):DISTAT CP MS")
}

record(mbbiDirect, "$(U):DISTATS2") {
  field(DESC, "Digital input higher bits")
  field(DTYP, "Raw Soft Channel")
  field(INP, "$(U):DISTAT CP MS")
  field(SHFT, "16")
}

record(ai, "$(U):STAT") {
  field(DESC, "axis status")
  field(PINI, "YES")
  field(DTYP, "stream")
  field(INP, "@aerotech.proto axisStatus($(AERO_AXIS)) $(ASYN)")
  field(SCAN, "1 second")
}

record(ai, "$(U):FAULT") {
  field(DESC, "axis fault")
  field(PINI, "YES")
  field(DTYP, "stream")
  field(INP, "@aerotech.proto axisFault($(AERO_AXIS)) $(ASYN)")
  field(SCAN, "1 second")
}

record(ai, "$(U):AUTOHOMETRIGFAULT") {
  field(DESC, "fault to trigger autohome")
  field(DTYP, "stream")
  field(INP,  "@aerotech.proto getIGLOBAL(60) $(ASYN)")
  field(PINI, "YES")
  field(SCAN,"1 second")
}

record(mbbiDirect, "$(U):AUTOHOMETRIGFAULTS1") {
  field(DESC, "fault lower bits")
  field(DTYP, "Raw Soft Channel")
  field(INP, "$(U):AUTOHOMETRIGFAULT CP MS")
}

record(mbbiDirect, "$(U):AUTOHOMETRIGFAULTS2") {
  field(DESC, "fault higher bits")
  field(DTYP, "Raw Soft Channel")
  field(INP, "$(U):AUTOHOMETRIGFAULT CP MS")
  field(SHFT, "16")
}

record(mbbiDirect, "$(U):STATS1") {
  field(DESC, "status lower bits")
  field(DTYP, "Raw Soft Channel")
  field(INP, "$(U):STAT CP MS")
}

record(mbbiDirect, "$(U):STATS2") {
  field(DESC, "status higher bits")
  field(DTYP, "Raw Soft Channel")
  field(INP, "$(U):STAT CP MS")
  field(SHFT, "16")
}

record(mbbiDirect, "$(U):FAULTS1") {
  field(DESC, "fault lower bits")
  field(DTYP, "Raw Soft Channel")
  field(INP, "$(U):FAULT CP MS")
}

record(mbbiDirect, "$(U):FAULTS2") {
  field(DESC, "fault higher bits")
  field(DTYP, "Raw Soft Channel")
  field(INP, "$(U):FAULT CP MS")
  field(SHFT, "16")
}

record(bi, "$(U):ENABLEDSTAT") {
  field(DESC, "Axis enabled")
  field(INP,  "$(U):STATS1.B0 CP MS")
  field(ZNAM, "Disabled")
  field(ONAM, "Enabled")
}

record(bi, "$(U):HOMEDSTAT") {
  field(DESC, "Axis homed")
  field(INP,  "$(U):STATS1.B1 CP MS")
  field(ZNAM, "Not Homed")
  field(ONAM, "Homed")
  field(ZSV, "MAJOR")
  field(OSV, "NO_ALARM")
}

# If both limit switch show as active
record(calcout, "$(U):CABLESTAT_CALC") {
  field(DESC, "Motor Cable Status")
  field(INPA, "$(U):STATS2.B6 CP MS")
  field(INPB, "$(U):STATS2.B7 CP MS")
  field(CALC, "(A&&B)")
  field(FLNK, "$(U):CABLESTAT")
}

record(bo, "$(U):CABLESTAT") {
  field(DESC, "Motor Cable Status")
  field(DOL,  "$(U):CABLESTAT_CALC MS")
  field(ONAM, "Motor cable disconnected")
  field(ZNAM, "OK")
  field(ZSV, "MAJOR")
  field(OSV, "NO_ALARM")
}

record(bi, "$(U):MOVEACTIVE") {
  field(DESC, "Move active")
  field(INP,  "$(U):STATS1.B3 CP MS")
  field(ZNAM, "Not moving")
  field(ONAM, "Moving")
}

record(stringout, "$(U):FAULTACK") {
  field(DESC, "Ack fault on axis")
  field(DTYP, "stream")
  field(OUT,  "@aerotech.proto axisFaultAck($(AERO_AXIS)) $(ASYN)")
}

record(stringout, "$(U):ENABLE") {
  field(DESC, "Enable axis")
  field(DTYP, "stream")
  field(OUT,  "@aerotech.proto axisEnable($(AERO_AXIS)) $(ASYN)")
}

record(stringout, "$(U):ABORT") {
  field(DESC, "Abort axis")
  field(DTYP, "stream")
  field(OUT,  "@aerotech.proto axisAbort($(AERO_AXIS)) $(ASYN)")
}

record(stringout, "$(U):DISABLE") {
  field(DESC, "Disable axis")
  field(DTYP, "stream")
  field(OUT,  "@aerotech.proto axisDisable($(AERO_AXIS)) $(ASYN)")
}

record(stringout, "$(U):HOME") {
  field(DESC, "Home axis")
  field(DTYP, "stream")
  field(OUT,  "@aerotech.proto axisHome($(AERO_AXIS)) $(ASYN)")
}

record(ai, "$(U):IDES") {
  field(DESC, "axis current")
  field(PINI, "YES")
  field(DTYP, "stream")
  field(INP, "@aerotech.proto getCur($(AERO_AXIS)) $(ASYN)")
  field(SCAN, "1 second")
  field(PREC, 2)
}

record(ai, "$(U):EXTPOSN") {
  field(DESC, "Aux Encoder Position")
  field(PINI, "YES")
  field(DTYP, "stream")
  field(INP, "@aerotech.proto extPos($(AERO_AXIS)) $(ASYN)")
  field(SCAN, "1 second")
  field(PREC, 3)
  field(LINR, "SLOPE")
  info(autosaveFields, "ESLO EOFF EGU")
}

record(ai, "$(U):EncOffset") {
    field(DESC, "$(MAD) Encoder offset")
    field(DTYP, "stream")
    field(INP, "@aerotech.proto getEncOff($(AERO_AXIS)) $(ASYN) ")
    field(PINI, "YES")
    field(PREC, "3")
    field(EGU, "mm")
}


# Borrowed
# File: xleap_din_bit.template
# Author: Wayne Lewis
# Date: 2017-05-08
#
# Description:
# This database is the template for the generic Aerotech 
# digital input PVs.
#
# Macros:
# U 	- Device prefix
# Port 	- Aerotech input port number (port is Aerotech terminology)
# In .	- Input number
# Word 	- MBBI word (from aerotech_din.db) 
# Bit 	- Bit number from word

record(bi, "$(U):DIP0IN0") {
  field(DESC, "Port 0 Input 0")
  field(INP,  "$(U):DISTATS0.B0 CP NMS")
  field(ZNAM, "Off")
  field(ONAM, "On")
  info(autosaveFields, "DESC")
}

# Borrowed
# File: xleap_din_bit.template
# Author: Wayne Lewis
# Date: 2017-05-08
#
# Description:
# This database is the template for the generic Aerotech 
# digital input PVs.
#
# Macros:
# U 	- Device prefix
# Port 	- Aerotech input port number (port is Aerotech terminology)
# In .	- Input number
# Word 	- MBBI word (from aerotech_din.db) 
# Bit 	- Bit number from word

record(bi, "$(U):DIP0IN1") {
  field(DESC, "Port 0 Input 1")
  field(INP,  "$(U):DISTATS0.B1 CP NMS")
  field(ZNAM, "Off")
  field(ONAM, "On")
  info(autosaveFields, "DESC")
}

# Borrowed
# File: xleap_din_bit.template
# Author: Wayne Lewis
# Date: 2017-05-08
#
# Description:
# This database is the template for the generic Aerotech 
# digital input PVs.
#
# Macros:
# U 	- Device prefix
# Port 	- Aerotech input port number (port is Aerotech terminology)
# In .	- Input number
# Word 	- MBBI word (from aerotech_din.db) 
# Bit 	- Bit number from word

record(bi, "$(U):DIP0IN2") {
  field(DESC, "Port 0 Input 2")
  field(INP,  "$(U):DISTATS0.B2 CP NMS")
  field(ZNAM, "Off")
  field(ONAM, "On")
  info(autosaveFields, "DESC")
}

# Borrowed
# File: xleap_din_bit.template
# Author: Wayne Lewis
# Date: 2017-05-08
#
# Description:
# This database is the template for the generic Aerotech 
# digital input PVs.
#
# Macros:
# U 	- Device prefix
# Port 	- Aerotech input port number (port is Aerotech terminology)
# In .	- Input number
# Word 	- MBBI word (from aerotech_din.db) 
# Bit 	- Bit number from word

record(bi, "$(U):DIP0IN3") {
  field(DESC, "Port 0 Input 3")
  field(INP,  "$(U):DISTATS0.B3 CP NMS")
  field(ZNAM, "Off")
  field(ONAM, "On")
  info(autosaveFields, "DESC")
}

# Borrowed
# File: xleap_din_bit.template
# Author: Wayne Lewis
# Date: 2017-05-08
#
# Description:
# This database is the template for the generic Aerotech 
# digital input PVs.
#
# Macros:
# U 	- Device prefix
# Port 	- Aerotech input port number (port is Aerotech terminology)
# In .	- Input number
# Word 	- MBBI word (from aerotech_din.db) 
# Bit 	- Bit number from word

record(bi, "$(U):DIP0IN4") {
  field(DESC, "Port 0 Input 4")
  field(INP,  "$(U):DISTATS0.B4 CP NMS")
  field(ZNAM, "Off")
  field(ONAM, "On")
  info(autosaveFields, "DESC")
}

# Borrowed
# File: xleap_din_bit.template
# Author: Wayne Lewis
# Date: 2017-05-08
#
# Description:
# This database is the template for the generic Aerotech 
# digital input PVs.
#
# Macros:
# U 	- Device prefix
# Port 	- Aerotech input port number (port is Aerotech terminology)
# In .	- Input number
# Word 	- MBBI word (from aerotech_din.db) 
# Bit 	- Bit number from word

record(bi, "$(U):DIP0IN5") {
  field(DESC, "Port 0 Input 5")
  field(INP,  "$(U):DISTATS0.B5 CP NMS")
  field(ZNAM, "Off")
  field(ONAM, "On")
  info(autosaveFields, "DESC")
}

# Borrowed
# File: xleap_din_bit.template
# Author: Wayne Lewis
# Date: 2017-05-08
#
# Description:
# This database is the template for the generic Aerotech 
# digital input PVs.
#
# Macros:
# U 	- Device prefix
# Port 	- Aerotech input port number (port is Aerotech terminology)
# In .	- Input number
# Word 	- MBBI word (from aerotech_din.db) 
# Bit 	- Bit number from word

record(bi, "$(U):DIP1IN0") {
  field(DESC, "Port 1 Input 0")
  field(INP,  "$(U):DISTATS0.B8 CP NMS")
  field(ZNAM, "Off")
  field(ONAM, "On")
  info(autosaveFields, "DESC")
}

# Borrowed
# File: xleap_din_bit.template
# Author: Wayne Lewis
# Date: 2017-05-08
#
# Description:
# This database is the template for the generic Aerotech 
# digital input PVs.
#
# Macros:
# U 	- Device prefix
# Port 	- Aerotech input port number (port is Aerotech terminology)
# In .	- Input number
# Word 	- MBBI word (from aerotech_din.db) 
# Bit 	- Bit number from word

record(bi, "$(U):DIP1IN1") {
  field(DESC, "Port 1 Input 1")
  field(INP,  "$(U):DISTATS0.B9 CP NMS")
  field(ZNAM, "Off")
  field(ONAM, "On")
  info(autosaveFields, "DESC")
}

# Borrowed
# File: xleap_din_bit.template
# Author: Wayne Lewis
# Date: 2017-05-08
#
# Description:
# This database is the template for the generic Aerotech 
# digital input PVs.
#
# Macros:
# U 	- Device prefix
# Port 	- Aerotech input port number (port is Aerotech terminology)
# In .	- Input number
# Word 	- MBBI word (from aerotech_din.db) 
# Bit 	- Bit number from word

record(bi, "$(U):DIP1IN2") {
  field(DESC, "Port 1 Input 2")
  field(INP,  "$(U):DISTATS0.BA CP NMS")
  field(ZNAM, "Off")
  field(ONAM, "On")
  info(autosaveFields, "DESC")
}

# Borrowed
# File: xleap_din_bit.template
# Author: Wayne Lewis
# Date: 2017-05-08
#
# Description:
# This database is the template for the generic Aerotech 
# digital input PVs.
#
# Macros:
# U 	- Device prefix
# Port 	- Aerotech input port number (port is Aerotech terminology)
# In .	- Input number
# Word 	- MBBI word (from aerotech_din.db) 
# Bit 	- Bit number from word

record(bi, "$(U):DIP1IN3") {
  field(DESC, "Port 1 Input 3")
  field(INP,  "$(U):DISTATS0.BB CP NMS")
  field(ZNAM, "Off")
  field(ONAM, "On")
  info(autosaveFields, "DESC")
}

# Borrowed
# File: xleap_din_bit.template
# Author: Wayne Lewis
# Date: 2017-05-08
#
# Description:
# This database is the template for the generic Aerotech 
# digital input PVs.
#
# Macros:
# U 	- Device prefix
# Port 	- Aerotech input port number (port is Aerotech terminology)
# In .	- Input number
# Word 	- MBBI word (from aerotech_din.db) 
# Bit 	- Bit number from word

record(bi, "$(U):DIP1IN4") {
  field(DESC, "Port 1 Input 4")
  field(INP,  "$(U):DISTATS0.BC CP NMS")
  field(ZNAM, "Off")
  field(ONAM, "On")
  info(autosaveFields, "DESC")
}

# Borrowed
# File: xleap_din_bit.template
# Author: Wayne Lewis
# Date: 2017-05-08
#
# Description:
# This database is the template for the generic Aerotech 
# digital input PVs.
#
# Macros:
# U 	- Device prefix
# Port 	- Aerotech input port number (port is Aerotech terminology)
# In .	- Input number
# Word 	- MBBI word (from aerotech_din.db) 
# Bit 	- Bit number from word

record(bi, "$(U):DIP1IN5") {
  field(DESC, "Port 1 Input 5")
  field(INP,  "$(U):DISTATS0.BD CP NMS")
  field(ZNAM, "Off")
  field(ONAM, "On")
  info(autosaveFields, "DESC")
}

# Borrowed
# File: xleap_din_bit.template
# Author: Wayne Lewis
# Date: 2017-05-08
#
# Description:
# This database is the template for the generic Aerotech 
# digital input PVs.
#
# Macros:
# U 	- Device prefix
# Port 	- Aerotech input port number (port is Aerotech terminology)
# In .	- Input number
# Word 	- MBBI word (from aerotech_din.db) 
# Bit 	- Bit number from word

record(bi, "$(U):DIP1IN6") {
  field(DESC, "Port 1 Input 6")
  field(INP,  "$(U):DISTATS0.BE CP NMS")
  field(ZNAM, "Off")
  field(ONAM, "On")
  info(autosaveFields, "DESC")
}

# Borrowed
# File: xleap_din_bit.template
# Author: Wayne Lewis
# Date: 2017-05-08
#
# Description:
# This database is the template for the generic Aerotech 
# digital input PVs.
#
# Macros:
# U 	- Device prefix
# Port 	- Aerotech input port number (port is Aerotech terminology)
# In .	- Input number
# Word 	- MBBI word (from aerotech_din.db) 
# Bit 	- Bit number from word

record(bi, "$(U):DIP1IN7") {
  field(DESC, "Port 1 Input 7")
  field(INP,  "$(U):DISTATS0.BF CP NMS")
  field(ZNAM, "Off")
  field(ONAM, "On")
  info(autosaveFields, "DESC")
}

# Borrowed
# File: xleap_din_bit.template
# Author: Wayne Lewis
# Date: 2017-05-08
#
# Description:
# This database is the template for the generic Aerotech 
# digital input PVs.
#
# Macros:
# U 	- Device prefix
# Port 	- Aerotech input port number (port is Aerotech terminology)
# In .	- Input number
# Word 	- MBBI word (from aerotech_din.db) 
# Bit 	- Bit number from word

record(bi, "$(U):DIP2IN0") {
  field(DESC, "Port 2 Input 0")
  field(INP,  "$(U):DISTATS1.B0 CP NMS")
  field(ZNAM, "Off")
  field(ONAM, "On")
  info(autosaveFields, "DESC")
}

# Borrowed
# File: xleap_din_bit.template
# Author: Wayne Lewis
# Date: 2017-05-08
#
# Description:
# This database is the template for the generic Aerotech 
# digital input PVs.
#
# Macros:
# U 	- Device prefix
# Port 	- Aerotech input port number (port is Aerotech terminology)
# In .	- Input number
# Word 	- MBBI word (from aerotech_din.db) 
# Bit 	- Bit number from word

record(bi, "$(U):DIP2IN1") {
  field(DESC, "Port 2 Input 1")
  field(INP,  "$(U):DISTATS1.B1 CP NMS")
  field(ZNAM, "Off")
  field(ONAM, "On")
  info(autosaveFields, "DESC")
}

# Borrowed
# File: xleap_din_bit.template
# Author: Wayne Lewis
# Date: 2017-05-08
#
# Description:
# This database is the template for the generic Aerotech 
# digital input PVs.
#
# Macros:
# U 	- Device prefix
# Port 	- Aerotech input port number (port is Aerotech terminology)
# In .	- Input number
# Word 	- MBBI word (from aerotech_din.db) 
# Bit 	- Bit number from word

record(bi, "$(U):DIP2IN2") {
  field(DESC, "Port 2 Input 2")
  field(INP,  "$(U):DISTATS1.B2 CP NMS")
  field(ZNAM, "Off")
  field(ONAM, "On")
  info(autosaveFields, "DESC")
}

# Borrowed
# File: xleap_din_bit.template
# Author: Wayne Lewis
# Date: 2017-05-08
#
# Description:
# This database is the template for the generic Aerotech 
# digital input PVs.
#
# Macros:
# U 	- Device prefix
# Port 	- Aerotech input port number (port is Aerotech terminology)
# In .	- Input number
# Word 	- MBBI word (from aerotech_din.db) 
# Bit 	- Bit number from word

record(bi, "$(U):DIP2IN3") {
  field(DESC, "Port 2 Input 3")
  field(INP,  "$(U):DISTATS1.B3 CP NMS")
  field(ZNAM, "Off")
  field(ONAM, "On")
  info(autosaveFields, "DESC")
}

# Borrowed
# File: xleap_din_bit.template
# Author: Wayne Lewis
# Date: 2017-05-08
#
# Description:
# This database is the template for the generic Aerotech 
# digital input PVs.
#
# Macros:
# U 	- Device prefix
# Port 	- Aerotech input port number (port is Aerotech terminology)
# In .	- Input number
# Word 	- MBBI word (from aerotech_din.db) 
# Bit 	- Bit number from word

record(bi, "$(U):DIP2IN4") {
  field(DESC, "Port 2 Input 4")
  field(INP,  "$(U):DISTATS1.B4 CP NMS")
  field(ZNAM, "Off")
  field(ONAM, "On")
  info(autosaveFields, "DESC")
}

# Borrowed
# File: xleap_din_bit.template
# Author: Wayne Lewis
# Date: 2017-05-08
#
# Description:
# This database is the template for the generic Aerotech 
# digital input PVs.
#
# Macros:
# U 	- Device prefix
# Port 	- Aerotech input port number (port is Aerotech terminology)
# In .	- Input number
# Word 	- MBBI word (from aerotech_din.db) 
# Bit 	- Bit number from word

record(bi, "$(U):DIP2IN5") {
  field(DESC, "Port 2 Input 5")
  field(INP,  "$(U):DISTATS1.B5 CP NMS")
  field(ZNAM, "Off")
  field(ONAM, "On")
  info(autosaveFields, "DESC")
}

# Borrowed
# File: xleap_din_bit.template
# Author: Wayne Lewis
# Date: 2017-05-08
#
# Description:
# This database is the template for the generic Aerotech 
# digital input PVs.
#
# Macros:
# U 	- Device prefix
# Port 	- Aerotech input port number (port is Aerotech terminology)
# In .	- Input number
# Word 	- MBBI word (from aerotech_din.db) 
# Bit 	- Bit number from word

record(bi, "$(U):DIP2IN6") {
  field(DESC, "Port 2 Input 6")
  field(INP,  "$(U):DISTATS1.B6 CP NMS")
  field(ZNAM, "Off")
  field(ONAM, "On")
  info(autosaveFields, "DESC")
}

# Borrowed
# File: xleap_din_bit.template
# Author: Wayne Lewis
# Date: 2017-05-08
#
# Description:
# This database is the template for the generic Aerotech 
# digital input PVs.
#
# Macros:
# U 	- Device prefix
# Port 	- Aerotech input port number (port is Aerotech terminology)
# In .	- Input number
# Word 	- MBBI word (from aerotech_din.db) 
# Bit 	- Bit number from word

record(bi, "$(U):DIP2IN7") {
  field(DESC, "Port 2 Input 7")
  field(INP,  "$(U):DISTATS1.B7 CP NMS")
  field(ZNAM, "Off")
  field(ONAM, "On")
  info(autosaveFields, "DESC")
}

record(motor, "$(U):MOTR") {
  field(DESC, "$(MAD)")
  field(DTYP, "asynMotor")
  field(DIR, "Pos")
  field(VELO, "10000")
  field(VBAS, "1000")
  field(VMAX, "30000")
  field(ACCL, "0.02")
  field(BDST, "0")
  field(OUT, "@asyn($(ASYN_MOTOR),$(AXIS))")
  field(MRES, "1")
  field(ERES, "1")
  field(PREC, "1")
  field(EGU, "um")
  field(DHLM, "0")
  field(DLLM, "0")
  field(UEIP, "1")
  field(TWV, "1")
  field(FOFF, "Frozen")
  field(OFF, "0")
  field(URIP, "0")
  field(RRES, "1")
  field(RTRY, "0")
  field(RDBL, "")
  field(RDBD, "1")
  field(DLY, "0")
  field(SCAN, "Passive")
  info(autosaveFields_pass0, "VAL")
  info(autosaveFields, "DIR DESC VMAX VBAS ACCL VELO MRES ERES PREC EGU DHLM DLLM DLY TWV RDBL RRES RTRY URIP UEIP FOFF OFF FRAC JVEL JAR HVEL HLM LLM")
}
record(bo, "$(U):MOTR_ALRM") {
  field(DESC, "In Beam Alarm")
  field(DOL,  "$(U):MOTRERROR MS")
  field(OMSL, "closed_loop")
  field(ZNAM, "IN_BEAM")
  field(ONAM, "OUT_OF_BEAM")
  field(ZSV,  "MAJOR")
  field(OSV,  "NO_ALARM")
}

record(calcout, "$(U):MOTRERROR") {
  field(CALC, "(A>=B)?0:1")
  field(FLNK, "$(U):MOTR_ALRM")
  field(SCAN, "1 second")
  field(INPA, "$(U):MOTR.RBV NPP MS")
  field(INPB, "3000")
  field(INPC, "0")
  field(HIGH, "1")
  field(LOW,  "0")
  field(HSV, "MAJOR")
  field(LSV, "NO_ALARM")
  info(autosaveFields, "CALC INPA INPB INPC")
}

# Init sequence record. Initialized by pressing :MOTR_INIT button.
# The init_seq, 
# a) turns off and then turns on the motor within 0.5s
# c) pushes 0 to home_check disable field and then homes the motor after 0.5s

record(bo, "$(U):MOTR_INIT") {
  field(DESC, "Init or Re Init")
  field(ZNAM, "Standby")
  field(ONAM, "Initialize ")
}

record(bo, "$(U):MOTR_INIT_DBG") {
  field(DTYP, "Raw Soft Channel")
  field(DESC, "Init debug flag")
  field(VAL, "0")
  field(ZNAM, "Debug Off")
  field(ONAM, "Debug On")
}

# Error acknowledge command initiates acknowledge sequence
# For linmot, disbale and then enable the motor to clear the error.

record(bo, "$(U):MOTR_ERR_ACK_CMD") {
  field(DESC, "Error Ack CMD")
  field(FLNK, "$(U):FAULTACK")
  field(ZNAM, "NO ACK")
  field(ONAM, "ACK")
}

record(seq, "$(U):ACK_ERR_SEQ") {
  field(DESC, "Acknowledge error")
  field(DLY1, "2")
  field(DOL1, "0")
  field(LNK1, "$(U):MOTR.CNEN")
  field(DOL2, "1")
  field(LNK2, "$(U):MOTR.CNEN")
  field(ASG,  "Internal")
}

# Motor switch on command
# Motor can be turned on by 
# a) MOTR.CNEN and MOTR_SWITCH_ON_CMD
# To ensure that both the commands work and not counter one another, calc records used
# and both the PV`s should be updated if one does. 


record(bo, "$(U):MOTR_SWITCH_ON_CMD") {
  field(DESC, "Motor switch on CMD")
  field(ZNAM, "OFF")
  field(ONAM, "ON")
}

record(calcout, "$(U):CALC_ENABLE") {
  field(DESC, "Check ON cmd is pressed")
  field(CALC, "(A#B)?1:0")
  field(INPA, "$(U):MOTR_SWITCH_ON_CMD CP")
  field(INPB, "$(U):MOTR.CNEN")
  field(OUT, "$(U):ENABLE_BO.PROC")
  field(OOPT, "When Non-zero")
  field(ASG,  "Internal")
}

record(bo, "$(U):ENABLE_BO") {
  field(DESC, "copies switch on to cnen")
  field(DOL, "$(U):MOTR_SWITCH_ON_CMD")
  field(OUT, "$(U):MOTR.CNEN PP")
  field(OMSL, "closed_loop")
  field(ASG,  "Internal")
}

record(calcout, "$(U):CALC_CNEN") {
  field(DESC, "Check CNEN is pressed")
  field(CALC, "(A#B)?1:0")
  field(INPA, "$(U):MOTR.CNEN CP")
  field(INPB, "$(U):MOTR_SWITCH_ON_CMD")
  field(OUT, "$(U):CNEN_BO.PROC")
  field(OOPT, "When Non-zero")
  field(ASG,  "Internal")
}

record(bo, "$(U):CNEN_BO") {
  field(DESC, "copies switch on to bo")
  field(DOL, "$(U):MOTR.CNEN")
  field(OUT, "$(U):MOTR_SWITCH_ON_CMD PP")
  field(OMSL, "closed_loop")
  field(ASG,  "Internal")
}

# Motor home command
# Motor can be homed by 
# a) MOTR.HOMR , HOML and MOTR_HOME_CMD
# To ensure that both the commands work and not counter one another, calc records used
# and both the PV`s should be updated if one does. 

record(bo, "$(U):MOTR_HOME_CMD") {
  field(DESC, "MOtor Home CMD")
  field(ZNAM, "OFF")
  field(ONAM, "HOME")
}

record(calcout, "$(U):CALC_HCMD") {
  field(DESC, "Check HOME cmd is pressed")
  field(CALC, "(A#B)?1:0")
  field(INPA, "$(U):MOTR_HOME_CMD CP")
  field(INPB, "$(U):MOTR.HOMR")
  field(OUT, "$(U):HCMD_BO.PROC")
  field(OOPT, "When Non-zero")
  field(ASG,  "Internal")
}

record(bo, "$(U):HCMD_BO") {
  field(DESC, "copies home cmd  to homr_bo")
  field(DOL, "$(U):MOTR_HOME_CMD")
  field(OUT, "$(U):MOTR.HOMR PP")
  field(OMSL, "closed_loop")
  field(ASG,  "Internal")
}

record(calcout, "$(U):CALC_HOMR") {
  field(DESC, "Check HOMR is pressed")
  field(CALC, "(A#B)?1:0")
  field(INPA, "$(U):MOTR.HOMR CP")
  field(INPB, "$(U):MOTR_HOME_CMD")
  field(OUT, "$(U):HOMR_BO.PROC")
  field(OOPT, "When Non-zero")
  field(ASG,  "Internal")
}

record(bo, "$(U):HOMR_BO") {
  field(DESC, "copies HOMR to HCMD_bo")
  field(DOL, "$(U):MOTR.HOMR")
  field(OUT, "$(U):MOTR_HOME_CMD PP")
  field(OMSL, "closed_loop")
  field(ASG,  "Internal")
}

# Retract pv inititates the retract sequence
# Retract equence homes and disables the motor

record(bo, "$(U):MOTR_RETRACT") {
  field(DESC, "Motor Home and Disable")
  field(ZNAM, "Standby")
  field(ONAM, "Retract")
}

# As counter is incremental, reset counter sequence is used.
# This sequence check`s if motor is homed and then resets the counter value.
# To check if motor is homed, motion active status should transition to zero.


# If motor record readback and external encoder readback are different
# Initiates a sequence which updates teh motor readback to match encoder
# Also make sure the retract position is higher than lower limit
# Ensure the links are passive process.
# No need for passive process for POSN. It updates as I/O interrupt
record(bo, "$(U):CORRECT"){
  field(DESC, "Update POSN value into MOTR value")
  field(FLNK, "$(U):CORRECT_SEQ")
  field(ZNAM, "No Update")
  field(ONAM, "Updating")
}

record(calcout, "$(U):CORRECT_CALC") {
  field(DESC, "Diff btw POSN and MOTR.VAL")
  field(CALC, "A-B+C")
  field(INPA, "$(U):POSN")
  field(INPB, "$(U):MOTR.RBV PP")
  field(INPC, "$(U):MOTR.OFF PP")
  field(ASG,  "Internal")
}

record(seq, "$(U):CORRECT_SEQ") {
  field(DESC, "Update POSN value into MOTR value")
  field(DOL1, "1")
  field(LNK1, "$(U):MOTR.SET PP")
  field(DOL2, "$(U):CORRECT_CALC.VAL PP")
  field(LNK2, "$(U):MOTR.OFF")
  field(DLY2, "1")
  field(DOL3, "0")
  field(LNK3, "$(U):MOTR.SET PP")
  field(DLY3, "1")
  field(DLY4, "1")
  field(DOL4, "$(U):MOTR_RETRACT_POS_CALC PP")
  field(LNK4, "$(U):MOTR_RETRACT_POS.VAL PP")
  field(DLY5, "1")
  field(DOL5, "1")
  field(LNK5, "$(U):CORRECT_STS PP")
  field(ASG,  "Internal")
}

record(calcout, "$(U):MOTR_RETRACT_POS_CALC") {
  field(DESC, "Diff btw lower limit and retract pos")
  field(CALC, "A+100")
  field(INPA, "$(U):MOTR.LLM PP")
  field(ASG,  "Internal")
}

record(bi, "$(U):CORRECT_STS") {
  field(DESC, "readback correct status")
  field(ZNAM, "No Update")
  field(ONAM, "Readback corrected")
}

# Store control architecture
record(bo, "$(U):ARCHITECTURE") {
  field(DESC, "set control architecture")
  field(SCAN, "Passive")
  field(ZNAM, "ATCA")
  field(ONAM, "APCI")
  field(VAL, "1")
  info(autosaveFields, "VAL")
}

record(bo, "$(U):Reset") {
  field(DESC, "trigger LLS Sw control reset - atca")
  field(SCAN, "Passive")
  field(ZNAM, "Idle")
  field(ONAM, "Reset")
  field(OUT, "$(U):LLS_SWCTRL_TOGGLE.PROC PP")
}

record(seq, "$(U):LLS_SWCTRL_TOGGLE") {
  field(DESC, "toggle LLS SW control - atca")
## Used while debugging
  field(TPRO, "1")
  field(DOL1, "0")
  field(LNK1, "$(U):LLSSwCtrl PP")
  field(DLY2, "1")
  field(DOL2, "1")
  field(LNK2, "$(U):LLSSwCtrl PP")
  field(DLY3, "1")
  field(DOL3, "0")
  field(LNK3, "$(U):LLSSwCtrl PP")
}
# File: wirescanner_status.db
#
# Description:
# This database is used to get the status PV on EDM 
# Homes and encoder 
# It uses the motor record to get PV`s used used by HLA
#
# Macros:
# P 	- Controller prefix
# M     - motor 

record(bi, "$(U):MOTR_ENABLED_STS") {
  field(DESC, "Enabled status")
  field(ZNAM, "Not Ready for WireScan")
  field(ONAM, "Ready for wirescan")
}

record(calcout, "$(U):CALC_ENABLED_STS") {
  field(DESC, "Check if enabled")
  field(CALC, "A&&B&&C")
  field(INPA, "$(U):MOTR_INIT_STS CP")
  field(INPB, "$(U):MOTR_ON_STS CP")
  field(INPC, "$(U):MOTR_HOMED_STS CP")
  field(OUT, "$(U):MOTR_ENABLED_STS PP")
}

record(bi, "$(U):MOTR_INIT_STS") {
  field(DESC, "Init status")
  field(ZNAM, "Not Initialized")
  field(ONAM, "Initialized")
}

record(bi, "$(U):MOTR_ON_STS") {
  field(DESC, "Torque status")
  field(INP, "$(U):STATS1.B0 CP")
  field(ZNAM, "Torque OFF")
  field(ONAM, "Torque ON")
}

record(bi, "$(U):MOTR_HOMED_STS") {
  field(DESC, "Homed")
  field(INP, "$(U):STATS1.B1 CP")
  field(ZNAM, "Not Homed")
  field(ONAM, "Homed")
}

record(bi, "$(U):MOTR_MOTION_ACT_STS") {
  field(DESC, "Motion Active")
  field(INP, "$(U):STATS1.B3 CP")
  field(ZNAM, "Not Moving")
  field(ONAM, "Moving")
}

record(bi, "$(U):MOTR_ERROR_STS") {
  field(DESC, "Error Status")
  field(INP, "$(U):AXIS_ERROR_CALC CP")
  field(ZNAM, "No Error")
  field(ONAM, "ERROR")
  field(ZSV, "NO_ALARM")
  field(OSV, "MAJOR")
}

record(calcout, "$(U):AXIS_ERROR_CALC") {
  field(DESC, "Check if Axis at fault")
  field(CALC, "(A>0)?1:0")
  field(INPA, "$(U):FAULT CP")
  field(OUT, "$(U):MOTR_ERROR_STS PP")
  field(ASG,  "Internal")
}

# Get the home position from the motor record lower limit
record(ao, "$(U):MOTR_RETRACT_POS") {
  field(ASG, "Internal")
  field(DESC, "Motor retract position")
  field(VAL, "0")
  info(autosaveFields, "VAL")
}

record(ao, "$(U):MOTR_TIMEOUT") {
  field(DTYP, "Raw Soft Channel")
  field(DESC, "Wait time before homing")
  field(VAL, "30")
  field(EGU, "sec")
  info(autosaveFields, "VAL")
}

record(ao, "$(U):MOTR_LTIMEOUT") {
  field(DTYP, "Raw Soft Channel")
  field(DESC, "Wait time at home to turn off")
  field(VAL, "30")
  field(EGU, "sec")
  info(autosaveFields, "VAL")
}

record(bo, "$(U):MOTR_TIMEOUTEN") {
  field(DTYP, "Raw Soft Channel")
  field(DESC, "Enable timeout: retract motor")
  field(ZNAM, "Disabled")
  field(ONAM, "Enabled")
  info(autosaveFields, "VAL")
}

record(bo, "$(U):MOTR_TIMEOUT_DBG") {
  field(DTYP, "Raw Soft Channel")
  field(DESC, "Timeout debug flag")
  field(VAL, "0")
  field(ZNAM, "Debug Off")
  field(ONAM, "Debug On")
}
#! Generated by VisualDCT v2.5
#! DBDSTART
#! DBDEND


#
# Wire Scanner Database Entries for WIRE:$(AREA):$(UNIT)
#
#
# Start or Stop Scanning WIRE:$(AREA):$(UNIT)
#
record(bo, "WIRE:$(AREA):$(UNIT):STARTSCAN") {
  field(DESC, "Start Wire Scan with $(MAD)")
  field(ASG, "WIREUSER")
  field(VAL, "0")
  field(SCAN, "Passive")
  field(PINI, "YES")
  field(ONAM, "Scanning")
  field(ZNAM, "Scan Stopped")
}

#
# Normally scanning moves from inner position to outer
# position, against the force of the vacuum.  If this
# PV is set to true, then WIRE:$(AREA):$(UNIT)
# will scan from the outer to inner position, moving
# with the force of the vacuum.  The scanner is expected
# to provide best results when moving against the force
# of the vacuum.
#
record(bo, "WIRE:$(AREA):$(UNIT):SCANTOCENTER") {
  field(DESC, "$(MAD) will scan inwards")
  field(ASG, "WIREUSER")
  field(VAL, "0")
  field(SCAN, "Passive")
  field(PINI, "YES")
  field(ONAM, "Scan to Center")
  field(ZNAM, "Scan from Center")
  info(autosaveFields, "VAL")
}

#
# Angle of WIRE:$(AREA):$(UNIT) from beam's point of view
#
record(ao, "WIRE:$(AREA):$(UNIT):INSTALLANGLE") {
  field(DESC, "Orientation of $(MAD)")
  field(ASG, "WIREADMIN")
  field(EGU, "degrees")
  field(VAL, "-45")
  field(SCAN, "Passive")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}

#
# Repeatability of WIRE:$(AREA):$(UNIT) when doing a wire scan.
# If the motion returns to the original LVDT-measured position, within
# POSNTHRESH microns, the scan is considered successful.  If not, then
# RETRIES number of scans (in total) will be attempted.
#
record(ao, "WIRE:$(AREA):$(UNIT):POSNTHRESH") {
  field(DESC, "$(MAD) Position Deadband")
  field(ASG, "WIREUSER")
  field(EGU, "microns")
  field(VAL, "1000")
  field(SCAN, "Passive")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}

#
# Calculated time for wire scan; actual time that wire is spent moving.
#
record(ao, "WIRE:$(AREA):$(UNIT):SCANTIME") {
  field(DESC, "$(MAD) Calc. Scan Time")
  field(ASG, "WIREUSER")
  field(EGU, "seconds")
  field(VAL, "0")
  field(SCAN, "Passive")
  field(PINI, "YES")
}

#
# The most recent scan WIRE:$(AREA):$(UNIT)
# was considered to have successfully moved.
#
record(mbbo, "WIRE:$(AREA):$(UNIT):HADSUCCESS") {
  field(DESC, "$(MAD) Scan Successful")
  field(ASG, "$WIREUSER")
  field(OMSL, "supervisory")
  field(VAL, "0")
  field(SCAN, "Passive")
  field(DTYP, "Raw Soft Channel")
  field(NOBT, "32")
  field(ZRST, "No Scan Attempt")
  field(ZRVL, "0")
  field(ONST, "Scan Successful")
  field(ONVL, "1")
  field(TWST, "Scan Failed")
  field(TWVL, "2")
  field(PINI, "YES")
}

#
# The total number of scans to be done by WIRE:$(AREA):$(UNIT)
# for a given scan request; if the scanner motion does not return
# to POSNTHRESH microns of where it started, then a retry is made.
#
record(ao, "WIRE:$(AREA):$(UNIT):RETRIES") {
  field(DESC, "$(MAD) Retries to Do")
  field(ASG, "WIREUSER")
  field(VAL, "0")
  field(SCAN, "Passive")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}

#
# The current retry attempt of WIRE:$(AREA):$(UNIT) to
# perform a scan.  Up to RETRIES attempts will be made, and this
# value indicates which attempt is currently underway.
#
record(ao, "WIRE:$(AREA):$(UNIT):CURRENTRETRY") {
  field(DESC, "$(MAD) Current Retry Count")
  field(ASG, "WIREUSER")
  field(VAL, "0")
  field(SCAN, "Passive")
  field(PINI, "YES")
}

#
# Does WIRE:$(AREA):$(UNIT) Have a Working X Wire?
#
record(bo, "WIRE:$(AREA):$(UNIT):HASXWIRE") {
  field(DESC, "Is X Wire Avail. on $(MAD)")
  field(ASG, "WIREADMIN")
  field(VAL, "1")
  field(SCAN, "Passive")
  field(PINI, "YES")
  field(ONAM, "X Wire is Usable")
  field(ZNAM, "X Wire NOT Usable")
  info(autosaveFields, "VAL")
}

#
# Will the X Wire from WIRE:$(AREA):$(UNIT) be Used?
#
record(bo, "WIRE:$(AREA):$(UNIT):USEXWIRE") {
  field(DESC, "Is X Wire Used on $(MAD)")
  field(ASG, "WIREUSER")
  field(VAL, "1")
  field(SCAN, "Passive")
  field(PINI, "YES")
  field(ONAM, "X Wire Selected")
  field(ZNAM, "X Wire NOT Selected")
  info(autosaveFields, "VAL")
}

#
# Distance of WIRE:$(AREA):$(UNIT) X Wire from beam centerline,
# when motor is at the 0 position.  The U Wire intersecting with the
# beam centerline is defined as 0.
#
record(ao, "WIRE:$(AREA):$(UNIT):XWIREOFFSET") {
  field(DESC, "Offset of $(MAD) X Wire")
  field(ASG, "WIREADMIN")
  field(EGU, "microns")
  field(VAL, "25000")
  field(SCAN, "Passive")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}

#
# The location at which the X Wire can be positioned to
# start a scan in pull-through-beam mode on WIRE:$(AREA):$(UNIT)
#
record(longout, "WIRE:$(AREA):$(UNIT):XWIREOUTER") {
  field(DESC, "Outer X on $(MAD)")
  field(ASG, "WIREUSER")
  field(VAL, "27000")
  field(EGU, "microns")
  field(SCAN, "Passive")
  field(PINI, "YES")
  field(DRVH, "46000")
  field(DRVL, "100")
  field(HOPR, "46000")
  field(LOPR, "100")
  info(autosaveFields, "VAL")
}

#
# The location at which the X Wire can be positioned to
# start a scan in push-through-beam mode on WIRE:$(AREA):$(UNIT)
#
record(longout, "WIRE:$(AREA):$(UNIT):XWIREINNER") {
  field(DESC, "Inner X on $(MAD)")
  field(ASG, "WIREUSER")
  field(VAL, "23000")
  field(EGU, "microns")
  field(SCAN, "Passive")
  field(PINI, "YES")
  field(DRVH, "46000")
  field(DRVL, "100")
  field(HOPR, "46000")
  field(LOPR, "100")
  info(autosaveFields, "VAL")
}

#
# Does WIRE:$(AREA):$(UNIT) Have a Working Y Wire?
#
record(bo, "WIRE:$(AREA):$(UNIT):HASYWIRE") {
  field(DESC, "Is Y Wire Avail. on $(MAD)")
  field(ASG, "WIREADMIN")
  field(VAL, "1")
  field(SCAN, "Passive")
  field(PINI, "YES")
  field(ONAM, "Y Wire is Usable")
  field(ZNAM, "Y Wire NOT Usable")
  info(autosaveFields, "VAL")
}

#
# Will the Y Wire from WIRE:$(AREA):$(UNIT) be Used?
#
record(bo, "WIRE:$(AREA):$(UNIT):USEYWIRE") {
  field(DESC, "Is Y Wire Used on $(MAD)")
  field(ASG, "WIREUSER")
  field(VAL, "0")
  field(SCAN, "Passive")
  field(PINI, "YES")
  field(ONAM, "Y Wire Selected")
  field(ZNAM, "Y Wire NOT Selected")
  info(autosaveFields, "VAL")
}

#
# Distance of WIRE:$(AREA):$(UNIT) Y Wire from beam centerline,
# when motor is at the 0 position.  The U Wire intersecting with the
# beam centerline is defined as 0.
#
record(ao, "WIRE:$(AREA):$(UNIT):YWIREOFFSET") {
  field(DESC, "Offset of $(MAD) Y Wire")
  field(ASG, "WIREADMIN")
  field(EGU, "microns")
  field(VAL, "36200")
  field(SCAN, "Passive")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}

#
# The location at which the Y Wire can be positioned to
# start a scan in pull-through-beam mode on WIRE:$(AREA):$(UNIT)
#
record(longout, "WIRE:$(AREA):$(UNIT):YWIREOUTER") {
  field(DESC, "Outer Y on $(MAD)")
  field(ASG, "WIREUSER")
  field(VAL, "38200")
  field(EGU, "microns")
  field(SCAN, "Passive")
  field(PINI, "YES")
  field(DRVH, "46000")
  field(DRVL, "100")
  field(HOPR, "46000")
  field(LOPR, "100")
  info(autosaveFields, "VAL")
}

#
# The location at which the Y Wire can be positioned to
# start a scan in push-through-beam mode on WIRE:$(AREA):$(UNIT)
#
record(longout, "WIRE:$(AREA):$(UNIT):YWIREINNER") {
  field(DESC, "Inner Y on $(MAD)")
  field(ASG, "WIREUSER")
  field(VAL, "34200")
  field(EGU, "microns")
  field(SCAN, "Passive")
  field(PINI, "YES")
  field(DRVH, "46000")
  field(DRVL, "100")
  field(HOPR, "46000")
  field(LOPR, "100")
  info(autosaveFields, "VAL")
}

# Does WIRE:$(AREA):$(UNIT) Have a Working U (diagonal) Wire?
#
record(bo, "WIRE:$(AREA):$(UNIT):HASUWIRE") {
  field(DESC, "Is U Wire Avail. on $(MAD)")
  field(ASG, "WIREADMIN")
  field(VAL, "1")
  field(SCAN, "Passive")
  field(PINI, "YES")
  field(ONAM, "U Wire is Usable")
  field(ZNAM, "U Wire NOT Usable")
  info(autosaveFields, "VAL")
}

#
# Will the U Wire from WIRE:$(AREA):$(UNIT) be Used?
#
record(bo, "WIRE:$(AREA):$(UNIT):USEUWIRE") {
  field(DESC, "Is U Wire Used on $(MAD)")
  field(ASG, "WIREUSER")
  field(VAL, "0")
  field(SCAN, "Passive")
  field(PINI, "YES")
  field(ONAM, "U Wire Selected")
  field(ZNAM, "U Wire NOT Selected")
  info(autosaveFields, "VAL")
}

#
# Distance of WIRE:$(AREA):$(UNIT) U Wire from beam centerline,
# when motor is at the 0 position.  The U Wire intersecting with the
# beam centerline is defined as 0.
#
record(ao, "WIRE:$(AREA):$(UNIT):UWIREOFFSET") {
  field(DESC, "Offset of $(MAD) U Wire")
  field(ASG, "WIREADMIN")
  field(EGU, "microns")
  field(VAL, "0")
  field(SCAN, "Passive")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}

#
# The location at which the U Wire can be positioned to
# start a scan in pull-through-beam mode on WIRE:$(AREA):$(UNIT)
#
record(longout, "WIRE:$(AREA):$(UNIT):UWIREOUTER") {
  field(DESC, "Outer U on $(MAD)")
  field(ASG, "WIREUSER")
  field(VAL, "19700")
  field(EGU, "microns")
  field(SCAN, "Passive")
  field(PINI, "YES")
  field(DRVH, "46000")
  field(DRVL, "100")
  field(HOPR, "46000")
  field(LOPR, "100")
  info(autosaveFields, "VAL")
}

#
# The location at which the U Wire can be positioned to
# start a scan in push-through-beam mode on WIRE:$(AREA):$(UNIT)
#
record(longout, "WIRE:$(AREA):$(UNIT):UWIREINNER") {
  field(DESC, "Inner U on $(MAD)")
  field(ASG, "WIREUSER")
  field(VAL, "15700")
  field(EGU, "microns")
  field(SCAN, "Passive")
  field(PINI, "YES")
  field(DRVH, "46000")
  field(DRVL, "100")
  field(HOPR, "46000")
  field(LOPR, "100")
  info(autosaveFields, "VAL")
}

#
# The position at which the current scan will start, set to
# the value of :XWIREOUTER, :YWIREOUTER or UWIREOUTER if in
# pull-through-beam mode, or set to :XWIREINNER, :YWIREINNER
# or UWIREINNER if in push-through-beam mode, for WIRE:$(AREA):$(UNIT)
#
record(ao, "WIRE:$(AREA):$(UNIT):SCANPOSSTART") {
  field(DESC, "$(MAD) Wire Start Pos")
  field(ASG, "WIREUSER")
  field(VAL, "23000")
  field(EGU, "microns")
  field(SCAN, "Passive")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}

#
# The position at which the current scan will stop, set to
# the value of :XWIREOUTER, :YWIREOUTER or UWIREOUTER if in
# push-through-beam mode, or set to :XWIREINNER, :YWIREINNER
# or UWIREINNER if in pull-through-beam mode, for WIRE:$(AREA):$(UNIT)
#
record(ao, "WIRE:$(AREA):$(UNIT):SCANPOSSTOP") {
  field(DESC, "$(MAD) Stop Position")
  field(ASG, "WIREUSER")
  field(VAL, "27000")
  field(EGU, "microns")
  field(SCAN, "Passive")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}

#
# The number of beam pulses which WIRE:$(AREA):$(UNIT)
# will intercept as it moves across the total range of travel.
# This is typically selected by the user.
#
record(ao, "WIRE:$(AREA):$(UNIT):SCANPULSES") {
  field(DESC, "Pulses needed by $(MAD)")
  field(ASG, "WIREUSER")
  field(VAL, "100")
  field(SCAN, "Passive")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}

#
# The time to delay between motion stop and position readout
#
record(ao, "WIRE:$(AREA):$(UNIT):SCANDELAY") {
  field(DESC, "$(MAD) Position Delay Time")
  field(ASG, "WIREUSER")
  field(VAL, "1.5")
  field(EGU, "seconds")
  field(SCAN, "Passive")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}

#
# An indication of progress in terms of percent
# completion of WIRE:$(AREA):$(UNIT)
#
record(ao, "WIRE:$(AREA):$(UNIT):SCANPROGRESS") {
  field(DESC, "Progress $(MAD) WireScan")
  field(ASG, "WIREUSER")
  field(VAL, "0")
  field(EGU, "percent")
  field(HOPR, "100")
  field(LOPR, "0")
  field(PREC, "0")
  field(SCAN, "Passive")
  field(PINI, "YES")
}

#
# A textual indication of the status of WIRE:$(AREA):$(UNIT)
#
record(stringout, "WIRE:$(AREA):$(UNIT):SCANTEXT") {
  field(DESC, "$(MAD) Wire Scan Status")
  field(ASG, "WIREUSER")
  field(VAL, "READY to START Wire Scan")
  field(SCAN, "Passive")
  field(PINI, "YES")
}

#! Further lines contain data used by VisualDCT
#! View(-194,-11,0.7)
#! Record("WIRE:$(AREA):$(UNIT):STARTSCAN",20,23,0,0,"WIRE:$(AREA):$(UNIT):STARTSCAN")
#! Record("WIRE:$(AREA):$(UNIT):SCANTOCENTER",260,23,0,0,"WIRE:$(AREA):$(UNIT):SCANTOCENTER")
#! Record("WIRE:$(AREA):$(UNIT):INSTALLANGLE",500,18,0,0,"WIRE:$(AREA):$(UNIT):INSTALLANGLE")
#! Record("WIRE:$(AREA):$(UNIT):POSNTHRESH",740,18,0,0,"WIRE:$(AREA):$(UNIT):POSNTHRESH")
#! Record("WIRE:$(AREA):$(UNIT):SCANTIME",980,12,0,0,"WIRE:$(AREA):$(UNIT):SCANTIME")
#! Record("WIRE:$(AREA):$(UNIT):HADSUCCESS",1220,22,0,0,"WIRE:$(AREA):$(UNIT):HADSUCCESS")
#! Record("WIRE:$(AREA):$(UNIT):RETRIES",1460,12,0,0,"WIRE:$(AREA):$(UNIT):RETRIES")
#! Record("WIRE:$(AREA):$(UNIT):CURRENTRETRY",1700,12,0,0,"WIRE:$(AREA):$(UNIT):CURRENTRETRY")
#! Record("WIRE:$(AREA):$(UNIT):HASXWIRE",1940,23,0,0,"WIRE:$(AREA):$(UNIT):HASXWIRE")
#! Record("WIRE:$(AREA):$(UNIT):USEXWIRE",2180,23,0,0,"WIRE:$(AREA):$(UNIT):USEXWIRE")
#! Record("WIRE:$(AREA):$(UNIT):XWIREOFFSET",2420,18,0,0,"WIRE:$(AREA):$(UNIT):XWIREOFFSET")
#! Record("WIRE:$(AREA):$(UNIT):XWIREOUTER",20,19,0,0,"WIRE:$(AREA):$(UNIT):XWIREOUTER")
#! Record("WIRE:$(AREA):$(UNIT):XWIREINNER",260,19,0,0,"WIRE:$(AREA):$(UNIT):XWIREINNER")
#! Record("WIRE:$(AREA):$(UNIT):HASYWIRE",3140,23,0,0,"WIRE:$(AREA):$(UNIT):HASYWIRE")
#! Record("WIRE:$(AREA):$(UNIT):USEYWIRE",3380,23,0,0,"WIRE:$(AREA):$(UNIT):USEYWIRE")
#! Record("WIRE:$(AREA):$(UNIT):YWIREOFFSET",3620,18,0,0,"WIRE:$(AREA):$(UNIT):YWIREOFFSET")
#! Record("WIRE:$(AREA):$(UNIT):YWIREOUTER",3860,19,0,0,"WIRE:$(AREA):$(UNIT):YWIREOUTER")
#! Record("WIRE:$(AREA):$(UNIT):YWIREINNER",4100,19,0,0,"WIRE:$(AREA):$(UNIT):YWIREINNER")
#! Record("WIRE:$(AREA):$(UNIT):HASUWIRE",4340,23,0,0,"WIRE:$(AREA):$(UNIT):HASUWIRE")
#! Record("WIRE:$(AREA):$(UNIT):USEUWIRE",4580,23,0,0,"WIRE:$(AREA):$(UNIT):USEUWIRE")
#! Record("WIRE:$(AREA):$(UNIT):UWIREOFFSET",20,378,0,0,"WIRE:$(AREA):$(UNIT):UWIREOFFSET")
#! Record("WIRE:$(AREA):$(UNIT):UWIREOUTER",260,319,0,0,"WIRE:$(AREA):$(UNIT):UWIREOUTER")
#! Record("WIRE:$(AREA):$(UNIT):UWIREINNER",500,319,0,0,"WIRE:$(AREA):$(UNIT):UWIREINNER")
#! Record("WIRE:$(AREA):$(UNIT):SCANPOSSTART",740,378,0,0,"WIRE:$(AREA):$(UNIT):SCANPOSSTART")
#! Record("WIRE:$(AREA):$(UNIT):SCANPOSSTOP",980,378,0,0,"WIRE:$(AREA):$(UNIT):SCANPOSSTOP")
#! Record("WIRE:$(AREA):$(UNIT):SCANPULSES",1220,372,0,0,"WIRE:$(AREA):$(UNIT):SCANPULSES")
#! Record("WIRE:$(AREA):$(UNIT):SCANDELAY",1460,378,0,0,"WIRE:$(AREA):$(UNIT):SCANDELAY")
#! Record("WIRE:$(AREA):$(UNIT):SCANPROGRESS",1700,373,0,0,"WIRE:$(AREA):$(UNIT):SCANPROGRESS")
#! Record("WIRE:$(AREA):$(UNIT):SCANTEXT",1940,372,0,0,"WIRE:$(AREA):$(UNIT):SCANTEXT")
#
# Angle of WIRE:$(AREA):$(UNIT) from beam's point of view
#
record(ao, "WIRE:$(AREA):$(UNIT):XWIRESIZE") {
  field(DESC, "Diam. of $(MAD) x wire")
  field(ASG, "WIREADMIN")
  field(EGU, "microns")
  field(VAL, "40")
  field(SCAN, "Passive")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}

record(ao, "WIRE:$(AREA):$(UNIT):YWIRESIZE") {
  field(DESC, "Diam. of $(MAD) y wire")
  field(ASG, "WIREADMIN")
  field(EGU, "microns")
  field(VAL, "40")
  field(SCAN, "Passive")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}

record(ao, "WIRE:$(AREA):$(UNIT):UWIRESIZE") {
  field(DESC, "Diam. of $(MAD) u wire")
  field(ASG, "WIREADMIN")
  field(EGU, "microns")
  field(VAL, "40")
  field(SCAN, "Passive")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}

#==================================================================
# Record example for an IntField, RO, 1 element, IEEE_754 encoding 
# register.
# It is a ai record with type asynFloat64.
# The INP field has the form @asyn(PORT,ADDR)PARAM where:
#  - PORT  : The asyn port name. It must match the port name given 
#            when calling "YCPSWASYNConfig" on st.cmd
#  - PARAM : The asyn paramter name. It must be defined in the 
#            dictionary file and assigned to a register.
#  - ADDR  : Addrres based on the type of register. 
#            For IntField, RO, with IEEE_754 encoding is 2.
#==================================================================

record(ai,      "$(U):Velo") {
    field(DTYP, "asynFloat64")
    field(DESC, "WireScanner Velo")
    field(PINI, "YES")
    field(SCAN, "1 second")
    field(EGU,  "um/sec")
    field(HIGH, "")
    field(HSV, "")
    field(LOW, "")
    field(LSV, "")
    field(EGU,  "um/sec")
    field(INP,  "@asyn(cpsw,2)MVR$(CPSW_AXIS):Velo")
}
#==================================================================
# Record example for an IntField, RO, 1 element, IEEE_754 encoding 
# register.
# It is a ai record with type asynFloat64.
# The INP field has the form @asyn(PORT,ADDR)PARAM where:
#  - PORT  : The asyn port name. It must match the port name given 
#            when calling "YCPSWASYNConfig" on st.cmd
#  - PARAM : The asyn paramter name. It must be defined in the 
#            dictionary file and assigned to a register.
#  - ADDR  : Addrres based on the type of register. 
#            For IntField, RO, with IEEE_754 encoding is 2.
#==================================================================

record(ai,      "$(U):CalcPos") {
    field(DTYP, "asynFloat64")
    field(DESC, "Coeff/Count")
    field(PINI, "YES")
    field(SCAN, "1 second")
    field(EGU,  "")
    field(HIGH, "")
    field(HSV, "")
    field(LOW, "")
    field(LSV, "")
    field(EGU,  "")
    field(INP,  "@asyn(cpsw,2)MVR$(CPSW_AXIS):CalcPos")
}
#==================================================================
# Record example for an IntField, RW, 1 element, IEEE_754 encoding
# register.
# It is an ao record with type asynFloat64.
# The OUT field has the form @asyn(PORT,ADDR)PARAM where:
#  - PORT  : The asyn port name. It must match the port name given
#            when calling "YCPSWASYNConfig" on st.cmd
#  - PARAM : The asyn parameter name. It must be defined in the
#            dictionary file and assigned to a register.
#  - ADDR  : Address based on the type of register.
#            For IntField, RW, with IEEE_754 encoding is 3.
#==================================================================

record(ao,      "$(U):CoefPos") {
    field(DTYP, "asynFloat64")
    field(DESC, "Counts/um")
    field(PINI, "NO")
    field(SCAN, "Passive")
    field(OUT,  "@asyn(cpsw,3)MVR$(CPSW_AXIS):CoefPos")
    info(autosaveFields, "VAL")
}
#==================================================================
# Record example for an IntField, RW, 1 element, IEEE_754 encoding
# register.
# It is an ao record with type asynFloat64.
# The OUT field has the form @asyn(PORT,ADDR)PARAM where:
#  - PORT  : The asyn port name. It must match the port name given
#            when calling "YCPSWASYNConfig" on st.cmd
#  - PARAM : The asyn parameter name. It must be defined in the
#            dictionary file and assigned to a register.
#  - ADDR  : Address based on the type of register.
#            For IntField, RW, with IEEE_754 encoding is 3.
#==================================================================

record(ao,      "$(U):CoefVel") {
    field(DTYP, "asynFloat64")
    field(DESC, "um/Counts/time")
    field(PINI, "NO")
    field(SCAN, "Passive")
    field(OUT,  "@asyn(cpsw,3)MVR$(CPSW_AXIS):CoefVel")
    info(autosaveFields, "VAL")
}
#==================================================================
# Record example for an IntField, RW, 1 element, IEEE_754 encoding
# register.
# It is an ao record with type asynFloat64.
# The OUT field has the form @asyn(PORT,ADDR)PARAM where:
#  - PORT  : The asyn port name. It must match the port name given
#            when calling "YCPSWASYNConfig" on st.cmd
#  - PARAM : The asyn parameter name. It must be defined in the
#            dictionary file and assigned to a register.
#  - ADDR  : Address based on the type of register.
#            For IntField, RW, with IEEE_754 encoding is 3.
#==================================================================

record(ao,      "$(U):LLimPos") {
    field(DTYP, "asynFloat64")
    field(DESC, "LLim Position")
    field(PINI, "NO")
    field(SCAN, "Passive")
    field(OUT,  "@asyn(cpsw,3)MVR$(CPSW_AXIS):LLimPos")
    info(autosaveFields, "VAL")
}
#==================================================================
# Record example for an IntField, RW, 1 element, IEEE_754 encoding
# register.
# It is an ao record with type asynFloat64.
# The OUT field has the form @asyn(PORT,ADDR)PARAM where:
#  - PORT  : The asyn port name. It must match the port name given
#            when calling "YCPSWASYNConfig" on st.cmd
#  - PARAM : The asyn parameter name. It must be defined in the
#            dictionary file and assigned to a register.
#  - ADDR  : Address based on the type of register.
#            For IntField, RW, with IEEE_754 encoding is 3.
#==================================================================

record(ao,      "$(U):MPSMonStartPos") {
    field(DTYP, "asynFloat64")
    field(DESC, "MPS Monitor Start")
    field(PINI, "NO")
    field(SCAN, "Passive")
    field(OUT,  "@asyn(cpsw,3)MVR$(CPSW_AXIS):MPSMonStart")
    info(autosaveFields, "VAL")
}
#==================================================================
# Record example for an IntField, RW, 1 element, IEEE_754 encoding
# register.
# It is an ao record with type asynFloat64.
# The OUT field has the form @asyn(PORT,ADDR)PARAM where:
#  - PORT  : The asyn port name. It must match the port name given
#            when calling "YCPSWASYNConfig" on st.cmd
#  - PARAM : The asyn parameter name. It must be defined in the
#            dictionary file and assigned to a register.
#  - ADDR  : Address based on the type of register.
#            For IntField, RW, with IEEE_754 encoding is 3.
#==================================================================

record(ao,      "$(U):MPSMonStopPos") {
    field(DTYP, "asynFloat64")
    field(DESC, "Stop MPS Monitor")
    field(PINI, "NO")
    field(SCAN, "Passive")
    field(OUT,  "@asyn(cpsw,3)MVR$(CPSW_AXIS):MPSMonStop")
    info(autosaveFields, "VAL")
}
#==================================================================
# Record example for an IntField, RW, 1 element, IEEE_754 encoding
# register.
# It is an ao record with type asynFloat64.
# The OUT field has the form @asyn(PORT,ADDR)PARAM where:
#  - PORT  : The asyn port name. It must match the port name given
#            when calling "YCPSWASYNConfig" on st.cmd
#  - PARAM : The asyn parameter name. It must be defined in the
#            dictionary file and assigned to a register.
#  - ADDR  : Address based on the type of register.
#            For IntField, RW, with IEEE_754 encoding is 3.
#==================================================================

record(ao,      "$(U):EndOfScanPos") {
    field(DTYP, "asynFloat64")
    field(DESC, "End of Scan Pos")
    field(PINI, "NO")
    field(SCAN, "Passive")
    field(OUT,  "@asyn(cpsw,3)MVR$(CPSW_AXIS):EndOfScan")
    info(autosaveFields, "VAL")
}
#==================================================================
# Record example for reading back an IntField, RW, 1 element,
# IEEE_754 encoding register.
# It is an ai record with type asynFloat64.
# The INP field has the form @asyn(PORT,ADDR)PARAM where:
#  - PORT  : The asyn port name. It must match the port name given
#            when calling "YCPSWASYNConfig" on st.cmd
#  - PARAM : The asyn parameter name. It must be defined in the
#            dictionary file and assigned to a register.
#  - ADDR  : Address based on the type of register.
#            For IntField, RW, with IEEE_754 encoding is 3.
#==================================================================

record(ai,      "$(U):CoefPosRBV") {
    field(DTYP, "asynFloat64")
    field(DESC, "Counts/um RBV")
    field(PINI, "YES")
    field(SCAN, "1 second")
    field(INP,  "@asyn(cpsw,3)MVR$(CPSW_AXIS):CoefPos")
}
#==================================================================
# Record example for reading back an IntField, RW, 1 element,
# IEEE_754 encoding register.
# It is an ai record with type asynFloat64.
# The INP field has the form @asyn(PORT,ADDR)PARAM where:
#  - PORT  : The asyn port name. It must match the port name given
#            when calling "YCPSWASYNConfig" on st.cmd
#  - PARAM : The asyn parameter name. It must be defined in the
#            dictionary file and assigned to a register.
#  - ADDR  : Address based on the type of register.
#            For IntField, RW, with IEEE_754 encoding is 3.
#==================================================================

record(ai,      "$(U):CoefVelRBV") {
    field(DTYP, "asynFloat64")
    field(DESC, "um/time/Counts RBV")
    field(PINI, "YES")
    field(SCAN, "1 second")
    field(INP,  "@asyn(cpsw,3)MVR$(CPSW_AXIS):CoefVel")
}
#==================================================================
# Record example for reading back an IntField, RW, 1 element,
# IEEE_754 encoding register.
# It is an ai record with type asynFloat64.
# The INP field has the form @asyn(PORT,ADDR)PARAM where:
#  - PORT  : The asyn port name. It must match the port name given
#            when calling "YCPSWASYNConfig" on st.cmd
#  - PARAM : The asyn parameter name. It must be defined in the
#            dictionary file and assigned to a register.
#  - ADDR  : Address based on the type of register.
#            For IntField, RW, with IEEE_754 encoding is 3.
#==================================================================

record(ai,      "$(U):LLimPosRBV") {
    field(DTYP, "asynFloat64")
    field(DESC, "LLim Position RBV")
    field(PINI, "YES")
    field(SCAN, "1 second")
    field(INP,  "@asyn(cpsw,3)MVR$(CPSW_AXIS):LLimPos")
}
#==================================================================
# Record example for reading back an IntField, RW, 1 element,
# IEEE_754 encoding register.
# It is an ai record with type asynFloat64.
# The INP field has the form @asyn(PORT,ADDR)PARAM where:
#  - PORT  : The asyn port name. It must match the port name given
#            when calling "YCPSWASYNConfig" on st.cmd
#  - PARAM : The asyn parameter name. It must be defined in the
#            dictionary file and assigned to a register.
#  - ADDR  : Address based on the type of register.
#            For IntField, RW, with IEEE_754 encoding is 3.
#==================================================================

record(ai,      "$(U):MPSMonStartPosRBV") {
    field(DTYP, "asynFloat64")
    field(DESC, "MPS Monitor Start RBV")
    field(PINI, "YES")
    field(SCAN, "1 second")
    field(INP,  "@asyn(cpsw,3)MVR$(CPSW_AXIS):MPSMonStart")
}
#==================================================================
# Record example for reading back an IntField, RW, 1 element,
# IEEE_754 encoding register.
# It is an ai record with type asynFloat64.
# The INP field has the form @asyn(PORT,ADDR)PARAM where:
#  - PORT  : The asyn port name. It must match the port name given
#            when calling "YCPSWASYNConfig" on st.cmd
#  - PARAM : The asyn parameter name. It must be defined in the
#            dictionary file and assigned to a register.
#  - ADDR  : Address based on the type of register.
#            For IntField, RW, with IEEE_754 encoding is 3.
#==================================================================

record(ai,      "$(U):MPSMonStopPosRBV") {
    field(DTYP, "asynFloat64")
    field(DESC, "Stop MPS Monitor RBV")
    field(PINI, "YES")
    field(SCAN, "1 second")
    field(INP,  "@asyn(cpsw,3)MVR$(CPSW_AXIS):MPSMonStop")
}
#==================================================================
# Record example for reading back an IntField, RW, 1 element,
# IEEE_754 encoding register.
# It is an ai record with type asynFloat64.
# The INP field has the form @asyn(PORT,ADDR)PARAM where:
#  - PORT  : The asyn port name. It must match the port name given
#            when calling "YCPSWASYNConfig" on st.cmd
#  - PARAM : The asyn parameter name. It must be defined in the
#            dictionary file and assigned to a register.
#  - ADDR  : Address based on the type of register.
#            For IntField, RW, with IEEE_754 encoding is 3.
#==================================================================

record(ai,      "$(U):EndOfScanPosRBV") {
    field(DTYP, "asynFloat64")
    field(DESC, "End of Scan Pos RBV")
    field(PINI, "YES")
    field(SCAN, "1 second")
    field(INP,  "@asyn(cpsw,3)MVR$(CPSW_AXIS):EndOfScan")
}
#==================================================================
# Record example for an IntField, RW, 1 element, no encoding register.
# It is a longout record with type asynInt32.
# The OUT field has the form @asyn(PORT,ADDR)PARAM where:
#  - PORT  : The asyn port name. It must match the port name given
#            when calling "YCPSWASYNConfig" on st.cmd
#  - PARAM : The asyn parameter name. It must be defined in the
#            dictionary file and assigned to a register.
#  - ADDR  : Address based on the type of register.
#            For IntField, RW, without encoding is 1.
#==================================================================

record(longout, "$(U):VelTOThresh") {
    field(DTYP, "asynInt32")
    field(DESC, "Vel Timeout Thres")
    field(PINI, "NO")
    field(SCAN, "Passive")
    field(OUT,  "@asyn(cpsw,1)MVR:SpeedTOThresh")
    info(autosaveFields, "VAL")
}
#==================================================================
# Record example for an IntField, RW, 1 element, no encoding register.
# It is a longout record with type asynInt32.
# The OUT field has the form @asyn(PORT,ADDR)PARAM where:
#  - PORT  : The asyn port name. It must match the port name given
#            when calling "YCPSWASYNConfig" on st.cmd
#  - PARAM : The asyn parameter name. It must be defined in the
#            dictionary file and assigned to a register.
#  - ADDR  : Address based on the type of register.
#            For IntField, RW, without encoding is 1.
#==================================================================

record(longout, "$(U):ChargeThresh") {
    field(DTYP, "asynInt32")
    field(DESC, "ChargeThreshold")
    field(PINI, "NO")
    field(SCAN, "Passive")
    field(OUT,  "@asyn(cpsw,1)MVR:ChargeThresh")
    info(autosaveFields, "VAL")
}
#==================================================================
# Record example for an IntField, RW, 1 element, no encoding register.
# It is a longout record with type asynInt32.
# The OUT field has the form @asyn(PORT,ADDR)PARAM where:
#  - PORT  : The asyn port name. It must match the port name given
#            when calling "YCPSWASYNConfig" on st.cmd
#  - PARAM : The asyn parameter name. It must be defined in the
#            dictionary file and assigned to a register.
#  - ADDR  : Address based on the type of register.
#            For IntField, RW, without encoding is 1.
#==================================================================

record(longout, "$(U):RepRateThresh") {
    field(DTYP, "asynInt32")
    field(DESC, "Allowed RepRate")
    field(PINI, "NO")
    field(SCAN, "Passive")
    field(OUT,  "@asyn(cpsw,1)MVR:RepRateThresh")
    info(autosaveFields, "VAL")
}
#==================================================================
# Record example for reading back from an IntField, RW, 1 element,
# no encoding register.
# It is a longin record with type asynInt32.
# The INP field has the form @asyn(PORT,ADDR)PARAM where:
#  - PORT  : The asyn port name. It must match the port name given
#            when calling "YCPSWASYNConfig" on st.cmd
#  - PARAM : The asyn parameter name. It must be defined in the
#            dictionary file and assigned to a register.
#  - ADDR  : Address based on the type of register.
#            For IntField, RW, without encoding is 1.
#==================================================================

record(longin,  "$(U):VelTOThreshRBV") {
    field(DTYP, "asynInt32")
    field(DESC, "Vel TO Thresh  RBV")
    field(PINI, "YES")
    field(SCAN, "1 second")
    field(INP,  "@asyn(cpsw,1)MVR:SpeedTOThresh")
}
#==================================================================
# Record example for reading back from an IntField, RW, 1 element,
# no encoding register.
# It is a longin record with type asynInt32.
# The INP field has the form @asyn(PORT,ADDR)PARAM where:
#  - PORT  : The asyn port name. It must match the port name given
#            when calling "YCPSWASYNConfig" on st.cmd
#  - PARAM : The asyn parameter name. It must be defined in the
#            dictionary file and assigned to a register.
#  - ADDR  : Address based on the type of register.
#            For IntField, RW, without encoding is 1.
#==================================================================

record(longin,  "$(U):ChargeThreshRBV") {
    field(DTYP, "asynInt32")
    field(DESC, "ChargeThreshold RBV")
    field(PINI, "YES")
    field(SCAN, "1 second")
    field(INP,  "@asyn(cpsw,1)MVR:ChargeThresh")
}
#==================================================================
# Record example for reading back from an IntField, RW, 1 element,
# no encoding register.
# It is a longin record with type asynInt32.
# The INP field has the form @asyn(PORT,ADDR)PARAM where:
#  - PORT  : The asyn port name. It must match the port name given
#            when calling "YCPSWASYNConfig" on st.cmd
#  - PARAM : The asyn parameter name. It must be defined in the
#            dictionary file and assigned to a register.
#  - ADDR  : Address based on the type of register.
#            For IntField, RW, without encoding is 1.
#==================================================================

record(longin,  "$(U):RepRateThreshRBV") {
    field(DTYP, "asynInt32")
    field(DESC, "Allowed RepRateRBV")
    field(PINI, "YES")
    field(SCAN, "1 second")
    field(INP,  "@asyn(cpsw,1)MVR:RepRateThresh")
}
#==================================================================
# Record example for an IntField, RW, 1 element, no encoding,
# enum (1-bit) register.
# It is a bo record with type asynUInt32Digital.
# The OUT field has the form @asynMask(PORT,ADDR,MASK)PARAM where:
#  - PORT  : The asyn port name. It must match the port name given
#            when calling "YCPSWASYNConfig" on st.cmd
#  - PARAM : The asyn parameter name. It must be defined in the
#            dictionary file and assigned to a register.
#  - MASK  : It is 1 for 1-bit register.
#  - ADDR  : Address based on the type of register.
#            For IntField, RW, without encoding is 1.
#==================================================================

record(bo,      "$(U):LLSSwCtrlEn") {
    field(DTYP, "asynUInt32Digital")
    field(DESC, "LLS SwCtrl Enable")
    field(PINI, "NO")
    field(SCAN, "Passive")
    field(OUT,  "@asynMask(cpsw,1,1)MVR$(CPSW_AXIS):LimitSwtchSWCtrlEn")
    field(ZNAM, "Disabled")
    field(ONAM, "Enabled")
}
#==================================================================
# Record example for an IntField, RW, 1 element, no encoding,
# enum (1-bit) register.
# It is a bo record with type asynUInt32Digital.
# The OUT field has the form @asynMask(PORT,ADDR,MASK)PARAM where:
#  - PORT  : The asyn port name. It must match the port name given
#            when calling "YCPSWASYNConfig" on st.cmd
#  - PARAM : The asyn parameter name. It must be defined in the
#            dictionary file and assigned to a register.
#  - MASK  : It is 1 for 1-bit register.
#  - ADDR  : Address based on the type of register.
#            For IntField, RW, without encoding is 1.
#==================================================================

record(bo,      "$(U):LLSSwCtrl") {
    field(DTYP, "asynUInt32Digital")
    field(DESC, "Encoder Counter Reset")
    field(PINI, "NO")
    field(SCAN, "Passive")
    field(OUT,  "@asynMask(cpsw,1,1)MVR$(CPSW_AXIS):LimitSwtchSWCtrl")
    field(ZNAM, "Disabled")
    field(ONAM, "Enabled")
}
#==================================================================
# Record example for an IntField, RW, 1 element, no encoding,
# enum (1-bit) register.
# It is a bo record with type asynUInt32Digital.
# The OUT field has the form @asynMask(PORT,ADDR,MASK)PARAM where:
#  - PORT  : The asyn port name. It must match the port name given
#            when calling "YCPSWASYNConfig" on st.cmd
#  - PARAM : The asyn parameter name. It must be defined in the
#            dictionary file and assigned to a register.
#  - MASK  : It is 1 for 1-bit register.
#  - ADDR  : Address based on the type of register.
#            For IntField, RW, without encoding is 1.
#==================================================================

record(bo,      "$(U):Ctrl") {
    field(DTYP, "asynUInt32Digital")
    field(DESC, "Reset control")
    field(PINI, "NO")
    field(SCAN, "Passive")
    field(OUT,  "@asynMask(cpsw,1,1)MVR$(CPSW_AXIS):MoverCtrl")
    field(ZNAM, "ATCA")
    field(ONAM, "LimitSw")
}
#==================================================================
# Record example for an IntField, RW, 1 element, no encoding,
# enum (1-bit) register.
# It is a bo record with type asynUInt32Digital.
# The OUT field has the form @asynMask(PORT,ADDR,MASK)PARAM where:
#  - PORT  : The asyn port name. It must match the port name given
#            when calling "YCPSWASYNConfig" on st.cmd
#  - PARAM : The asyn parameter name. It must be defined in the
#            dictionary file and assigned to a register.
#  - MASK  : It is 1 for 1-bit register.
#  - ADDR  : Address based on the type of register.
#            For IntField, RW, without encoding is 1.
#==================================================================

record(bo,      "$(U):Stop") {
    field(DTYP, "asynUInt32Digital")
    field(DESC, "Stop command from FPGA")
    field(PINI, "NO")
    field(SCAN, "Passive")
    field(OUT,  "@asynMask(cpsw,1,1)MVR$(CPSW_AXIS):MoverStop")
    field(ZNAM, "OK")
    field(ONAM, "STOP")
}
#==================================================================
# Record example for an IntField, RW, 1 element, no encoding,
# enum (1-bit) register.
# It is a bo record with type asynUInt32Digital.
# The OUT field has the form @asynMask(PORT,ADDR,MASK)PARAM where:
#  - PORT  : The asyn port name. It must match the port name given
#            when calling "YCPSWASYNConfig" on st.cmd
#  - PARAM : The asyn parameter name. It must be defined in the
#            dictionary file and assigned to a register.
#  - MASK  : It is 1 for 1-bit register.
#  - ADDR  : Address based on the type of register.
#            For IntField, RW, without encoding is 1.
#==================================================================

record(bo,      "$(U):SwFltCtrlEn") {
    field(DTYP, "asynUInt32Digital")
    field(DESC, "SW Fault Ctrl Enable")
    field(PINI, "NO")
    field(SCAN, "Passive")
    field(OUT,  "@asynMask(cpsw,1,1)MVR$(CPSW_AXIS):MoverFltSimEn")
    field(ZNAM, "Disabled")
    field(ONAM, "Enabled")
}
#==================================================================
# Record example for an IntField, RW, 1 element, no encoding,
# enum (1-bit) register.
# It is a bo record with type asynUInt32Digital.
# The OUT field has the form @asynMask(PORT,ADDR,MASK)PARAM where:
#  - PORT  : The asyn port name. It must match the port name given
#            when calling "YCPSWASYNConfig" on st.cmd
#  - PARAM : The asyn parameter name. It must be defined in the
#            dictionary file and assigned to a register.
#  - MASK  : It is 1 for 1-bit register.
#  - ADDR  : Address based on the type of register.
#            For IntField, RW, without encoding is 1.
#==================================================================

record(bo,      "$(U):SwFltCtrl") {
    field(DTYP, "asynUInt32Digital")
    field(DESC, "SW Fault Ctrl")
    field(PINI, "NO")
    field(SCAN, "Passive")
    field(OUT,  "@asynMask(cpsw,1,1)MVR$(CPSW_AXIS):MoverFltSim")
    field(ZNAM, "OK")
    field(ONAM, "FAULT")
}
