# Status summaries for integration
# with production operations.
# May move to FEED

# Geared towards cavity summary display
# That display checks SEVR==INVALID for 
# all records, so do not include additional
# severity checks here, just us MS/MSI

# Subset of standard ALH chassis alarms
record(calc, "$(CM,recursive)00:RACKA:HWINITSUM1") {
  field(DESC, "Hardware init needed")
  field(SCAN, "1 second")
  field(CALC, "A")
  field(INPA, "$(CM,recursive)00:RACKA:HWSTATSUM MS")
  field(INPB, "$(CM,recursive)00:PRCA:STATUS MS")
  field(INPC, "$(CM,recursive)00:PRCA:CRCERR_STAT MS")
  field(INPD, "$(CM,recursive)00:PRCA:AMC_ALARMSUM MS")
  field(INPE, "$(CM,recursive)00:RFS1A:STATUS MS")
  field(INPF, "$(CM,recursive)00:RFS1A:CRCERR_STAT MS")
  field(INPG, "$(CM,recursive)00:RFS1A:AMC_ALARMSUM MS")
  field(INPH, "$(CM,recursive)00:RFS1A:RESLINK MS")
  field(INPI, "$(CM,recursive)00:RFS2A:STATUS MS")
  field(INPJ, "$(CM,recursive)00:RFS2A:CRCERR_STAT MS")
  field(INPK, "$(CM,recursive)00:RFS2A:AMC_ALARMSUM MS")
  field(INPL, "$(CM,recursive)00:RFS2A:RESLINK MS")
  field(FLNK, "$(CM,recursive)00:RACKA:HWINITSUM2")
}

record(calc, "$(CM,recursive)00:RACKA:HWINITSUM2") {
  field(DESC, "Hardware init needed")
  field(SCAN, "1 second")
  field(CALC, "A")
  field(INPA, "$(CM,recursive)00:RACKA:HWINITSUM1 MS")
  field(INPB, "$(CM,recursive)00:RESA:CTRL_STATUS MS")
  field(INPC, "$(CM,recursive)00:RESA:RFS1LINK MS")
  field(INPD, "$(CM,recursive)00:RESA:RFS2LINK MS")
  field(FLNK, "$(CM,recursive)00:RACKA:HWINITSUM3")
}

record(calc, "$(CM,recursive)00:RACKA:HWINITSUM3") {
  field(DESC, "Hardware init needed")
  field(HIGH, "1")
  field(HSV,  "MINOR")
  field(HIHI, "2")
  field(HHSV, "MAJOR")
  field(LOLO, "0")
  field(CALC, "(A=0)?2:(A=2)?1:(B>1)?2:0")
# Last rack checkout failed or
# rack checkout currently running
  field(INPA, "$(CM,recursive)00:RACKA:TESTSTAT")
  field(INPB, "$(CM,recursive)00:RACKA:HWINITSUM2.SEVR MSI")
  field(FLNK, "$(CM,recursive)00:RACKA:HWINITSUM")
}

record(calc, "$(CM,recursive)00:RACKA:HWINITSUM") {
  field(DESC, "Hardware init needed")
  field(CALC, "A")
  field(INPA, "$(CM,recursive)00:RACKA:HWINITSUM1 MS")
}
# Status summaries for integration
# with production operations.
# May move to FEED

# Geared towards cavity summary display
# That display checks SEVR==INVALID for 
# all records, so do not include additional
# severity checks here, just us MS/MSI

# Subset of standard ALH chassis alarms
record(calc, "$(CM,recursive)00:RACKB:HWINITSUM1") {
  field(DESC, "Hardware init needed")
  field(SCAN, "1 second")
  field(CALC, "A")
  field(INPA, "$(CM,recursive)00:RACKB:HWSTATSUM MS")
  field(INPB, "$(CM,recursive)00:PRCB:STATUS MS")
  field(INPC, "$(CM,recursive)00:PRCB:CRCERR_STAT MS")
  field(INPD, "$(CM,recursive)00:PRCB:AMC_ALARMSUM MS")
  field(INPE, "$(CM,recursive)00:RFS1B:STATUS MS")
  field(INPF, "$(CM,recursive)00:RFS1B:CRCERR_STAT MS")
  field(INPG, "$(CM,recursive)00:RFS1B:AMC_ALARMSUM MS")
  field(INPH, "$(CM,recursive)00:RFS1B:RESLINK MS")
  field(INPI, "$(CM,recursive)00:RFS2B:STATUS MS")
  field(INPJ, "$(CM,recursive)00:RFS2B:CRCERR_STAT MS")
  field(INPK, "$(CM,recursive)00:RFS2B:AMC_ALARMSUM MS")
  field(INPL, "$(CM,recursive)00:RFS2B:RESLINK MS")
  field(FLNK, "$(CM,recursive)00:RACKB:HWINITSUM2")
}

record(calc, "$(CM,recursive)00:RACKB:HWINITSUM2") {
  field(DESC, "Hardware init needed")
  field(SCAN, "1 second")
  field(CALC, "A")
  field(INPA, "$(CM,recursive)00:RACKB:HWINITSUM1 MS")
  field(INPB, "$(CM,recursive)00:RESB:CTRL_STATUS MS")
  field(INPC, "$(CM,recursive)00:RESB:RFS1LINK MS")
  field(INPD, "$(CM,recursive)00:RESB:RFS2LINK MS")
  field(FLNK, "$(CM,recursive)00:RACKB:HWINITSUM3")
}

record(calc, "$(CM,recursive)00:RACKB:HWINITSUM3") {
  field(DESC, "Hardware init needed")
  field(HIGH, "1")
  field(HSV,  "MINOR")
  field(HIHI, "2")
  field(HHSV, "MAJOR")
  field(LOLO, "0")
  field(CALC, "(A=0)?2:(A=2)?1:(B>1)?2:0")
# Last rack checkout failed or
# rack checkout currently running
  field(INPA, "$(CM,recursive)00:RACKB:TESTSTAT")
  field(INPB, "$(CM,recursive)00:RACKB:HWINITSUM2.SEVR MSI")
  field(FLNK, "$(CM,recursive)00:RACKB:HWINITSUM")
}

