#! Generated by VisualDCT v2.6
#! DBDSTART
#! DBD("../../../../dbd/mgntSoft.dbd")
#! DBDEND

record(dfanout, "$(DEVICE):DEGAUSINIT") {
  field(DESC, "Proc. Degauss PVs on boot")
  field(PINI, "YES")
  field(DOL,  "1")
  field(OUTA, "$(DEVICE):DEGAUSIMIN.PROC PP")
  field(OUTB, "$(DEVICE):DEGAUSIMAX.PROC PP")
  field(OUTC, "$(DEVICE):DEGAUSTYPE.PROC PP")
  field(OUTD, "$(DEVICE):DEGAUSSTEP.PROC PP")
  field(OUTE, "$(DEVICE):MADNAME.PROC PP")
  field(OUTF, "$(DEVICE):PSTYPE.PROC PP")
  field(OUTG, "$(DEVICE):DEGAUSSUB.DISV PP")
  field(ASG,  "Internal")
}

# Inputs:
#  A - Degauss minimum current, only used of E=Standard or Oscillating
#  B - Degauss maximum current, only used of E=Standard or Oscillating
#  C - Degauss type, (ref: element name in the LCLS Oracle Infrastructure)
#      Set to None unless <dev>:DEGUASMETHOD = Oscillating
#  D - Not used
#  E - Degauss method    (0=None , 1=standard, 2=Oscillating, 3=not used)
#  F - Power Supply type (0=bipolar, 1=unipolar, 2=unipolar with polarity switch, 3=none)
#  G - Debug flag from the pv <device>:DEBUG
#
# Degaussing is available for unipolar power supplies with a polarity switch.
# There are three types of degausing procedures used, the most common is the
# the Standard. This will generate a set of current set points that will ramp
# the power supply first to 0, and then cycle the current from a minimum to
# maximum current a number of times defined by the PVs, and then finally to 0 current
# as the last setpoint.
#
#  <dev>:DEGAUSCYCLENUM  -- Note: oly used for standard degauss method
#  <dev>:DEGAUSIMIN
#  <dev>:DEGAUSIMAX 
#
# Finally the power supply is turned off and the 
# degauss flaged as completed by setting the following PV.
#
#  <dev>:DEGAUSOK  (1=successfuly completed, 0=not degaussed)
#
# Note: currently only the BXHS, BXSS, BCXXL bend chicane magnets
# in the LCLS undulator. These magents use the osicllating methiod
# where a predefined set of points have been provided by
# Magnet Measurements (MMF) for degaussing. 
#
#  <dev>:DEGAUSMETHOD  (e.g. None, Standard , Oscillation ) 
#  <dev>:DEGAUSTYPE    (e.g. BXHS2, BXSS2, BCXXL2 )
#
#  Note: Degauss is not available for unipolar power supplies
#  without a polarity switch (DTYP=3) Check PV <dev>:PSTYPE 
#  to determine the type of power supply.
#
record(aSub, "$(DEVICE):DEGAUSSUB") {
  field(DESC, "Degauss subroutine")
  field(INAM, "mgntDegaussInit")
  field(SNAM, "mgntDegauss")
  field(BRSV, "INVALID")  
  field(INPA, "$(DEVICE):DEGAUSIMIN NPP NMS")
  field(INPB, "$(DEVICE):DEGAUSIMAX NPP NMS")
  field(INPC, "$(DEVICE):DEGAUSTYPE.RVAL NPP NMS")
  field(INPE, "$(DEVICE):DEGAUSMETHOD.RVAL NPP NMS")
  field(INPF, "$(DEVICE):PSTYPE NPP NMS")
  field(INPG, "$(DEVICE):DEBUG.RVAL NPP NMS")
  field(INPH, "$(DEVICE):DEGAUSSTEP NPP NMS")
  field(FTA, "DOUBLE")
  field(FTB, "DOUBLE")
  field(FTC, "ULONG")
  field(FTD, "ULONG")
  field(FTE, "ULONG")
  field(FTF, "USHORT")
  field(FTG, "ULONG")
  field(FTH, "DOUBLE")

# Outputs:
#  OUTA: Degauss set point waveform
#  OUTB: Status (0=success,1=None,2=output wf too small,3=invalid ps type,4=invalid method)
#  OUTC: Deguass number of cycles, where one cycle is min to max.
#      The number of data points would be
#         bipolar supplies:  (2*D)+2
#      where the additional 2 points are the starting and ending points, which is 0.
#         unipolar supplies with a polarity switch: 2*D
#
# Note: the aSub record sets the NORD field of the
# waveform record based on the value in NOVA.
#
  field(OUTA, "$(DEVICE):DEGAUSWF PP")
  field(OUTB, "$(DEVICE):DEGAUSMSG PP")
  field(OUTC, "$(DEVICE):DEGAUSCYCLENUM PP")
  field(FTVA, "DOUBLE")
  field(FTVB, "USHORT")
  field(FTVC, "ULONG")
  field(NOVA, "60")

# On boot disable this PV from processing.
# Processing will be enabled by the pv
# <dev>:DEGAUSINIT, after all input pvs
# have been processed.
  field(DISV, "0")
}

