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


record(sSub, "$(DEV):STATSUB") {
  field(DESC, "Build STATus ")
  field(INAM, "mgntInit")
  field(SNAM, "mgntSlcStat")
  field(INPA, "$(DEV):$(PHY)ACT.STAT")
  field(INPB, "$(DEV):$(PHY)DES.STAT")
  field(INPC, "$(DEV):IRIPL.STAT")
  field(INPD, "$(DRVSET)")
  field(INPE, "$(DRVACT)")
# INPF is used to propagate BCON to lclshome for selective magnets.
# if used for standard magnet set to <dev>:BCON.STAT
# if used for EFC correctors set to <useg>:GapAct.STAT
  field(INPF, "$(BCONSTAT="")")
  field(INPG, "$(DEV):$(PHY)ACT.SEVR")
  field(INPH, "$(DEV):$(PHY)DES.SEVR")
  field(INPI, "$(DEV):IRIPL.SEVR")
  field(INPJ, "$(DRVSETS)")
  field(INPK, "$(DRVACTS)")
#
# INPL is used to propagate BCON to lclshome for selective magnets.
# if used for standard magnet set to <dev>:BCON.SEVR
# if used for EFC correctors set to <useg>GapAct.SEVR
  field(INPL, "$(BCONSEVR="")")
  field(INPM, "$(DEV):STATE.RVAL")
  field(INPN, "$(SOK=$(DEV):STDZOK)")
  field(INPO, "$(DEV):CALBOK")
  field(INPP, "$(DEV):OUTOFSERVICE.RVAL")
  field(INPQ, "$(DEV):CONFIG.RVAL")
  field(INPR, "$(DEV):HSTA")
  field(INPS, "$(DEV):CTRL.RVAL")
  field(INPT, "$(DOK=$(DEV):DEGAUSOK)") 
  field(INPV, "$(DEV):INTLKSUMY")
#
# INPY is used to for kicker trigger status. If the kicker plc
# has disabled trigger to the modulator, the ps can still be on
# and trimmed nothing is being sent out to the magnet.
# So the default is the TRIG macro is blank, unless this is a kicker
# that has a trigger status.
  field(INPY, "$(TRIG="")")
# Outputs
# U - Input to UNAVAIL via UNAVAILGO seq record
# W = worst STAT (BACT,BDES,RIPL,ISETPT,IACT,BCON)
# X = worst SEVR (BACT,BDES,RIPL,ISETPT,IACT,BCON)
  field(SCAN, "2 second")
  field(PINI, "YES")
  field(FLNK, "$(DEV):STAT")
}

record(longout, "$(DEV):STAT") {
  field(DESC, "STAT sent to SLC")
  field(SCAN, "Passive")
  field(FLNK, "$(DEV):STATCTRLSUB")
  field(DOL, "$(DEV):STATSUB.VAL")
  field(OMSL, "closed_loop")
}

record(sSub, "$(DEV):STATCTRLSUB") {
  field(DESC, "Decode SLC STAT into mbbo")
  field(INAM, "mgntInit")
  field(SNAM, "mgntStatDecode")
  field(INPA, "$(DEV):STAT")
  field(INPB, "$(DEV):HSTA")
  field(INPD, "$(DEV):ONOFFCTRL.RVAL")
  field(FLNK, "$(DEV):STATMSG")
}

record(mbbo, "$(DEV):STATMSG") {
  field(DESC, "Status Message - worst case")
  field(NOBT, "16")
  field(ZRST, "Good")
  field(ONST, "BCON Warning")
  field(TWST, "Offline")
  field(THST, "PAU Ctrl")
  field(FRST, "Turned Off")
  field(FVST, "Not Degaus'd")
  field(SXST, "Not Cal'd")
  field(SVST, "Feedback Ctrl")
  field(EIST, "PS Tripped")
  field(NIST, "DAC Error")
  field(TEST, "ADC Error")
  field(ELST, "Not Stdz'd")
  field(TVST, "Out-of-Tol")
  field(TTST, "BAD Ripple")
  field(FTST, "BAD BACT")
  field(FFST, "No Control")
  field(ZRSV, "NO_ALARM")
  field(ONSV, "MINOR")
  field(TWSV, "NO_ALARM")
  field(THSV, "MINOR")
  field(FRSV, "MAJOR")
  field(FVSV, "MINOR")
  field(SXSV, "MINOR")
  field(SVSV, "NO_ALARM")
  field(EISV, "MAJOR")
  field(NISV, "MAJOR")
  field(TESV, "MAJOR")
  field(ELSV, "MINOR")
  field(TVSV, "MAJOR")
  field(TTSV, "MINOR")
  field(FTSV, "MAJOR")
  field(FFSV, "NO_ALARM")
  field(OMSL, "closed_loop")
  field(FLNK, "$(DEV):UNAVAILGO")
  field(DOL, "$(DEV):STATCTRLSUB.W")
}

