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


#record(ai, "$(P)$(M):GAP") {
#  field(DESC, "Phase shifter GAP setpoint")
  #field(FLNK, "$(P)$(M):GoSQ")
#  field(PREC, "3")
#  field(EGU, "mm")
#  field(LOW, "9.95")
#  field(HIGH, "100")
#  field(LSV, "MINOR")
#  field(HSV, "MINOR")
#  info(autosaveFields_pass0, "VAL")
#}

record(ao, "$(P):GapDes") {
  field(DESC, "Phase shifter GAP setpoint")
  field(PREC, "3")
  field(DRVH, "100")
  field(DRVL, "9.95")
  field(EGU, "mm")
  field(HIGH, "100")
  field(LOW, "9.95")
  field(HSV, "MINOR")
  field(LSV, "MINOR")
  info(autosaveFields,"VAL")
}

# Convert desired PI to desired Gap button
record(fanout, "$(P):ConvertGap2PI") {
   field(DESC, "Trigger proc of desired Gap 2 PI")
   field(LNK1, "$(P):DG2PISpl:InputTempCor")
#   field(LNK2, "$(P):DG2PISpl:Check")
}

record(bo, "$(P):Go") {
  field(DESC, "Start changing PS gap")
  field(FLNK, "$(P):GoSQ")
}

record(seq, "$(P):GapDmovSQ") {
  field(DESC, "Phase Shifter GAP complete seq")
  field(DLY1, "1")
  field(DOL1, "0")
  field(LNK1, "$(P):$(M).CNEN PP")
  field(DLY2, "0.5")
  field(DOL2, "0")
  field(LNK2, "$(P):GapDmov.VAL PP")
}

record(seq, "$(P):GoSQ") {
  field(DESC, "Phase shifter GAP start seq")
  field(PREC, "3")
  field(DOL1, "1")
  field(LNK1, "$(P):GapDmov.VAL PP")
  field(DOL2, "1")
  field(LNK2, "$(P):EnableDrive.PROC PP")
  field(DLY3, "0.5")
  field(DOL3, "1")
  field(LNK3, "$(P):$(M).CNEN PP")
  field(DLY4, "0.5")
  field(DOL4, "$(P):GapDes.VAL NPP")
  field(LNK4, "$(P):$(M).VAL CA")
}

record(bi, "$(P):GapDmov") {
  field(DESC, "Phase Shifter gap move status")
  field(ZNAM, "Idle")
  field(ONAM, "Moving")
}

record(calcout, "$(P):GapDmovTrig") {
  field(DESC, "Trigger of GAP complete sequence")
  field(SCAN, "1 second")
  field(CALC, "A")
  field(INPA, "$(P):$(M).DMOV NPP")
  field(OUT, "$(P):GapDmovSQ.PROC PP")
  field(OOPT, "Transition To Non-zero")
  field(DOPT, "Use OCAL")
  field(OCAL, "1")
}

record(ai, "$(P):GapAct"){
  field(DESC, "Phase Shifter actual gap")
  field(DTYP, "Soft Channel")
  field(INP, "$(P):EncRbck CP")
  field(PREC, "6")
  field(EGU, "mm")
}

########################################################
# Calibrates motor with encoder based position
########################################################
record(seq,"$(P):CalibrateMotor") {
  field(DESC,"Calibrate Motor")
  field(ASG,"SYSTEM")
  field(PINI, "YES")
  field(DOL1,"0")
  field(LNK1,"$(P):$(M).SPMG PP NMS")
  field(DLY2,"0.1")
  field(DOL2,"1")
  field(LNK2,"$(P):$(M).SET PP NMS")
  field(DLY3,"0.1")
  field(DOL3,"$(P):EncRbck NPP NMS")
  field(LNK3,"$(P):$(M).VAL PP NMS")
  field(DLY4,"0.1")
  field(DOL4,"3")
  field(LNK4,"$(P):$(M).SPMG PP NMS")
  field(DLY5,"0.1")
  field(DOL5,"0")
  field(LNK5,"$(P):$(M).SPMG PP NMS")
  field(DLY6,"0.1")
  field(DOL6,"0")
  field(LNK6,"$(P):$(M).SET PP NMS")
  field(DLY7,"0.1")
  field(DOL7,"3")
  field(LNK7,"$(P):$(M).SPMG PP NMS")
}

record(stringin,"$(P):SerialNum") {
  field(DESC,"Device Identifier String")
  field(VAL, "SXR PS XXXX")
  info(autosaveFields,"VAL")
}
record(bo, "$(P):MaintenanceM") {
  field(DESC, "PS maintenance")
  field(PINI, "YES")
  field(VAL, "0")
  field(ZNAM, "ACTIVE")
  field(ONAM, "UNDER_MAINTENANCE")
  info(autosaveFields_pass0, "VAL")
}

record(bo, "$(P):EnableDrive"){
  field(DESC, "Set relay to enable drive")
  field(DTYP, "stream")
  field(VAL, "1")
  field(OUT, "@$(PROTO) psDriveEn $(PORT)")
  field(OMSL, "supervisory")
}

record(bo, "$(P):DisableDrive"){
  field(DESC, "Set relay to disable drive")
  field(DTYP, "stream")
  field(VAL, "0")
  field(OUT, "@$(PROTO) psDriveEn $(PORT)")
  field(OMSL, "supervisory")
}