# This is the degauss waveform generated by
# the <device>:DEGAUSSUB
record(waveform, "$(DEVICE):DEGAUSWF") {
  field(DESC, "Degauss Setpts")
  field(NELM, "60")
  field(FTVL, "DOUBLE")
}

record(mbbo,"$(DEVICE):DEGAUSMSG") {
  field(DESC, "Degauss Status Msg")
  field(NOBT, "3")
  field(ZRST, "Success")
  field(ONST, "None")
  field(TWST, "Wf too small")
  field(THST, "PS is not bipolar")
  field(FRST, "Unknown Degauss Type")
  field(TWSV, "MINOR")
  field(THSV, "MAJOR")
  field(FRSV, "MAJOR")
}


# Using the default degauss method of "Standard"
# number of full cycle is 1, which equals 4 data points
# for a bipolar supply and 5 data points for a unipolar
# supply with a polarity switch. For the method "Oscillating"
# the default number of full cycles is 25, which equals
# 52 data points.
# Note: this pv is populated by <dev>:DEGAUSSUB
record(longout, "$(DEVICE):DEGAUSCYCLENUM") {
  field(DESC, "No. Degauss Cycles")
  field(HOPR, "27")
  field(DRVH, "30")
  field(LOPR, "0")
  field(PINI, "YES")
}

# Number of full cycles done during the degauss
# Note: This pv is set by the sequence mgntCtrl.st during
# the degauss procedure.
record(longout, "$(DEVICE):DEGAUSCYCLECNT") {
  field(DESC, "Degauss Cycle Count")
  field(PINI, "YES")
}

# The DEGAUSSLAVESGO pv is used to force processing of a set of related magnets as the first step
# of degaussing the main. These related magnest, in this case the trim coils, are DAC_ZEROed,
# the the  main is degaussed, afterwhich the trim coils are TRIMmed to their BDES value,
# the main is turned off and the DEGAUSOK flag set to true. 
#
# NOTE: Only when the DEGAUSOK flag is false and the main is turned off, will a minor alarm 
# be set and the summary message (STATAMSG) indicate a degauss warning.
#
# When the main is turned on and the DEGAUSOK flag is set to false, this case is considered
# a major alarm. Note that some ps have on/off control and others do not. For example,
# QSM1 does not have on/off control and so the supply is left on after degaussing.
# However, for HXRSS,SXRSS and 50B1 these do have on/off control and the check for degauss
# lost is different.
#
record(bo, "$(DEVICE):DEGAUSOK") {
  field(DESC, "Degauss Successful")
  field(DTYP, "Raw Soft Channel")
  field(ZNAM, "NO")
  field(ONAM, "YES")
  field(PINI, "YES")
  info(autosaveFields,"VAL RVAL")
}

# For a magnet hw configuration that does not permit
# the ps to be turned off after degaussing, such as QSM1,
# after degaussing the ps is set to zero Amps, and the 
# and as long as the b-field limit remains below
# a limit BLIMIIT, the degauss is maintained. Otherwise,
# the degauss will  be lost. 
record(ao, "$(DEVICE):DEGAUSBLIMIT") {
  field(DESC, "B-field limit for degausok")
  field(DTYP, "Soft Channel")
  field(PINI, "YES")
  field(DRVH, "20")
  field(VAL,  "0.06")
  field(PREC, "4")
}