record(seq, "$(DEV):UNAVAILGO") {
  field(DESC, "Process UNAVAIL")
  field(DOL1, "$(DEV):STATSUB.U")
  field(LNK1, "$(DEV):UNAVAIL PP")
}

record(stringout, "$(DEV):SNLSTATMSG") {
  field(DTYP, "Soft Channel")
}


#! TextBox(TB0,820,1000,1200,1220,0,"Dialog",12,1,16777215,"$(DEV):STATUSSUB - future\nOverall device status - takes input from action snls, record sevrs, master snl(s) and outputs final status\n\nInputs:\nA - $(DEV):CTRLSTATUS - snl status\nB - MGNT:CTRLSTATUS - master list status\nC\nD - $(DEV):SEVRSTATUS (future)",null)
#! TextBox(TB9,1300,900,1680,1140,0,"Dialog",12,1,16777215,"STATDECODE is used for HSTA/STAT\nDiagnostic Display only",null)
#! TextBox(TB8,1360,960,1540,1260,0,"Dialog",12,1,16777215,"Inputs:\nA - STAT\nOutputs:\nH -  STAT_GOOD\nI -  STAT_OK\nJ -  STAT_DEAD\nK -  STAT_SICK\nL -  STAT_OFF\nM -  STAT_STDZOK\nN -  STAT_CALOK\nO -  STAT_DRIFTING\nP -  STAT_DBERR\nQ -  STAT_DACERR\nR -  STAT_ADCERR\nS -  STAT_BADCUR\nT -  STAT_OUTTOL\nU -  STAT_BADRIPL\nV -  STAT_BADBACT",null)
#! TextBox(TB5,1680,960,1960,1080,0,"Dialog",18,1,16777215,"Macros:\nDEV = DEVICE:AREA:POSN\nDEVICE = BEND, QUAD, *COR, etc\nMGNT = MGNT\nAREA = area\nPOSN = position\n",null)
#! TextBox(TB3,800,1180,1320,1300,0,"Dialog",14,1,16777215,"STAT - slc aware\n\nSTATSUB formats control bo's into STAT for SLC\nSTATSUBSEQ gets STATSUB outputs to STAT \n\n\n",null)
#! TextBox(TB2,780,620,980,1000,0,"Dialog",12,1,16777215,"$(DEV)STATSUB\nformat control bo's into slc STAT\n\nInputs:\nA - $(DEV):STATUS\nC - $(DEV):ON\nD - $(DEV):STDZOK\nE - $(DEV):CALBOK\nF - $(DEV):BACTDRIFT (future)\nG -\nH- $(DEV):DACSTATUS\nI -$(DEV):ADCSTATUS\nJ - $(DEV):BACTSTATUS\nK - $(DEV):BDESSTATUS\nL - $(DEV):RIPLSTATUS\n\nOutput:\nP - $(DEV):STAT - slc STAT\n",null)
#! TextBox(TB1,1520,680,1980,840,0,"Dialog",12,1,16777215,"Note:\nThere will most likely be a sub record for each of:\nADC record's .SEVR and .STAT -> ADCSTATUS\nDAC record's .SEVR and .STAT -> DACSTATUS\nBACT record's .SEVR and .STAT -> BACTSTATUS\nBDES record's .SEVR and .STAT -> BDESSTATUS\n?RIPL record's .SEVR and .STAT -> RIPLSTATUS\n -- above is all done in STATSUB",null)