record(calc, "$(CM,recursive)00:RACKB:HWINITSUM") {
  field(DESC, "Hardware init needed")
  field(CALC, "A")
  field(INPA, "$(CM,recursive)00:RACKB:HWINITSUM1 MS")
}
# Status summaries for integration
# with production operations.
# May move to FEED

# Geared towards cavity summary display
# That display checks SEVR==INVALID for 
# all records, so do not include additional
# severity checks here, just us MS/MSI

record(calc, "$(CM,undefined)10:PZT:HWSTATSUM1") {
  field(DESC, "Piezo tuner status sum")
  field(SCAN, "1 second")
  field(HIHI, "2")
  field(HHSV, "MAJOR")
  field(LOLO, "0")
  field(CALC, "(A>0)?2:0")
# Either channel power limit
  field(INPA, "$(CM,undefined)10:PZT:PWRLIM MSI")
  field(FLNK, "$(CM,undefined)10:PZT:HWSTATSUM")
}

record(calc, "$(CM,undefined)10:PZT:HWSTATSUM") {
  field(DESC, "Piezo tuner status sum")
  field(CALC, "A")
  field(INPA, "$(CM,undefined)10:PZT:HWSTATSUM1 MS")
}

record(calc, "$(CM,undefined)10:STEP:HWSTATSUM1") {
  field(DESC, "Stepper tuner status sum")
  field(SCAN, "1 second")
  field(HIHI, "2")
  field(HHSV, "MAJOR")
  field(LOLO, "0")
  field(CALC, "(A+B+C+D+E)>0?2:0")
# Limit B
  field(INPA, "$(CM,undefined)10:STEP:STATWRD.B3 MSI")
# Limit A
  field(INPB, "$(CM,undefined)10:STEP:STATWRD.B4 MSI")
# Any Limit
  field(INPC, "$(CM,undefined)10:STEP:STATWRD.B5 MSI")
# Inhibit
  field(INPD, "$(CM,undefined)10:STEP:STATWRD.B6 MSI")
# Low Current
  field(INPE, "$(CM,undefined)10:STEP:STATWRD.B7 MSI")
  field(FLNK, "$(CM,undefined)10:STEP:HWSTATSUM")
}

record(calc, "$(CM,undefined)10:STEP:HWSTATSUM") {
  field(DESC, "Stepper tuner status sum")
  field(CALC, "A")
  field(INPA, "$(CM,undefined)10:STEP:HWSTATSUM1 MS")
}

record(calc, "$(CM,undefined)10:CAV:CALSTATSUM1") {
  field(DESC, "Cavity characterization needed")
  field(SCAN, "1 second")
  field(HIHI, "2")
  field(HHSV, "MAJOR")
  field(LOLO, "0")
  field(CALC, "(A>0)?2:(B=0)?2:(C#1)?2:0")
# Last characterization incomplete/failed
  field(INPA, "$(CM,undefined)10:CAV:CALSUM.SEVR")
  field(INPB, "$(CM,undefined)10:DF_ENABLE_RBV MSI")
  field(INPC, "$(CM,undefined)10:SEL_ENABLE_RBV MSI")
  field(FLNK, "$(CM,undefined)10:CAV:CALSTATSUM")
}

record(calc, "$(CM,undefined)10:CAV:CALSTATSUM") {
  field(DESC, "Cavity characterization needed")
  field(CALC, "A")
  field(INPA, "$(CM,undefined)10:CAV:CALSTATSUM1 MS")
}

record(calc, "$(CM,undefined)10:PZT:READY") {
  field(DESC, "Piezo tuner nominal config")
  field(SCAN, "1 second")
  field(HIHI, "2")
  field(HHSV, "MAJOR")
  field(LOLO, "0")
  field(CALC, "(A#1)?2:(B#0)?2:(C#1)?2:(D#1)?2:0")
# Controller = Integrator
  field(INPA, "$(CM,undefined)10:PZT:CTRL_RBV MSI")
# Source = RFS
  field(INPB, "$(CM,undefined)10:PZT:DF_SRC_RBV MSI")
# Bias enabled
  field(INPC, "$(CM,undefined)10:PZT:BIAS_ENABLE_RBV MSI")
# Integrator enabled
  field(INPD, "$(CM,undefined)10:PZT:INTEG_ENABLE_RBV MSI")
  field(FLNK, "$(CM,undefined)10:PZT:FBSTATSUM1")
}

record(calc, "$(CM,undefined)10:PZT:FBSTATSUM1") {
  field(DESC, "Piezo feedback status sum")
  field(SCAN, "1 second")
  field(HIHI, "2")
  field(HHSV, "MAJOR")
  field(LOLO, "0")
  field(CALC, "(A=0)?2:(B#0)?2:(C#1)?2:(ABS(D)>10)?1:(E#0)?2:0")
# Piezo enabled (1)
  field(INPA, "$(CM,undefined)10:PZT:ENABLESTAT MSI")
# Piezo in nominal configuration (0)
  field(INPB, "$(CM,undefined)10:PZT:READY MS")
# Detune from RFS is valid (1)
  field(INPC, "$(CM,undefined)10:PZT:DFVALID_RFS MSI")
# Detune from RFS is within +/-10 Hz
  field(INPD, "$(CM,undefined)10:PZT:DF_RFS MSI")
# Piezo at limit (0)
  field(INPE, "$(CM,undefined)10:PZT:INTEG_AT_LIM MSI")
  field(FLNK, "$(CM,undefined)10:PZT:FBSTATSUM")
}

record(calc, "$(CM,undefined)10:PZT:FBSTATSUM") {
  field(DESC, "Piezo feedback status sum")
  field(CALC, "A")
  field(INPA, "$(CM,undefined)10:PZT:FBSTATSUM1 MS")
}
# Status summaries for integration
# with production operations.
# May move to FEED

# Geared towards cavity summary display
# That display checks SEVR==INVALID for 
# all records, so do not include additional
# severity checks here, just us MS/MSI

record(calc, "$(CM,undefined)20:PZT:HWSTATSUM1") {
  field(DESC, "Piezo tuner status sum")
  field(SCAN, "1 second")
  field(HIHI, "2")
  field(HHSV, "MAJOR")
  field(LOLO, "0")
  field(CALC, "(A>0)?2:0")
# Either channel power limit
  field(INPA, "$(CM,undefined)20:PZT:PWRLIM MSI")
  field(FLNK, "$(CM,undefined)20:PZT:HWSTATSUM")
}