record(ao, "$(DEVICE):DEGAUSIMIN") {
  field(DESC, "Min. Degauss I")
  field(PREC, "1")
  field(EGU,  "Amps")
  field(HOPR, "$(HIHI)")
  field(LOPR, "-$(HIHI)")
  field(DRVH, "$(HIHI)")
  field(DRVL, "-$(HIHI)")
  field(VAL,  "-$(HIHI)")
}
record(ao, "$(DEVICE):DEGAUSIMAX") {
  field(DESC, "Max. Degauss I")
  field(PREC, "1")
  field(EGU,  "Amps")
  field(HOPR, "$(HIHI)")
  field(LOPR, "-$(HIHI)")
  field(DRVH, "$(HIHI)")
  field(DRVL, "-$(HIHI)")
  field(VAL,  "$(HIHI)")
}

# Degauss type
#
# 0=None
# 1=BCXH1
# 2=BCXSS1
# 3=BCXXL1
# 4=CRYO (Use data points from FERMI)
# 5=XCPEPX1
# 6=BCXCBX13
# 7=BCXCBX21
#
# Note: this pv is looked at in a function in
# thie field: mgntApp/src/mgntSub.c
record(mbbo,"$(DEVICE):DEGAUSTYPE") {
  field(DESC, "Type Degauss")
  field(DTYP, "Raw Soft Channel")
  field(NOBT, "3")
  field(ZRST, "None")
  field(ONST, "BCXHS1")
  field(TWST, "BCXSS1")
  field(THST, "BCXXL1")
  field(FRST, "CRYO")
  field(FVST, "XCPEPX1")
  field(SXST, "BCXCBX13")
  field(ZRVL, "0")
  field(ONVL, "1")
  field(TWVL, "2")
  field(THVL, "3")
  field(FRVL, "4")
  field(FVVL, "5")
  field(SXVL, "6")
  field(FLNK, "$(DEVICE):DEGAUSSUB")
  field(VAL,  "0")
}

#   Degauss method
#   None      -  Degauss not available.
#   Standard  - cycle up/down beween min and max, for ncycles,
#               defined in <dev>:DEGAUSCYCLENUM            
#   Oscillate - oscillate between min and max, from the outer
#               limits towards zero, using a specified step size,
#               defined in <dev>:DEGAUSSTEP.
#               If this is sent then <dev>:DEAUSTYPE will be used.
#
record(mbbo,"$(DEVICE):DEGAUSMETHOD") {
  field(DESC, "Method of Degauss")
  field(DTYP, "Raw Soft Channel")
  field(NOBT, "2")
  field(ZRST, "None")
  field(ONST, "Standard")
  field(TWST, "Oscillating")
  field(THST, "Unknown")
  field(ZRVL, "0")
  field(ONVL, "1")
  field(TWVL, "2")
  field(THVL, "3")
  field(VAL,  "0")
}

# This is the degauss step size, which applies
# to the degauss type,or method "Oscillating",
# where the set of degauss points is generated
# starting from 0, and oscillating been max and
# min, decressing in step size towards zero.
# and ending at zero.
record(ao, "$(DEVICE):DEGAUSSTEP") {
  field(DESC, "Degauss step size")
  field(DOL,  "0.88")
  field(EGU,  "Amps")
}

# Change to DEGAUSIRAMPRATE 
# Need to change: psCtrl.h,
# To change default for degauss ramp rate
# use static restore file <nodename>_static.cwConfig 
record(ao, "$(DEVICE):DEGAUSRAMPRATE") {
  field(DESC, "Degauss Ramp rate ")
  field(PINI, "YES")
  field(PREC, "3")
  field(EGU,  "Amps/sec")
  field(HOPR, "30.0")
  field(DRVH, "30.0")
  field(DRVL, "0.001")
  field(LOPR, "0.001")
  field(VAL, "2")
}

