#==================================
#----------------------------------
# cryoSupportCav.template:
#
# Support communication with cryo
#----------------------------------
#==================================

#==================================
#
#==================================

# Dissipated power calculation from AACT
# Keep for now as comparison with AACT_SQR value
# Remove when this latter fully commissioned
record(calc, "$(CM)$(CAV)0:RFCRYO_PWRDISS_CALC") {
  field(DESC, "Calc dissipated power")
  field(CALC, "A*A*1e12/B/C")
  field(EGU, "W")
  field(INPA, "$(CM)$(CAV)0:AACT CP")
  field(INPB, "$(CM)$(CAV)0:IMPED CP")
  field(INPC, "$(CM)$(CAV)0:Q0 CP")
}

# TODO: add source PV (when avail in FW)
record(ao, "$(CM)$(CAV)0:RFCRYO_PWRDISS") {
  field(DESC, "Write gradient to cryo")
  field(DTYP, "EtherIP")
  field(OMSL, "closed_loop")
  field(DOL,  "$(CM)00:RFCRYO_SUB.VAL$(GINP)")
# Use E flag because we write single element in large array
# and do not want to try to write all lower-indexed elements
# Causes read/write errors in some instances
$(TEST=#)  field(OUT, "@$(PLC) RF_$(TAGINST)_CRF_1$(CAV)55_RFCRYO_PWRDISS[$(CMCRYO)] E S 1")
  field(EGU, "W")
# field(ASG, "")
}