record(calc, "$(CM,undefined)20:PZT:HWSTATSUM") {
  field(DESC, "Piezo tuner status sum")
  field(CALC, "A")
  field(INPA, "$(CM,undefined)20:PZT:HWSTATSUM1 MS")
}

record(calc, "$(CM,undefined)20:STEP:HWSTATSUM1") {
  field(DESC, "Stepper tuner status sum")
  field(SCAN, "1 second")
  field(HIHI, "2")
  field(HHSV, "MAJOR")
  field(LOLO, "0")
  field(CALC, "(A+B+C+D+E)>0?2:0")
# Limit B
  field(INPA, "$(CM,undefined)20:STEP:STATWRD.B3 MSI")
# Limit A
  field(INPB, "$(CM,undefined)20:STEP:STATWRD.B4 MSI")
# Any Limit
  field(INPC, "$(CM,undefined)20:STEP:STATWRD.B5 MSI")
# Inhibit
  field(INPD, "$(CM,undefined)20:STEP:STATWRD.B6 MSI")
# Low Current
  field(INPE, "$(CM,undefined)20:STEP:STATWRD.B7 MSI")
  field(FLNK, "$(CM,undefined)20:STEP:HWSTATSUM")
}

record(calc, "$(CM,undefined)20:STEP:HWSTATSUM") {
  field(DESC, "Stepper tuner status sum")
  field(CALC, "A")
  field(INPA, "$(CM,undefined)20:STEP:HWSTATSUM1 MS")
}

record(calc, "$(CM,undefined)20:CAV:CALSTATSUM1") {
  field(DESC, "Cavity characterization needed")
  field(SCAN, "1 second")
  field(HIHI, "2")
  field(HHSV, "MAJOR")
  field(LOLO, "0")
  field(CALC, "(A>0)?2:(B=0)?2:(C#1)?2:0")
# Last characterization incomplete/failed
  field(INPA, "$(CM,undefined)20:CAV:CALSUM.SEVR")
  field(INPB, "$(CM,undefined)20:DF_ENABLE_RBV MSI")
  field(INPC, "$(CM,undefined)20:SEL_ENABLE_RBV MSI")
  field(FLNK, "$(CM,undefined)20:CAV:CALSTATSUM")
}

record(calc, "$(CM,undefined)20:CAV:CALSTATSUM") {
  field(DESC, "Cavity characterization needed")
  field(CALC, "A")
  field(INPA, "$(CM,undefined)20:CAV:CALSTATSUM1 MS")
}

record(calc, "$(CM,undefined)20:PZT:READY") {
  field(DESC, "Piezo tuner nominal config")
  field(SCAN, "1 second")
  field(HIHI, "2")
  field(HHSV, "MAJOR")
  field(LOLO, "0")
  field(CALC, "(A#1)?2:(B#0)?2:(C#1)?2:(D#1)?2:0")
# Controller = Integrator
  field(INPA, "$(CM,undefined)20:PZT:CTRL_RBV MSI")
# Source = RFS
  field(INPB, "$(CM,undefined)20:PZT:DF_SRC_RBV MSI")
# Bias enabled
  field(INPC, "$(CM,undefined)20:PZT:BIAS_ENABLE_RBV MSI")
# Integrator enabled
  field(INPD, "$(CM,undefined)20:PZT:INTEG_ENABLE_RBV MSI")
  field(FLNK, "$(CM,undefined)20:PZT:FBSTATSUM1")
}

record(calc, "$(CM,undefined)20:PZT:FBSTATSUM1") {
  field(DESC, "Piezo feedback status sum")
  field(SCAN, "1 second")
  field(HIHI, "2")
  field(HHSV, "MAJOR")
  field(LOLO, "0")
  field(CALC, "(A=0)?2:(B#0)?2:(C#1)?2:(ABS(D)>10)?1:(E#0)?2:0")
# Piezo enabled (1)
  field(INPA, "$(CM,undefined)20:PZT:ENABLESTAT MSI")
# Piezo in nominal configuration (0)
  field(INPB, "$(CM,undefined)20:PZT:READY MS")
# Detune from RFS is valid (1)
  field(INPC, "$(CM,undefined)20:PZT:DFVALID_RFS MSI")
# Detune from RFS is within +/-10 Hz
  field(INPD, "$(CM,undefined)20:PZT:DF_RFS MSI")
# Piezo at limit (0)
  field(INPE, "$(CM,undefined)20:PZT:INTEG_AT_LIM MSI")
  field(FLNK, "$(CM,undefined)20:PZT:FBSTATSUM")
}

record(calc, "$(CM,undefined)20:PZT:FBSTATSUM") {
  field(DESC, "Piezo feedback status sum")
  field(CALC, "A")
  field(INPA, "$(CM,undefined)20:PZT:FBSTATSUM1 MS")
}
# Status summaries for integration
# with production operations.
# May move to FEED

# Geared towards cavity summary display
# That display checks SEVR==INVALID for 
# all records, so do not include additional
# severity checks here, just us MS/MSI

record(calc, "$(CM,undefined)30:PZT:HWSTATSUM1") {
  field(DESC, "Piezo tuner status sum")
  field(SCAN, "1 second")
  field(HIHI, "2")
  field(HHSV, "MAJOR")
  field(LOLO, "0")
  field(CALC, "(A>0)?2:0")
# Either channel power limit
  field(INPA, "$(CM,undefined)30:PZT:PWRLIM MSI")
  field(FLNK, "$(CM,undefined)30:PZT:HWSTATSUM")
}

record(calc, "$(CM,undefined)30:PZT:HWSTATSUM") {
  field(DESC, "Piezo tuner status sum")
  field(CALC, "A")
  field(INPA, "$(CM,undefined)30:PZT:HWSTATSUM1 MS")
}

record(calc, "$(CM,undefined)30:STEP:HWSTATSUM1") {
  field(DESC, "Stepper tuner status sum")
  field(SCAN, "1 second")
  field(HIHI, "2")
  field(HHSV, "MAJOR")
  field(LOLO, "0")
  field(CALC, "(A+B+C+D+E)>0?2:0")
# Limit B
  field(INPA, "$(CM,undefined)30:STEP:STATWRD.B3 MSI")
# Limit A
  field(INPB, "$(CM,undefined)30:STEP:STATWRD.B4 MSI")
# Any Limit
  field(INPC, "$(CM,undefined)30:STEP:STATWRD.B5 MSI")
# Inhibit
  field(INPD, "$(CM,undefined)30:STEP:STATWRD.B6 MSI")
# Low Current
  field(INPE, "$(CM,undefined)30:STEP:STATWRD.B7 MSI")
  field(FLNK, "$(CM,undefined)30:STEP:HWSTATSUM")
}