# Settle time between step. If the degauss type
# or method "Standard" then the settle time
# will take place at the flat-top. If the
# method is "Oscillating" or "File" then 
# the settle time after each step.
record(ao, "$(DEVICE):DEGAUSSETL") {
  field(DESC, "Settle time after each step")
  field(DTYP, "Soft Channel")
  field(PINI, "YES")
  field(PREC, "1")
  field(EGU, "sec")
  field(DRVL, "0.5")
  field(LOPR, "0.5")
  field(DRVH, "60.0")
  field(HOPR, "60.0")
  field(VAL,  "2")
}

record(stringout, "$(DEVICE):DEGAUSTOD") {
  field(DESC, "Successful Degauss Time")
  field(DTYP, "Soft Channel")
  field(PINI, "YES")
  field(VAL,  " ")
  info(autosaveFields,"VAL")
}

record(stringout, "$(DEVICE):DEGAUSLOSTTOD") {
  field(DESC, "Degauss Lost Time")
  field(DTYP, "Soft Channel")
  field(PINI, "YES")
  field(VAL,  " ")
  info(autosaveFields,"VAL")
}

record(ao, "$(DEVICE):DEGAUSTIME") {
  field(DESC, "Time to complete")
  field(PINI, "YES")
  field(EGU,  "secs")
  field(OUT, "$(DEVICE):DEGAUSTIME_MIN.A PP")
  info(autosaveFields,"VAL")
}
record(calc, "$(DEVICE):DEGAUSTIME_MIN") {
  field(DESC, "Time to complete")
  field(CALC, "A?A/60:0")
  field(EGU,  "min")
  info(autosaveFields,"VAL")
}

# For degaussed magnets set the bdes of the trim coils
# to zero before degauss begins, so that after the degauss
# is complete they are trimmed to zero. For degaussed magnets
# with trim coils set the macros OUT1-4 to the following:
#   OUT1= <dev1>:BDES PP
#
# For magnets that do not have degauss use the macro
# OUTA-D setting to blank.
record(dfanout, "$(DEVICE):DEGAUSGO") {
  field(DESC,  "Set bdes of btrms to zero")
  field(ASG,   "Internal")
  field(OUTA,  "")
  field(OUTB,  "")
  field(OUTC,  "")
  field(OUTD,  "")
}

# ===========  CRYO ONLY =========== 

record(bo, "$(DEVICE):DEGAUSAUTO") {
  field(DESC, "Perform an auto-degauss")
  field(DTYP, "Raw Soft Channel")
  field(ZNAM, "NO")
  field(ONAM, "YES")
  info(autosaveFields,"VAL RVAL")
}

# Set Max Current while Magent is degaussed 
#
# If the requested current is greater than imax, then
# the magnet will be trimmed and the imax updated to
# the requested current.
record(calcout, "$(DEVICE):DEGAUS_IMAX_CHECK") {
  field(DESC, "Check if imax shoud chg")
  field(CALC, "(C==4)&&(B>A)?1:0")
  field(INPA, "$(DEVICE):DEGAUS_IMAX")
  field(INPB, "$(DEVICE):ISETPT")
  field(INPC, "$(DEVICE):DEGAUSTYPE.RVAL")
  field(OUT,  "$(DEVICE):DEGAUS_IMAX_UPDATE.SELN")
  field(FLNK, "$(DEVICE):DEGAUS_IMAX_UPDATE")
}
record(seq, "$(DEVICE):DEGAUS_IMAX_UPDATE")
{
  field(DESC, "Degauss IMAX Update")
  field(SELM, "Specified")
  field(DOL1, "$(DEVICE):ISETPT")
  field(LNK1, "$(DEVICE):DEGAUS_IMAX PP")
}


# Set the maximum current after a successful
# degauss. This pv is updated by the
# sequence.
record(ao, "$(DEVICE):DEGAUS_IMAX") {
  field(DESC, "Max I set afer a degauss")
  field(EGU,  "Amps")
  field(PINI, "YES")
  field(PREC, "6")
  field(HOPR, "$(HIHI)")
  field(LOPR, "-$(HIHI)")
  field(DRVH, "$(HIHI)")
  field(DRVL, "-$(HIHI)")
  field(VAL,  "$(HIHI)")
  field(FLNK, "$(DEVICE):DEGAUS_IMAXPOL_CHECK")
  info(autosaveFields,"VAL,RVAL")
}

