# White balance.  The low and high parts of the white balance register are independent.
# Have 2 separate records and combine them into one for both output and readback

record(longout, "$(P)$(R)$(FEATURE)_LO") {
  field(PINI, "YES")
  field(DESC, "White bal. R/V")
  field(OUT, "$(P)$(R)$(FEATURE)_CALC.A PP MS")
}


record(longout, "$(P)$(R)$(FEATURE)_HI") {
  field(PINI, "YES")
  field(DESC, "White bal. B/U")
  field(OUT, "$(P)$(R)$(FEATURE)_CALC.B PP MS")
}

record(calcout, "$(P)$(R)$(FEATURE)_CALC") {
  field(CALC, "(B<<12) | A")
  field(OUT,  "$(P)$(R)$(FEATURE).VAL PP MS")
}

record(calcout, "$(P)$(R)$(FEATURE)_LO_RBV_CALC") {
  field(CALC, "A & 4095")
  field(INPA,  "$(P)$(R)$(FEATURE)_RBV.VAL CP MS")
  field(FLNK, "$(P)$(R)$(FEATURE)_LO_RBV")
}

record(longin, "$(P)$(R)$(FEATURE)_LO_RBV") {
  field(INP, "$(P)$(R)$(FEATURE)_LO_RBV_CALC NPP NMS")
}

record(calcout, "$(P)$(R)$(FEATURE)_HI_RBV_CALC") {
  field(CALC, "(A>>12) & 4095")
  field(INPA,  "$(P)$(R)$(FEATURE)_RBV.VAL CP MS")
  field(FLNK, "$(P)$(R)$(FEATURE)_HI_RBV")
}

record(longin, "$(P)$(R)$(FEATURE)_HI_RBV") {
  field(INP, "$(P)$(R)$(FEATURE)_HI_RBV_CALC NPP NMS")
}

# Set DRLV field of the value PV
record(calcout, "$(P)$(R)$(FEATURE)_LO_DRVL") {
  field(INPA, "$(P)$(R)$(FEATURE)_MIN CP MS")
  field(CALC, "A & 4095")
  field(OUT, "$(P)$(R)$(FEATURE)_LO.DRVL NPP NMS")
}

# Set DRLV field of the value PV
record(calcout, "$(P)$(R)$(FEATURE)_HI_DRVL") {
  field(INPA, "$(P)$(R)$(FEATURE)_MIN CP MS")
  field(CALC, "A & 4095")
  field(OUT, "$(P)$(R)$(FEATURE)_HI.DRVL NPP NMS")
}

# Set LOPR field of the value PV
record(calcout, "$(P)$(R)$(FEATURE)_LO_LOPR") {
  field(INPA, "$(P)$(R)$(FEATURE)_MIN CP MS")
  field(CALC, "A & 4095")
  field(OUT, "$(P)$(R)$(FEATURE)_LO.LOPR NPP NMS")
}

# Set LOPR field of the value PV
record(calcout, "$(P)$(R)$(FEATURE)_HI_LOPR") {
  field(INPA, "$(P)$(R)$(FEATURE)_MIN CP MS")
  field(CALC, "A & 4095")
  field(OUT, "$(P)$(R)$(FEATURE)_HI.LOPR NPP NMS")
}

# Set DRLH field of the value PV
record(calcout, "$(P)$(R)$(FEATURE)_LO_DRVH") {
  field(INPA, "$(P)$(R)$(FEATURE)_MAX CP MS")
  field(CALC, "A & 4095")
  field(OUT, "$(P)$(R)$(FEATURE)_LO.DRVH NPP NMS")
}

# Set DRLH field of the value PV
record(calcout, "$(P)$(R)$(FEATURE)_HI_DRVH") {
  field(INPA, "$(P)$(R)$(FEATURE)_MAX CP MS")
  field(CALC, "A & 4095")
  field(OUT, "$(P)$(R)$(FEATURE)_HI.DRVH NPP NMS")
}
# Set HOPR field of the value PV
record(calcout, "$(P)$(R)$(FEATURE)_LO_HOPR") {
  field(INPA, "$(P)$(R)$(FEATURE)_MAX CP MS")
  field(CALC, "A & 4095")
  field(OUT, "$(P)$(R)$(FEATURE)_LO.HOPR NPP NMS")
}

# Set HOPR field of the value PV
record(calcout, "$(P)$(R)$(FEATURE)_HI_HOPR") {
  field(INPA, "$(P)$(R)$(FEATURE)_MAX CP MS")
  field(CALC, "A & 4095")
  field(OUT, "$(P)$(R)$(FEATURE)_HI.HOPR NPP NMS")
}