record(calc, "$(CM,undefined)30:STEP:HWSTATSUM") {
  field(DESC, "Stepper tuner status sum")
  field(CALC, "A")
  field(INPA, "$(CM,undefined)30:STEP:HWSTATSUM1 MS")
}

record(calc, "$(CM,undefined)30:CAV:CALSTATSUM1") {
  field(DESC, "Cavity characterization needed")
  field(SCAN, "1 second")
  field(HIHI, "2")
  field(HHSV, "MAJOR")
  field(LOLO, "0")
  field(CALC, "(A>0)?2:(B=0)?2:(C#1)?2:0")
# Last characterization incomplete/failed
  field(INPA, "$(CM,undefined)30:CAV:CALSUM.SEVR")
  field(INPB, "$(CM,undefined)30:DF_ENABLE_RBV MSI")
  field(INPC, "$(CM,undefined)30:SEL_ENABLE_RBV MSI")
  field(FLNK, "$(CM,undefined)30:CAV:CALSTATSUM")
}

record(calc, "$(CM,undefined)30:CAV:CALSTATSUM") {
  field(DESC, "Cavity characterization needed")
  field(CALC, "A")
  field(INPA, "$(CM,undefined)30:CAV:CALSTATSUM1 MS")
}

record(calc, "$(CM,undefined)30:PZT:READY") {
  field(DESC, "Piezo tuner nominal config")
  field(SCAN, "1 second")
  field(HIHI, "2")
  field(HHSV, "MAJOR")
  field(LOLO, "0")
  field(CALC, "(A#1)?2:(B#0)?2:(C#1)?2:(D#1)?2:0")
# Controller = Integrator
  field(INPA, "$(CM,undefined)30:PZT:CTRL_RBV MSI")
# Source = RFS
  field(INPB, "$(CM,undefined)30:PZT:DF_SRC_RBV MSI")
# Bias enabled
  field(INPC, "$(CM,undefined)30:PZT:BIAS_ENABLE_RBV MSI")
# Integrator enabled
  field(INPD, "$(CM,undefined)30:PZT:INTEG_ENABLE_RBV MSI")
  field(FLNK, "$(CM,undefined)30:PZT:FBSTATSUM1")
}

record(calc, "$(CM,undefined)30:PZT:FBSTATSUM1") {
  field(DESC, "Piezo feedback status sum")
  field(SCAN, "1 second")
  field(HIHI, "2")
  field(HHSV, "MAJOR")
  field(LOLO, "0")
  field(CALC, "(A=0)?2:(B#0)?2:(C#1)?2:(ABS(D)>10)?1:(E#0)?2:0")
# Piezo enabled (1)
  field(INPA, "$(CM,undefined)30:PZT:ENABLESTAT MSI")
# Piezo in nominal configuration (0)
  field(INPB, "$(CM,undefined)30:PZT:READY MS")
# Detune from RFS is valid (1)
  field(INPC, "$(CM,undefined)30:PZT:DFVALID_RFS MSI")
# Detune from RFS is within +/-10 Hz
  field(INPD, "$(CM,undefined)30:PZT:DF_RFS MSI")
# Piezo at limit (0)
  field(INPE, "$(CM,undefined)30:PZT:INTEG_AT_LIM MSI")
  field(FLNK, "$(CM,undefined)30:PZT:FBSTATSUM")
}

record(calc, "$(CM,undefined)30:PZT:FBSTATSUM") {
  field(DESC, "Piezo feedback status sum")
  field(CALC, "A")
  field(INPA, "$(CM,undefined)30:PZT:FBSTATSUM1 MS")
}
# Status summaries for integration
# with production operations.
# May move to FEED

# Geared towards cavity summary display
# That display checks SEVR==INVALID for 
# all records, so do not include additional
# severity checks here, just us MS/MSI

record(calc, "$(CM,undefined)40:PZT:HWSTATSUM1") {
  field(DESC, "Piezo tuner status sum")
  field(SCAN, "1 second")
  field(HIHI, "2")
  field(HHSV, "MAJOR")
  field(LOLO, "0")
  field(CALC, "(A>0)?2:0")
# Either channel power limit
  field(INPA, "$(CM,undefined)40:PZT:PWRLIM MSI")
  field(FLNK, "$(CM,undefined)40:PZT:HWSTATSUM")
}

record(calc, "$(CM,undefined)40:PZT:HWSTATSUM") {
  field(DESC, "Piezo tuner status sum")
  field(CALC, "A")
  field(INPA, "$(CM,undefined)40:PZT:HWSTATSUM1 MS")
}

record(calc, "$(CM,undefined)40:STEP:HWSTATSUM1") {
  field(DESC, "Stepper tuner status sum")
  field(SCAN, "1 second")
  field(HIHI, "2")
  field(HHSV, "MAJOR")
  field(LOLO, "0")
  field(CALC, "(A+B+C+D+E)>0?2:0")
# Limit B
  field(INPA, "$(CM,undefined)40:STEP:STATWRD.B3 MSI")
# Limit A
  field(INPB, "$(CM,undefined)40:STEP:STATWRD.B4 MSI")
# Any Limit
  field(INPC, "$(CM,undefined)40:STEP:STATWRD.B5 MSI")
# Inhibit
  field(INPD, "$(CM,undefined)40:STEP:STATWRD.B6 MSI")
# Low Current
  field(INPE, "$(CM,undefined)40:STEP:STATWRD.B7 MSI")
  field(FLNK, "$(CM,undefined)40:STEP:HWSTATSUM")
}

record(calc, "$(CM,undefined)40:STEP:HWSTATSUM") {
  field(DESC, "Stepper tuner status sum")
  field(CALC, "A")
  field(INPA, "$(CM,undefined)40:STEP:HWSTATSUM1 MS")
}