# Set the polarity if degauss_imax
record(calcout, "$(DEVICE):DEGAUS_IMAXPOL_CHECK") {
  field(DESC, "Determine polarity of imax")
  field(CALC, "A>=0?0:1")
  field(INPA, "$(DEVICE):DEGAUS_IMAX")
  field(FLNK, "$(DEVICE):DEGAUS_IMAXPOL")
}
record(bo, "$(DEVICE):DEGAUS_IMAXPOL") {
  field(DESC, "Polarity of imax I")
  field(DTYP, "Raw Soft Channel")
  field(ZNAM, "Positive")
  field(ONAM, "Negative")
  field(FLNK, "$(DEVICE):DEGAUS_ABSIMAX")
  info(autosaveFields,"VAL RVAL")
}

# This is the maximum absoulte current
# that has been set after a degusss.
# Once the degauss has been lost the
# Absolute maximum current is no longer
# tracked until a degauss has been performed,
# at which point this pv will be reset.

# 1. If the requested current is greater than 85% of 
# DEGAUSABSIMAX for a trim request, the trim
# the trim proceeds normally and DEGAUSABSIMAX
# woudl be updated to the new value. 
#
# 2. However, if the requeted current is greater
# than 85% of DEGAUSABSIMAX but less than DEGUSABSIMAX,
# the magnetr would be trimmed normally but 
# DEGAUSABSIMAX will NOT be updated.
#
# 3. If the requested current is less than 85% of
# DEGAUSABSIMAX or the polarity of the requested
# current has changed, then a degauss would be done 
# automatically, which will take about 100 seconds. 
# The current would then be set to the desired value,
# which would update Imax and the polarity setting if
# it has changed. During the degauss cycle, there 
# should be some sort of indicator in EPICs that 
# this is occurring, and perhaps an option provided to abort it. 
#
record(calc, "$(DEVICE):DEGAUS_ABSIMAX") {
  field(DESC, "Absolute Max. Degauss I")
  field(CALC, "ABS(A)")
  field(INPA, "$(DEVICE):DEGAUS_IMAX")
  field(PREC, "6")
  field(EGU,  "Amps")
  field(HOPR, "$(HIHI)")
  field(LOPR, "-$(HIHI)")
  info(autosaveFields,"VAL RVAL")
}

# IACT Polarity
record(calcout, "$(DEVICE):IACTPOL_CHECK") {
  field(DESC, "Determine IACT polarity")
  field(SCAN, "5 second")
  field(CALC, "ABS(A-B)>C?(A>=0?0:1):D")
  field(INPA, "$(DEVICE):IACT")
  field(INPB, "$(DEVICE):IACTPOL_CHECK.LA")
  field(INPC, "0.0001")
  field(INPD, "$(DEVICE):IACTPOL_CHECK.PVAL")
  field(OOPT, "On Change")
  field(FLNK, "$(DEVICE):IACTPOL")
}
record(bo, "$(DEVICE):IACTPOL") {
  field(DESC, "Polarity of IACT")
  field(DTYP, "Raw Soft Channel")
  field(ZNAM, "Positive")
  field(ONAM, "Negative")
  info(autosaveFields,"VAL RVAL")
}#! Generated by VisualDCT v2.6
#! DBDSTART
#! DBD("../../../../dbd/mgntSoft.dbd")
#! DBDEND