record(calc, "$(CM,undefined)40:CAV:CALSTATSUM1") {
  field(DESC, "Cavity characterization needed")
  field(SCAN, "1 second")
  field(HIHI, "2")
  field(HHSV, "MAJOR")
  field(LOLO, "0")
  field(CALC, "(A>0)?2:(B=0)?2:(C#1)?2:0")
# Last characterization incomplete/failed
  field(INPA, "$(CM,undefined)40:CAV:CALSUM.SEVR")
  field(INPB, "$(CM,undefined)40:DF_ENABLE_RBV MSI")
  field(INPC, "$(CM,undefined)40:SEL_ENABLE_RBV MSI")
  field(FLNK, "$(CM,undefined)40:CAV:CALSTATSUM")
}

record(calc, "$(CM,undefined)40:CAV:CALSTATSUM") {
  field(DESC, "Cavity characterization needed")
  field(CALC, "A")
  field(INPA, "$(CM,undefined)40:CAV:CALSTATSUM1 MS")
}

record(calc, "$(CM,undefined)40:PZT:READY") {
  field(DESC, "Piezo tuner nominal config")
  field(SCAN, "1 second")
  field(HIHI, "2")
  field(HHSV, "MAJOR")
  field(LOLO, "0")
  field(CALC, "(A#1)?2:(B#0)?2:(C#1)?2:(D#1)?2:0")
# Controller = Integrator
  field(INPA, "$(CM,undefined)40:PZT:CTRL_RBV MSI")
# Source = RFS
  field(INPB, "$(CM,undefined)40:PZT:DF_SRC_RBV MSI")
# Bias enabled
  field(INPC, "$(CM,undefined)40:PZT:BIAS_ENABLE_RBV MSI")
# Integrator enabled
  field(INPD, "$(CM,undefined)40:PZT:INTEG_ENABLE_RBV MSI")
  field(FLNK, "$(CM,undefined)40:PZT:FBSTATSUM1")
}

record(calc, "$(CM,undefined)40:PZT:FBSTATSUM1") {
  field(DESC, "Piezo feedback status sum")
  field(SCAN, "1 second")
  field(HIHI, "2")
  field(HHSV, "MAJOR")
  field(LOLO, "0")
  field(CALC, "(A=0)?2:(B#0)?2:(C#1)?2:(ABS(D)>10)?1:(E#0)?2:0")
# Piezo enabled (1)
  field(INPA, "$(CM,undefined)40:PZT:ENABLESTAT MSI")
# Piezo in nominal configuration (0)
  field(INPB, "$(CM,undefined)40:PZT:READY MS")
# Detune from RFS is valid (1)
  field(INPC, "$(CM,undefined)40:PZT:DFVALID_RFS MSI")
# Detune from RFS is within +/-10 Hz
  field(INPD, "$(CM,undefined)40:PZT:DF_RFS MSI")
# Piezo at limit (0)
  field(INPE, "$(CM,undefined)40:PZT:INTEG_AT_LIM MSI")
  field(FLNK, "$(CM,undefined)40:PZT:FBSTATSUM")
}

record(calc, "$(CM,undefined)40:PZT:FBSTATSUM") {
  field(DESC, "Piezo feedback status sum")
  field(CALC, "A")
  field(INPA, "$(CM,undefined)40:PZT:FBSTATSUM1 MS")
}
# Status summaries for integration
# with production operations.
# May move to FEED

# Geared towards cavity summary display
# That display checks SEVR==INVALID for 
# all records, so do not include additional
# severity checks here, just us MS/MSI

record(calc, "$(CM,undefined)50:PZT:HWSTATSUM1") {
  field(DESC, "Piezo tuner status sum")
  field(SCAN, "1 second")
  field(HIHI, "2")
  field(HHSV, "MAJOR")
  field(LOLO, "0")
  field(CALC, "(A>0)?2:0")
# Either channel power limit
  field(INPA, "$(CM,undefined)50:PZT:PWRLIM MSI")
  field(FLNK, "$(CM,undefined)50:PZT:HWSTATSUM")
}

record(calc, "$(CM,undefined)50:PZT:HWSTATSUM") {
  field(DESC, "Piezo tuner status sum")
  field(CALC, "A")
  field(INPA, "$(CM,undefined)50:PZT:HWSTATSUM1 MS")
}

record(calc, "$(CM,undefined)50:STEP:HWSTATSUM1") {
  field(DESC, "Stepper tuner status sum")
  field(SCAN, "1 second")
  field(HIHI, "2")
  field(HHSV, "MAJOR")
  field(LOLO, "0")
  field(CALC, "(A+B+C+D+E)>0?2:0")
# Limit B
  field(INPA, "$(CM,undefined)50:STEP:STATWRD.B3 MSI")
# Limit A
  field(INPB, "$(CM,undefined)50:STEP:STATWRD.B4 MSI")
# Any Limit
  field(INPC, "$(CM,undefined)50:STEP:STATWRD.B5 MSI")
# Inhibit
  field(INPD, "$(CM,undefined)50:STEP:STATWRD.B6 MSI")
# Low Current
  field(INPE, "$(CM,undefined)50:STEP:STATWRD.B7 MSI")
  field(FLNK, "$(CM,undefined)50:STEP:HWSTATSUM")
}

record(calc, "$(CM,undefined)50:STEP:HWSTATSUM") {
  field(DESC, "Stepper tuner status sum")
  field(CALC, "A")
  field(INPA, "$(CM,undefined)50:STEP:HWSTATSUM1 MS")
}

record(calc, "$(CM,undefined)50:CAV:CALSTATSUM1") {
  field(DESC, "Cavity characterization needed")
  field(SCAN, "1 second")
  field(HIHI, "2")
  field(HHSV, "MAJOR")
  field(LOLO, "0")
  field(CALC, "(A>0)?2:(B=0)?2:(C#1)?2:0")
# Last characterization incomplete/failed
  field(INPA, "$(CM,undefined)50:CAV:CALSUM.SEVR")
  field(INPB, "$(CM,undefined)50:DF_ENABLE_RBV MSI")
  field(INPC, "$(CM,undefined)50:SEL_ENABLE_RBV MSI")
  field(FLNK, "$(CM,undefined)50:CAV:CALSTATSUM")
}

record(calc, "$(CM,undefined)50:CAV:CALSTATSUM") {
  field(DESC, "Cavity characterization needed")
  field(CALC, "A")
  field(INPA, "$(CM,undefined)50:CAV:CALSTATSUM1 MS")
}

record(calc, "$(CM,undefined)50:PZT:READY") {
  field(DESC, "Piezo tuner nominal config")
  field(SCAN, "1 second")
  field(HIHI, "2")
  field(HHSV, "MAJOR")
  field(LOLO, "0")
  field(CALC, "(A#1)?2:(B#0)?2:(C#1)?2:(D#1)?2:0")
# Controller = Integrator
  field(INPA, "$(CM,undefined)50:PZT:CTRL_RBV MSI")
# Source = RFS
  field(INPB, "$(CM,undefined)50:PZT:DF_SRC_RBV MSI")
# Bias enabled
  field(INPC, "$(CM,undefined)50:PZT:BIAS_ENABLE_RBV MSI")
# Integrator enabled
  field(INPD, "$(CM,undefined)50:PZT:INTEG_ENABLE_RBV MSI")
  field(FLNK, "$(CM,undefined)50:PZT:FBSTATSUM1")
}

record(calc, "$(CM,undefined)50:PZT:FBSTATSUM1") {
  field(DESC, "Piezo feedback status sum")
  field(SCAN, "1 second")
  field(HIHI, "2")
  field(HHSV, "MAJOR")
  field(LOLO, "0")
  field(CALC, "(A=0)?2:(B#0)?2:(C#1)?2:(ABS(D)>10)?1:(E#0)?2:0")
# Piezo enabled (1)
  field(INPA, "$(CM,undefined)50:PZT:ENABLESTAT MSI")
# Piezo in nominal configuration (0)
  field(INPB, "$(CM,undefined)50:PZT:READY MS")
# Detune from RFS is valid (1)
  field(INPC, "$(CM,undefined)50:PZT:DFVALID_RFS MSI")
# Detune from RFS is within +/-10 Hz
  field(INPD, "$(CM,undefined)50:PZT:DF_RFS MSI")
# Piezo at limit (0)
  field(INPE, "$(CM,undefined)50:PZT:INTEG_AT_LIM MSI")
  field(FLNK, "$(CM,undefined)50:PZT:FBSTATSUM")
}

record(calc, "$(CM,undefined)50:PZT:FBSTATSUM") {
  field(DESC, "Piezo feedback status sum")
  field(CALC, "A")
  field(INPA, "$(CM,undefined)50:PZT:FBSTATSUM1 MS")
}
# Status summaries for integration
# with production operations.
# May move to FEED

# Geared towards cavity summary display
# That display checks SEVR==INVALID for 
# all records, so do not include additional
# severity checks here, just us MS/MSI

record(calc, "$(CM,undefined)60:PZT:HWSTATSUM1") {
  field(DESC, "Piezo tuner status sum")
  field(SCAN, "1 second")
  field(HIHI, "2")
  field(HHSV, "MAJOR")
  field(LOLO, "0")
  field(CALC, "(A>0)?2:0")
# Either channel power limit
  field(INPA, "$(CM,undefined)60:PZT:PWRLIM MSI")
  field(FLNK, "$(CM,undefined)60:PZT:HWSTATSUM")
}

record(calc, "$(CM,undefined)60:PZT:HWSTATSUM") {
  field(DESC, "Piezo tuner status sum")
  field(CALC, "A")
  field(INPA, "$(CM,undefined)60:PZT:HWSTATSUM1 MS")
}

record(calc, "$(CM,undefined)60:STEP:HWSTATSUM1") {
  field(DESC, "Stepper tuner status sum")
  field(SCAN, "1 second")
  field(HIHI, "2")
  field(HHSV, "MAJOR")
  field(LOLO, "0")
  field(CALC, "(A+B+C+D+E)>0?2:0")
# Limit B
  field(INPA, "$(CM,undefined)60:STEP:STATWRD.B3 MSI")
# Limit A
  field(INPB, "$(CM,undefined)60:STEP:STATWRD.B4 MSI")
# Any Limit
  field(INPC, "$(CM,undefined)60:STEP:STATWRD.B5 MSI")
# Inhibit
  field(INPD, "$(CM,undefined)60:STEP:STATWRD.B6 MSI")
# Low Current
  field(INPE, "$(CM,undefined)60:STEP:STATWRD.B7 MSI")
  field(FLNK, "$(CM,undefined)60:STEP:HWSTATSUM")
}

record(calc, "$(CM,undefined)60:STEP:HWSTATSUM") {
  field(DESC, "Stepper tuner status sum")
  field(CALC, "A")
  field(INPA, "$(CM,undefined)60:STEP:HWSTATSUM1 MS")
}

record(calc, "$(CM,undefined)60:CAV:CALSTATSUM1") {
  field(DESC, "Cavity characterization needed")
  field(SCAN, "1 second")
  field(HIHI, "2")
  field(HHSV, "MAJOR")
  field(LOLO, "0")
  field(CALC, "(A>0)?2:(B=0)?2:(C#1)?2:0")
# Last characterization incomplete/failed
  field(INPA, "$(CM,undefined)60:CAV:CALSUM.SEVR")
  field(INPB, "$(CM,undefined)60:DF_ENABLE_RBV MSI")
  field(INPC, "$(CM,undefined)60:SEL_ENABLE_RBV MSI")
  field(FLNK, "$(CM,undefined)60:CAV:CALSTATSUM")
}

record(calc, "$(CM,undefined)60:CAV:CALSTATSUM") {
  field(DESC, "Cavity characterization needed")
  field(CALC, "A")
  field(INPA, "$(CM,undefined)60:CAV:CALSTATSUM1 MS")
}

record(calc, "$(CM,undefined)60:PZT:READY") {
  field(DESC, "Piezo tuner nominal config")
  field(SCAN, "1 second")
  field(HIHI, "2")
  field(HHSV, "MAJOR")
  field(LOLO, "0")
  field(CALC, "(A#1)?2:(B#0)?2:(C#1)?2:(D#1)?2:0")
# Controller = Integrator
  field(INPA, "$(CM,undefined)60:PZT:CTRL_RBV MSI")
# Source = RFS
  field(INPB, "$(CM,undefined)60:PZT:DF_SRC_RBV MSI")
# Bias enabled
  field(INPC, "$(CM,undefined)60:PZT:BIAS_ENABLE_RBV MSI")
# Integrator enabled
  field(INPD, "$(CM,undefined)60:PZT:INTEG_ENABLE_RBV MSI")
  field(FLNK, "$(CM,undefined)60:PZT:FBSTATSUM1")
}