# ==================== USED BY NON-CRYO MAGNETS ONLY ===================
#
# There are different magnet hw configurations 
# that must be considered, when determining
# when degauss is lost.
#
# Configruation type 1: ps reamin on after degaussing  - Cryo Quads and QSM1 (decomissioned)
# Configuration type 2: ps is turned off after degaussing  - BXHS, BXSS, BCXXL
#==============================================================================
#
# FOR CONFIGUATION TYPE 2: non-cryo quads
# ------------------------
# Case 1: When the b-field is set above a limit <device>:DEGAUSBLIMIT,
# degauss is lost.
#
#  - set <device>:DEGAUSOK=NO           - degauss ok status
#  - set <device>:DEGAUSOK.ZSV=MINOR    - degauss ok severity warning
#  - set <device>:STATMSG.FVSV=MINOR    - summary status, "Not Degaus'd" alarm
#  - set <device>:STATMSG.FRSV=MAJOR    - summary status, "Turned Off" alarm
#
# Case 2: When the main supply is turned on, degauss is lost. (Warning)
#
#  - set <device>:DEGAUSOK=NO           - degauss ok status
#  - set <device>:DEGAUSOK.ZSV=MINOR    - degauss ok severity warning
#  - set <device>:STATMSG.FVSV=MINOR    - summary status, "Not Degaus'd" alarm
#  - set <device>:STATMSG.FRSV=MAJOR    - summary status, "Turned Off" alarm
#
# Case 3: if the main (bulk) ps is turned off and magnet was degaussed
# successfully, then degauss is lost.
#
#  - set <device>:STATMSG.FVSV=MAJOR - summary status, "Not Degaus'd" alarm
#  - set <device>:STATMSG.FRSV=MAJOR - sumamry status, "Turned Off" alarm
#  - set <device>:DEGAUSOK.ZSV=MAJOR - degauss status NO severity
#  - set <device>:DEGAUSOK=NO        - degauss status
# 
record(calcout,"$(DEVICE):DEGAUS_STATE_CHECK") {
  field(DESC, "Check Degauss lost")
  field(CALC, "D=3?0:A=0?1:B&&C?2:B&&(C=0)?3:(B+C)=0?4:0")
  field(INPA, "$(DEVICE):DEGAUSENABLE CP")
  field(INPB, "$(DEVICE):DEGAUSOK")
  field(INPC, "$(DEVICE):STATE CP")
  field(INPD, "$(DEVICE):STATE.SEVR")
  field(OUT,  "$(DEVICE):DEGAUS_STATE_SEQ.SELN PP")
  field(ASG,  "Internal")
}
record(seq, "$(DEVICE):DEGAUS_STATE_SEQ") {
  field(DESC, "Degauss State Sequence")
  field(SELM, "Specified")
  field(SELL, "$(DEVICE):DEGAUS_STATE_CHECK")
  field(LNK1, "$(DEVICE):DEGAUS_STATE_DISABLE.PROC PP")
  field(LNK2, "$(DEVICE):DEGAUS_STATE_LOST.PROC PP")
  field(LNK3, "$(DEVICE):DEGAUS_STATE_GOOD.PROC PP")
  field(LNK4, "$(DEVICE):DEGAUS_STATE_OFF.PROC PP")
  field(ASG,  "Internal")
}


# If degauss disabled then 
#  - set the status summary message alarm severit to
#     - "Turned Off"   to MAJOR
#     - "Not Degaus'd" to MINOR
#  - set DEGUASOK=NO 
#  - set DEGAUSOK.ZSV=NO_ALARM
#
# If this is the string main then also,
#  - set slaves status summary message "Turned Off" severity to MAJOR
#
#  LNK=DEGAUSSLAVESGO.DOL PP
#
# The pv DEGAUSSLAVESGO must be created in the database substitutions file
# for the main, instantianting mgnt_string_ctrl.template 
# specifying the string slaves in CH1-8..
# 
record(seq, "$(DEVICE):DEGAUS_STATE_DISABLE") {
  field(DESC, "Degauss not used")
  field(LNK1, "$(DEVICE):DEGAUSOK.ZSV")
  field(LNK2, "$(DEVICE):DEGAUSOK PP")

# Set status summary msg "Turned Off"   severity to MAJOR
# Set status summary msg "Not Degaus'd" severity to MINOR
  field(DOL3, "2")
  field(DOL4, "1")
  field(DOL5, "2")
  field(LNK3, "$(DEVICE):STATMSG.FRSV")
  field(LNK4, "$(DEVICE):STATMSG.FVSV PP")
  field(LNK5, "")
  field(ASG,  "Internal")
}