record(calc, "$(CM,undefined)60:PZT:FBSTATSUM1") {
  field(DESC, "Piezo feedback status sum")
  field(SCAN, "1 second")
  field(HIHI, "2")
  field(HHSV, "MAJOR")
  field(LOLO, "0")
  field(CALC, "(A=0)?2:(B#0)?2:(C#1)?2:(ABS(D)>10)?1:(E#0)?2:0")
# Piezo enabled (1)
  field(INPA, "$(CM,undefined)60:PZT:ENABLESTAT MSI")
# Piezo in nominal configuration (0)
  field(INPB, "$(CM,undefined)60:PZT:READY MS")
# Detune from RFS is valid (1)
  field(INPC, "$(CM,undefined)60:PZT:DFVALID_RFS MSI")
# Detune from RFS is within +/-10 Hz
  field(INPD, "$(CM,undefined)60:PZT:DF_RFS MSI")
# Piezo at limit (0)
  field(INPE, "$(CM,undefined)60:PZT:INTEG_AT_LIM MSI")
  field(FLNK, "$(CM,undefined)60:PZT:FBSTATSUM")
}

record(calc, "$(CM,undefined)60:PZT:FBSTATSUM") {
  field(DESC, "Piezo feedback status sum")
  field(CALC, "A")
  field(INPA, "$(CM,undefined)60:PZT:FBSTATSUM1 MS")
}
# Status summaries for integration
# with production operations.
# May move to FEED

# Geared towards cavity summary display
# That display checks SEVR==INVALID for 
# all records, so do not include additional
# severity checks here, just us MS/MSI

record(calc, "$(CM,undefined)70:PZT:HWSTATSUM1") {
  field(DESC, "Piezo tuner status sum")
  field(SCAN, "1 second")
  field(HIHI, "2")
  field(HHSV, "MAJOR")
  field(LOLO, "0")
  field(CALC, "(A>0)?2:0")
# Either channel power limit
  field(INPA, "$(CM,undefined)70:PZT:PWRLIM MSI")
  field(FLNK, "$(CM,undefined)70:PZT:HWSTATSUM")
}

record(calc, "$(CM,undefined)70:PZT:HWSTATSUM") {
  field(DESC, "Piezo tuner status sum")
  field(CALC, "A")
  field(INPA, "$(CM,undefined)70:PZT:HWSTATSUM1 MS")
}

record(calc, "$(CM,undefined)70:STEP:HWSTATSUM1") {
  field(DESC, "Stepper tuner status sum")
  field(SCAN, "1 second")
  field(HIHI, "2")
  field(HHSV, "MAJOR")
  field(LOLO, "0")
  field(CALC, "(A+B+C+D+E)>0?2:0")
# Limit B
  field(INPA, "$(CM,undefined)70:STEP:STATWRD.B3 MSI")
# Limit A
  field(INPB, "$(CM,undefined)70:STEP:STATWRD.B4 MSI")
# Any Limit
  field(INPC, "$(CM,undefined)70:STEP:STATWRD.B5 MSI")
# Inhibit
  field(INPD, "$(CM,undefined)70:STEP:STATWRD.B6 MSI")
# Low Current
  field(INPE, "$(CM,undefined)70:STEP:STATWRD.B7 MSI")
  field(FLNK, "$(CM,undefined)70:STEP:HWSTATSUM")
}

record(calc, "$(CM,undefined)70:STEP:HWSTATSUM") {
  field(DESC, "Stepper tuner status sum")
  field(CALC, "A")
  field(INPA, "$(CM,undefined)70:STEP:HWSTATSUM1 MS")
}

record(calc, "$(CM,undefined)70:CAV:CALSTATSUM1") {
  field(DESC, "Cavity characterization needed")
  field(SCAN, "1 second")
  field(HIHI, "2")
  field(HHSV, "MAJOR")
  field(LOLO, "0")
  field(CALC, "(A>0)?2:(B=0)?2:(C#1)?2:0")
# Last characterization incomplete/failed
  field(INPA, "$(CM,undefined)70:CAV:CALSUM.SEVR")
  field(INPB, "$(CM,undefined)70:DF_ENABLE_RBV MSI")
  field(INPC, "$(CM,undefined)70:SEL_ENABLE_RBV MSI")
  field(FLNK, "$(CM,undefined)70:CAV:CALSTATSUM")
}

record(calc, "$(CM,undefined)70:CAV:CALSTATSUM") {
  field(DESC, "Cavity characterization needed")
  field(CALC, "A")
  field(INPA, "$(CM,undefined)70:CAV:CALSTATSUM1 MS")
}

record(calc, "$(CM,undefined)70:PZT:READY") {
  field(DESC, "Piezo tuner nominal config")
  field(SCAN, "1 second")
  field(HIHI, "2")
  field(HHSV, "MAJOR")
  field(LOLO, "0")
  field(CALC, "(A#1)?2:(B#0)?2:(C#1)?2:(D#1)?2:0")
# Controller = Integrator
  field(INPA, "$(CM,undefined)70:PZT:CTRL_RBV MSI")
# Source = RFS
  field(INPB, "$(CM,undefined)70:PZT:DF_SRC_RBV MSI")
# Bias enabled
  field(INPC, "$(CM,undefined)70:PZT:BIAS_ENABLE_RBV MSI")
# Integrator enabled
  field(INPD, "$(CM,undefined)70:PZT:INTEG_ENABLE_RBV MSI")
  field(FLNK, "$(CM,undefined)70:PZT:FBSTATSUM1")
}

record(calc, "$(CM,undefined)70:PZT:FBSTATSUM1") {
  field(DESC, "Piezo feedback status sum")
  field(SCAN, "1 second")
  field(HIHI, "2")
  field(HHSV, "MAJOR")
  field(LOLO, "0")
  field(CALC, "(A=0)?2:(B#0)?2:(C#1)?2:(ABS(D)>10)?1:(E#0)?2:0")
# Piezo enabled (1)
  field(INPA, "$(CM,undefined)70:PZT:ENABLESTAT MSI")
# Piezo in nominal configuration (0)
  field(INPB, "$(CM,undefined)70:PZT:READY MS")
# Detune from RFS is valid (1)
  field(INPC, "$(CM,undefined)70:PZT:DFVALID_RFS MSI")
# Detune from RFS is within +/-10 Hz
  field(INPD, "$(CM,undefined)70:PZT:DF_RFS MSI")
# Piezo at limit (0)
  field(INPE, "$(CM,undefined)70:PZT:INTEG_AT_LIM MSI")
  field(FLNK, "$(CM,undefined)70:PZT:FBSTATSUM")
}

record(calc, "$(CM,undefined)70:PZT:FBSTATSUM") {
  field(DESC, "Piezo feedback status sum")
  field(CALC, "A")
  field(INPA, "$(CM,undefined)70:PZT:FBSTATSUM1 MS")
}
# Status summaries for integration
# with production operations.
# May move to FEED

# Geared towards cavity summary display
# That display checks SEVR==INVALID for 
# all records, so do not include additional
# severity checks here, just us MS/MSI

record(calc, "$(CM,undefined)80:PZT:HWSTATSUM1") {
  field(DESC, "Piezo tuner status sum")
  field(SCAN, "1 second")
  field(HIHI, "2")
  field(HHSV, "MAJOR")
  field(LOLO, "0")
  field(CALC, "(A>0)?2:0")
# Either channel power limit
  field(INPA, "$(CM,undefined)80:PZT:PWRLIM MSI")
  field(FLNK, "$(CM,undefined)80:PZT:HWSTATSUM")
}

record(calc, "$(CM,undefined)80:PZT:HWSTATSUM") {
  field(DESC, "Piezo tuner status sum")
  field(CALC, "A")
  field(INPA, "$(CM,undefined)80:PZT:HWSTATSUM1 MS")
}

record(calc, "$(CM,undefined)80:STEP:HWSTATSUM1") {
  field(DESC, "Stepper tuner status sum")
  field(SCAN, "1 second")
  field(HIHI, "2")
  field(HHSV, "MAJOR")
  field(LOLO, "0")
  field(CALC, "(A+B+C+D+E)>0?2:0")
# Limit B
  field(INPA, "$(CM,undefined)80:STEP:STATWRD.B3 MSI")
# Limit A
  field(INPB, "$(CM,undefined)80:STEP:STATWRD.B4 MSI")
# Any Limit
  field(INPC, "$(CM,undefined)80:STEP:STATWRD.B5 MSI")
# Inhibit
  field(INPD, "$(CM,undefined)80:STEP:STATWRD.B6 MSI")
# Low Current
  field(INPE, "$(CM,undefined)80:STEP:STATWRD.B7 MSI")
  field(FLNK, "$(CM,undefined)80:STEP:HWSTATSUM")
}

record(calc, "$(CM,undefined)80:STEP:HWSTATSUM") {
  field(DESC, "Stepper tuner status sum")
  field(CALC, "A")
  field(INPA, "$(CM,undefined)80:STEP:HWSTATSUM1 MS")
}

record(calc, "$(CM,undefined)80:CAV:CALSTATSUM1") {
  field(DESC, "Cavity characterization needed")
  field(SCAN, "1 second")
  field(HIHI, "2")
  field(HHSV, "MAJOR")
  field(LOLO, "0")
  field(CALC, "(A>0)?2:(B=0)?2:(C#1)?2:0")
# Last characterization incomplete/failed
  field(INPA, "$(CM,undefined)80:CAV:CALSUM.SEVR")
  field(INPB, "$(CM,undefined)80:DF_ENABLE_RBV MSI")
  field(INPC, "$(CM,undefined)80:SEL_ENABLE_RBV MSI")
  field(FLNK, "$(CM,undefined)80:CAV:CALSTATSUM")
}

record(calc, "$(CM,undefined)80:CAV:CALSTATSUM") {
  field(DESC, "Cavity characterization needed")
  field(CALC, "A")
  field(INPA, "$(CM,undefined)80:CAV:CALSTATSUM1 MS")
}

record(calc, "$(CM,undefined)80:PZT:READY") {
  field(DESC, "Piezo tuner nominal config")
  field(SCAN, "1 second")
  field(HIHI, "2")
  field(HHSV, "MAJOR")
  field(LOLO, "0")
  field(CALC, "(A#1)?2:(B#0)?2:(C#1)?2:(D#1)?2:0")
# Controller = Integrator
  field(INPA, "$(CM,undefined)80:PZT:CTRL_RBV MSI")
# Source = RFS
  field(INPB, "$(CM,undefined)80:PZT:DF_SRC_RBV MSI")
# Bias enabled
  field(INPC, "$(CM,undefined)80:PZT:BIAS_ENABLE_RBV MSI")
# Integrator enabled
  field(INPD, "$(CM,undefined)80:PZT:INTEG_ENABLE_RBV MSI")
  field(FLNK, "$(CM,undefined)80:PZT:FBSTATSUM1")
}

record(calc, "$(CM,undefined)80:PZT:FBSTATSUM1") {
  field(DESC, "Piezo feedback status sum")
  field(SCAN, "1 second")
  field(HIHI, "2")
  field(HHSV, "MAJOR")
  field(LOLO, "0")
  field(CALC, "(A=0)?2:(B#0)?2:(C#1)?2:(ABS(D)>10)?1:(E#0)?2:0")
# Piezo enabled (1)
  field(INPA, "$(CM,undefined)80:PZT:ENABLESTAT MSI")
# Piezo in nominal configuration (0)
  field(INPB, "$(CM,undefined)80:PZT:READY MS")
# Detune from RFS is valid (1)
  field(INPC, "$(CM,undefined)80:PZT:DFVALID_RFS MSI")
# Detune from RFS is within +/-10 Hz
  field(INPD, "$(CM,undefined)80:PZT:DF_RFS MSI")
# Piezo at limit (0)
  field(INPE, "$(CM,undefined)80:PZT:INTEG_AT_LIM MSI")
  field(FLNK, "$(CM,undefined)80:PZT:FBSTATSUM")
}

record(calc, "$(CM,undefined)80:PZT:FBSTATSUM") {
  field(DESC, "Piezo feedback status sum")
  field(CALC, "A")
  field(INPA, "$(CM,undefined)80:PZT:FBSTATSUM1 MS")
}