# If degauss is enabled, and the magnet was degaussed successfully 
# and the ps state was turned on(1), then degauss
# has been lost. 
#
#  - set the status summary messages alarm severity for
#     -	"Turned Off"    to MINOR
#     - "Not Degaus'd"  to MINOR
#  - set DEGAUSLOSTOD, this is done in sequence mgntCtrl.st
#  - set DEGAUSOK=NO 
#  - set DEGAUSOK.ZSV=MINOR
#
# If this is the string main then also,
#  - set slaves status summary message "Turned Off" severity to MINOR
#  LNK=DEGAUSSLAVESGO.DOL PP
#
# The pv DEGAUSSLAVESGO must be created in the database substitutions file
# that defines the main, by instantianting mgnt_string_ctrl.template 
# specifying the string slaves in CH1-8.
#
record(seq, "$(DEVICE):DEGAUS_STATE_LOST") {
  field(DESC, "Degauss lost and ps On")
  field(DOL1, "1")
  field(LNK1, "$(DEVICE):DEGAUSOK.ZSV")
  field(LNK2, "$(DEVICE):DEGAUSOK PP")

# Set status summary msg "Turned Off"   severity to MINOR
# Set status summary msg "Not Degaus'd" severity to MINOR
  field(DOL3, "1")
  field(DOL4, "1")
  field(DOL5, "1")
  field(LNK3, "$(DEVICE):STATMSG.FRSV")
  field(LNK4, "$(DEVICE):STATMSG.FVSV PP")
  field(LNK5, "")
  field(ASG,  "Internal")
}

# If degauss is enabled, the magnet is not degaussed,
# and the ps state is 0(off), then:
#
#  - set the status summary message alarm severity 
#      - "Turned Off"   to  MAJOR
#      - "Not Degaus'd" to  MAJOR
#  - set DEGAUSOK.ZSV=MAJOR
#
# If this is the string main then also,
#  - set slaves status summary message "Turned Off" severity to MAJOR
#  LNK=DEGAUSSLAVESGO.DOL PP
#
# The pv DEGAUSSLAVESGO must be created in the database substitutions file
# that defines the main, by instantianting mgnt_string_ctrl.template 
# specifying the string slaves in CH1-8.
#
record(seq, "$(DEVICE):DEGAUS_STATE_OFF") {
  field(DESC, "Degaused lost and ps Off")
  field(DOL1, "2")
  field(LNK1, "$(DEVICE):DEGAUSOK.ZSV PP")

# Set status summary msg "Turned Off"   severity to MAJOR
# Set status summary msg "Not Degaus'd" severity to MAJOR
  field(DOL2, "2")
  field(DOL3, "2")
  field(DOL4, "2")
  field(LNK2, "$(DEVICE):STATMSG.FRSV")
  field(LNK3, "$(DEVICE):STATMSG.FVSV PP")
  field(LNK4, "")
  field(ASG,  "Internal")
}

# Degauss is enabled, the magent was degaussed successfully,
# and the ps state is 0 (off), then:
#
# Case 1: for non-cryo magnets(0x1e/30 dec)
#  - set the status summary message alarm severity
#      -  "Turned Off"   to to NO_ALARM
#      -  "Not Degaus'd" to to MINOR
#  - set the DEGAUSOK.ZSV=MINOR
#
# Note: This LNK macro is no longer needed, so use default of blank.
# If this is the string main then also,
#  - set slaves status summary message "Turned Off" severity to MINOR
#  LNK=DEGAUSSLAVESGO.DOL PP
#
# The pv DEGAUSSLAVESGO must be crated in the database substitutions file
# that defines the main, by instantianting mgnt_string_ctrl.template 
# specifying the string slaves in CH1-8..
#
# Case 2: for cryo magnets (1)
#  - set the status summary message alarm severity for:
#       "Not Degaus'd" to to MINOR
#
record(seq, "$(DEVICE):DEGAUS_STATE_GOOD") {
  field(DESC, "Degauss good")
  field(DOL1, "1")
  field(LNK1, "$(DEVICE):DEGAUSOK.ZSV PP")

# Set status summary msg "Turned Off"   severity to NO_ALARM
# Set status summary msg "Not Degaus'd" severity to MINOR
  field(DOL3, "1")
  field(LNK2, "$(DEVICE):STATMSG.FRSV PP")
  field(LNK3, "$(DEVICE):STATMSG.FVSV PP")
  field(LNK4, "")
  field(ASG,  "Internal")
}

